From adce2c7538e525963f6293b7c1281ea42358c049 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Mon, 13 Sep 2021 12:57:52 +0100 Subject: [PATCH] Perf tweaks --- GL/draw.c | 13 +++++-------- GL/immediate.c | 4 ++-- GL/private.h | 6 +++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/GL/draw.c b/GL/draw.c index f6e9e51..09547bf 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -11,11 +11,11 @@ AttribPointerList ATTRIB_POINTERS; GLuint ENABLED_VERTEX_ATTRIBUTES = 0; -GLboolean FAST_PATH_ENABLED = GL_FALSE; +GLuint FAST_PATH_ENABLED = GL_FALSE; static GLubyte ACTIVE_CLIENT_TEXTURE = 0; -extern inline GLboolean _glRecalcFastPath(); +extern inline GLuint _glRecalcFastPath(); #define ITERATE(count) \ GLuint i = count; \ @@ -1135,9 +1135,6 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL target->extras = &extras; } - const GLboolean doLighting = LIGHTING_ENABLED; - const GLboolean doMultitexture = TEXTURES_ENABLED[1]; - /* Polygons are treated as triangle fans, the only time this would be a * problem is if we supported glPolygonMode(..., GL_LINE) but we don't. * We optimise the triangle and quad cases. @@ -1175,7 +1172,7 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL * If we're not doing lighting though we can optimise by taking * vertices straight to clip-space */ - if(doLighting) { + if(LIGHTING_ENABLED) { _glMatrixLoadModelView(); } else { _glMatrixLoadModelViewProjection(); @@ -1190,7 +1187,7 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL transform(target); } - if(doLighting){ + if(LIGHTING_ENABLED){ light(target); /* OK eye-space work done, now move into clip space */ @@ -1241,7 +1238,7 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL - We want to set the uv coordinates to the passed st ones */ - if(!doMultitexture) { + if(!TEXTURES_ENABLED[1]) { /* Multitexture actively disabled */ return; } diff --git a/GL/immediate.c b/GL/immediate.c index a3743b7..5e19240 100644 --- a/GL/immediate.c +++ b/GL/immediate.c @@ -12,7 +12,7 @@ #include "private.h" -extern inline GLboolean _glRecalcFastPath(); +extern inline GLuint _glRecalcFastPath(); GLboolean IMMEDIATE_MODE_ACTIVE = GL_FALSE; static GLenum ACTIVE_POLYGON_MODE = GL_TRIANGLES; @@ -248,7 +248,7 @@ void APIENTRY glEnd() { #ifndef NDEBUG // Immediate mode should always activate the fast path - GLboolean fastPathEnabled = _glRecalcFastPath(); + GLuint fastPathEnabled = _glRecalcFastPath(); assert(fastPathEnabled); #else /* If we're not debugging, set to true - we assume we haven't broken it! */ diff --git a/GL/private.h b/GL/private.h index cd036bc..2bcee46 100644 --- a/GL/private.h +++ b/GL/private.h @@ -391,9 +391,9 @@ GLboolean _glIsNormalizeEnabled(); extern AttribPointerList ATTRIB_POINTERS; extern GLuint ENABLED_VERTEX_ATTRIBUTES; -extern GLboolean FAST_PATH_ENABLED; +extern GLuint FAST_PATH_ENABLED; -GL_FORCE_INLINE GLboolean _glIsVertexDataFastPathCompatible() { +GL_FORCE_INLINE GLuint _glIsVertexDataFastPathCompatible() { /* The fast path is enabled when all enabled elements of the vertex * match the output format. This means: * @@ -443,7 +443,7 @@ GL_FORCE_INLINE GLboolean _glIsVertexDataFastPathCompatible() { return GL_TRUE; } -GL_FORCE_INLINE GLboolean _glRecalcFastPath() { +GL_FORCE_INLINE GLuint _glRecalcFastPath() { FAST_PATH_ENABLED = _glIsVertexDataFastPathCompatible(); return FAST_PATH_ENABLED; }