(RGL) More cleanups pt. 6

This commit is contained in:
twinaphex 2013-01-04 07:28:14 +01:00
parent 4382875749
commit 14590e1846
7 changed files with 113 additions and 89 deletions

View File

@ -46,7 +46,7 @@ PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe
PPU_LDLIBS = -lio_stub PPU_LDLIBS = -lio_stub
DEFINES += -D__CELLOS_LV2__ -DJS_PLATFORM_CELL DEFINES += -D__CELLOS_LV2__
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
PPU_OPTIMIZE_LV := -O0 -g PPU_OPTIMIZE_LV := -O0 -g

View File

@ -29,9 +29,9 @@ extern "C"
#define RGL_BOOLEAN_REGISTERS_COUNT 32 #define RGL_BOOLEAN_REGISTERS_COUNT 32
// parameter setter, prototype of functions called when a uniform is set. // parameter setter, prototype of functions called when a uniform is set.
typedef void( *_cgSetFunction )( struct CgRuntimeParameter* _RGL_RESTRICT, const void* _RGL_RESTRICT ); typedef void( *_cgSetFunction )( void *, const void* _RGL_RESTRICT );
typedef void( *_cgSetArrayIndexFunction )( struct CgRuntimeParameter* _RGL_RESTRICT, const void* _RGL_RESTRICT, const int index ); typedef void( *_cgSetArrayIndexFunction )( void *, const void*, const int index );
typedef struct _CgUniform typedef struct _CgUniform
{ {
@ -199,12 +199,12 @@ extern "C"
RGL_EXPORT void rglCgProgramErase( _CGprogram* prog ); RGL_EXPORT void rglCgProgramErase( _CGprogram* prog );
// default setters // default setters
void _cgRaiseInvalidParam( CgRuntimeParameter*p, const void*v ); void _cgRaiseInvalidParam( void *data, const void*v );
void _cgRaiseNotMatrixParam( CgRuntimeParameter*p, const void*v ); void _cgRaiseNotMatrixParam( void *data, const void*v );
void _cgIgnoreSetParam( CgRuntimeParameter*p, const void*v ); void _cgIgnoreSetParam( void *dat, const void*v );
void _cgRaiseInvalidParamIndex( CgRuntimeParameter*p, const void*v, const int index ); void _cgRaiseInvalidParamIndex( void *dat, const void*v, const int index );
void _cgRaiseNotMatrixParamIndex( CgRuntimeParameter*p, const void*v, const int index ); void _cgRaiseNotMatrixParamIndex( void *dat, const void*v, const int index );
void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index ); void _cgIgnoreSetParamIndex( void *dat, const void*v, const int index );
// cg helpers // cg helpers

View File

@ -11,7 +11,7 @@ void rglGcmTransferData (GLuint dstId, GLuint dstIdOffset,
GLint srcPitch, GLint bytesPerRow, GLint rowCount); GLint srcPitch, GLint bytesPerRow, GLint rowCount);
int32_t rglOutOfSpaceCallback (void *data, uint32_t spaceInWords); int32_t rglOutOfSpaceCallback (void *data, uint32_t spaceInWords);
void rglGcmFifoGlSetRenderTarget (rglGcmRenderTargetEx const * const args); void rglGcmFifoGlSetRenderTarget (const void *args);
void rglpFifoGlFinish (void); void rglpFifoGlFinish (void);
void rglCreatePushBuffer (void *data); void rglCreatePushBuffer (void *data);
void rglSetDefaultValuesFP (void *data); void rglSetDefaultValuesFP (void *data);

View File

