shithub: tinygl

Download patch

ref: a56648c28c1cd33fc1fb12c0e8995c70500bb19a
parent: 24cda3ba54744353aaadbc4dfadbf60b37673b66
author: David <gek@katherine>
date: Fri Feb 19 16:52:53 EST 2021

A

--- a/include/zfeatures.h
+++ b/include/zfeatures.h
@@ -1,7 +1,5 @@
 #ifndef _tgl_features_h_
 #define _tgl_features_h_
-//This include is for debugging, you can safely remove it if it's enabled
-//#include <stdio.h>
 /* It is possible to enable/disable (compile time) features in this
    header file. */
 
@@ -9,8 +7,8 @@
 //Disabling this has slight performance gains.
 #define TGL_FEATURE_ERROR_CHECK 1
 //Strict out-of-memory checking. All OpenGL function calls are invalidated (ALL OF THEM) if a GL_OUT_OF_MEMORY error occurs.
-//This slows down the renderer so we don't usually do it, but
-//it's part of the GL spec.
+//The checks slow down the renderer so it is not recommended , but
+//it's part of the GL spec and it was relatively easy to add so I added it.
 #define TGL_FEATURE_STRICT_OOM_CHECKS 0
 //Use Fast Inverse Square Root. Toggleable because it's actually slower on some systems, i've heard.
 #define TGL_FEATURE_FISR 1
--- a/src/list.c
+++ b/src/list.c
@@ -182,6 +182,8 @@
 
 #if TGL_FEATURE_ERROR_CHECK == 1
 	if (l == NULL) {gl_fatal_error("Bad list op, not defined");}
+#else
+	if(l == NULL)return; //MARK <COST>
 #endif
 	p = l->first_op_buffer->ops;
 
@@ -214,8 +216,8 @@
 #include "error_check.h"
 
 #else
-	//assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE);
-	//assert(c->compile_flag == 0);
+	assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE); //MARK <COST>
+	assert(c->compile_flag == 0); //MARK <COST>
 #endif
 	l = find_list(c, list);
 	if (l != NULL)
@@ -245,7 +247,7 @@
 #define ERROR_FLAG GL_INVALID_OPERATION
 #include "error_check.h"
 #else
-//	assert(c->compile_flag == 1);
+	assert(c->compile_flag == 1); //MARK <COST>
 #endif
 	/* end of list */
 	p[0].op = OP_EndList;
--- a/src/ztriangle.h
+++ b/src/ztriangle.h
@@ -9,7 +9,7 @@
 fuck up!
 
 Things to keep in mind:
- 1) Tight control of the lifetimes of variables lets us use registers more often and memory less
+ 1) Tight control of the lifetimes, scopes, and usage of variables lets us use registers more often and memory less
  2) Doing the same operation on multiple items is faster than doing different things on different items, generally, because
    they will be able to take advantage of any/all applicable SIMD/vector ops on your hardware.
  3) Divide operations are vastly more expensive than add/sub/bitwise/etc
@@ -16,7 +16,7 @@
  4) Bit shifting is your friend, it's the fast way to multiply or divide by 2.
  5) Fixed point math is used for the depth "z" buffer
  6) We're not just using floats for everything because this is still supposed to be fast on platforms without SSE2
- 7) 
+ 7) Fewer variables is usually better
  */
 
 {