optimise mipmaps
https://git.do.srb2.org/STJr/SRB2/-/commit/cc12496e9c3fce929546640bbe2c1b35056d7a86
This commit is contained in:
1 parent
c5476ff8f9
commit
7dae68561e
6 files changed
+34
-20
No files matched your search
+14
-10
@@ -504,6 +504,9 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
|
||||
|
||||
// Set the first colormap to the one that comes after it.
|
||||
next = pat->mipmap->nextcolormap;
|
||||
if (!next)
|
||||
break;
|
||||
|
||||
pat->mipmap->nextcolormap = next->nextcolormap;
|
||||
|
||||
// Free image data from memory.
|
||||
@@ -511,14 +514,15 @@ static void FreeMipmapColormap(INT32 patchnum, void *patch)
|
||||
Z_Free(next->grInfo.data);
|
||||
next->grInfo.data = NULL;
|
||||
|
||||
// Free the old colormap from memory.
|
||||
// Free the old colormap mipmap from memory.
|
||||
free(next);
|
||||
}
|
||||
}
|
||||
|
||||
void HWR_FreeTextureCache(void)
|
||||
void HWR_FreeMipmapCache(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
// free references to the textures
|
||||
HWD.pfnClearMipMapCache();
|
||||
|
||||
@@ -528,10 +532,15 @@ void HWR_FreeTextureCache(void)
|
||||
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED);
|
||||
|
||||
// Alam: free the Z_Blocks before freeing it's users
|
||||
|
||||
// free all patch colormaps after each level: must be done after ClearMipMapCache!
|
||||
for (i = 0; i < numwadfiles; i++)
|
||||
M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);
|
||||
}
|
||||
|
||||
void HWR_FreeTextureCache(void)
|
||||
{
|
||||
// free references to the textures
|
||||
HWR_FreeMipmapCache();
|
||||
|
||||
// now the heap don't have any 'user' pointing to our
|
||||
// texturecache info, we can free it
|
||||
@@ -541,20 +550,15 @@ void HWR_FreeTextureCache(void)
|
||||
gr_numtextures = 0;
|
||||
}
|
||||
|
||||
void HWR_PrepLevelCache(size_t pnumtextures)
|
||||
void HWR_LoadTextures(size_t pnumtextures)
|
||||
{
|
||||
// problem: the mipmap cache management hold a list of mipmaps.. but they are
|
||||
// reallocated on each level..
|
||||
//sub-optimal, but 1) just need re-download stuff in hardware cache VERY fast
|
||||
// 2) sprite/menu stuff mixed with level textures so can't do anything else
|
||||
|
||||
// we must free it since numtextures changed
|
||||
HWR_FreeTextureCache();
|
||||
|
||||
gr_numtextures = pnumtextures;
|
||||
gr_textures = calloc(pnumtextures, sizeof (*gr_textures));
|
||||
if (gr_textures == NULL)
|
||||
I_Error("HWR_PrepLevelCache: can't alloc gr_textures");
|
||||
I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!");
|
||||
}
|
||||
|
||||
void HWR_SetPalette(RGBA_t *palette)
|
||||
|
||||
@@ -57,6 +57,7 @@ extern size_t addsubsector;
|
||||
// --------
|
||||
void HWR_InitTextureCache(void);
|
||||
void HWR_FreeTextureCache(void);
|
||||
void HWR_FreeMipmapCache(void);
|
||||
void HWR_FreeExtraSubsectors(void);
|
||||
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap);
|
||||
|
||||
@@ -6207,6 +6207,7 @@ void HWR_Shutdown(void)
|
||||
{
|
||||
CONS_Printf("HWR_Shutdown()\n");
|
||||
HWR_FreeExtraSubsectors();
|
||||
HWR_FreeMipmapCache();
|
||||
HWR_FreeTextureCache();
|
||||
HWD.pfnFlushScreenTextures();
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum);
|
||||
extern boolean gr_maphasportals;
|
||||
|
||||
// hw_cache.c
|
||||
void HWR_PrepLevelCache(size_t pnumtextures);
|
||||
void HWR_LoadTextures(size_t pnumtextures);
|
||||
|
||||
// hw_trick.c
|
||||
void HWR_CorrectSWTricks(void);
|
||||
|
||||
+12
-9
@@ -3143,8 +3143,19 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
P_SpawnPrecipitation();
|
||||
|
||||
#ifdef HWRENDER // not win32 only 19990829 by Kin
|
||||
if (rendermode != render_soft && rendermode != render_none)
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
// 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();
|
||||
|
||||
// Correct missing sidedefs & deep water trick
|
||||
HWR_CorrectSWTricks();
|
||||
HWR_CreatePlanePolygons((INT32)numnodes - 1);
|
||||
@@ -3355,14 +3366,6 @@ boolean P_SetupLevel(boolean skipprecip)
|
||||
// clear special respawning que
|
||||
iquehead = iquetail = 0;
|
||||
|
||||
// preload graphics
|
||||
#ifdef HWRENDER // not win32 only 19990829 by Kin
|
||||
if (rendermode != render_soft && rendermode != render_none)
|
||||
{
|
||||
HWR_PrepLevelCache(numtextures);
|
||||
}
|
||||
#endif
|
||||
|
||||
P_MapEnd();
|
||||
|
||||
// Remove the loading shit from the screen
|
||||
|
||||
@@ -536,6 +536,11 @@ void R_LoadTextures(void)
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
HWR_LoadTextures(numtextures);
|
||||
#endif
|
||||
}
|
||||
|
||||
static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
|
||||
|
||||
Reference in new issue
Block a user