ref: 3bc4b591d0543aa27da6bcbdad94af3e253322a6
parent: d29ae2940e7f7145c6f36426647e5cf462cfeae6
author: David <gek@katherine>
date: Wed Feb 24 05:42:42 EST 2021
Perf boosts
--- a/include/zfeatures.h
+++ b/include/zfeatures.h
@@ -53,7 +53,7 @@
#define TGL_POLYGON_STIPPLE_MASK_Y 31
//Use lookup tables for calculating specular light.
-#define TGL_FEATURE_SPECULAR_BUFFERS 1
+#define TGL_FEATURE_SPECULAR_BUFFERS 0
//Prevent ZB_copyFrameBuffer from copying certain colors.
#define TGL_FEATURE_NO_COPY_COLOR 0
--- a/src/error_check.h
+++ b/src/error_check.h
@@ -7,29 +7,32 @@
#if TGL_FEATURE_ERROR_CHECK == 1
//LEVEL 1 ERROR_CHECK
//#error should never execute.
+
+
+
+
+
#ifndef ERROR_FLAG
//LEVEL 2 ERROR_FLAG
//BEGIN LEVEL 3
#if TGL_FEATURE_STRICT_OOM_CHECKS == 1
- if(c->error_flag == GL_OUT_OF_MEMORY)
- return RETVAL;
-#else
- /* a comment */
+ if(c->error_flag == GL_OUT_OF_MEMORY) return RETVAL;
#endif
//EOF LEVEL 3
#elif ERROR_FLAG != GL_OUT_OF_MEMORY
-//LEVEL 2 ERROR_FLAG
-//Deal with the smalltime error case.
{c->error_flag = ERROR_FLAG; return RETVAL;}
//OUT OF MEMORY ELSE
#else
-//LEVEL 2 ERROR_FLAG
-//Deal with the out-of-memory case
{c->error_flag = GL_OUT_OF_MEMORY; return RETVAL;}
-//^ end of TGL_FEATURE_ERROR_CHECK check,
#endif
+//
+
+
+
+
+
//LEVEL 1 ERROR_CHECK
#endif
//^End of TGL_FEATURE_ERROR_CHECK, level 0
--- a/src/error_check_no_context.h
+++ b/src/error_check_no_context.h
@@ -13,6 +13,9 @@
GLContext* c = gl_get_context();
#endif
+
+
+
#endif
#undef RETVAL
--- a/src/list.c
+++ b/src/list.c
@@ -29,8 +29,7 @@
GLList* l;
l = find_list(c, list);
- if (l == NULL) {
- //tgl_warning("\nAttempted to delete NULL list!!!!\n");
+ if (l == NULL) { //MARK <COST>
return;
}
//assert(l != NULL);
@@ -71,8 +70,8 @@
#include "error_check.h"
#else
-if(!l || !ob)
- gl_fatal_error("GL_OUT_OF_MEMORY");
+ //if(!l || !ob) gl_fatal_error("GL_OUT_OF_MEMORY");
+ //This will crash a few lines down, so, let it!
#endif
ob->next = NULL;
l->first_op_buffer = ob;
@@ -119,6 +118,8 @@
GLenum type,
const GLuint* lists){
GLContext* c = gl_get_context();
+//A ridiculously expensive error check.
+/*
#include "error_check.h"
#if TGL_FEATURE_ERROR_CHECK == 1
if(type != GL_UNSIGNED_INT &&
@@ -126,6 +127,7 @@
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
#endif
+*/
for(GLint i = 0; i < n; i++)
glCallList(c->listbase + lists[i]);
}
@@ -143,12 +145,14 @@
if ((index + op_size) > (OP_BUFFER_MAX_SIZE - 2)) {
ob1 = gl_zalloc(sizeof(GLParamBuffer));
-if(!ob1)
+
#if TGL_FEATURE_ERROR_CHECK == 1
+if(!ob1)
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
#else
- gl_fatal_error("GL_OUT_OF_MEMORY");
+ //if(!ob1) gl_fatal_error("GL_OUT_OF_MEMORY");
+ //This will crash a few lines down, so, let it!
#endif
ob1->next = NULL;
@@ -211,6 +215,7 @@
if(!(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE))
#define ERROR_FLAG GL_INVALID_ENUM
#include "error_check.h"
+
if(!(c->compile_flag == 0))
#define ERROR_FLAG GL_INVALID_OPERATION
#include "error_check.h"
@@ -220,8 +225,7 @@
//assert(c->compile_flag == 0); //MARK <COST>
#endif
l = find_list(c, list);
- if (l != NULL)
- delete_list(c, list);
+ if (l != NULL) delete_list(c, list);
l = alloc_list(c, list);
#include "error_check.h"
#if TGL_FEATURE_ERROR_CHECK == 1
@@ -229,6 +233,7 @@
#define ERROR_FLAG GL_OUT_OF_MEMORY
#include "error_check.h"
#else
+ //Nearly cost-free
if(l==NULL) gl_fatal_error("Could not find or allocate list.");
#endif
c->current_op_buffer = l->first_op_buffer;
--- a/src/specbuf.c
+++ b/src/specbuf.c
@@ -38,7 +38,8 @@
#define RETVAL NULL
#include "error_check.h"
#else
- if (!buf) gl_fatal_error("GL_OUT_OF_MEMORY");
+ //if (!buf) gl_fatal_error("GL_OUT_OF_MEMORY");
+ //It will crash a few lines down, just LET IT
#endif
c->specbuf_num_buffers++;
buf->next = c->specbuf_first;
--- a/src/zgl.h
+++ b/src/zgl.h
@@ -335,16 +335,22 @@
extern void gl_compile_op(GLContext* c, GLParam* p);
static inline void gl_add_op(GLParam* p) {
GLContext* c = gl_ctx;
+#if TGL_FEATURE_ERROR_CHECK == 1
#include "error_check.h"
+#endif
GLint op;
op = p[0].op;
if (c->exec_flag) {
op_table_func[op](c, p);
+#if TGL_FEATURE_ERROR_CHECK == 1
#include "error_check.h"
+#endif
}
if (c->compile_flag) {
gl_compile_op(c, p);
+#if TGL_FEATURE_ERROR_CHECK == 1
#include "error_check.h"
+#endif
}
//if (c->print_flag) {
// gl_print_op(stderr, p);
--- a/src/zraster.c
+++ b/src/zraster.c
@@ -58,8 +58,6 @@
}
c->rasterpos.v[0] = v.zp.x;
c->rasterpos.v[1] = v.zp.y;
- //c->rasterpos.v[2] = v.pc.Z;
- //c->rasterpos.v[3] = v.pc.W;
c->rastervertex = v;
//c->rasterpos.v[2] = v.zp.z;
c->rasterpos_zz = v.zp.z >> ZB_POINT_Z_FRAC_BITS; //I believe this is it?
--- a/src/ztriangle.c
+++ b/src/ztriangle.c
@@ -19,28 +19,28 @@
#define YSTIP (the_y & TGL_POLYGON_STIPPLE_MASK_Y)
// NOTES Divide by 8 to get the byte Get the actual bit
#define STIPBIT(_a) (zbstipplepattern[(XSTIP(_a) | (YSTIP << TGL_POLYGON_STIPPLE_POW2_WIDTH)) >> 3] & (1 << (XSTIP(_a) & 7)))
-#define STIPTEST(_a) (!(zbdostipple && !STIPBIT(_a)))
+#define STIPTEST(_a) && (!(zbdostipple && !STIPBIT(_a)))
#else
#define TGL_STIPPLEVARS /* a comment */
-#define STIPTEST(_a) (1)
+#define STIPTEST(_a) /* a comment*/
#endif
#if TGL_FEATURE_NO_DRAW_COLOR == 1
-#define NODRAWTEST(c) ((c & TGL_COLOR_MASK) != TGL_NO_DRAW_COLOR)
+#define NODRAWTEST(c) && ((c & TGL_COLOR_MASK) != TGL_NO_DRAW_COLOR)
#else
-#define NODRAWTEST(c) (1)
+#define NODRAWTEST(c) /* a comment */
#endif
-#define ZCMP(z, zpix, _a, c) ( ((!zbdt) || (z >= zpix)) && STIPTEST(_a) && NODRAWTEST(c))
-#define ZCMPSIMP(z, zpix, _a, crabapple) ( ((!zbdt) || (z >= zpix)) && STIPTEST(_a) )
+#define ZCMP(z, zpix, _a, c) ( ((!zbdt) || (z >= zpix)) STIPTEST(_a) NODRAWTEST(c))
+#define ZCMPSIMP(z, zpix, _a, crabapple) ( ((!zbdt) || (z >= zpix)) STIPTEST(_a) )
void ZB_fillTriangleFlat(ZBuffer* zb, ZBufferPoint* p0, ZBufferPoint* p1, ZBufferPoint* p2) {
-
- PIXEL color = RGB_TO_PIXEL(p2->r, p2->g, p2->b); GLubyte zbdw = zb->depth_write; GLubyte zbdt = zb->depth_test;
+GLubyte zbdt = zb->depth_test;GLubyte zbdw = zb->depth_write;
+ GLuint color;
TGL_BLEND_VARS
TGL_STIPPLEVARS
@@ -52,7 +52,7 @@
#define INTERP_Z
//#define INTERP_RGB
-#define DRAW_INIT() { }
+#define DRAW_INIT() {color=RGB_TO_PIXEL(p2->r, p2->g, p2->b);}
#define PUT_PIXEL(_a) \
{ \
@@ -117,12 +117,12 @@
#if TGL_FEATURE_NO_DRAW_COLOR != 1
#define PUT_PIXEL(_a) \
{ \
- register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
+ {register GLuint zz =z >> ZB_POINT_Z_FRAC_BITS; \
if (ZCMPSIMP(zz, pz[_a], _a, 0)) { \
/*pp[_a] = RGB_TO_PIXEL(or1, og1, ob1);*/ \
TGL_BLEND_FUNC_RGB(or1, og1, ob1, (pp[_a])); \
if(zbdw)pz[_a] = zz; \
- } \
+ }} \
z += dzdx; \
og1 += dgdx; \
or1 += drdx; \