From eca9c60d9b8a9122fe9078462e615b8f9b3ba4dc Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 29 May 2025 17:58:00 +0200 Subject: [PATCH 1/2] call HWR_LoadMapTextures in paletterender toggle callback from srb2 pr --- src/hardware/hw_batching.c | 2 +- src/hardware/hw_main.c | 4 ++-- src/st_stuff.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 3655beb8a..b8490f4ed 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -124,7 +124,7 @@ void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPt polygonArray[polygonArraySize].numVerts = iNumPts; polygonArray[polygonArraySize].polyFlags = PolyFlags; polygonArray[polygonArraySize].texture = current_texture; - polygonArray[polygonArraySize].shader = (shader_target != -1) ? HWR_GetShaderFromTarget(shader_target) : shader_target; + polygonArray[polygonArraySize].shader = (shader_target != SHADER_NONE) ? HWR_GetShaderFromTarget(shader_target) : shader_target; polygonArray[polygonArraySize].horizonSpecial = horizonSpecial; polygonArraySize++; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 0f308017d..51f3346dc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5764,7 +5764,7 @@ static void HWR_TogglePaletteRendering(void) // If the r_opengl "texture palette" stays the same during this switch, these textures // will not be cleared out. However they are still out of date since the // composite texture blending method has changed. Therefore they need to be cleared. - GL_ClearMipMapCache(); + HWR_LoadMapTextures(numtextures); } } else @@ -5778,7 +5778,7 @@ static void HWR_TogglePaletteRendering(void) // If the r_opengl "texture palette" stays the same during this switch, these textures // will not be cleared out. However they are still out of date since the // composite texture blending method has changed. Therefore they need to be cleared. - GL_ClearMipMapCache(); + HWR_LoadMapTextures(numtextures); } } } diff --git a/src/st_stuff.c b/src/st_stuff.c index 04523f577..4f5401aae 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -187,7 +187,7 @@ void ST_doPaletteStuff(void) #ifdef HWRENDER if (rendermode == render_opengl && !HWR_PalRenderFlashpal()) - palette = 0; // No flashpals here in OpenGL + palette = 0; // Don't set the palette to a flashpal in OpenGL's truecolor mode #endif palette = min(max(palette, 0), 13); From bf44a054a1a614d1756813fec90311d6e708897c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 29 May 2025 18:17:07 +0200 Subject: [PATCH 2/2] move HWR_GetTexturePalette calls to after early returns/where they are used --- src/hardware/hw_cache.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 85e50465a..36f6a57a5 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -46,12 +46,16 @@ RGBA_t *HWR_GetTexturePalette(void) static INT32 format2bpp(GLTextureFormat_t format) { - if (format == GL_TEXFMT_RGBA) - return 4; - else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88) - return 2; - else - return 1; + switch (format) + { + case GL_TEXFMT_RGBA: + return 4; + case GL_TEXFMT_ALPHA_INTENSITY_88: + case GL_TEXFMT_AP_88: + return 2; + default: + return 1; + } } // This code was originally placed directly in HWR_DrawPatchInCache. @@ -221,8 +225,6 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (texture->width <= 0 || texture->height <= 0) return; - palette = HWR_GetTexturePalette(); - x1 = patch->originx; width = SHORT(realpatch->width); height = SHORT(realpatch->height); @@ -234,6 +236,8 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, if (patch->originy > texture->height || (patch->originy + height) < 0) return; // patch not located within texture's y bounds, ignore + palette = HWR_GetTexturePalette(); + // patch is actually inside the texture! // now check if texture is partly off-screen and adjust accordingly @@ -323,7 +327,6 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe boolean skyspecial = false; // poor hack for Legacy large skies.. RGBA_t *palette; - palette = HWR_GetTexturePalette(); texture = textures[texnum]; @@ -361,6 +364,8 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe INT32 j; RGBA_t col; + palette = HWR_GetTexturePalette(); + col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX]; for (idx = 0, j = 0; j < blockheight; j++)