From 442e6c9d77400ed67174fcd1f8b2ff31dd319372 Mon Sep 17 00:00:00 2001 From: ewasylishen Date: Fri, 4 Sep 2015 09:22:33 +0000 Subject: [PATCH] TexMgr_ReloadImages: attempt to fix random texture recoloring after mode change (http://sourceforge.net/p/quakespasm/bugs/10/) This removes the Cache_Flush() call that was here, which was there to fix the jam3_tronyn / low heapsize bug, and instead adds a different workaround for that issue. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1247 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/gl_texmgr.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/quakespasm/Quake/gl_texmgr.c b/quakespasm/Quake/gl_texmgr.c index f9c2bf97..c1fc9d3f 100644 --- a/quakespasm/Quake/gl_texmgr.c +++ b/quakespasm/Quake/gl_texmgr.c @@ -343,6 +343,9 @@ gltexture_t *TexMgr_NewTexture (void) static void GL_DeleteTexture (gltexture_t *texture); +//ericw -- workaround for preventing TexMgr_FreeTexture during TexMgr_ReloadImages +static qboolean in_reload_images; + /* ================ TexMgr_FreeTexture @@ -352,6 +355,9 @@ void TexMgr_FreeTexture (gltexture_t *kill) { gltexture_t *glt; + if (in_reload_images) + return; + if (kill == NULL) { Con_Printf ("TexMgr_FreeTexture: NULL texture\n"); @@ -1390,18 +1396,23 @@ void TexMgr_ReloadImages (void) { gltexture_t *glt; -// ericw -- flush the cache before reloading textures. This avoids an obscure -// bug where, if the hunk is almost full, an allocation in TexMgr_ReloadImage +// ericw -- tricky bug: if the hunk is almost full, an allocation in TexMgr_ReloadImage // triggers cache items to be freed, which calls back into TexMgr to free the -// texture. Calling TexMgr_FreeTexture within the loop below causes things to -// go haywire. A test case is jam3_tronyn.bsp with -heapsize 65536 - Cache_Flush(); +// texture. If this frees 'glt' in the loop below, the active_gltextures +// list gets corrupted. +// A test case is jam3_tronyn.bsp with -heapsize 65536, and do several mode +// switches/fullscreen toggles +// 2015-09-04 -- Cache_Flush workaround was causing issues (http://sourceforge.net/p/quakespasm/bugs/10/) +// switching to a boolean flag. + in_reload_images = true; for (glt = active_gltextures; glt; glt = glt->next) { glGenTextures(1, &glt->texnum); TexMgr_ReloadImage (glt, -1, -1); } + + in_reload_images = false; } /*