Skip to content

Commit

Permalink
GLES2: Fixed another memory leak
Browse files Browse the repository at this point in the history
Also added possible memory leak tracking
  • Loading branch information
GrapheneCt committed Aug 17, 2021
1 parent 1d4c497 commit 213cb9e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
13 changes: 13 additions & 0 deletions eurasiacon/opengles1/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,19 @@ __inline IMG_VOID *GLES1CallocHeapUNC(GLES1Context *gc, unsigned int size)
#define GLES1FreeAsync(X,Y) texOpAsyncAddForCleanup(X, Y)
__inline IMG_VOID GLES1Free(GLES1Context *gc, void *mem)
{

#if defined(DEBUG)
SceKernelMemBlockInfo sMemInfo;
sMemInfo.size = sizeof(SceKernelMemBlockInfo);
sMemInfo.type = 0;
sceKernelGetMemBlockInfoByAddr(mem, &sMemInfo);
if (sMemInfo.type != SCE_KERNEL_MEMBLOCK_TYPE_USER_RW && !gc)
{
PVR_DPF((PVR_DBG_WARNING, "GLES1Free called on uncached memory, but gc is NULL!"));
abort();
}
#endif

if (gc)
{
if (sceHeapFreeHeapMemory(gc->pvUNCHeap, mem) == SCE_HEAP_ERROR_INVALID_POINTER)
Expand Down
16 changes: 15 additions & 1 deletion eurasiacon/opengles2/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,19 @@ __inline IMG_VOID *GLES2CallocHeapUNC(GLES2Context *gc, unsigned int size)
#define GLES2FreeAsync(X,Y) texOpAsyncAddForCleanup(X, Y)
__inline IMG_VOID GLES2Free(GLES2Context *gc, void *mem)
{

#if defined(DEBUG)
SceKernelMemBlockInfo sMemInfo;
sMemInfo.size = sizeof(SceKernelMemBlockInfo);
sMemInfo.type = 0;
sceKernelGetMemBlockInfoByAddr(mem, &sMemInfo);
if (sMemInfo.type != SCE_KERNEL_MEMBLOCK_TYPE_USER_RW && !gc)
{
PVR_DPF((PVR_DBG_WARNING, "GLES2Free called on uncached memory, but gc is NULL!"));
abort();
}
#endif

if (gc)
{
if (sceHeapFreeHeapMemory(gc->pvUNCHeap, mem) == SCE_HEAP_ERROR_INVALID_POINTER)
Expand Down Expand Up @@ -415,9 +428,10 @@ __inline PVRSRV_ERROR GLES2ALLOCDEVICEMEM_HEAP(GLES2Context *gc, IMG_UINT32 ui32
}

psMemInfo = GLES2Calloc(gc, sizeof(PVRSRV_CLIENT_MEM_INFO));

if (!psMemInfo)
{
GLES2Free(IMG_NULL, mem);
GLES2Free(gc, mem);
return PVRSRV_ERROR_OUT_OF_MEMORY;
}

Expand Down
8 changes: 4 additions & 4 deletions eurasiacon/opengles2/psp2/swtexop.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ IMG_INTERNAL IMG_VOID SWTextureUpload(
psArg->psSyncInfo = psTex->psMemInfo->psClientSyncInfo;
}

/*do
do
{
eResult = SGX2DQueryBlitsComplete(gc->ps3DDevData, psArg->psSyncInfo, IMG_TRUE);
} while (eResult == PVRSRV_ERROR_TIMEOUT);*/
} while (eResult == PVRSRV_ERROR_TIMEOUT);

PVRSRVCreateSyncInfoModObj(gc->psSysContext->psConnection, &psArg->hOpSyncObj);

Expand Down Expand Up @@ -186,7 +186,7 @@ IMG_VOID texOpAsyncAddForCleanup(GLES2Context *gc, IMG_PVOID pvPtr)

PVR_DPF((PVR_DBG_WARNING, "texOpAsyncAddForCleanup: not enough space in free queue"));

GLES2Free(IMG_NULL, pvPtr);
GLES2Free(gc, pvPtr);
}

IMG_INT32 texOpAsyncCleanupThread(IMG_UINT32 argSize, IMG_VOID *pArgBlock)
Expand All @@ -206,7 +206,7 @@ IMG_INT32 texOpAsyncCleanupThread(IMG_UINT32 argSize, IMG_VOID *pArgBlock)
if (pvAsDstPtr[i] != IMG_NULL && !gc->ui32AsyncTexOpNum)
{
SGXWaitTransfer(gc->ps3DDevData, gc->psSysContext->hTransferContext);
GLES2Free(IMG_NULL, pvAsDstPtr[i]);
GLES2Free(gc, pvAsDstPtr[i]);
pvAsDstPtr[i] = IMG_NULL;
}
}
Expand Down
Binary file modified gpu_es4_ext/libSceGpuEs4UserForVsh_stub.a
Binary file not shown.
Binary file modified gpu_es4_ext/libSceGpuEs4User_stub.a
Binary file not shown.

0 comments on commit 213cb9e

Please sign in to comment.