From 20e062b031457292fa82fff012599d23edae4a76 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 22 Jun 2024 07:14:33 +0200 Subject: [PATCH] move HWR_LoadLevel to hw_main --- src/hardware/hw_main.c | 19 +++++++++++++++++++ src/p_setup.c | 11 ----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 8b9672b03..b24d07d25 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5948,6 +5948,25 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWR_RenderFrame(viewnumber, player, false); } +void HWR_LoadLevel(void) +{ + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeMipmapCache(); + + HWR_CreatePlanePolygons((INT32)numnodes - 1); + + if (HWR_ShouldUsePaletteRendering()) + HWR_SetMapPalette(); +} + // enable or disable palette rendering state depending on settings and availability // called when relevant settings change // shader recompilation is done in the cvar callback diff --git a/src/p_setup.c b/src/p_setup.c index d31c091d8..65053e90d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3302,17 +3302,6 @@ boolean P_SetupLevel(boolean skipprecip) return true; } -#ifdef HWRENDER -void HWR_LoadLevel(void) -{ - HWR_FreeMipmapCache(); - HWR_CreatePlanePolygons((INT32)numnodes - 1); - - if (HWR_ShouldUsePaletteRendering()) - HWR_SetMapPalette(); -} -#endif - // // P_RunSOC //