diff --git a/ps3/rgl/src/ps3/include/GmmAlloc.h b/ps3/rgl/src/ps3/include/GmmAlloc.h index bd8a38041a..04093ab531 100644 --- a/ps3/rgl/src/ps3/include/GmmAlloc.h +++ b/ps3/rgl/src/ps3/include/GmmAlloc.h @@ -111,7 +111,8 @@ typedef struct GmmAllocator uint32_t gmmDestroy(void); char *gmmIdToAddress(const uint32_t id); uint32_t gmmFree (const uint32_t freeId); -uint32_t gmmAlloc(const uint8_t isTile, const uint32_t size); +uint32_t gmmAlloc(const uint32_t size); +uint32_t gmmAllocTiled(const uint32_t size); extern GmmAllocator *pGmmLocalAllocator; diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index 8bff0c3370..db36d7379e 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -366,7 +366,7 @@ static inline void rglGcmSetVertexProgramParameterBlock(struct CellGcmContextDat (thisContext->current) += 2; #define rglGcmSend(dstId, dstOffset, pitch, src, size) \ - GLuint id = gmmAlloc(0, size); \ + GLuint id = gmmAlloc(size); \ memcpy( gmmIdToAddress(id), (src), size ); \ rglGcmTransferData( dstId, dstOffset, size, id, 0, size, size, 1 ); \ gmmFree( id ) diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index 3a1b5aa1cd..faa95efd37 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -1317,28 +1317,6 @@ static void gmmAllocSweep(void *data) } } -static uint32_t gmmInternalAlloc( - GmmAllocator *pAllocator, - const uint8_t isTile, - const uint32_t size - ) -{ - uint32_t retId; - - if (isTile) - { - GmmTileBlock *pBlock = gmmFindFreeTileBlock(pAllocator, size); - retId = (uint32_t)gmmAllocTileBlock(pAllocator, size, pBlock); - } - else - retId = (uint32_t)gmmAllocBlock(pAllocator, size); - - if (retId == 0) - return GMM_ERROR; - - return retId; -} - static void gmmRemoveFree( GmmAllocator *pAllocator, GmmBlock *pBlock, @@ -1415,45 +1393,22 @@ static uint32_t gmmFindFreeBlock( return retId; } -uint32_t gmmAlloc(const uint8_t isTile, const uint32_t size) +uint32_t gmmAlloc(const uint32_t size) { - GmmAllocator *pAllocator; - uint32_t retId; - uint32_t newSize; - - if (size == 0) - return GMM_ERROR; - - pAllocator = pGmmLocalAllocator; - - if (!isTile) - { - newSize = PAD(size, GMM_ALIGNMENT); - - retId = gmmFindFreeBlock(pAllocator, newSize); - } - else - { - newSize = PAD(size, GMM_TILE_ALIGNMENT); - retId = GMM_ERROR; - } + GmmAllocator *pAllocator = pGmmLocalAllocator; + uint32_t newSize = PAD(size, GMM_ALIGNMENT); + uint32_t retId = gmmFindFreeBlock(pAllocator, newSize); if (retId == GMM_ERROR) { - retId = gmmInternalAlloc(pAllocator, - isTile, - newSize); + retId = (uint32_t)gmmAllocBlock(pAllocator, newSize); if (retId == GMM_ERROR) { gmmAllocSweep((CellGcmContextData*)&rglGcmState_i.fifo); + retId = (uint32_t)gmmAllocBlock(pAllocator, newSize); - retId = gmmInternalAlloc(pAllocator, - isTile, - newSize); - - if (!isTile && - retId == GMM_ERROR) + if (retId == GMM_ERROR) retId = gmmFindFreeBlock(pAllocator, newSize); } } @@ -1461,6 +1416,25 @@ uint32_t gmmAlloc(const uint8_t isTile, const uint32_t size) return retId; } +uint32_t gmmAllocTiled(const uint32_t size) +{ + GmmAllocator *pAllocator = pGmmLocalAllocator; + uint32_t newSize = PAD(size, GMM_TILE_ALIGNMENT); + uint32_t retId = GMM_ERROR; + GmmTileBlock *pBlock = gmmFindFreeTileBlock(pAllocator, newSize); + + retId = (uint32_t)gmmAllocTileBlock(pAllocator, newSize, pBlock); + + if (retId == GMM_ERROR) + { + gmmAllocSweep((CellGcmContextData*)&rglGcmState_i.fifo); + pBlock = gmmFindFreeTileBlock(pAllocator, newSize); + retId = (uint32_t)gmmAllocTileBlock(pAllocator, newSize, pBlock); + } + + return retId; +} + /*============================================================ FIFO BUFFER ============================================================ */ @@ -2227,7 +2201,7 @@ GLuint rglGcmAllocCreateRegion( { uint32_t id; - if ((id = gmmAlloc(1, size)) != GMM_ERROR) + if ((id = gmmAllocTiled(size)) != GMM_ERROR) { if ( rglGcmTryResizeTileRegion( (GLuint)gmmIdToOffset(id), gmmGetBlockSize(id), data ) ) { @@ -2510,8 +2484,8 @@ static void rescInit( const RGLdeviceParameters* params, rglGcmDevice *gcmDevice // allocate space for vertex array and fragment shader for drawing the rescaling texture-mapped quad int32_t colorBuffersSize, vertexArraySize, fragmentShaderSize; cellRescGetBufferSize( &colorBuffersSize, &vertexArraySize, &fragmentShaderSize ); - gcmDevice->RescVertexArrayId = gmmAlloc(0, vertexArraySize); - gcmDevice->RescFragmentShaderId = gmmAlloc(0, fragmentShaderSize); + gcmDevice->RescVertexArrayId = gmmAlloc(vertexArraySize); + gcmDevice->RescFragmentShaderId = gmmAlloc(fragmentShaderSize); // tell resc how to access the destination (scanout) buffer @@ -2528,7 +2502,7 @@ static void rescInit( const RGLdeviceParameters* params, rglGcmDevice *gcmDevice { const unsigned int tableLength = 32; // this was based on the guidelines in the resc reference guide unsigned int tableSize = sizeof(uint16_t) * 4 * tableLength; // 2 bytes per FLOAT16 * 4 values per entry * length of table - void *interlaceTable = gmmIdToAddress(gmmAlloc(0, tableSize)); + void *interlaceTable = gmmIdToAddress(gmmAlloc(tableSize)); int32_t errorCode = cellRescCreateInterlaceTable(interlaceTable,params->renderHeight,CELL_RESC_ELEMENT_HALF,tableLength); (void)errorCode; } diff --git a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp index 9b69d417a1..8a4db2767e 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp @@ -181,7 +181,7 @@ static int rglGcmGenerateProgram (void *data, int profileIndex, const CgProgramH if ( program->loadProgramId == GMM_ERROR ) { - program->loadProgramId = gmmAlloc(0, ucodeSize); + program->loadProgramId = gmmAlloc(ucodeSize); program->loadProgramOffset = 0; } diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index b35385185b..edb6f6ea8d 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -792,7 +792,7 @@ static void rglpsAllocateBuffer (void *data) // allocate in GPU memory rglBuffer->pool = RGLGCM_SURFACE_POOL_LINEAR; - rglBuffer->bufferId = gmmAlloc(0, rglBuffer->bufferSize); + rglBuffer->bufferId = gmmAlloc(rglBuffer->bufferSize); rglBuffer->pitch = 0; if ( rglBuffer->bufferId == GMM_ERROR ) @@ -1004,7 +1004,7 @@ static void rglPlatformBufferObjectSetDataTextureReference(void *buf_data, GLint // partial buffer write // STREAM and DYNAMIC buffers get transfer via a bounce buffer. // copy via bounce buffer - GLuint id = gmmAlloc(0, size); + GLuint id = gmmAlloc(size); memset(gmmIdToAddress(id), 0, size); rglGcmTransferData(rglBuffer->bufferId, offset, rglBuffer->pitch, id, 0, size, size, 1); gmmFree(id); @@ -1723,7 +1723,7 @@ beginning: GLuint VBOId = GMM_ERROR; if ( RGL_UNLIKELY( dparams->xferTotalSize ) ) { - xferId = gmmAlloc(0, dparams->xferTotalSize); + xferId = gmmAlloc(dparams->xferTotalSize); xferBuffer = gmmIdToAddress(xferId); } @@ -2082,7 +2082,7 @@ static void rglPlatformValidateTextureResources (void *data) rglPlatformDropTexture( texture ); // allocate in the specified pool - id = gmmAlloc(0, size); + id = gmmAlloc(size); // set new gcmTexture->pool = RGLGCM_SURFACE_POOL_LINEAR; @@ -2137,7 +2137,7 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE, { // lazy allocation of bounce buffer if ( bounceBufferId == GMM_ERROR && layout->baseDepth == 1 ) - bounceBufferId = gmmAlloc(0, gcmTexture->gpuSize); + bounceBufferId = gmmAlloc(gcmTexture->gpuSize); if ( bounceBufferId != GMM_ERROR ) {