Skip to content

Commit

Permalink
[rend2-sp] Fix precaching related memory leaks
Browse files Browse the repository at this point in the history
Gpu buffers, fbos, the gpu shaders and the image pool were allocated twice and leaking the second time... Looks like there's still something that leaks though.
  • Loading branch information
SomaZ committed Apr 26, 2024
1 parent 08ad1d1 commit 7c21d86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 5 additions & 0 deletions shared/rd-rend2/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static struct ImagesPool
image_t *pPool;
ImagesPool *pNext;
} *imagesPool;
static bool imagePoolInitialized = false;

static image_t *hashTable[FILE_HASH_SIZE];

Expand Down Expand Up @@ -3599,11 +3600,14 @@ Initialise the images pool allocator
*/
void R_InitImagesPool()
{
if (imagePoolInitialized)
return;
Com_Memset(hashTable, 0, sizeof(hashTable));

imagesPool = NULL;
tr.imagesFreeList = NULL;
R_ExtendImagesPool();
imagePoolInitialized = true;
}

/*
Expand Down Expand Up @@ -3644,6 +3648,7 @@ void R_DeleteTextures( void ) {
imagesPool = pNext;
}

imagePoolInitialized = false;
Com_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) );
GL_SelectTexture( 1 );
qglBindTexture( GL_TEXTURE_2D, 0 );
Expand Down
3 changes: 0 additions & 3 deletions shared/rd-rend2/tr_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,9 +1598,6 @@ void R_SVModelInit()

R_InitImagesPool();
R_InitImages();
R_InitGPUBuffers();
FBO_Init();
GLSL_LoadGPUShaders();
R_InitShaders(qfalse);
#endif

Expand Down

0 comments on commit 7c21d86

Please sign in to comment.