From 1c9ad648a86c8ad961585bd98968a78391849200 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 14 Apr 2013 23:16:40 +0200 Subject: [PATCH] (RGL PS3) More opts. --- ps3/rgl/src/ps3/include/rgl-inline.h | 88 +++++++++++++++++++++++++++- ps3/rgl/src/ps3/rgl_ps3_cg.cpp | 36 +----------- ps3/rgl/src/ps3/rgl_ps3_raster.cpp | 10 ++-- 3 files changed, 95 insertions(+), 39 deletions(-) diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index 2f777cafff..00bf8c20d7 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -178,6 +178,21 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current)[1] = ((cullNearFarEnable) | ((zclampEnable) << 4) | ((cullIgnoreW)<<8)); \ (thisContext->current) += 2; +#define rglGcmSetVertexAttribOutputMask(thisContext, mask) \ + (thisContext->current)[0] = (((1) << (18)) | ((0x00001ff4))); \ + (thisContext->current)[1] = (mask); \ + (thisContext->current) += 2; + +#define rglGcmSetNopCommand(thisContext, i, count) \ + for(i=0;icurrent[i] = 0; \ + thisContext->current += count; + +#define rglGcmSetAntiAliasingControl(thisContext, enable, alphaToCoverage, alphaToOne, sampleMask) \ + (thisContext->current)[0] = (((1) << (18)) | ((0x00001d7c))); \ + (thisContext->current)[1] = ((enable) | ((alphaToCoverage) << 4) | ((alphaToOne) << 8) | ((sampleMask) << 16)); \ + (thisContext->current) += 2; + static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, uint8_t mode, uint32_t first, uint32_t count) { @@ -560,6 +575,11 @@ static inline GLuint rglGcmGetBufferObjectOrigin (GLuint buffer) return gcmBuffer->bufferId; } +#define CL0039_MIN_PITCH -32768 +#define CL0039_MAX_PITCH 32767 +#define CL0039_MAX_LINES 0x3fffff +#define CL0039_MAX_ROWS 0x7ff + static inline void rglGcmTransferData ( GLuint dstId, @@ -581,5 +601,71 @@ static inline void rglGcmTransferData (thisContext->current)[2] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ (thisContext->current) += 3; - cellGcmTransferDataInline(thisContext, dstOffset, dstPitch, srcOffset, srcPitch, bytesPerRow, rowCount); + uint32_t colCount; + uint32_t rows; + uint32_t cols; + + if ((srcPitch == bytesPerRow) && (dstPitch == bytesPerRow)) + { + bytesPerRow *= rowCount; + rowCount = 1; + srcPitch = 0; + dstPitch = 0; + } + + if ((srcPitch < CL0039_MIN_PITCH) || (srcPitch > CL0039_MAX_PITCH) || + (dstPitch < CL0039_MIN_PITCH) || (dstPitch > CL0039_MAX_PITCH)) + { + while(--rowCount >= 0) + { + for(colCount = bytesPerRow; colCount>0; colCount -= cols) + { + cols = (colCount > CL0039_MAX_LINES) ? CL0039_MAX_LINES : colCount; + + (thisContext->current)[0] = (((8) << (18)) | ((0x0000230C))); + (thisContext->current)[1] = (srcOffset + (bytesPerRow - colCount)); + (thisContext->current)[2] = (dstOffset + (bytesPerRow - colCount)); + (thisContext->current)[3] = (0); + (thisContext->current)[4] = (0); + (thisContext->current)[5] = (cols); + (thisContext->current)[6] = (1); + (thisContext->current)[7] = (((1) << 8) | (1)); + (thisContext->current)[8] = (0); + (thisContext->current) += 9; + } + + dstOffset += dstPitch; + srcOffset += srcPitch; + } + } + else + { + for(;rowCount>0; rowCount -= rows) + { + rows = (rowCount > CL0039_MAX_ROWS) ? CL0039_MAX_ROWS : rowCount; + + for(colCount = bytesPerRow; colCount>0; colCount -= cols) + { + cols = (colCount > CL0039_MAX_LINES) ? CL0039_MAX_LINES : colCount; + + (thisContext->current)[0] = (((8) << (18)) | ((0x0000230C))); + (thisContext->current)[1] = (srcOffset + (bytesPerRow - colCount)); + (thisContext->current)[2] = (dstOffset + (bytesPerRow - colCount)); + (thisContext->current)[3] = (srcPitch); + (thisContext->current)[4] = (dstPitch); + (thisContext->current)[5] = (cols); + (thisContext->current)[6] = (rows); + (thisContext->current)[7] = (((1) << 8) | (1)); + (thisContext->current)[8] = (0); + (thisContext->current) += 9; + } + + srcOffset += rows * srcPitch; + dstOffset += rows * dstPitch; + } + } + + (thisContext->current)[0] = (((1) << (18)) | ((0x00002310))); + (thisContext->current)[1] = (0); + (thisContext->current) += 2; } diff --git a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp index 84d27dd7ac..75e447a7e1 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp @@ -2768,9 +2768,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr ( *nvParams )->type = ( CGtype )( paramResource->type ); // sub type for row params of matrix for ( int row = 1; row <= ( int )rowCount; row++ ) - { ( *nvParams + row )->type = getMatrixRowType(( CGtype )paramResource->type ); - } // varying parameters if (( paramEntry->flags & CGPV_MASK ) == CGPV_VARYING ) @@ -2903,9 +2901,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr ( *nvParamOffsets )->ucodeCount = embeddedConstantCount; unsigned int ec = 0; for ( ec = 0; ec < embeddedConstantCount; ec++ ) - { ( *nvParamOffsets )->ucodeOffset[ec] = *( resPtr++ ); - } // set the field in the nv param ( *nvParams )->embeddedConst = ( char* )( *nvParamOffsets ) - nvBinary; // forward pointer to nvParamOffsets @@ -2921,9 +2917,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr ( *nvParamOffsets )->ucodeCount = embeddedConstantCount; unsigned int ec = 0; for ( ec = 0; ec < embeddedConstantCount; ec++ ) - { ( *nvParamOffsets )->ucodeOffset[ec] = *( resPtr++ ); - } // set the field in the nv param ( *nvParams + row )->embeddedConst = ( char* )( *nvParamOffsets ) - nvBinary; // forward pointer to nvParamOffsets @@ -2994,9 +2988,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr strcpy( *nvParamStrings, semantic ); // set the name offset in the param (or params if a matrix) for ( int row = 0; row <= ( int )rowCount; row++ ) - { ( *nvParams )->semantic = *nvParamStrings - nvBinary; - } // increment the names cursor *nvParamStrings += strlen( semantic ) + 1; } @@ -3006,11 +2998,8 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr for ( unsigned int def = 0; def < defaultIndexCount; def++ ) { CgParameterDefaultValue* defaultIndex = defaultIndexTable + def; - if ( defaultIndex->entryIndex == entryIndex ) - { - // found the default for this parameter + if ( defaultIndex->entryIndex == entryIndex ) // found the default for this parameter defaults = ( float* )consttab->data + defaultIndex->defaultValueIndex; - } } if ( defaults ) { @@ -3020,15 +3009,11 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr memcpy( *nvParamDefaults, defaults, defaultsCount * sizeof( float ) ); // set the field in the param to point to them if ( rowCount == 0 ) - { ( *nvParams )->defaultValue = ( char* )( *nvParamDefaults ) - nvBinary; - } else { for ( int row = 1; row <= ( int )rowCount; row++ ) - { ( *nvParams + row )->defaultValue = ( char* )( *nvParamDefaults + 4 * ( row - 1 ) ) - nvBinary; - } } // forward the buffer pointer @@ -3039,7 +3024,6 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr // fill other fields, once for the matrix and once for every row for ( int row = 0; row <= ( int )rowCount; row++ ) { - // var unsigned int variability = paramEntry->flags & CGPV_MASK; if ( variability == CGPV_VARYING ) @@ -3051,9 +3035,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr else if ( variability == CGPV_MIXED ) ( *nvParams )->var = CG_MIXED; else - { ( *nvParams )->var = ( CGenum )0; - } //direction unsigned int direction = paramEntry->flags & CGPD_MASK; @@ -3064,9 +3046,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr else if ( direction == CGPD_INOUT ) ( *nvParams )->direction = CG_INOUT; else - { ( *nvParams )->direction = ( CGenum )0; - } // paramno if ( paramEntry->flags & CGPF_GLOBAL ) @@ -3077,9 +3057,7 @@ void PopulateDataForParamResource( CgParameterEntry* paramEntry, CgParameterEntr { ( *nvParams )->paramno = *localParamNo; if ( row == 0 ) - { *localParamNo += 1; - } } // isReferenced @@ -3117,9 +3095,7 @@ void PopulateDataForParamArray( CgParameterEntry* paramEntry, CgParameterEntry* // to get the number of parameters, must recurse over struct fields unsigned int numElements = 1; for ( unsigned int dim = 0; dim < paramArray->dimensionCount; dim++ ) - { numElements *= paramArray->dimensions[dim]; - }; // for name handling char* prefixIn = prefix; @@ -3147,9 +3123,7 @@ void PopulateDataForParamArray( CgParameterEntry* paramEntry, CgParameterEntry* sprintf( *nvParamStrings, "%s[%d]", ( strtab->data + paramEntry->nameOffset ), element ); if ( prefix == NULL ) - { prefix = *nvParamStrings; - } *nvParamStrings += strlen( *nvParamStrings ); @@ -3223,9 +3197,8 @@ void PopulateDataForParamStruct( CgParameterEntry* paramEntry, CgParameterEntry* // set the prefix pointer if it is not already set if ( prefix == NULL ) - { prefix = *nvParamStrings; - } + // add prefix of struct name and . // !!! but what about if we are inside an array??? then no struct name? or is . built in? if ( paramEntry->nameOffset > 0 ) // is this the right test??? @@ -5152,10 +5125,7 @@ static unsigned int stringTableFind( std::vector &stringTable, const char* while (p && (end-data)>0) { if (!memcmp(p - length, str, length)) - { - //found return (unsigned int)(p - length - &stringTable[0]); - } data = p+1; p = (char*)memchr(data,'\0',end-data); } @@ -5878,9 +5848,7 @@ int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness if (done) { if (strlen(sem)) - { strncpy(structuralElement->_semantic,sem,sizeof(structuralElement->_semantic)); - } else structuralElement->_semantic[0] = '\0'; } diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index d413afe28f..1fe97022e9 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -1724,8 +1724,8 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count) rglGcmInterpolantState *s = &rglGcmState_i.state.interpolant; s->vertexProgramAttribMask = program->header.vertexProgram.attributeOutputMask; - GCM_FUNC( cellGcmSetVertexAttribOutputMask, (( s->vertexProgramAttribMask) & - s->fragmentProgramAttribMask) ); + rglGcmSetVertexAttribOutputMask(thisContext, (( s->vertexProgramAttribMask) & + s->fragmentProgramAttribMask)); int count = program->defaultValuesIndexCount; for ( int i = 0;i < count;i++ ) @@ -1842,7 +1842,8 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count) uint32_t padding_in_word = ( ( 0x10-(((uint32_t)rglGcmState_i.fifo.current)&0xf))&0xf )>>2; uint32_t padded_size = ( ((cgprog->constantPushBufferWordSize)<<2) + 0xf )&~0xf; - GCM_FUNC( cellGcmSetNopCommandUnsafe, padding_in_word ); + unsigned i; + rglGcmSetNopCommand(thisContext, i, padding_in_word ); memcpy16(rglGcmState_i.fifo.current, cgprog->constantPushBuffer, padded_size); rglGcmState_i.fifo.current+=cgprog->constantPushBufferWordSize; } @@ -2938,6 +2939,7 @@ GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, // Set current render target to args void rglGcmFifoGlSetRenderTarget (const void *data) { + CellGcmContextData *thisContext = (CellGcmContextData*)gCellGcmCurrentContext; rglGcmRenderTarget *rt = &rglGcmState_i.renderTarget; CellGcmSurface *grt = &rglGcmState_i.renderTarget.gcmRenderTarget; const rglGcmRenderTargetEx *args = (const rglGcmRenderTargetEx*)data; @@ -3039,7 +3041,7 @@ void rglGcmFifoGlSetRenderTarget (const void *data) // Update rt's AA and Swizzling parameters with args - GCM_FUNC( cellGcmSetAntiAliasingControl, + rglGcmSetAntiAliasingControl(thisContext, CELL_GCM_FALSE, CELL_GCM_FALSE, CELL_GCM_FALSE,