Skip to content

Commit

Permalink
GLES1: Bugfixes
Browse files Browse the repository at this point in the history
- Fixed a bug where library would not wait for GPU to catch up before resizng vertex buffer;
- Fixed a bug which caused incorrect sync info to be submitted to HW transfers;
- CPU-cached memory is now used for PVRTC textures to improve texture upload performance.
  • Loading branch information
GrapheneCt committed Aug 9, 2021
1 parent 511624a commit 532a6fc
Show file tree
Hide file tree
Showing 33 changed files with 234 additions and 151 deletions.
1 change: 0 additions & 1 deletion eurasiacon/common/buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@ IMG_INTERNAL CircularBuffer *CBUF_CreateBuffer(PVRSRV_DEV_DATA *ps3DDevData,
return IMG_NULL;
}


if (PVRSRVAllocSyncInfo(ps3DDevData, &psMemInfo->psClientSyncInfo))
{
PVR_DPF((PVR_DBG_ERROR, "CBUF_CreateBuffer: PVRSRVAllocSyncInfo failed for buffer %d", ui32BufferType));
Expand Down
10 changes: 4 additions & 6 deletions eurasiacon/imgegl/imgegl/srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,15 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV KEGLAllocDeviceMemTrack(SrvSysContext *psSy
eError = PVRSRVAllocDeviceMem(psDevData, hDevMemHeap, ui32Attribs, ui32Size, ui32Alignment, psSysContext->hPerProcRef, ppsMemInfo);
if(eError == PVRSRV_OK)
{
PVR_DPF((PVR_DBG_VERBOSE, "KEGLAllocDeviceMemTrack: PVRSRVAllocDeviceMem\n\nHeap handle 0x%X\nAllocation size: 0x%X\nAllocation attrib: 0x%X\n\n", hDevMemHeap, ui32Size, ui32Attribs));

psAllocation = &psSysContext->psDevMemAllocations[psSysContext->ui32CurrentAllocations];

psAllocation->psMemInfo = *ppsMemInfo;
psAllocation->psDevData = psDevData;
psAllocation->u32Line = u32Line;
psAllocation->pszFile = pszFile;

PVR_DPF((PVR_DBG_VERBOSE, "KEGLAllocDeviceMemTrack: PVRSRVAllocDeviceMem\n\nHeap handle 0x%X\nAllocation size: 0x%X\nAllocation attrib: 0x%X\nDev vaddr: 0x%X\n\n", hDevMemHeap, ui32Size, ui32Attribs, psAllocation->psMemInfo->sDevVAddr.uiAddr));

psSysContext->ui32CurrentAllocations++;
}
else
Expand Down Expand Up @@ -691,6 +691,8 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV KEGLAllocDeviceMemPsp2(SrvSysContext *psSys
{
psMemInfo = *ppsMemInfo;

psMemInfo->psClientSyncInfo = IMG_NULL;

if (bNeedSync)
{
eError = PVRSRVAllocSyncInfo(psDevData, &psMemInfo->psClientSyncInfo);
Expand All @@ -701,10 +703,6 @@ IMG_EXPORT PVRSRV_ERROR IMG_CALLCONV KEGLAllocDeviceMemPsp2(SrvSysContext *psSys
return eError;
}
}
else
{
psMemInfo->psClientSyncInfo = IMG_NULL;
}
}

return eError;
Expand Down
8 changes: 7 additions & 1 deletion eurasiacon/imgegl/imgegl/srv_sgx.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,13 @@ IMG_INTERNAL IMG_BOOL KEGL_SGXDestroyRenderSurface(SrvSysContext *psSysContext,
IMG_BOOL bUnused;

/* Wait for operations on the surface to complete */
if(sceGpuSignalWait(sceKernelGetTLSAddr(0x44), 1000000) != PVRSRV_OK)
if(PVRSRVPollForValue(psSysContext->psConnection,
psSysContext->sHWInfo.sMiscInfo.hOSGlobalEvent,
psSurface->sPDSBuffer.pui32ReadOffset,
psSurface->sPDSBuffer.ui32CommittedHWOffsetInBytes,
0xFFFFFFFF,
1000,
1000) != PVRSRV_OK)
{
bSuccess = IMG_FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion eurasiacon/opengles1/bufobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static IMG_VOID FreeBufferObject(GLES1Context *gc, GLESBufferObject *psBufObj, I

KRM_RemoveResourceFromAllLists(&gc->psSharedState->sBufferObjectKRM, &psBufObj->sResource);

GLES1Free(gc, psBufObj);
GLES1Free(IMG_NULL, psBufObj);
}


Expand Down
33 changes: 22 additions & 11 deletions eurasiacon/opengles1/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,24 @@ __inline IMG_VOID *GLES1CallocHeapUNC(GLES1Context *gc, unsigned int size)
return ret;
}
#define GLES1ReallocHeapUNC(X,Y,Z) (IMG_VOID*)sceHeapReallocHeapMemory(X->pvUNCHeap, Y, Z)
#define GLES1FreeHeapUNC(X,Y) sceHeapFreeHeapMemory(X->pvUNCHeap, Y)
#define GLES1FreeHeapAsyncUNC(X,Y) texOpAsyncAddForCleanup(X, Y)
#define GLES1FreeAsync(X,Y) texOpAsyncAddForCleanup(X, Y)
__inline IMG_VOID GLES1Free(GLES1Context *gc, void *mem)
{
if (gc)
{
if (sceHeapFreeHeapMemory(gc->pvUNCHeap, mem) == SCE_HEAP_ERROR_INVALID_POINTER)
{
if (sceHeapFreeHeapMemory(gc->pvCDRAMHeap, mem) == SCE_HEAP_ERROR_INVALID_POINTER)
{
free(mem);
}
}
}
else
{
free(mem);
}
}


#define GLES1MallocHeapCDRAM(X,Y) (IMG_VOID*)sceHeapAllocHeapMemory(X->pvCDRAMHeap, Y)
Expand All @@ -634,7 +650,6 @@ __inline IMG_VOID *GLES1CallocHeapCDRAM(GLES1Context *gc, unsigned int size)
return ret;
}
#define GLES1ReallocHeapCDRAM(X,Y,Z) (IMG_VOID*)sceHeapReallocHeapMemory(X->pvCDRAMHeap, Y, Z)
#define GLES1FreeHeapCDRAM(X,Y) sceHeapFreeHeapMemory(X->pvCDRAMHeap, Y)


__inline PVRSRV_ERROR GLES1ALLOCDEVICEMEM_HEAP(GLES1Context *gc, IMG_UINT32 ui32Attribs, IMG_UINT32 ui32Size, IMG_UINT32 ui32Alignment, PVRSRV_CLIENT_MEM_INFO **ppsMemInfo)
Expand All @@ -652,10 +667,10 @@ __inline PVRSRV_ERROR GLES1ALLOCDEVICEMEM_HEAP(GLES1Context *gc, IMG_UINT32 ui32
return PVRSRV_ERROR_OUT_OF_MEMORY;
}

psMemInfo = GLES1Malloc(gc, sizeof(PVRSRV_CLIENT_MEM_INFO));
psMemInfo = GLES1Calloc(gc, sizeof(PVRSRV_CLIENT_MEM_INFO));
if (!psMemInfo)
{
GLES1FreeHeapCDRAM(gc, mem);
GLES1Free(gc, mem);
return PVRSRV_ERROR_OUT_OF_MEMORY;
}

Expand Down Expand Up @@ -688,12 +703,8 @@ __inline PVRSRV_ERROR GLES1FREEDEVICEMEM_HEAP(GLES1Context *gc, PVRSRV_CLIENT_ME
PVRSRVFreeSyncInfo(gc->ps3DDevData, psMemInfo->psClientSyncInfo);
}

if (psMemInfo->ui32Flags & PVRSRV_MAP_GC_MMU)
GLES1FreeHeapCDRAM(gc, psMemInfo->pvLinAddr);
else
GLES1FreeHeapUNC(gc, psMemInfo->pvLinAddr);

GLES1Free(gc, psMemInfo);
GLES1Free(gc, psMemInfo->pvLinAddr);
GLES1Free(IMG_NULL, psMemInfo);

return PVRSRV_OK;
}
Expand Down
22 changes: 11 additions & 11 deletions eurasiacon/opengles1/drawvarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ static IMG_VOID DrawBatchOnVBuffer(GLES1Context *gc, GLenum eMode, IMG_UINT32 ui

} while(ui32IndexStart + ui32RewindCount < ui32CountIn);

GLES1Free(gc, pui16Tmpindex);
GLES1Free(IMG_NULL, pui16Tmpindex);

break;
}
Expand Down Expand Up @@ -1585,7 +1585,7 @@ static PFNDrawVArray PickDrawElementsProc(GLES1Context *gc, GLenum eMode, GLenum
{
PVR_DPF((PVR_DBG_WARNING,"PickDrawElementsProc: Resized dynamic vertex buffer. Was %u bytes, now %u bytes",
gc->apsBuffers[CBUF_TYPE_VERTEX_DATA_BUFFER]->ui32BufferLimitInBytes, psBuffer->ui32BufferLimitInBytes));

CBUF_DestroyBuffer(gc->ps3DDevData, gc->apsBuffers[CBUF_TYPE_VERTEX_DATA_BUFFER]);

gc->apsBuffers[CBUF_TYPE_VERTEX_DATA_BUFFER] = psBuffer;
Expand Down Expand Up @@ -1811,7 +1811,7 @@ static IMG_UINT16* TransformIndicesTo16Bits(GLES1Context *gc, IMG_UINT32 ui32Cou
else
{
PVR_DPF((PVR_DBG_MESSAGE,"TransformIndicesTo16Bits: Unsupported index type 0x%X", eType));
GLES1Free(gc, pui16OutIndices);
GLES1Free(IMG_NULL, pui16OutIndices);
pui16OutIndices = IMG_NULL;
}

Expand Down Expand Up @@ -2610,7 +2610,7 @@ GL_API void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type,

if(bIndicesWerePromoted)
{
GLES1Free(gc, pui16NewElements);
GLES1Free(IMG_NULL, pui16NewElements);
}

/*
Expand Down Expand Up @@ -2984,7 +2984,7 @@ static IMG_VOID MultiDrawBatchOnVBuffer(GLES1Context *gc, GLenum eMode, IMG_UINT

} while(ui32IndexStart + ui32RewindCount < pui32CountIn[i]);

GLES1Free(gc, pui16Tmpindex);
GLES1Free(IMG_NULL, pui16Tmpindex);

break;
}
Expand Down Expand Up @@ -3175,7 +3175,7 @@ static IMG_VOID MultiDrawElementsDeindex(GLES1Context *gc, GLenum eMode, IMG_UIN
ui32Offset += pui32Count[i];
}

GLES1Free(gc, pui16DeIndices);
GLES1Free(IMG_NULL, pui16DeIndices);
}


Expand Down Expand Up @@ -3624,7 +3624,7 @@ GL_API_EXT void GL_APIENTRY glMultiDrawArraysEXT(GLenum mode, GLint * first, GLs
ui32MinFirst, ui32MaxCount, (IMG_UINT32)primcount);


GLES1Free(gc, pui32ActualCount);
GLES1Free(IMG_NULL, pui32ActualCount);

/*
Update vertex and index buffers committed primitive offset
Expand Down Expand Up @@ -3949,7 +3949,7 @@ GL_API_EXT void GL_APIENTRY glMultiDrawElementsEXT(GLenum mode, const GLsizei *c

for(i = 0; i < ui32ActualPrimCount; i++)
{
GLES1Free(gc, (IMG_VOID *)((IMG_UINTPTR_T)(ppvElements[i])));
GLES1Free(IMG_NULL, (IMG_VOID *)((IMG_UINTPTR_T)(ppvElements[i])));
}
}
else if ((VAO_INDEX_BUFFER_OBJECT(gc)) && (pfnMultiDrawElements != MultiDrawElementsIndexBO))
Expand Down Expand Up @@ -3999,17 +3999,17 @@ GL_API_EXT void GL_APIENTRY glMultiDrawElementsEXT(GLenum mode, const GLsizei *c

if(ppvElements)
{
GLES1Free(gc, (IMG_VOID*) ppvElements);
GLES1Free(IMG_NULL, (IMG_VOID*) ppvElements);
}

if(ppvActualIndices)
{
GLES1Free(gc, (IMG_VOID*) ppvActualIndices);
GLES1Free(IMG_NULL, (IMG_VOID*) ppvActualIndices);
}

if(pui32ActualCount)
{
GLES1Free(gc, pui32ActualCount);
GLES1Free(IMG_NULL, pui32ActualCount);
}

GLES1_TIME_STOP(GLES1_TIMER_ELEMENT_POINTS_TIME+mode);
Expand Down
16 changes: 8 additions & 8 deletions eurasiacon/opengles1/eglglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static GLES1Context* _GLES1CreateContext(IMG_VOID)
************************************************************************************/
static IMG_VOID _GLES1DestroyContext(GLES1Context *gc)
{
GLES1Free(0, gc);
GLES1Free(IMG_NULL, gc);
}


Expand Down Expand Up @@ -218,7 +218,7 @@ static IMG_VOID FreeContextSharedState(GLES1Context *gc)
/* Clear for safety */
GLES1MemSet(psSharedState, 0, sizeof(GLES1ContextSharedState));

GLES1Free(gc, psSharedState);
GLES1Free(IMG_NULL, psSharedState);
}

gc->psSharedState = IMG_NULL;
Expand Down Expand Up @@ -286,7 +286,7 @@ static IMG_BOOL CreateSharedState(GLES1Context *gc, GLES1Context *psShareContext
{
PVR_DPF((PVR_DBG_ERROR,"CreateSharedState: PVRSRVCreateMutex failed on hPrimaryLock (%d)", eError));

GLES1Free(gc, psSharedState);
GLES1Free(IMG_NULL, psSharedState);

return IMG_FALSE;
}
Expand All @@ -304,7 +304,7 @@ static IMG_BOOL CreateSharedState(GLES1Context *gc, GLES1Context *psShareContext
PVR_DPF((PVR_DBG_ERROR, "CreateSharedState: PVRSRVDestroyMutex failed on hPrimaryLock (%d)", eError));
}

GLES1Free(gc, psSharedState);
GLES1Free(IMG_NULL, psSharedState);

return IMG_FALSE;
}
Expand All @@ -329,7 +329,7 @@ static IMG_BOOL CreateSharedState(GLES1Context *gc, GLES1Context *psShareContext
PVR_DPF((PVR_DBG_ERROR, "CreateSharedState: PVRSRVDestroyMutex failed on hPrimaryLock (%d)", eError));
}

GLES1Free(gc, psSharedState);
GLES1Free(IMG_NULL, psSharedState);

return IMG_FALSE;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ static IMG_BOOL CreateSharedState(GLES1Context *gc, GLES1Context *psShareContext
PVR_DPF((PVR_DBG_ERROR, "CreateSharedState: PVRSRVDestroyMutex failed on hPrimaryLock (%d)", eError));
}

GLES1Free(gc, psSharedState);
GLES1Free(IMG_NULL, psSharedState);

return IMG_FALSE;
}
Expand Down Expand Up @@ -1379,7 +1379,7 @@ static IMG_BOOL GLESCreateGC(SrvSysContext *psSysContext,
SceKernelMemBlockInfo sMbInfo;
sMbInfo.size = sizeof(SceKernelMemBlockInfo);
sceKernelGetMemBlockInfoByAddr(pvDummy, &sMbInfo);
int ret = PVRSRVMapMemoryToGpu(
PVRSRVMapMemoryToGpu(
gc->ps3DDevData,
gc->psSysContext->hDevMemContext,
0,
Expand All @@ -1388,7 +1388,7 @@ static IMG_BOOL GLESCreateGC(SrvSysContext *psSysContext,
sMbInfo.mappedBase,
PVRSRV_MEM_READ | PVRSRV_MEM_WRITE | PVRSRV_MEM_USER_SUPPLIED_DEVVADDR,
IMG_NULL);
GLES1Free(0, pvDummy);
GLES1Free(IMG_NULL, pvDummy);

#if defined (TIMING) || defined (DEBUG)
if (!InitMetrics(gc))
Expand Down
12 changes: 6 additions & 6 deletions eurasiacon/opengles1/fbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ IMG_INTERNAL IMG_BOOL FlushAllUnflushedFBO(GLES1Context *gc,
{
*ppsFlushList = psFlushItem->psNext;

GLES1Free(gc, psFlushItem);
GLES1Free(IMG_NULL, psFlushItem);
}
}
else
Expand Down Expand Up @@ -379,7 +379,7 @@ static IMG_VOID FreeFrameBuffer(GLES1Context *gc, GLESFrameBuffer *psFrameBuffer
}
}

GLES1Free(gc, psFrameBuffer);
GLES1Free(IMG_NULL, psFrameBuffer);
}


Expand Down Expand Up @@ -425,7 +425,7 @@ IMG_INTERNAL IMG_VOID DestroyFBOAttachableRenderSurface(GLES1Context *gc, GLES1F
gc->psRenderSurface = IMG_NULL;
}

GLES1Free(gc, psAttachment->psRenderSurface);
GLES1Free(IMG_NULL, psAttachment->psRenderSurface);
}

psAttachment->psRenderSurface = IMG_NULL;
Expand Down Expand Up @@ -468,7 +468,7 @@ static IMG_VOID FreeRenderBuffer(GLES1Context *gc, GLESRenderBuffer *psRenderBuf
GLES1FREEDEVICEMEM_HEAP(gc, psRenderBuffer->psMemInfo);
}

GLES1Free(gc, psRenderBuffer);
GLES1Free(IMG_NULL, psRenderBuffer);
}

/***********************************************************************************
Expand Down Expand Up @@ -973,7 +973,7 @@ static IMG_BOOL SetupFrameBufferColorAttachment(GLES1Context *gc, GLESFrameBuffe
IMG_FALSE,
psFrameBuffer->sDrawParams.psRenderSurface))
{
GLES1Free(gc, psAttachment->psRenderSurface);
GLES1Free(IMG_NULL, psAttachment->psRenderSurface);

psAttachment->psRenderSurface = 0;

Expand Down Expand Up @@ -1664,7 +1664,7 @@ static IMG_VOID ComputeFrameBufferCompleteness(GLES1Context *gc)
IMG_FALSE,
psFrameBuffer->sDrawParams.psRenderSurface))
{
GLES1Free(gc, psAttachment->psRenderSurface);
GLES1Free(IMG_NULL, psAttachment->psRenderSurface);

psAttachment->psRenderSurface = 0;

Expand Down
14 changes: 7 additions & 7 deletions eurasiacon/opengles1/fftex.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,15 @@ IMG_INTERNAL IMG_VOID DestroyHashedBlendState(GLES1Context *gc, IMG_UINT32 ui32I
{
if(psFFTBProgramDesc->psFFGENProgramDetails->pui32Instructions)
{
GLES1Free(gc, psFFTBProgramDesc->psFFGENProgramDetails->pui32Instructions);
GLES1Free(IMG_NULL, psFFTBProgramDesc->psFFGENProgramDetails->pui32Instructions);
}

GLES1Free(gc, psFFTBProgramDesc->psFFGENProgramDetails);
GLES1Free(IMG_NULL, psFFTBProgramDesc->psFFGENProgramDetails);
}

FreeUSEASMInstructionList(gc, &psFFTBProgramDesc->sUSEASMInfo);

GLES1Free(gc, psFFTBProgramDesc);
GLES1Free(IMG_NULL, psFFTBProgramDesc);
}

/* Unlink shader */
Expand Down Expand Up @@ -555,7 +555,7 @@ static GLES1_MEMERROR ReuseHashedBlendState(GLES1Context *gc,

if(!psFFTBProgramDesc)
{
GLES1Free(gc, pui32HashData);
GLES1Free(IMG_NULL, pui32HashData);

PVR_DPF((PVR_DBG_ERROR,"ReuseHashedBlendState: malloc() failed"));

Expand All @@ -568,7 +568,7 @@ static GLES1_MEMERROR ReuseHashedBlendState(GLES1Context *gc,
{
PVR_DPF((PVR_DBG_ERROR,"ReuseHashedBlendState: malloc() failed"));

GLES1Free(gc, psFFTBProgramDesc);
GLES1Free(IMG_NULL, psFFTBProgramDesc);

return GLES1_GENERAL_MEM_ERROR;
}
Expand All @@ -582,8 +582,8 @@ static GLES1_MEMERROR ReuseHashedBlendState(GLES1Context *gc,
{
PVR_DPF((PVR_DBG_ERROR,"ReuseHashedBlendState: CreateIntegerFragmentProgramFromFF failed"));

GLES1Free(gc, psFFTBProgramDesc);
GLES1Free(gc, psFragmentShader);
GLES1Free(IMG_NULL, psFFTBProgramDesc);
GLES1Free(IMG_NULL, psFragmentShader);
return GLES1_GENERAL_MEM_ERROR;
}

Expand Down
Loading

0 comments on commit 532a6fc

Please sign in to comment.