diff --git a/ps3/rgl/src/include/rgl-inline.h b/ps3/rgl/src/include/rgl-inline.h index ef59b6afdc..2262dc8446 100644 --- a/ps3/rgl/src/include/rgl-inline.h +++ b/ps3/rgl/src/include/rgl-inline.h @@ -494,14 +494,8 @@ static inline void rglGcmSetInlineTransfer(struct CellGcmContextData *thisContex static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisContext, const CellCgbFragmentProgramConfiguration *conf, const uint32_t location) { - uint32_t rawData = ((conf->offset)&0x1fffffff); - uint32_t shCtrl0; - uint32_t registerCount; - uint32_t texMask; - uint32_t inMask; - uint32_t texMask2D; - uint32_t texMaskCentroid; - uint32_t i; + uint32_t rawData, shCtrl0, registerCount, texMask, inMask, texMask2D, texMaskCentroid, i; + rawData = ((conf->offset) & 0x1fffffff); (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SHADER_PROGRAM); (thisContext->current)[1] = ((location+1) | (rawData)); @@ -513,7 +507,6 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC (thisContext->current)[1] = (inMask); (thisContext->current) += 2; - texMask = conf->texCoordsInputMask; texMask2D = conf->texCoords2D; texMaskCentroid = conf->texCoordsCentroid; @@ -532,7 +525,6 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC texMaskCentroid >>= 1; } - registerCount = conf->registerCount; if (registerCount < 2) @@ -547,13 +539,12 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC static void rglGcmSetDrawArraysSlow(struct CellGcmContextData *thisContext, uint8_t mode, uint32_t first, uint32_t count) { - uint32_t lcount; + uint32_t lcount, i,j, loop, rest; --count; lcount = count & 0xff; count >>= 8; - uint32_t loop, rest; loop = count / CELL_GCM_MAX_METHOD_COUNT; rest = count % CELL_GCM_MAX_METHOD_COUNT; @@ -572,8 +563,6 @@ static void rglGcmSetDrawArraysSlow(struct CellGcmContextData *thisContext, uint (thisContext->current) += 2; first += lcount + 1; - uint32_t i,j; - for(i=0;icurrent[0] = ((((2047)) << (18)) | CELL_GCM_NV4097_DRAW_ARRAYS | (0x40000000)); @@ -635,15 +624,12 @@ static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, u static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisContext, const CellCgbVertexProgramConfiguration *conf, const void *ucode) { - const uint32_t *rawData; - uint32_t instCount; - uint32_t instIndex; + uint32_t *rawData, instCount, instIndex, loop, rest, i, j; - rawData = (const uint32_t*)ucode; + rawData = (uint32_t*)ucode; instCount = conf->instructionCount; instIndex = conf->instructionSlot; - uint32_t loop, rest; loop = instCount / 8; rest = (instCount % 8) * 4; @@ -652,8 +638,6 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon (thisContext->current)[2] = (instIndex); (thisContext->current) += 3; - uint32_t i, j; - for (i = 0; i < loop; i++) { thisContext->current[0] = (((32) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_PROGRAM); @@ -672,7 +656,6 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon thisContext->current += (1 + rest); } - (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_VERTEX_ATTRIB_INPUT_MASK); (thisContext->current)[1] = ((conf->attributeInputMask)); (thisContext->current) += 2; @@ -688,13 +671,18 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFar) { - CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext; - rglGcmViewportState *vp = (rglGcmViewportState*)data; - rglGcmRenderTarget *rt = &rglGcmState_i.renderTarget; + GLint clipY0, clipY1, clipX0, clipX1; + GLfloat z_scale, z_center; + rglGcmViewportState *vp; + rglGcmRenderTarget *rt; + CellGcmContextData *thisContext; - GLint clipY0, clipY1; - GLint clipX0 = vp->x; - GLint clipX1 = vp->x + vp->w; + thisContext = (CellGcmContextData*)gCellGcmCurrentContext; + vp = (rglGcmViewportState*)data; + rt = (rglGcmRenderTarget*)&rglGcmState_i.renderTarget; + + clipX0 = vp->x; + clipX1 = vp->x + vp->w; if (rt->yInverted) { @@ -737,8 +725,8 @@ static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFa } // compute viewport values for hw [no doubles, so we might loose a few lsb] - GLfloat z_scale = ( GLfloat )( 0.5f * ( zFar - zNear ) ); - GLfloat z_center = ( GLfloat )( 0.5f * ( zFar + zNear ) ); + z_scale = (GLfloat)( 0.5f * ( zFar - zNear ) ); + z_center = (GLfloat)( 0.5f * ( zFar + zNear ) ); // hw zNear/zFar clipper if (zNear > zFar) @@ -795,18 +783,19 @@ static inline void rglGcmSetTransferImage(struct CellGcmContextData *thisContext for (y = dstY; y < finalDstY;) { - uint32_t dstTop = y & ~(BLOCKSIZE_MAX_DIMENSIONS - 1); - uint32_t dstBltHeight = (( (dstTop + BLOCKSIZE_MAX_DIMENSIONS) < finalDstY) - ? (dstTop + BLOCKSIZE_MAX_DIMENSIONS) : finalDstY) - y; + uint32_t dstTop, dstBltHeight; + dstTop = y & ~(BLOCKSIZE_MAX_DIMENSIONS - 1); + dstBltHeight = (( (dstTop + BLOCKSIZE_MAX_DIMENSIONS) < finalDstY) ? (dstTop + BLOCKSIZE_MAX_DIMENSIONS) : finalDstY) - y; for (x = dstX; x < finalDstX;) { - uint32_t dstLeft = x & ~(BLOCKSIZE_MAX_DIMENSIONS - 1); - uint32_t dstRight = dstLeft + BLOCKSIZE_MAX_DIMENSIONS; - uint32_t dstBltWidth = ((dstRight < finalDstX) ? dstRight : finalDstX) - x; - uint32_t dstBlockOffset = bytesPerPixel * (dstLeft & ~(BLOCKSIZE_MAX_DIMENSIONS - 1)) + dstPitch * dstTop; - uint32_t srcBlockOffset = bytesPerPixel * (srcX + x-dstX) + srcPitch * (srcY + y-dstY); - uint32_t safeDstBltWidth = (dstBltWidth < 16) ? 16 : (dstBltWidth + 1) & ~1; + uint32_t dstLeft, dstRight, dstBltWidth, dstBlockOffset, srcBlockOffset, safeDstBltWidth; + dstLeft = x & ~(BLOCKSIZE_MAX_DIMENSIONS - 1); + dstRight = dstLeft + BLOCKSIZE_MAX_DIMENSIONS; + dstBltWidth = ((dstRight < finalDstX) ? dstRight : finalDstX) - x; + dstBlockOffset = bytesPerPixel * (dstLeft & ~(BLOCKSIZE_MAX_DIMENSIONS - 1)) + dstPitch * dstTop; + srcBlockOffset = bytesPerPixel * (srcX + x-dstX) + srcPitch * (srcY + y-dstY); + safeDstBltWidth = (dstBltWidth < 16) ? 16 : (dstBltWidth + 1) & ~1; (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_OFFSET_DESTIN); (thisContext->current)[1] = dstOffset + dstBlockOffset; @@ -918,12 +907,14 @@ static inline GLuint RGLGCM_QUICK_FLOAT2UINT (const GLfloat f) } // construct a packed unsigned int ARGB8 color -static inline void RGLGCM_CALC_COLOR_LE_ARGB8( GLuint *color0, const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a ) +static inline void RGLGCM_CALC_COLOR_LE_ARGB8( GLuint *color0, const GLfloat r, + const GLfloat g, const GLfloat b, const GLfloat a ) { - GLuint r2 = RGLGCM_QUICK_FLOAT2UINT( r * 255.0f ); - GLuint g2 = RGLGCM_QUICK_FLOAT2UINT( g * 255.0f ); - GLuint b2 = RGLGCM_QUICK_FLOAT2UINT( b * 255.0f ); - GLuint a2 = RGLGCM_QUICK_FLOAT2UINT( a * 255.0f ); + GLuint r2, g2, b2, a2; + r2 = RGLGCM_QUICK_FLOAT2UINT( r * 255.0f ); + g2 = RGLGCM_QUICK_FLOAT2UINT( g * 255.0f ); + b2 = RGLGCM_QUICK_FLOAT2UINT( b * 255.0f ); + a2 = RGLGCM_QUICK_FLOAT2UINT( a * 255.0f ); *color0 = ( a2 << 24 ) | ( r2 << 16 ) | ( g2 << 8 ) | ( b2 << 0 ); } @@ -1000,7 +991,7 @@ static inline void rglGcmTransferData { uint32_t colCount, rows, cols; GLuint dstOffset, srcOffset; - struct CellGcmContextData *thisContext = gCellGcmCurrentContext; + struct CellGcmContextData *thisContext = (struct CellGcmContextData*)gCellGcmCurrentContext; dstOffset = gmmIdToOffset(dstId) + dstIdOffset; srcOffset = gmmIdToOffset(srcId) + srcIdOffset; diff --git a/ps3/rgl/src/rgl_ps3.cpp b/ps3/rgl/src/rgl_ps3.cpp index 423d6660ad..b47fdb6f04 100644 --- a/ps3/rgl/src/rgl_ps3.cpp +++ b/ps3/rgl/src/rgl_ps3.cpp @@ -70,7 +70,7 @@ unsigned int rglCreateName(void *data, void* object) return 0; memcpy( newData, name->data, name->capacity * sizeof( void* ) ); - if (name->data != NULL) + if (name->data) free (name->data); name->data = newData; @@ -614,7 +614,7 @@ static GmmTileBlock *gmmCreateTileBlock( pAllocator->tileSize = pAllocator->tileStartAddress + pAllocator->tileSize - address; pAllocator->tileStartAddress = address; - pNewBlock = gmmAllocFixedTileBlock(); + pNewBlock = (GmmTileBlock*)gmmAllocFixedTileBlock(); if (!pNewBlock) return NULL; @@ -1093,7 +1093,7 @@ static uint8_t gmmInternalSweep(void *data) uint8_t ret = 0; uint32_t totalMoveSize = 0; - while (pBlock != NULL) + while (pBlock) { if (pBlock->isPinned == 0) { @@ -1461,7 +1461,7 @@ GLboolean rglGcmFifoReferenceInUse (void *data, GLuint reference) return GL_TRUE; } -void rglGcmFifoInit (void *data, void *dmaControl, unsigned long dmaPushBufferOffset, uint32_t*dmaPushBuffer, +void rglGcmFifoInit (void *data, void *dmaControl, uint32_t dmaPushBufferOffset, uint32_t*dmaPushBuffer, GLuint dmaPushBufferSize ) { rglGcmFifo *fifo = (rglGcmFifo*)data; @@ -1998,7 +1998,7 @@ GLboolean rglPlatformDeviceInit (void *data) RGLinitOptions *options = (RGLinitOptions*)data; GLuint fifoSize = RGLGCM_FIFO_SIZE_DEFAULT; - if ( options != NULL ) + if (options) { if ( options->enable & RGL_INIT_FIFO_SIZE ) fifoSize = options->fifoSize; @@ -2814,10 +2814,9 @@ 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; + GmmBlock *pBlock, *pTemp; GmmAllocator *pAllocator = pGmmLocalAllocator; - rglGcmFifo * fifo = &rglGcmState_i.fifo; + rglGcmFifo * fifo = (rglGcmFifo*)&rglGcmState_i.fifo; unsigned int offset_bytes = 0; pBlock = pAllocator->pPendingFreeHead; diff --git a/ps3/rgl/src/rgl_ps3_raster.cpp b/ps3/rgl/src/rgl_ps3_raster.cpp index b812e61292..b04012d4ae 100644 --- a/ps3/rgl/src/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/rgl_ps3_raster.cpp @@ -22,8 +22,6 @@ #include #include -using namespace cell::Gcm; - /*============================================================ MEMORY MANAGER ============================================================ */ @@ -37,20 +35,20 @@ using namespace cell::Gcm; int _parameterAlloc = 0; int _ucodeAlloc = 0; -int rglGetTypeResource( _CGprogram* program, unsigned short typeIndex, short *resourceIndex ); -int rglGetTypeResourceID( _CGprogram* program, unsigned short typeIndex ); -int rglGetTypeResourceRegisterCountVP( _CGprogram* program, short resourceIndex, int resourceCount, unsigned short *resource ); +int rglGetTypeResource( _CGprogram* program, uint16_t typeIndex, int16_t *resourceIndex ); +int rglGetTypeResourceID( _CGprogram* program, uint16_t typeIndex ); +int rglGetTypeResourceRegisterCountVP( _CGprogram* program, int16_t resourceIndex, int resourceCount, uint16_t *resource ); -static void setAttribConstantIndex (void *data, const void* __restrict v, const int ) // index +static void setAttribConstantIndex (void *data, const void* v, const int ) // index { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; - _CGprogram *program = ptr->program; + _CGprogram *program = (_CGprogram*)ptr->program; const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry ); GLuint index = parameterResource->resource - CG_ATTR0; float * f = ( float* ) v; - RGLcontext* LContext = _CurrentContext; + RGLcontext* LContext = (RGLcontext*)_CurrentContext; - rglAttribute* attrib = LContext->attribs->attrib + index; + rglAttribute* attrib = (rglAttribute*)LContext->attribs->attrib + index; attrib->value[0] = f[0]; attrib->value[1] = f[1]; attrib->value[2] = f[2]; @@ -62,8 +60,8 @@ static void setAttribConstantIndex (void *data, const void* __restrict v, const #define swapandsetfp(SIZE, ucodeSize, loadProgramId, loadProgramOffset, ec, v) \ CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext; \ rglGcmSetTransferLocation(thisContext, CELL_GCM_LOCATION_LOCAL ); \ - unsigned short count = *( ec++ ); \ - for ( unsigned long offsetIndex = 0; offsetIndex < count; ++offsetIndex ) \ + uint16_t count = *( ec++ ); \ + for ( uint32_t offsetIndex = 0; offsetIndex < count; ++offsetIndex ) \ { \ void *pointer=NULL; \ const int paddedSIZE = (SIZE + 1) & ~1; /* even width only */ \ @@ -79,18 +77,18 @@ static void setAttribConstantIndex (void *data, const void* __restrict v, const } \ } -template static void setVectorTypefp( void *dat, const void* __restrict v ) +template static void setVectorTypefp( void *dat, const void* v) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)dat; - float * __restrict f = ( float* )v; - float * __restrict data = ( float* )ptr->pushBufferPointer;/*(float*)ptr->offset*;*/ - for ( long i = 0; i < SIZE; ++i ) //TODO: ced: find out if this loop for the get or for the reset in a future use of the same shader or just for the alignment??? + float *f = ( float* )v; + float *data = ( float* )ptr->pushBufferPointer;/*(float*)ptr->offset*;*/ + for (int i = 0; i < SIZE; ++i ) //TODO: ced: find out if this loop for the get or for the reset in a future use of the same shader or just for the alignment??? data[i] = f[i]; _CGprogram *program = ptr->program; CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry ); - unsigned short resource = parameterResource->resource; - unsigned short *ec = ( unsigned short * )( ptr->program->resources ) + resource + 1;//+1 to skip the register + uint16_t resource = parameterResource->resource; + uint16_t *ec = ( uint16_t * )( ptr->program->resources ) + resource + 1;//+1 to skip the register if ( RGL_LIKELY( *ec ) ) { swapandsetfp(SIZE, (program->header.instructionCount*16), program->loadProgramId, program->loadProgramOffset, ec, data); @@ -106,18 +104,18 @@ template static void setVectorTypefp( void *dat, const void* __restric #define ROW_MAJOR 0 #define COL_MAJOR 1 -template static void setVectorTypevpIndex (void *data, const void* __restrict v, const int index ) +template static void setVectorTypevpIndex (void *data, const void*v, const int index ) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; RGLcontext * LContext = _CurrentContext; - const float * __restrict f = ( const float* )v; - float * __restrict dst; + const float *f = ( const float* )v; + float *dst; if (isIndex) dst = ( float* )( *(( unsigned int ** )ptr->pushBufferPointer + index ) ); else dst = ( float* )ptr->pushBufferPointer; - for ( long i = 0; i < SIZE; ++ i ) + for ( int i = 0; i < SIZE; ++ i ) dst[i] = f[i]; LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; } @@ -125,15 +123,15 @@ template static void setVectorTypevpIndex (void *data, template static void setVectorTypefpIndex (void *dat, const void *v, const int index) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)dat; - float * __restrict f = (float*)v; - float * __restrict data = (float*)ptr->pushBufferPointer;/*(float*)ptr->offset*;*/ - for ( long i = 0; i < SIZE; ++i ) //TODO: ced: find out if this loop for the get or for the reset in a future use of the same shader or just for the alignment??? + float * f = (float*)v; + float * data = (float*)ptr->pushBufferPointer;/*(float*)ptr->offset*;*/ + for ( int i = 0; i < SIZE; ++i ) //TODO: ced: find out if this loop for the get or for the reset in a future use of the same shader or just for the alignment??? data[i] = f[i]; _CGprogram *program = ptr->program; const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry ); - unsigned short resource = parameterResource->resource; - unsigned short *ec = ( unsigned short * )( ptr->program->resources ) + resource + 1; + uint16_t resource = parameterResource->resource; + uint16_t *ec = ( uint16_t * )( ptr->program->resources ) + resource + 1; if (isIndex) { int arrayIndex = index; @@ -150,43 +148,43 @@ template static void setVectorTypefpIndex (void *dat, co } //matrices -template static void setMatrixvpIndex (void *data, const void* __restrict v, const int index ) +template static void setMatrixvpIndex (void *data, const void* v, const int index ) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; RGLcontext * LContext = _CurrentContext; - float * __restrict f = ( float* )v; - float * __restrict dst = ( float* )ptr->pushBufferPointer; - for ( long row = 0; row < ROWS; ++row ) + float *f = ( float* )v; + float *dst = ( float* )ptr->pushBufferPointer; + for ( int row = 0; row < ROWS; ++row ) { - for ( long col = 0; col < COLS; ++col ) + for ( int col = 0; col < COLS; ++col ) dst[row * 4 + col] = ( ORDER == ROW_MAJOR ) ? f[row * COLS + col] : f[col * ROWS + row]; } LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; } -template static void setMatrixvpIndexArray (void *data, const void* __restrict v, const int index ) +template static void setMatrixvpIndexArray (void *data, const void* v, const int index ) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; - RGLcontext * LContext = _CurrentContext; - float * __restrict f = ( float* )v; - float * __restrict dst = ( float* )( *(( unsigned int ** )ptr->pushBufferPointer + index ) ); - for ( long row = 0; row < ROWS; ++row ) + RGLcontext *LContext = (RGLcontext*)_CurrentContext; + float *f = (float*)v; + float *dst = (float*)( *(( unsigned int ** )ptr->pushBufferPointer + index ) ); + for ( int row = 0; row < ROWS; ++row ) { - for ( long col = 0; col < COLS; ++col ) + for ( int col = 0; col < COLS; ++col ) dst[row * 4 + col] = ( ORDER == ROW_MAJOR ) ? f[row * COLS + col] : f[col * ROWS + row]; } LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; } -template static void setMatrixfpIndex (void *data, const void* __restrict v, const int /*index*/ ) +template static void setMatrixfpIndex (void *data, const void* v, const int /*index*/ ) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; - float * __restrict f = ( float* )v; - float * __restrict dst = ( float* )ptr->pushBufferPointer; + float *f = (float*)v; + float *dst = (float*)ptr->pushBufferPointer; _CGprogram *program = (( CgRuntimeParameter* )ptr )->program; const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry ); - unsigned short resource = parameterResource->resource; - unsigned short *ec = ( unsigned short * )program->resources + resource + 1; //+1 to skip the register + uint16_t resource = parameterResource->resource; + uint16_t *ec = ( uint16_t * )program->resources + resource + 1; //+1 to skip the register for ( long row = 0; row < ROWS; ++row ) { for ( long col = 0; col < COLS; ++col ) @@ -194,26 +192,26 @@ template static void setMatrixfpIndex (void *dat int count = *ec; if ( RGL_LIKELY( count ) ) { - const unsigned int * __restrict v = ( unsigned int * )dst + row * 4; + const unsigned int *v = (unsigned int*)dst + row * 4; swapandsetfp(COLS, (program->header.instructionCount*16), program->loadProgramId, program->loadProgramOffset, ec, v); } ec += count + 2; //+1 for the register, +1 for the count, + count for the number of embedded consts } } -template static void setMatrixfpIndexArray (void *data, const void* __restrict v, const int index ) +template static void setMatrixfpIndexArray (void *data, const void* v, const int index ) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; - float * __restrict f = ( float* )v; - float * __restrict dst = ( float* )ptr->pushBufferPointer; + float *f = (float*)v; + float *dst = (float*)ptr->pushBufferPointer; _CGprogram *program = ptr->program; const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry ); - unsigned short resource = parameterResource->resource; - unsigned short *ec = ( unsigned short * )program->resources + resource + 1;//+1 to skip the register + uint16_t resource = parameterResource->resource; + uint16_t *ec = (uint16_t*)program->resources + resource + 1;//+1 to skip the register int arrayIndex = index * ROWS; while ( arrayIndex ) //jump to the right index... this is slow { - unsigned short count = ( *ec ); + uint16_t count = ( *ec ); ec += ( count + 2 ); //+1 for the register, +1 for the count, +count for the number of embedded consts arrayIndex--; } @@ -224,7 +222,7 @@ template static void setMatrixfpIndexArray (void int count = *ec; if ( RGL_LIKELY( count ) ) { - const unsigned int * __restrict v = ( unsigned int * )dst + row * 4; + const unsigned int *v = ( unsigned int * )dst + row * 4; swapandsetfp(COLS, (program->header.instructionCount*16), program->loadProgramId, program->loadProgramOffset, ec, v); } ec += count + 2;//+1 for the register, +1 for the count, +count for the number of embedded consts @@ -307,7 +305,7 @@ static void setSamplerfp (void *data, const void*v, int /* index */) { CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; _CGprogram *program = (( CgRuntimeParameter* )ptr )->program; - const CgParameterResource *parameterResource = rglGetParameterResource( program, (( CgRuntimeParameter* )ptr )->parameterEntry ); + const CgParameterResource *parameterResource = (const CgParameterResource*)rglGetParameterResource( program, (( CgRuntimeParameter* )ptr )->parameterEntry ); // the value of v == NULL when it is called from cgGLEnableTextureParameter // the value of v == NULL when it is called from cgGLSetTextureParameter @@ -318,7 +316,7 @@ static void setSamplerfp (void *data, const void*v, int /* index */) *(GLuint*)ptr->pushBufferPointer = *(GLuint*)v; else { - rglTextureImageUnit *unit = _CurrentContext->TextureImageUnits + ( parameterResource->resource - CG_TEXUNIT0 ); + rglTextureImageUnit *unit = (rglTextureImageUnit*)(_CurrentContext->TextureImageUnits + ( parameterResource->resource - CG_TEXUNIT0 )); rglBindTextureInternal( unit, *(GLuint*)ptr->pushBufferPointer, ptr->glType ); } } @@ -330,9 +328,11 @@ static void setSamplervp (void *data, const void*v, int /* index */) // this may be called by a connected param to propagate its value // the spec says that the set should not cause the bind // so only do the bind when the call comes from cgGLEnableTextureParameter - CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; if (v) + { + CgRuntimeParameter *ptr = (CgRuntimeParameter*)data; *(GLuint*)ptr->pushBufferPointer = *( GLuint* )v; + } } @@ -782,7 +782,7 @@ static void rglpsAllocateBuffer (void *data) GLboolean rglpCreateBufferObject (void *data) { rglBufferObject *bufferObject = (rglBufferObject*)data; - rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; + rglGcmBufferObject *rglBuffer = (rglGcmBufferObject*)bufferObject->platformBufferObject; rglBuffer->pool = RGLGCM_SURFACE_POOL_NONE; rglBuffer->bufferId = GMM_ERROR; @@ -917,7 +917,7 @@ char *rglPlatformBufferObjectMap (void *data, GLenum access) GLboolean rglPlatformBufferObjectUnmap (void *data) { rglBufferObject *bufferObject = (rglBufferObject*)data; - rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; + rglGcmBufferObject *rglBuffer = (rglGcmBufferObject*)bufferObject->platformBufferObject; // can't unmap if not mapped if ( --rglBuffer->mapCount == 0 ) @@ -1023,7 +1023,7 @@ GLAPI void APIENTRY glClear( GLbitfield mask ) RGLcontext* LContext = _CurrentContext; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext; - rglGcmFifo * fifo = &rglGcmState_i.fifo; + rglGcmFifo * fifo = (rglGcmFifo*)&rglGcmState_i.fifo; if ( LContext->needValidate & RGL_VALIDATE_FRAMEBUFFER ) { @@ -1449,7 +1449,7 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count) const CgParameterResource *parameterResource = rglGetParameterResource( program, parameterEntry ); - GLboolean cond2 = parameterResource->resource != (unsigned short) - 1; + GLboolean cond2 = parameterResource->resource != (uint16_t) - 1; if (!cond2) continue; @@ -1667,7 +1667,7 @@ beginning: return; // check for any writable mapped buffers - if ( driver->flushBufferCount != 0 ) + if (driver->flushBufferCount) driver->invalidateVertexCache = GL_TRUE; GLuint gpuOffset = GMM_ERROR; @@ -1720,7 +1720,7 @@ beginning: // don't transfer data that is not going to be used, from 0 to first*stride GLuint offset = ( dparams->firstVertex / freq ) * stride; - char * b = (char*)xferBuffer + dparams->attribXferOffset[i]; + char *b = (char*)xferBuffer + dparams->attribXferOffset[i]; memcpy(b + offset, (char*)attrib->clientData + offset, dparams->attribXferSize[i] - offset); @@ -1861,17 +1861,18 @@ beginning: GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint32_t indexCount) { rglDrawParams *dparams = (rglDrawParams*)data; - RGLcontext* LContext = _CurrentContext; - rglAttributeState* as = LContext->attribs; + RGLcontext* LContext = (RGLcontext*)_CurrentContext; + rglAttributeState* as = (rglAttributeState*)LContext->attribs; // are any enabled attributes on the client-side? const GLuint clientSideMask = as->EnabledMask & ~as->HasVBOMask; - if ( RGL_UNLIKELY( clientSideMask ) ) + + if (RGL_UNLIKELY(clientSideMask)) { // determine transfer buffer requirements for client-side attributes for ( int i = 0; i < RGL_MAX_VERTEX_ATTRIBS; ++i ) { - if ( clientSideMask & ( 1 << i ) ) + if (clientSideMask & (1 << i)) { rglAttribute* attrib = as->attrib + i; const GLuint freq = attrib->frequency; @@ -1903,15 +1904,14 @@ GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint3 // Calculate required size in bytes for given texture layout static GLuint rglGetGcmTextureSize (void *data) { + GLuint bytesNeeded, faceAlign, width, height; rglGcmTextureLayout *layout = (rglGcmTextureLayout*)data; - GLuint bytesNeeded = 0; - GLuint faceAlign = layout->pitch ? 1 : 128; - GLuint width = layout->baseWidth; - GLuint height = layout->baseHeight; + bytesNeeded = 0; + faceAlign = layout->pitch ? 1 : 128; - width = MAX(1U, width ); - height = MAX(1U, height ); + width = MAX(1U, layout->baseWidth ); + height = MAX(1U, layout->baseHeight ); if ( !layout->pitch ) bytesNeeded += layout->pixelBits * width * height / 8; @@ -2008,7 +2008,7 @@ static void rglPlatformValidateTextureResources (void *data) rglGcmTextureLayout newLayout; // get layout and size compatible with this pool - rglImage *image = texture->image; + rglImage *image = (rglImage*)texture->image; newLayout.levels = 1; newLayout.faces = 1; @@ -2193,8 +2193,8 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE, GLuint internalFormat = layout->internalFormat; // set the format and remap( control 1) - uint8_t *gcmFormat = &platformTexture->gcmTexture.format; - uint32_t *remap = &platformTexture->gcmTexture.remap; + uint8_t *gcmFormat = (uint8_t*)&platformTexture->gcmTexture.format; + uint32_t *remap = (uint32_t*)&platformTexture->gcmTexture.remap; *gcmFormat = 0; @@ -2434,13 +2434,14 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE, // Choose internal storage type and size, and set it to image, based on given format GLenum rglPlatformChooseInternalStorage (void *data, GLenum internalFormat ) { + GLenum *format, *type; rglImage *image = (rglImage*)data; // see note at bottom concerning storageSize image->storageSize = 0; - GLenum *format = &image->format; - GLenum *type = &image->type; + format = (GLenum*)&image->format; + type = (GLenum*)&image->type; // Choose internal format closest to given format // and extract right format, type @@ -2516,12 +2517,11 @@ GLenum rglPlatformChooseInternalStorage (void *data, GLenum internalFormat ) GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset ) { - RGLcontext* LContext = _CurrentContext; + RGLcontext* LContext = (RGLcontext*)_CurrentContext; rglImage *image; - rglTexture *texture = rglGetCurrentTexture( LContext->CurrentImageUnit, target ); - rglBufferObject *bufferObject = - (rglBufferObject*)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer]; + rglTexture *texture = (rglTexture*)rglGetCurrentTexture( LContext->CurrentImageUnit, target ); + rglBufferObject *bufferObject = (rglBufferObject*)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer]; rglReallocateImages( texture, 0, MAX(baseWidth, baseHeight)); image = texture->image; @@ -2604,8 +2604,8 @@ GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, void rglGcmFifoGlSetRenderTarget (const void *data) { CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext; - rglGcmRenderTarget *rt = &rglGcmState_i.renderTarget; - CellGcmSurface *grt = &rglGcmState_i.renderTarget.gcmRenderTarget; + rglGcmRenderTarget *rt = (rglGcmRenderTarget*)&rglGcmState_i.renderTarget; + CellGcmSurface *grt = (CellGcmSurface*)&rglGcmState_i.renderTarget.gcmRenderTarget; const rglGcmRenderTargetEx *args = (const rglGcmRenderTargetEx*)data; // GlSetRenderTarget implementation starts here @@ -2740,15 +2740,15 @@ void rglGcmFifoGlSetRenderTarget (const void *data) GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ) { - RGLcontext* LContext = _CurrentContext; + RGLcontext* LContext = (RGLcontext*)_CurrentContext; - switch ( pname ) - { - case GL_PACK_ALIGNMENT: - LContext->packAlignment = param; - break; - case GL_UNPACK_ALIGNMENT: - LContext->unpackAlignment = param; - break; - } + switch (pname) + { + case GL_PACK_ALIGNMENT: + LContext->packAlignment = param; + break; + case GL_UNPACK_ALIGNMENT: + LContext->unpackAlignment = param; + break; + } }