@ -1006,33 +1006,22 @@ static inline void gmmMemcpy(void *data, const uint8_t mode,
static uint8_t gmmInternalSweep(void *data, const uint8_t location) static uint8_t gmmInternalSweep(void *data, const uint8_t location)
{ {
CellGcmContextData *thisContext = (CellGcmContextData*)data; CellGcmContextData *thisContext = (CellGcmContextData*)data;
GmmAllocator *pAllocator; GmmAllocator *pAllocator = pGmmLocalAllocator;
GmmBlock *pBlock; GmmBlock *pBlock = pAllocator->pSweepHead;
GmmBlock *pSrcBlock; GmmBlock *pSrcBlock = pBlock;
GmmBlock *pTempBlock; GmmBlock *pTempBlock;
GmmBlock *pTempBlockNext; GmmBlock *pTempBlockNext;
uint32_t dstAddress, srcAddress; uint32_t dstAddress = 0;
uint32_t srcAddress = 0;
uint32_t srcOffset, dstOffset; uint32_t srcOffset, dstOffset;
uint32_t prevEndAddress; uint32_t prevEndAddress = 0;
uint32_t moveSize, moveDistance; uint32_t moveSize, moveDistance;
uint8_t mode; uint8_t mode = CELL_GCM_TRANSFER_LOCAL_TO_LOCAL;
uint8_t ret = 0; uint8_t ret = 0;
uint32_t totalMoveSize = 0; uint32_t totalMoveSize = 0;
pAllocator = pGmmLocalAllocator;
mode = CELL_GCM_TRANSFER_LOCAL_TO_LOCAL;
pBlock = pAllocator->pSweepHead;
srcAddress = 0;
dstAddress = 0;
prevEndAddress = 0;
pSrcBlock = pBlock;
while (pBlock != NULL) while (pBlock != NULL)
{ {
if (pBlock->isPinned == 0) if (pBlock->isPinned == 0)
{ {
if (pBlock->pPrev) if (pBlock->pPrev)
@ -1197,10 +1186,8 @@ static uint8_t gmmInternalSweep(void *data, const uint8_t location)
return ret; return ret;
} }
static void gmmRemovePendingFree( static void gmmRemovePendingFree (GmmAllocator *pAllocator,
GmmAllocator *pAllocator, GmmBlock *pBlock)
GmmBlock *pBlock
)
{ {
if (pBlock == pAllocator->pPendingFreeHead) if (pBlock == pAllocator->pPendingFreeHead)
pAllocator->pPendingFreeHead = pBlock->pNextFree; pAllocator->pPendingFreeHead = pBlock->pNextFree;
@ -1634,9 +1621,10 @@ GLuint rglGcmFifoPutReference (void *data)
return fifo->lastSWReferenceWritten; return fifo->lastSWReferenceWritten;
} }
GLuint rglGcmFifoReadReference( rglGcmFifo *fifo ) GLuint rglGcmFifoReadReference (void *data)
{ {
GLuint ref = *(( volatile GLuint * ) & fifo->dmaControl->Reference ); rglGcmFifo *fifo = (rglGcmFifo*)data;
GLuint ref = *((volatile GLuint *)&fifo->dmaControl->Reference);
fifo->lastHWReferenceRead = ref; fifo->lastHWReferenceRead = ref;
return ref; return ref;
} }
@ -1662,7 +1650,6 @@ GLboolean rglGcmFifoReferenceInUse (void *data, GLuint reference)
return GL_TRUE; return GL_TRUE;
} }
// Wait until the requested space is available. // Wait until the requested space is available.
// If not currently available, will call the out of space callback // If not currently available, will call the out of space callback
@ -1715,11 +1702,8 @@ void rglGcmFifoInit (void *data, void *dmaControl, unsigned long dmaPushBufferOf
rglGcmFifoFlush( fifo ); // Here, we jump to this new buffer rglGcmFifoFlush( fifo ); // Here, we jump to this new buffer
// a finish that waits for 0 specifically. // a finish that waits for 0 specifically.
for ( ;; ) while (rglGcmFifoReadReference(fifo) != 0)
{ sys_timer_usleep(10);
if ( rglGcmFifoReadReference( fifo ) == 0 ) break;
sys_timer_usleep( 10 );
}
} }
fifo->dmaPushBufferGPU = dmaPushBuffer; fifo->dmaPushBufferGPU = dmaPushBuffer;
fifo->spuid = 0; fifo->spuid = 0;
@ -1823,8 +1807,10 @@ GLuint rglGcmGetGraphicsClock(void)
return GraphicsClock; return GraphicsClock;
} }
GLboolean rglGcmInit( RGLinitOptions* options, rglGcmResource *resource ) GLboolean rglGcmInit (void *opt_data, void *res_data)
{ {
rglGcmResource *resource = (rglGcmResource*)res_data;
RGLinitOptions *options = (RGLinitOptions*)opt_data;
if ( !rglGcmInitFromRM( resource ) ) if ( !rglGcmInitFromRM( resource ) )
{ {
fprintf( stderr, "RGL GCM failed initialisation" ); fprintf( stderr, "RGL GCM failed initialisation" );
@ -1953,8 +1939,9 @@ void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch,
============================================================ */ ============================================================ */
// resc is enabled by setting ANY of the resc related device parameters (using the enable mask) // resc is enabled by setting ANY of the resc related device parameters (using the enable mask)
static inline int rescIsEnabled( RGLdeviceParameters* params ) static inline int rescIsEnabled (void *data)
{ {
RGLdeviceParameters *params = (RGLdeviceParameters*)data;
return params->enable & ( RGL_DEVICE_PARAMETERS_RESC_RENDER_WIDTH_HEIGHT | return params->enable & ( RGL_DEVICE_PARAMETERS_RESC_RENDER_WIDTH_HEIGHT |
RGL_DEVICE_PARAMETERS_RESC_RATIO_MODE | RGL_DEVICE_PARAMETERS_RESC_RATIO_MODE |
RGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE | RGL_DEVICE_PARAMETERS_RESC_PAL_TEMPORAL_MODE |
@ -1965,8 +1952,9 @@ static inline int rescIsEnabled( RGLdeviceParameters* params )
// Platform-specific initialization for Cell processor: // Platform-specific initialization for Cell processor:
// manage allocation/free of SPUs, and optional debugging console. // manage allocation/free of SPUs, and optional debugging console.
void rglPlatformInit( RGLinitOptions* options ) void rglPlatformInit (void *data)
{ {
(void)data;
} }
@ -1978,8 +1966,9 @@ void rglPlatformExit(void)
PLATFORM REPORTING PLATFORM REPORTING
============================================================ */ ============================================================ */
void rglInitConsole( GLuint enable ) void rglInitConsole (GLuint enable)
{ {
(void)enable;
} }
void rglExitConsole(void) void rglExitConsole(void)
@ -2057,6 +2046,7 @@ void rglPsglPlatformInit (void *data)
void rglPsglPlatformExit(void) void rglPsglPlatformExit(void)
{ {
RGLcontext* LContext = _CurrentContext; RGLcontext* LContext = _CurrentContext;
if ( LContext ) if ( LContext )
{ {
glFlush(); glFlush();
@ -2363,7 +2353,6 @@ int rglGcmInitRM( rglGcmResource *gcmResource, unsigned int hostMemorySize, int
// Set our Fifo functions // Set our Fifo functions
gCellGcmCurrentContext->callback = ( CellGcmContextCallback )rglOutOfSpaceCallback; gCellGcmCurrentContext->callback = ( CellGcmContextCallback )rglOutOfSpaceCallback;
fprintf(stderr, "RGLGCM resource: MClk: %f Mhz NVClk: %f Mhz\n", ( float )gcmResource->MemoryClock / 1E6, ( float )gcmResource->GraphicsClock / 1E6 ); fprintf(stderr, "RGLGCM resource: MClk: %f Mhz NVClk: %f Mhz\n", ( float )gcmResource->MemoryClock / 1E6, ( float )gcmResource->GraphicsClock / 1E6 );
fprintf(stderr, "RGLGCM resource: Video Memory: %i MB\n", gcmResource->localSize / ( 1024*1024 ) ); fprintf(stderr, "RGLGCM resource: Video Memory: %i MB\n", gcmResource->localSize / ( 1024*1024 ) );
fprintf(stderr, "RGLGCM resource: localAddress mapped at %p\n", gcmResource->localAddress ); fprintf(stderr, "RGLGCM resource: localAddress mapped at %p\n", gcmResource->localAddress );

View File

@ -69,8 +69,10 @@ static int rglpsLoadFPShader (void *data)
return GL_TRUE; return GL_TRUE;
} }
static void rglpsUnloadFPShader(_CGprogram *program) static void rglpsUnloadFPShader (void *data)
{ {
_CGprogram *program = (_CGprogram*)data;
if ( program->loadProgramId != GMM_ERROR ) if ( program->loadProgramId != GMM_ERROR )
{ {
gmmFree( program->loadProgramId ); gmmFree( program->loadProgramId );

View File

@ -51,9 +51,9 @@ int rglGetTypeResource( _CGprogram* program, unsigned short typeIndex, short *re
int rglGetTypeResourceID( _CGprogram* program, unsigned short typeIndex ); int rglGetTypeResourceID( _CGprogram* program, unsigned short typeIndex );
int rglGetTypeResourceRegisterCountVP( _CGprogram* program, short resourceIndex, int resourceCount, unsigned short *resource ); int rglGetTypeResourceRegisterCountVP( _CGprogram* program, short resourceIndex, int resourceCount, unsigned short *resource );
static void setAttribConstantIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int ) // index static void setAttribConstantIndex (void *data, const void* __restrict v, const int ) // index
{ {
// XXX not sure why it was testing unused res CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
_CGprogram *program = ptr->program; _CGprogram *program = ptr->program;
const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( program, ptr->parameterEntry );
GLuint index = parameterResource->resource - CG_ATTR0; GLuint index = parameterResource->resource - CG_ATTR0;
@ -117,8 +117,9 @@ template<int SIZE> static void setVectorTypefp( CgRuntimeParameter* __restrict p
} }
} }
template<int SIZE> static void setVectorTypeSharedfpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ ) template<int SIZE> static void setVectorTypeSharedfpIndex (void *data, const void* __restrict v, const int /*index*/ )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
RGLcontext * LContext = _CurrentContext; RGLcontext * LContext = _CurrentContext;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry );
@ -139,8 +140,9 @@ template<int SIZE> static void setVectorTypeSharedfpIndex( CgRuntimeParameter* _
++LContext->LastFPConstantModification; ++LContext->LastFPConstantModification;
} }
template<int SIZE> static void setVectorTypeSharedfpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template<int SIZE> static void setVectorTypeSharedfpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
RGLcontext * LContext = _CurrentContext; RGLcontext * LContext = _CurrentContext;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry );
@ -170,8 +172,9 @@ template<int SIZE> static void setVectorTypeSharedfpIndexArray( CgRuntimeParamet
// XXX we don't care about 32bit wrapping, do we ? // XXX we don't care about 32bit wrapping, do we ?
++LContext->LastFPConstantModification; ++LContext->LastFPConstantModification;
} }
template<int SIZE> static void setVectorTypeSharedvpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ ) template<int SIZE> static void setVectorTypeSharedvpIndex (void *data, const void* __restrict v, const int /*index*/ )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
const float * __restrict f = ( const float * __restrict )v; const float * __restrict f = ( const float * __restrict )v;
const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry );
unsigned short resource = parameterResource->resource; unsigned short resource = parameterResource->resource;
@ -181,8 +184,9 @@ template<int SIZE> static void setVectorTypeSharedvpIndex( CgRuntimeParameter* _
rglPlatformSetVertexRegister4fv( resource, dst ); rglPlatformSetVertexRegister4fv( resource, dst );
} }
template<int SIZE> static void setVectorTypeSharedvpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template<int SIZE> static void setVectorTypeSharedvpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
const float * __restrict f = ( const float * __restrict )v; const float * __restrict f = ( const float * __restrict )v;
const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry );
unsigned short resource = parameterResource->resource + index; ///TODO: assume contiguous here , right ? unsigned short resource = parameterResource->resource + index; ///TODO: assume contiguous here , right ?
@ -202,8 +206,9 @@ template<int SIZE> static void setVectorTypeSharedvpIndexArray( CgRuntimeParamet
#define ROW_MAJOR 0 #define ROW_MAJOR 0
#define COL_MAJOR 1 #define COL_MAJOR 1
template <int SIZE> static void setVectorTypevpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ ) template <int SIZE> static void setVectorTypevpIndex (void *data, const void* __restrict v, const int /*index*/ )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
RGLcontext * LContext = _CurrentContext; RGLcontext * LContext = _CurrentContext;
const float * __restrict f = ( const float* )v; const float * __restrict f = ( const float* )v;
float * __restrict dst = ( float* )ptr->pushBufferPointer; float * __restrict dst = ( float* )ptr->pushBufferPointer;
@ -211,8 +216,9 @@ template <int SIZE> static void setVectorTypevpIndex( CgRuntimeParameter* __rest
dst[i] = f[i]; dst[i] = f[i];
LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS;
} }
template <int SIZE> static void setVectorTypevpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template <int SIZE> static void setVectorTypevpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
RGLcontext * LContext = _CurrentContext; RGLcontext * LContext = _CurrentContext;
const float * __restrict f = ( const float* )v; const float * __restrict f = ( const float* )v;
float * __restrict dst = ( float* )( *(( unsigned int ** )ptr->pushBufferPointer + index ) ); float * __restrict dst = ( float* )( *(( unsigned int ** )ptr->pushBufferPointer + index ) );
@ -220,10 +226,12 @@ template <int SIZE> static void setVectorTypevpIndexArray( CgRuntimeParameter* _
dst[i] = f[i]; dst[i] = f[i];
LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS;
} }
template<int SIZE> static void setVectorTypefpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ )
template<int SIZE> static void setVectorTypefpIndex (void *dat, const void *v, const int /*index*/ )
{ {
float * __restrict f = ( float* )v; CgRuntimeParameter *ptr = (CgRuntimeParameter*)dat;
float * __restrict data = ( float* )ptr->pushBufferPointer;/*(float*)ptr->offset*;*/ 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??? 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???
data[i] = f[i]; data[i] = f[i];
_CGprogram *program = ptr->program; _CGprogram *program = ptr->program;
@ -236,8 +244,10 @@ template<int SIZE> static void setVectorTypefpIndex( CgRuntimeParameter* __restr
swapandsetfp<SIZE>( program->header.instructionCount*16, program->loadProgramId, program->loadProgramOffset, ec, ( unsigned int * )data ); swapandsetfp<SIZE>( program->header.instructionCount*16, program->loadProgramId, program->loadProgramOffset, ec, ( unsigned int * )data );
} }
} }
template<int SIZE> static void setVectorTypefpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index )
template<int SIZE> static void setVectorTypefpIndexArray (void *dat, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)dat;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict data = ( float* )ptr->pushBufferPointer;/*(float*)ptr->offset*;*/ 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??? 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???
@ -260,8 +270,9 @@ template<int SIZE> static void setVectorTypefpIndexArray( CgRuntimeParameter* __
} }
//matrices //matrices
template <int ROWS, int COLS, int ORDER> static void setMatrixvpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template <int ROWS, int COLS, int ORDER> static void setMatrixvpIndex (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
RGLcontext * LContext = _CurrentContext; RGLcontext * LContext = _CurrentContext;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict dst = ( float* )ptr->pushBufferPointer; float * __restrict dst = ( float* )ptr->pushBufferPointer;
@ -273,8 +284,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixvpIndex( CgRuntime
LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS;
} }
template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ ) template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndex (void *data, const void* __restrict v, const int /*index*/ )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict dst = ( float* )ptr->pushBufferPointer; float * __restrict dst = ( float* )ptr->pushBufferPointer;
@ -291,11 +303,12 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndex( CgR
for ( long col = COLS; col < 4; ++col ) tmp[row*4 + col] = dst[row*4+col]; for ( long col = COLS; col < 4; ++col ) tmp[row*4 + col] = dst[row*4+col];
} }
GCM_FUNC( cellGcmSetVertexProgramParameterBlock, resource, ROWS, ( const float* )tmp ); GCM_FUNC( cellGcmSetVertexProgramParameterBlock, resource, ROWS, (const float*)tmp);
} }
template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict dst = ( float* )ptr->pushBufferPointer; float * __restrict dst = ( float* )ptr->pushBufferPointer;
@ -314,8 +327,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndexArray
GCM_FUNC( cellGcmSetVertexProgramParameterBlock, resource, ROWS, tmp ); GCM_FUNC( cellGcmSetVertexProgramParameterBlock, resource, ROWS, tmp );
} }
template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ ) template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndex (void *data, const void* __restrict v, const int /*index*/ )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( ptr->program, ptr->parameterEntry );
@ -353,8 +367,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndex( CgR
++LContext->LastFPConstantModification; ++LContext->LastFPConstantModification;
} }
template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
//TODO: double check for the semi endian swap... not done here, is it done by the RSX ? //TODO: double check for the semi endian swap... not done here, is it done by the RSX ?
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
@ -402,8 +417,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndexArray
} }
//TODO ?: check: //works only for the consecutive alloc... //TODO ?: check: //works only for the consecutive alloc...
template <int ROWS, int COLS, int ORDER> static void setMatrixvpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template <int ROWS, int COLS, int ORDER> static void setMatrixvpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
RGLcontext * LContext = _CurrentContext; RGLcontext * LContext = _CurrentContext;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict dst = ( float* )( *(( unsigned int ** )ptr->pushBufferPointer + index ) ); float * __restrict dst = ( float* )( *(( unsigned int ** )ptr->pushBufferPointer + index ) );
@ -414,8 +430,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixvpIndexArray( CgRu
} }
LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS; LContext->needValidate |= RGL_VALIDATE_VERTEX_CONSTANTS;
} }
template <int ROWS, int COLS, int ORDER> static void setMatrixfpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int /*index*/ ) template <int ROWS, int COLS, int ORDER> static void setMatrixfpIndex (void *data, const void* __restrict v, const int /*index*/ )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict dst = ( float* )ptr->pushBufferPointer; float * __restrict dst = ( float* )ptr->pushBufferPointer;
_CGprogram *program = (( CgRuntimeParameter* )ptr )->program; _CGprogram *program = (( CgRuntimeParameter* )ptr )->program;
@ -434,8 +451,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixfpIndex( CgRuntime
ec += count + 2; //+1 for the register, +1 for the count, + count for the number of embedded consts ec += count + 2; //+1 for the register, +1 for the count, + count for the number of embedded consts
} }
} }
template <int ROWS, int COLS, int ORDER> static void setMatrixfpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) template <int ROWS, int COLS, int ORDER> static void setMatrixfpIndexArray (void *data, const void* __restrict v, const int index )
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
float * __restrict f = ( float* )v; float * __restrict f = ( float* )v;
float * __restrict dst = ( float* )ptr->pushBufferPointer; float * __restrict dst = ( float* )ptr->pushBufferPointer;
_CGprogram *program = ptr->program; _CGprogram *program = ptr->program;
@ -560,8 +578,9 @@ _cgSetArrayIndexFunction getMatrixTypeIndexSetterFunction( unsigned short a, uns
return setMatrixTypeIndex[a][b][c][d][e][f]; return setMatrixTypeIndex[a][b][c][d][e][f];
} }
static void setSamplerfp( CgRuntimeParameter*ptr, const void*v, int ) //index static void setSamplerfp (void *data, const void*v, int ) //index
{ {
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
_CGprogram *program = (( CgRuntimeParameter* )ptr )->program; _CGprogram *program = (( CgRuntimeParameter* )ptr )->program;
const CgParameterResource *parameterResource = rglGetParameterResource( program, (( CgRuntimeParameter* )ptr )->parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( program, (( CgRuntimeParameter* )ptr )->parameterEntry );
@ -579,16 +598,17 @@ static void setSamplerfp( CgRuntimeParameter*ptr, const void*v, int ) //index
} }
} }
static void setSamplervp( CgRuntimeParameter*ptr, const void*v, int ) //index static void setSamplervp (void *data, const void*v, int ) //index
{ {
// the value of v == NULL when it is called from cgGLEnableTextureParameter // the value of v == NULL when it is called from cgGLEnableTextureParameter
// the value of v == NULL when it is called from cgGLSetTextureParameter // the value of v == NULL when it is called from cgGLSetTextureParameter
// this may be called by a connected param to propagate its value // this may be called by a connected param to propagate its value
// the spec says that the set should not cause the bind // the spec says that the set should not cause the bind
// so only do the bind when the call comes from cgGLEnableTextureParameter // so only do the bind when the call comes from cgGLEnableTextureParameter
if ( v ) CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
if (v)
{ {
*( GLuint* )ptr->pushBufferPointer = *( GLuint* )v; *(GLuint*)ptr->pushBufferPointer = *( GLuint* )v;
} }
} }
@ -1170,9 +1190,10 @@ void rglSetDefaultValuesFP (void *data)
PLATFORM BUFFER PLATFORM BUFFER
============================================================ */ ============================================================ */
static void rglDeallocateBuffer( rglBufferObject* bufferObject ) static void rglDeallocateBuffer (void *data)
{ {
rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; rglBufferObject *bufferObject = (rglBufferObject*)data;
rglGcmBufferObject *rglBuffer = (rglGcmBufferObject*)bufferObject->platformBufferObject;
switch ( rglBuffer->pool ) switch ( rglBuffer->pool )
{ {
@ -1189,9 +1210,10 @@ static void rglDeallocateBuffer( rglBufferObject* bufferObject )
rglBuffer->bufferId = GMM_ERROR; rglBuffer->bufferId = GMM_ERROR;
} }
static void rglpsAllocateBuffer(rglBufferObject* bufferObject) static void rglpsAllocateBuffer (void *data)
{ {
rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; rglBufferObject *bufferObject = (rglBufferObject*)data;
rglGcmBufferObject *rglBuffer = (rglGcmBufferObject*)bufferObject->platformBufferObject;
// free current buffer (if any) // free current buffer (if any)
rglDeallocateBuffer( bufferObject ); rglDeallocateBuffer( bufferObject );
@ -2876,10 +2898,11 @@ GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf,
// Render target rt's color and depth buffer parameters are updated with args // Render target rt's color and depth buffer parameters are updated with args
// Fifo functions are called as required // Fifo functions are called as required
void static inline rglGcmSetColorDepthBuffers(void *data, rglGcmRenderTargetEx const * const args ) void static inline rglGcmSetColorDepthBuffers(void *data, const void *data_args)
{ {
rglGcmRenderTarget *rt = (rglGcmRenderTarget*)data; rglGcmRenderTarget *rt = (rglGcmRenderTarget*)data;
CellGcmSurface *grt = &rt->gcmRenderTarget; CellGcmSurface *grt = &rt->gcmRenderTarget;
const rglGcmRenderTargetEx* args = (const rglGcmRenderTargetEx*)data_args;
rt->colorBufferCount = args->colorBufferCount; rt->colorBufferCount = args->colorBufferCount;
@ -2943,10 +2966,11 @@ void static inline rglGcmSetColorDepthBuffers(void *data, rglGcmRenderTargetEx c
} }
// Update rt's color and depth format with args // Update rt's color and depth format with args
void static inline rglGcmSetColorDepthFormats (void *data, rglGcmRenderTargetEx const * const args) void static inline rglGcmSetColorDepthFormats (void *data, const void *data_args)
{ {
rglGcmRenderTarget *rt = (rglGcmRenderTarget*)data; rglGcmRenderTarget *rt = (rglGcmRenderTarget*)data;
CellGcmSurface * grt = &rt->gcmRenderTarget; CellGcmSurface * grt = &rt->gcmRenderTarget;
const rglGcmRenderTargetEx *args = (const rglGcmRenderTargetEx*)data_args;
// set the color format // set the color format
switch ( args->colorFormat ) switch ( args->colorFormat )
@ -2973,10 +2997,11 @@ void static inline rglGcmSetColorDepthFormats (void *data, rglGcmRenderTargetEx
} }
// Update rt's color targets // Update rt's color targets
static void inline rglGcmSetTarget (void *data, rglGcmRenderTargetEx const * const args ) static void inline rglGcmSetTarget (void *data, const void *data_args)
{ {
rglGcmRenderTarget *rt = (rglGcmRenderTarget*)data; rglGcmRenderTarget *rt = (rglGcmRenderTarget*)data;
CellGcmSurface * grt = &rt->gcmRenderTarget; CellGcmSurface * grt = &rt->gcmRenderTarget;
const rglGcmRenderTargetEx *args = (const rglGcmRenderTargetEx*)data_args;
// set target combo // set target combo
switch ( rt->colorBufferCount ) switch ( rt->colorBufferCount )
@ -3000,10 +3025,11 @@ static void inline rglGcmSetTarget (void *data, rglGcmRenderTargetEx const * con
} }
// Set current render target to args // Set current render target to args
void rglGcmFifoGlSetRenderTarget( rglGcmRenderTargetEx const * const args ) void rglGcmFifoGlSetRenderTarget (const void *data)
{ {
rglGcmRenderTarget *rt = &rglGcmState_i.renderTarget; rglGcmRenderTarget *rt = &rglGcmState_i.renderTarget;
CellGcmSurface * grt = &rglGcmState_i.renderTarget.gcmRenderTarget; CellGcmSurface * grt = &rglGcmState_i.renderTarget.gcmRenderTarget;
const rglGcmRenderTargetEx *args = (const rglGcmRenderTargetEx*)data;
rglGcmSetColorDepthBuffers( rt, args ); rglGcmSetColorDepthBuffers( rt, args );
rglGcmSetColorDepthFormats( rt, args ); rglGcmSetColorDepthFormats( rt, args );

View File

@ -263,26 +263,32 @@ unsigned int rglCountFloatsInCgType( CGtype type )
return size; return size;
} }
void _cgRaiseInvalidParam( CgRuntimeParameter*p, const void*v ) void _cgRaiseInvalidParam (void *data, const void*v )
{ {
(void)data;
rglCgRaiseError( CG_INVALID_PARAMETER_ERROR ); rglCgRaiseError( CG_INVALID_PARAMETER_ERROR );
} }
void _cgRaiseInvalidParamIndex( CgRuntimeParameter*p, const void*v, const int index ) void _cgRaiseInvalidParamIndex (void *data, const void*v, const int index )
{ {
(void)data;
rglCgRaiseError( CG_INVALID_PARAMETER_ERROR ); rglCgRaiseError( CG_INVALID_PARAMETER_ERROR );
} }
void _cgRaiseNotMatrixParam( CgRuntimeParameter*p, const void*v ) void _cgRaiseNotMatrixParam (void *data, const void*v )
{
rglCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR );
}
void _cgRaiseNotMatrixParamIndex( CgRuntimeParameter*p, const void*v, const int index )
{ {
(void)data;
rglCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR ); rglCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR );
} }
void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index ) void _cgRaiseNotMatrixParamIndex( void *data, const void*v, const int index )
{ {
(void)data;
rglCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR );
}
void _cgIgnoreSetParamIndex (void *data, const void*v, const int index )
{
(void)data;
// nothing // nothing
} }
@ -712,9 +718,10 @@ void rglCgDestroyContextParam( CgRuntimeParameter* ptr )
free( ptr ); free( ptr );
} }
static void _setSamplerRuntimeParameter( CgRuntimeParameter*ptr, const void*v, int /*index*/ ) static void _setSamplerRuntimeParameter (void *data, const void*v, int /*index*/ )
{ {
if ( v ) CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
if (v)
{ {
*( GLuint* )ptr->pushBufferPointer = *( GLuint* )v; *( GLuint* )ptr->pushBufferPointer = *( GLuint* )v;
} }