diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 98034970d..6a875543f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -509,8 +509,8 @@ void HWR_FreeMipmapCache(void) // free all hardware-converted graphics cached in the heap // our gool is only the textures since user of the texture is the texture cache - Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); + //Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); + //Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); // Alam: free the Z_Blocks before freeing it's users diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4395570a4..cf95fdbcb 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5760,17 +5760,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) 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()) diff --git a/src/p_setup.c b/src/p_setup.c index fa490bb9f..e5f947a87 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2770,6 +2770,12 @@ boolean P_SetupLevel(boolean skipprecip) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); +#ifdef HWRENDER + // Free GPU textures before freeing patches. + if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) + HWR_FreeMipmapCache(); +#endif + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS)