(RGL PS3) GMM allocator optimizations

This commit is contained in:
twinaphex 2013-11-02 03:40:41 +01:00
parent 3e914f42b3
commit 1ce7bed027
2 changed files with 25 additions and 65 deletions
ps3/rgl/src/ps3

@ -69,16 +69,18 @@ typedef struct GmmBlock{
uint32_t fence;
}GmmBlock;
typedef struct GmmTileBlock{
typedef struct GmmTileBlock
{
GmmBaseBlock base; // inheritence
struct GmmTileBlock *pPrev;
struct GmmTileBlock *pNext;
uint32_t tileTag;
void *pData;
}GmmTileBlock;
} GmmTileBlock;
typedef struct GmmAllocator{
typedef struct GmmAllocator
{
uint32_t memoryBase;
uint32_t startAddress;
@ -104,7 +106,7 @@ typedef struct GmmAllocator{
GmmBlock *pFreeTail[GMM_NUM_FREE_BINS];
uint32_t totalSize; // == size + tileSize
}GmmAllocator;
} GmmAllocator;
uint32_t gmmInit(
const void *localMemoryBase,
@ -114,17 +116,7 @@ uint32_t gmmInit(
uint32_t gmmDestroy(void);
char *gmmIdToAddress(const uint32_t id);
uint32_t gmmFPOffsetToId(
const uint32_t offset,
uint32_t *pOutOffset,
bool bLocalMemory
);
void gmmPinId (const uint32_t id);
void gmmUnpinId (const uint32_t id);
uint32_t gmmFree (const uint32_t freeId);
uint32_t gmmAlloc(
void *data,
const uint8_t isTile,
@ -143,10 +135,16 @@ extern GmmAllocator *pGmmLocalAllocator;
#define gmmFreeFixedBlock(data) (gmmFreeFixed(0, (GmmBlock*)data))
#define gmmAllocTileBlock(pAllocator, size, pBlock) ((pBlock == NULL) ? gmmCreateTileBlock(pAllocator, size) : pBlock)
void gmmSetTileAttrib(
const uint32_t id,
const uint32_t tag,
void *pData
);
#define gmmSetTileAttrib(id, tag, data) \
((GmmTileBlock*)id)->tileTag = tag; \
((GmmTileBlock*)id)->pData = data;
#define gmmPinId(id) \
if (!((GmmBaseBlock*)id)->isTile) \
((GmmBlock *)id)->isPinned = 1;
#define gmmUnpinId(id) \
if (!((GmmBaseBlock*)id)->isTile) \
((GmmBlock *)id)->isPinned = 0;
#endif

@ -480,15 +480,6 @@ uint32_t gmmInit(
return gmmInitFixedAllocator();
}
static inline void gmmWaitForSweep (void)
{
while (cachedLockValue != 0)
{
sys_timer_usleep(30);
cachedLockValue = *pLock;
}
}
uint32_t gmmDestroy (void)
{
GmmBlock *pBlock, *pTmpBlock;
@ -529,46 +520,15 @@ uint32_t gmmDestroy (void)
return CELL_OK;
}
void gmmSetTileAttrib(const uint32_t id, const uint32_t tag,
void *pData)
{
GmmTileBlock *pTileBlock = (GmmTileBlock *)id;
pTileBlock->tileTag = tag;
pTileBlock->pData = pData;
}
char *gmmIdToAddress (const uint32_t id)
{
GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id;
gmmWaitForSweep();
return (char *)pBaseBlock->address;
}
void gmmPinId(const uint32_t id)
{
GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id;
if (!pBaseBlock->isTile)
while (cachedLockValue != 0)
{
GmmBlock *pBlock = (GmmBlock *)id;
pBlock->isPinned = 1;
}
}
void gmmUnpinId(const uint32_t id)
{
GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id;
if (!pBaseBlock->isTile)
{
GmmBlock *pBlock = (GmmBlock *)id;
pBlock->isPinned = 0;
// wait for sweep
sys_timer_usleep(30);
cachedLockValue = *pLock;
}
return (char *)((GmmBaseBlock*)id)->address;
}
static GmmBlock *gmmAllocBlock(
@ -807,7 +767,7 @@ static uint32_t gmmAllocExtendedTileBlock(const uint32_t size, const uint32_t ta
if (pNewBlock->pPrev->pData != pNewBlock->pNext->pData)
resizeSucceed = rglGcmTryResizeTileRegion( (GLuint)gmmIdToOffset((uint32_t)pNewBlock), tileSize+newSize, pBlock->pData );
}
gmmSetTileAttrib( retId, tag, pBlock->pData );
gmmSetTileAttrib(retId, tag, pBlock->pData);
break;
}
@ -2316,7 +2276,9 @@ GLuint rglGcmAllocCreateRegion(
if ( id != GMM_ERROR )
{
if ( rglGcmTryResizeTileRegion( (GLuint)gmmIdToOffset(id), gmmGetBlockSize(id), data ) )
{
gmmSetTileAttrib( id, tag, data );
}
else
{
gmmFree( id );