rhi: Reset patch atlas if patch is freed

This commit is contained in:
Eidolon 2023-04-15 22:19:01 -05:00
parent 3ad3dd5cd9
commit 2b01d8a589
4 changed files with 23 additions and 0 deletions

View file

@ -11,6 +11,8 @@
#include <stb_rect_pack.h>
#include "../r_patch.h"
using namespace srb2;
using namespace srb2::hwr2;
using namespace srb2::rhi;
@ -168,6 +170,10 @@ bool PatchAtlasCache::need_to_reset() const
{
return true;
}
if (Patch_WasFreedThisFrame())
{
return true;
}
return false;
}

View file

@ -455,6 +455,7 @@ static InternalPassData build_pass_manager()
void I_NewTwodeeFrame(void)
{
g_2d = Twodee();
Patch_ResetFreedThisFrame();
}
void I_NewImguiFrame(void)

View file

@ -99,6 +99,8 @@ static void Patch_FreeData(patch_t *patch)
Z_Free(patch->columns);
}
static boolean g_patch_was_freed_this_frame = false;
void Patch_Free(patch_t *patch)
{
if (!patch || patch == missingpat)
@ -106,6 +108,18 @@ void Patch_Free(patch_t *patch)
Patch_FreeData(patch);
Z_Free(patch);
g_patch_was_freed_this_frame = true;
}
boolean Patch_WasFreedThisFrame(void)
{
return g_patch_was_freed_this_frame;
}
void Patch_ResetFreedThisFrame(void)
{
g_patch_was_freed_this_frame = false;
}
//

View file

@ -24,6 +24,8 @@ extern "C" {
// Patch functions
patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest);
void Patch_Free(patch_t *patch);
boolean Patch_WasFreedThisFrame(void);
void Patch_ResetFreedThisFrame(void);
#define Patch_FreeTag(tagnum) Patch_FreeTags(tagnum, tagnum)
void Patch_FreeTags(INT32 lowtag, INT32 hightag);