(RGL PS3) More opts.

This commit is contained in:
twinaphex 2013-04-14 23:16:40 +02:00
parent 8c58ff191a
commit 1c9ad648a8
3 changed files with 95 additions and 39 deletions

View File

@ -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;i<count;i++) \
thisContext->current[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;
}

View File

@ -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<char> &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';
}

View File

@ -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,