From aed81d2dad6cd21c58daec52376ba2dcc202dc2a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Apr 2013 19:16:54 +0200 Subject: [PATCH] (RGL PS3) Implement our own versions of cellGcmSetDrawArrays, cellGcmSetClearSurface, cellGcmSetTextureControl, and cellGcmSetTextureRemap --- ps3/rgl/src/ps3/include/rgl-inline.h | 78 ++++++++++++++++++++++++++++ ps3/rgl/src/ps3/rgl_ps3.cpp | 9 ++-- ps3/rgl/src/ps3/rgl_ps3_raster.cpp | 13 ++--- 3 files changed, 87 insertions(+), 13 deletions(-) diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index 4cbd228992..a0f4d10e6c 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -56,6 +56,84 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current)[1] = 0; \ (thisContext->current) += 2; +#define rglGcmSetClearSurface(thisContext, mask) \ + (thisContext->current)[0] = (((1) << (18)) | ((0x00001d94))); \ + (thisContext->current)[1] = (mask); \ + (thisContext->current) += 2; \ + (thisContext->current)[0] = (((1) << (18)) | ((0x00000100))); \ + (thisContext->current)[1] = 0; \ + (thisContext->current) += 2; + +#define rglGcmSetTextureControl(thisContext, index, enable, minlod, maxlod, maxaniso) \ + (thisContext->current)[0] = (((1) << (18)) | ((0x00001a0c) + 0x20 * ((index)))); \ + (thisContext->current)[1] = ((((0) << 2) | ((maxaniso)) << 4) | (((maxlod)) << 7) | (((minlod)) << 19) | ((enable) << 31)); \ + (thisContext->current) += 2; + +#define rglGcmSetTextureRemap(thisContext, index, remap) \ + (thisContext->current)[0] = (((1) << (18)) | ((0x00001a10) + ((index)) * 32)); \ + (thisContext->current)[1] = (remap); \ + (thisContext->current) += 2; + +static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, uint8_t mode, + uint32_t first, uint32_t count) +{ + uint32_t lcount; + + --count; + lcount = count & 0xff; + count >>= 8; + + uint32_t loop, rest; + loop = count / (2047); + rest = count % (2047); + + (thisContext->current)[0] = (((3) << (18)) | ((0x00001714)) | (0x40000000)); + (thisContext->current)[1] = 0; + (thisContext->current)[2] = 0; + (thisContext->current)[3] = 0; ; (thisContext->current) += 4; + + (thisContext->current)[0] = (((1) << (18)) | ((0x00001808))); + (thisContext->current)[1] = ((mode)); + (thisContext->current) += 2; + + (thisContext->current)[0] = (((1) << (18)) | ((0x00001814))); + (thisContext->current)[1] = ((first) | ((lcount)<<24)); + (thisContext->current) += 2; + first += lcount + 1; + + uint32_t i,j; + + for(i=0;icurrent[0] = ((((2047)) << (18)) | ((0x00001814)) | (0x40000000)); + thisContext->current++; + + for(j=0;j<(2047);j++) + { + thisContext->current[0] = ((first) | ((255U)<<24)); + thisContext->current++; + first += 256; + } + } + + if(rest) + { + thisContext->current[0] = (((rest) << (18)) | ((0x00001814)) | (0x40000000)); + thisContext->current++; + + for(j=0;jcurrent[0] = ((first) | ((255U)<<24)); + thisContext->current++; + first += 256; + } + } + + (thisContext->current)[0] = (((1) << (18)) | ((0x00001808))); + (thisContext->current)[1] = (0); + (thisContext->current) += 2; +} + static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFar) { rglGcmViewportState *vp = (rglGcmViewportState*)data; diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index 4e384f0bfe..5bfe2fa226 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -1698,6 +1698,7 @@ void rglGcmFifoInit (void *data, void *dmaControl, unsigned long dmaPushBufferOf void rglGcmSetOpenGLState (void *data) { rglGcmState *rglGcmSt = (rglGcmState*)data; + CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext; GLuint i; // initialize the default OpenGL state @@ -1727,8 +1728,8 @@ void rglGcmSetOpenGLState (void *data) GCM_FUNC( cellGcmSetTextureFilter, i, 0, CELL_GCM_TEXTURE_NEAREST_LINEAR, CELL_GCM_TEXTURE_LINEAR, CELL_GCM_TEXTURE_CONVOLUTION_QUINCUNX ); - // update the texture control to setup antisotropic settings - GCM_FUNC( cellGcmSetTextureControl, i, CELL_GCM_TRUE, 0, 12 << 8, CELL_GCM_TEXTURE_MAX_ANISO_1 ); + // update the texture control to setup anisotropic settings + rglGcmSetTextureControl(thisContext, i, CELL_GCM_TRUE, 0, 12 << 8, CELL_GCM_TEXTURE_MAX_ANISO_1 ); // update border color GCM_FUNC( cellGcmSetTextureBorderColor, i, borderColor ); @@ -2896,7 +2897,7 @@ int rglPlatformCreateDevice (void *data) rglGcmFifoGlSetRenderTarget( &gcmDevice->rt ); if (rglGcmState_i.renderTarget.colorFormat) - GCM_FUNC( cellGcmSetClearSurface, CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | + rglGcmSetClearSurface(thisContext, CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | CELL_GCM_CLEAR_B | CELL_GCM_CLEAR_A ); } // restore parameters @@ -2914,7 +2915,7 @@ int rglPlatformCreateDevice (void *data) rglGcmFifoGlSetRenderTarget( &gcmDevice->rt ); if (rglGcmState_i.renderTarget.colorFormat) - GCM_FUNC( cellGcmSetClearSurface, CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | + rglGcmSetClearSurface(thisContext, CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | CELL_GCM_CLEAR_B | CELL_GCM_CLEAR_A ); } } diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index e500030c15..1c7863ba0f 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -1351,10 +1351,8 @@ GLAPI void APIENTRY glClear( GLbitfield mask ) GCM_FUNC( cellGcmSetClearColor, 0 ); - GCM_FUNC( cellGcmSetClearSurface, CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | + rglGcmSetClearSurface(thisContext, CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | CELL_GCM_CLEAR_B | CELL_GCM_CLEAR_A ); - - rglGcmSetInvalidateVertexCache(thisContext); rglGcmFifoFlush( &rglGcmState_i.fifo ); } @@ -1676,7 +1674,6 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count) else { // Validate incomplete texture by remapping - //RGL_REPORT_EXTRA( RGL_REPORT_TEXTURE_INCOMPLETE, "Texture %d bound to unit %d(%s) is incomplete.", texture->name, unit, rglGetGLEnumName( texture->target ) ); GLuint remap = CELL_GCM_REMAP_MODE( CELL_GCM_TEXTURE_REMAP_ORDER_XYXY, CELL_GCM_TEXTURE_REMAP_FROM_A, @@ -1688,10 +1685,8 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count) CELL_GCM_TEXTURE_REMAP_ZERO, CELL_GCM_TEXTURE_REMAP_ZERO ); - // disable control 0 - GCM_FUNC( cellGcmSetTextureControl, unit, CELL_GCM_FALSE, 0, 0, 0 ); - // set texture remap only - GCM_FUNC( cellGcmSetTextureRemap, unit, remap ); + rglGcmSetTextureControl(thisContext, unit, CELL_GCM_FALSE, 0, 0, 0 ); // disable control 0 + rglGcmSetTextureRemap(thisContext, unit, remap ); // set texture remap only } } } @@ -2147,7 +2142,7 @@ beginning: break; } - GCM_FUNC_SAFE( cellGcmSetDrawArrays, gcmMode, dparams->firstVertex, dparams->vertexCount ); + rglGcmSetDrawArrays(thisContext, gcmMode, dparams->firstVertex, dparams->vertexCount ); } // must always call this before rglPlatformDraw() to setup rglDrawParams