From 2e3d77e8f2b78e1570c214857dd013ae27c78eed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 28 Mar 2013 16:21:32 +0100 Subject: [PATCH] (RGL PS3) Optimize FIFO out of space callback --- ps3/rgl/src/ps3/include/rgl-externs.h | 1 - ps3/rgl/src/ps3/rgl_ps3.cpp | 28 +++------------------------ ps3/rgl/src/ps3/rgl_ps3_raster.cpp | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/ps3/rgl/src/ps3/include/rgl-externs.h b/ps3/rgl/src/ps3/include/rgl-externs.h index 1465905a26..e8046fe583 100644 --- a/ps3/rgl/src/ps3/include/rgl-externs.h +++ b/ps3/rgl/src/ps3/include/rgl-externs.h @@ -2,7 +2,6 @@ void rglGcmFifoFinish (void *data); GLboolean rglGcmFifoReferenceInUse (void *data, GLuint reference); GLuint rglGcmFifoPutReference (void *data); void rglGcmFifoFlush (void *data); -uint32_t *rglGcmFifoWaitForFreeSpace (void *data, GLuint spaceInWords); void rglGcmGetTileRegionInfo (void *data, GLuint *address, GLuint *size); GLboolean rglGcmTryResizeTileRegion( GLuint address, GLuint size, void *data); diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index 7f74f1ecf6..0961fcbc8e 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -1500,19 +1500,6 @@ GLboolean rglGcmFifoReferenceInUse (void *data, GLuint reference) return GL_TRUE; } -// Wait until the requested space is available. -// If not currently available, will call the out of space callback - -uint32_t * rglGcmFifoWaitForFreeSpace (void *data, GLuint spaceInWords) -{ - rglGcmFifo *fifo = (rglGcmFifo*)data; - - if ( fifo->current + spaceInWords + 1024 > fifo->end ) - rglOutOfSpaceCallback( fifo, spaceInWords ); - - return rglGcmState_i.fifo.current; -} - void rglGcmFifoInit (void *data, void *dmaControl, unsigned long dmaPushBufferOffset, uint32_t*dmaPushBuffer, GLuint dmaPushBufferSize ) { @@ -2065,15 +2052,10 @@ int32_t rglOutOfSpaceCallback (void *data, uint32_t spaceInWords) // If the current end isn't the same as the full fifo end we // aren't at the end. Just go ahead and set the next begin and end if(fifo->end != fifo->dmaPushBufferEnd) - { nextbegin = (uint32_t *)fifo->end + 1; - nextend = nextbegin + fifo->fifoBlockSize/sizeof(uint32_t) - 1; - } else - { nextbegin = (uint32_t *)fifo->dmaPushBufferBegin; - nextend = nextbegin + (fifo->fifoBlockSize)/sizeof(uint32_t) - 1; - } + nextend = nextbegin + (fifo->fifoBlockSize)/sizeof(uint32_t) - 1; cellGcmAddressToOffset(nextbegin, &nextbeginoffset); cellGcmAddressToOffset(nextend, &nextendoffset); @@ -2087,8 +2069,6 @@ int32_t rglOutOfSpaceCallback (void *data, uint32_t spaceInWords) fifo->current = nextbegin; fifo->end = nextend; - const GLuint nopsAtBegin = 8; - //if Gpu busy with the new area, stall and flush uint32_t get = fifo->dmaControl->Get; @@ -2106,17 +2086,15 @@ int32_t rglOutOfSpaceCallback (void *data, uint32_t spaceInWords) while(((get >= nextbeginoffset) && (get <= nextendoffset)) || ((0 <= get) && (get < 0x10000))) { - // Don't be a ppu hog ;) - sys_timer_usleep(30); get = fifo->dmaControl->Get; cellGcmIoOffsetToAddress( get, &getEA ); } // need to add some nops here at the beginning for a issue with the get and the put being at the // same position when the fifo is in GPU memory. - for ( GLuint i = 0; i < nopsAtBegin; i++ ) + for ( GLuint i = 0; i < 8; i++ ) { - fifo->current[0] = RGLGCM_NOP(); + fifo->current[0] = 0; fifo->current++; } diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index c1b891d092..b557577457 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -1766,7 +1766,14 @@ static inline void rglValidateStates (GLuint mask) conf.registerCount = program->header.vertexProgram.registerCount; conf.attributeInputMask = program->header.attributeInputMask; - rglGcmFifoWaitForFreeSpace( &rglGcmState_i.fifo, 7 + 5 * conf.instructionCount ); + rglGcmFifo *fifo = (rglGcmFifo*)&rglGcmState_i.fifo; + GLuint spaceInWords = 7 + 5 * conf.instructionCount; + + // Push a CG program onto the current command buffer + + // make sure there is space for the pushbuffer + any nops we need to add for alignment + if ( fifo->current + spaceInWords + 1024 > fifo->end ) + rglOutOfSpaceCallback( fifo, spaceInWords ); GCM_FUNC( cellGcmSetVertexProgramLoad, &conf, program->ucode ); GCM_FUNC( cellGcmSetUserClipPlaneControl, 0, 0, 0, 0, 0, 0 ); @@ -1896,11 +1903,14 @@ static inline void rglValidateStates (GLuint mask) if (RGL_LIKELY(needValidate & RGL_VALIDATE_VERTEX_CONSTANTS) || validate_vertex_consts) { _CGprogram *cgprog = LContext->BoundVertexProgram; + rglGcmFifo *fifo = (rglGcmFifo*)&rglGcmState_i.fifo; + GLuint spaceInWords = cgprog->constantPushBufferWordSize + 4 + 32; // Push a CG program onto the current command buffer // make sure there is space for the pushbuffer + any nops we need to add for alignment - rglGcmFifoWaitForFreeSpace( &rglGcmState_i.fifo, cgprog->constantPushBufferWordSize + 4 + 32); + if ( fifo->current + spaceInWords + 1024 > fifo->end ) + rglOutOfSpaceCallback( fifo, spaceInWords ); // first add nops to get us the next alligned position in the fifo // [YLIN] Use VMX register to copy