From 06529d4fe7286e3af44b9334d8bce4bf4e847096 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Sat, 8 May 2021 14:38:55 +0100 Subject: [PATCH] Perf tweaks --- GL/flush.c | 16 +++------------- GL/private.h | 27 ++++++++++++++++++++++++--- GL/state.c | 12 ++---------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/GL/flush.c b/GL/flush.c index 6040804..c52b1be 100644 --- a/GL/flush.c +++ b/GL/flush.c @@ -2,9 +2,9 @@ #include "../containers/aligned_vector.h" #include "private.h" -static PolyList OP_LIST; -static PolyList PT_LIST; -static PolyList TR_LIST; +PolyList OP_LIST; +PolyList PT_LIST; +PolyList TR_LIST; /** Don't fully comply to the GL standard to make some performance * gains. Specifically glDepthRange will be ignored, and the final @@ -15,16 +15,6 @@ static PolyList TR_LIST; #define FAST_MODE GL_TRUE -PolyList* _glActivePolyList() { - if(_glIsBlendingEnabled()) { - return &TR_LIST; - } else if(_glIsAlphaTestEnabled()) { - return &PT_LIST; - } else { - return &OP_LIST; - } -} - PolyList* _glOpaquePolyList() { return &OP_LIST; } diff --git a/GL/private.h b/GL/private.h index 94a566e..c810872 100644 --- a/GL/private.h +++ b/GL/private.h @@ -277,7 +277,6 @@ struct SubmissionTarget; float _glClipLineToNearZ(const Vertex* v1, const Vertex* v2, Vertex* vout); void _glClipTriangleStrip(SubmissionTarget* target, uint8_t fladeShade); -PolyList *_glActivePolyList(); PolyList* _glOpaquePolyList(); PolyList* _glPunchThruPolyList(); PolyList *_glTransparentPolyList(); @@ -338,8 +337,30 @@ void _glSetInternalPaletteFormat(GLenum val); GLboolean _glIsSharedTexturePaletteEnabled(); void _glApplyColorTable(TexturePalette *palette); -GLboolean _glIsBlendingEnabled(); -GLboolean _glIsAlphaTestEnabled(); +extern GLboolean BLEND_ENABLED; +extern GLboolean ALPHA_TEST_ENABLED; + +GL_FORCE_INLINE GLboolean _glIsBlendingEnabled() { + return BLEND_ENABLED; +} + +GL_FORCE_INLINE GLboolean _glIsAlphaTestEnabled() { + return ALPHA_TEST_ENABLED; +} + +extern PolyList OP_LIST; +extern PolyList PT_LIST; +extern PolyList TR_LIST; + +GL_FORCE_INLINE PolyList* _glActivePolyList() { + if(BLEND_ENABLED) { + return &TR_LIST; + } else if(ALPHA_TEST_ENABLED) { + return &PT_LIST; + } else { + return &OP_LIST; + } +} GLboolean _glIsMipmapComplete(const TextureObject* obj); GLubyte* _glGetMipmapLocation(const TextureObject* obj, GLuint level); diff --git a/GL/state.c b/GL/state.c index cbe1e50..9bcf0b2 100644 --- a/GL/state.c +++ b/GL/state.c @@ -23,7 +23,7 @@ static GLboolean LIGHTING_ENABLED = GL_FALSE; /* Is the shared texture palette enabled? */ static GLboolean SHARED_PALETTE_ENABLED = GL_FALSE; -static GLboolean ALPHA_TEST_ENABLED = GL_FALSE; +GLboolean ALPHA_TEST_ENABLED = GL_FALSE; static GLboolean POLYGON_OFFSET_ENABLED = GL_FALSE; @@ -89,7 +89,7 @@ static int _calc_pvr_depth_test() { static GLenum BLEND_SFACTOR = GL_ONE; static GLenum BLEND_DFACTOR = GL_ZERO; -static GLboolean BLEND_ENABLED = GL_FALSE; +GLboolean BLEND_ENABLED = GL_FALSE; static GLfloat OFFSET_FACTOR = 0.0f; static GLfloat OFFSET_UNITS = 0.0f; @@ -98,14 +98,6 @@ GLboolean _glIsNormalizeEnabled() { return NORMALIZE_ENABLED; } -GLboolean _glIsBlendingEnabled() { - return BLEND_ENABLED; -} - -GLboolean _glIsAlphaTestEnabled() { - return ALPHA_TEST_ENABLED; -} - static int _calcPVRBlendFactor(GLenum factor) { switch(factor) { case GL_ZERO: