(RGL PS3) Implement our own version of cellGcmSetInvalidateVertexCache

This commit is contained in:
twinaphex 2013-04-14 18:43:38 +02:00
parent 90cd21821f
commit 964aff3773
3 changed files with 33 additions and 10 deletions

View File

@ -42,6 +42,20 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat)
(thisContext->current)[1] = (value); \
(thisContext->current) += 2;
#define rglGcmSetInvalidateVertexCache(thisContext) \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001710))); \
(thisContext->current)[1] = 0; \
(thisContext->current) += 2; \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001714))); \
(thisContext->current)[1] = 0; \
(thisContext->current) += 2; \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001714))); \
(thisContext->current)[1] = 0; \
(thisContext->current) += 2; \
(thisContext->current)[0] = (((1) << (18)) | ((0x00001714))); \
(thisContext->current)[1] = 0; \
(thisContext->current) += 2;
static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFar)
{
rglGcmViewportState *vp = (rglGcmViewportState*)data;

View File

@ -1904,10 +1904,11 @@ void rglPsglPlatformInit (void *data)
void rglPsglPlatformExit(void)
{
RGLcontext* LContext = _CurrentContext;
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
if ( LContext )
{
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFlush( &rglGcmState_i.fifo );
psglMakeCurrent( NULL, NULL );
@ -2773,6 +2774,7 @@ static void rglSetDisplayMode( const VideoMode *vm, GLushort bitsPerPixel, GLuin
int rglPlatformCreateDevice (void *data)
{
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
RGLdevice *device = (RGLdevice*)data;
rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice;
RGLdeviceParameters* params = &device->deviceParameters;
@ -2995,7 +2997,7 @@ int rglPlatformCreateDevice (void *data)
rglSetDisplayMode( vm, gcmDevice->color[0].bpp*8, gcmDevice->color[0].pitch );
cellGcmSetFlipMode( gcmDevice->vsync ? CELL_GCM_DISPLAY_VSYNC : CELL_GCM_DISPLAY_HSYNC );
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFinish( &rglGcmState_i.fifo );
for ( int i = 0; i < params->bufferingMode; ++i )
@ -3021,8 +3023,9 @@ void rglPlatformDestroyDevice (void *data)
RGLdevice *device = (RGLdevice*)data;
rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice;
RGLdeviceParameters *params = &device->deviceParameters;
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFinish( &rglGcmState_i.fifo );
// Stop flip callback
@ -3060,6 +3063,7 @@ void rglPlatformDestroyDevice (void *data)
GLAPI void RGL_EXPORT psglSwap (void)
{
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
const uint32_t fence = rglGcmState_i.semaphores->userSemaphores[RGLGCM_SEMA_FENCE].val;
GmmBlock *pBlock = NULL;
GmmBlock *pTemp = NULL;
@ -3135,12 +3139,12 @@ GLAPI void RGL_EXPORT psglSwap (void)
context->needValidate = RGL_VALIDATE_ALL;
context->attribs->DirtyMask = ( 1 << RGL_MAX_VERTEX_ATTRIBS ) - 1;
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFlush( &rglGcmState_i.fifo );
while (sys_semaphore_wait(FlipSem,1000) != CELL_OK);
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFlush( &rglGcmState_i.fifo );
if ( device->deviceParameters.bufferingMode == RGL_BUFFERING_MODE_DOUBLE )
@ -4108,10 +4112,11 @@ RGLcontext *psglGetCurrentContext(void)
void RGL_EXPORT psglDestroyContext (void *data)
{
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
RGLcontext *LContext = (RGLcontext*)data;
if ( _CurrentContext == LContext )
{
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFinish( &rglGcmState_i.fifo );
}

View File

@ -1234,6 +1234,7 @@ char *rglPlatformBufferObjectMap (void *data, GLenum access)
{
rglBufferObject *bufferObject = (rglBufferObject*)data;
rglGcmBufferObject *rglBuffer = (rglGcmBufferObject*)bufferObject->platformBufferObject;
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
if (rglBuffer->mapCount++ == 0)
{
@ -1252,7 +1253,7 @@ char *rglPlatformBufferObjectMap (void *data, GLenum access)
else
{
// must wait in order to read
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFinish( &rglGcmState_i.fifo );
}
@ -1310,6 +1311,7 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
{
RGLcontext* LContext = _CurrentContext;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
if ( LContext->needValidate & RGL_VALIDATE_FRAMEBUFFER )
{
@ -1353,7 +1355,7 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
CELL_GCM_CLEAR_B | CELL_GCM_CLEAR_A );
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFlush( &rglGcmState_i.fifo );
}
@ -1530,7 +1532,8 @@ void rglPlatformFramebuffer::validate (void *data)
// shader and needed connections between GL state and the shader
void *rglPlatformRasterInit (void)
{
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
rglGcmSetInvalidateVertexCache(thisContext);
rglGcmFifoFinish( &rglGcmState_i.fifo );
rglGcmDriver *driver = (rglGcmDriver*)malloc(sizeof(rglGcmDriver));
@ -1577,6 +1580,7 @@ static uint8_t s_dparams_buff[ c_rounded_size_ofrglDrawParams ] __attribute__((a
GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
{
RGLcontext* LContext = _CurrentContext;
CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext;
if (RGL_UNLIKELY(!RGLBIT_GET(LContext->attribs->EnabledMask, RGL_ATTRIB_POSITION_INDEX)))
return;
@ -2101,7 +2105,7 @@ beginning:
if ( driver->invalidateVertexCache )
{
driver->invalidateVertexCache = GL_FALSE;
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmSetInvalidateVertexCache(thisContext);
}
GCM_FUNC( cellGcmSetUpdateFragmentProgramParameter,