From 7c21d866492debb30edd3b4cf24e6eec180c928a Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:53:25 +0200 Subject: [PATCH] [rend2-sp] Fix precaching related memory leaks 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. --- shared/rd-rend2/tr_image.cpp | 5 +++++ shared/rd-rend2/tr_model.cpp | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/shared/rd-rend2/tr_image.cpp b/shared/rd-rend2/tr_image.cpp index 8919c40563..7dd0fa1e62 100644 --- a/shared/rd-rend2/tr_image.cpp +++ b/shared/rd-rend2/tr_image.cpp @@ -37,6 +37,7 @@ static struct ImagesPool image_t *pPool; ImagesPool *pNext; } *imagesPool; +static bool imagePoolInitialized = false; static image_t *hashTable[FILE_HASH_SIZE]; @@ -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; } /* @@ -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 ); diff --git a/shared/rd-rend2/tr_model.cpp b/shared/rd-rend2/tr_model.cpp index 1bacf55519..2ef0db0372 100644 --- a/shared/rd-rend2/tr_model.cpp +++ b/shared/rd-rend2/tr_model.cpp @@ -1598,9 +1598,6 @@ void R_SVModelInit() R_InitImagesPool(); R_InitImages(); - R_InitGPUBuffers(); - FBO_Init(); - GLSL_LoadGPUShaders(); R_InitShaders(qfalse); #endif