From 40ed394b06b7de78e91e0203a995c6fa57413341 Mon Sep 17 00:00:00 2001 From: VReaperV Date: Fri, 10 May 2024 01:01:00 +0300 Subject: [PATCH] Move currenttextures to trGlobals_t Move it to tr so we can keep memset for glState --- src/engine/renderer/tr_backend.cpp | 8 ++++---- src/engine/renderer/tr_image.cpp | 2 +- src/engine/renderer/tr_init.cpp | 2 +- src/engine/renderer/tr_local.h | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/engine/renderer/tr_backend.cpp b/src/engine/renderer/tr_backend.cpp index bcc6de758e..792bdba2ed 100644 --- a/src/engine/renderer/tr_backend.cpp +++ b/src/engine/renderer/tr_backend.cpp @@ -57,10 +57,10 @@ void GL_Bind( image_t *image ) texnum = tr.blackImage->texnum; } - if ( glState.currenttextures[ glState.currenttmu ] != texnum ) + if ( tr.currenttextures[ glState.currenttmu ] != texnum ) { image->frameUsed = tr.frameCount; - glState.currenttextures[ glState.currenttmu ] = texnum; + tr.currenttextures[ glState.currenttmu ] = texnum; glBindTexture( image->type, texnum ); } } @@ -69,7 +69,7 @@ void GL_Unbind( image_t *image ) { GLimp_LogComment( "--- GL_Unbind() ---\n" ); - glState.currenttextures[ glState.currenttmu ] = 0; + tr.currenttextures[ glState.currenttmu ] = 0; glBindTexture( image->type, 0 ); } @@ -180,7 +180,7 @@ void GL_BindToTMU( int unit, image_t *image ) Sys::Drop( "GL_BindToTMU: unit %i is out of range\n", unit ); } - if ( glState.currenttextures[ unit ] == texnum ) + if ( tr.currenttextures[ unit ] == texnum ) { return; } diff --git a/src/engine/renderer/tr_image.cpp b/src/engine/renderer/tr_image.cpp index aa7dc463cf..711eceec75 100644 --- a/src/engine/renderer/tr_image.cpp +++ b/src/engine/renderer/tr_image.cpp @@ -2993,7 +2993,7 @@ void R_ShutdownImages() glDeleteTextures( 1, &image->texnum ); } - glState.currenttextures.clear(); + tr.currenttextures.clear(); tr.images.clear(); tr.lightmaps.clear(); diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 3e6ae23040..de118a313a 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -814,7 +814,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p GL_CheckErrors(); - glState.currenttextures.resize( glConfig2.maxTextureUnits ); + tr.currenttextures.resize( glConfig2.maxTextureUnits ); // initialize downstream texture units if we're running // in a multitexture environment diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index e424f81a62..8e1386a303 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -2477,8 +2477,6 @@ enum class dynamicLightRenderer_t { LEGACY, TILED }; float polygonOffsetFactor, polygonOffsetUnits; vec2_t tileStep; - // Maximum reported is 192, see https://opengl.gpuinfo.org/displaycapability.php?name=GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS - std::vector currenttextures; int currenttmu; int stackIndex; @@ -2644,6 +2642,9 @@ enum class dynamicLightRenderer_t { LEGACY, TILED }; const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load + // Maximum reported is 192, see https://opengl.gpuinfo.org/displaycapability.php?name=GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS + std::vector currenttextures; + image_t *defaultImage; image_t *cinematicImage[ MAX_IN_GAME_VIDEOS ]; image_t *fogImage;