(RGL) More cleanups

This commit is contained in:
twinaphex 2013-01-03 14:55:11 +01:00
parent 471acec6c9
commit 4a45ead07e
3 changed files with 50 additions and 54 deletions

View File

@ -184,50 +184,50 @@ extern "C"
//---------------------------------------- //----------------------------------------
// Platform/Init.c // Platform/Init.c
//---------------------------------------- //----------------------------------------
extern void rglPlatformInit( PSGLinitOptions* options ); extern void rglPlatformInit (PSGLinitOptions* options);
extern void rglPlatformExit(); extern void rglPlatformExit (void);
//---------------------------------------- //----------------------------------------
// Device/Device.c // Device/Device.c
//---------------------------------------- //----------------------------------------
extern void rglDeviceInit( PSGLinitOptions* options ); extern void rglDeviceInit (PSGLinitOptions* options);
extern void rglDeviceExit(); extern void rglDeviceExit (void);
extern PSGLdeviceParameters * rglShadowDeviceParameters( void ); extern PSGLdeviceParameters * rglShadowDeviceParameters (void);
//---------------------------------------- //----------------------------------------
// Device/.../PlatformDevice.c // Device/.../PlatformDevice.c
//---------------------------------------- //----------------------------------------
extern GLboolean rglPlatformDeviceInit( PSGLinitOptions* options ); extern GLboolean rglPlatformDeviceInit (PSGLinitOptions* options);
extern void rglPlatformDeviceExit(); extern void rglPlatformDeviceExit (void);
extern int rglPlatformDeviceSize(); extern int rglPlatformDeviceSize (void);
extern int rglPlatformCreateDevice( RGLdevice* device ); extern int rglPlatformCreateDevice (void *data);
extern void rglPlatformDestroyDevice( RGLdevice* device ); extern void rglPlatformDestroyDevice (void *data);
extern void rglPlatformMakeCurrent( void* device ); extern void rglPlatformMakeCurrent (void *data);
extern void rglPlatformSwapBuffers( RGLdevice* device ); extern void rglPlatformSwapBuffers (void *data);
extern const GLvoid* rglPlatformGetProcAddress( const char *funcName ); extern const GLvoid* rglPlatformGetProcAddress (const char *funcName);
//---------------------------------------- //----------------------------------------
// Raster/.../PlatformRaster.c // Raster/.../PlatformRaster.c
//---------------------------------------- //----------------------------------------
void* rglPlatformRasterInit (void); void* rglPlatformRasterInit (void);
void rglPlatformRasterExit (void* driver); void rglPlatformRasterExit (void* data);
void rglPlatformRasterDestroyResources (void); void rglPlatformRasterDestroyResources (void);
void rglPlatformDraw( rglDrawParams* dparams ); void rglPlatformDraw (rglDrawParams* dparams);
GLboolean rglPlatformNeedsConversion( const rglAttributeState* as, GLuint index ); GLboolean rglPlatformNeedsConversion (const rglAttributeState* as, GLuint index);
// [YLIN] Try to avoid LHS inside this function. // [YLIN] Try to avoid LHS inside this function.
// In oringinal implementation, indexType and indexCount will be stored right before this function // In oringinal implementation, indexType and indexCount will be stored right before this function
// and since we will load them right after enter this function, there are LHS. // and since we will load them right after enter this function, there are LHS.
GLboolean rglPlatformRequiresSlowPath( rglDrawParams* dparams, const GLenum indexType, uint32_t indexCount); GLboolean rglPlatformRequiresSlowPath( rglDrawParams* dparams, const GLenum indexType, uint32_t indexCount);
void rglPlatformRasterGetIntegerv( GLenum pname, GLint* params ); void rglPlatformRasterGetIntegerv( GLenum pname, GLint* params );
void rglPlatformRasterFlush(); void rglPlatformRasterFlush (void);
void rglPlatformRasterFinish(); void rglPlatformRasterFinish (void);
void rglValidateFragmentProgram(); void rglValidateFragmentProgram (void);
void rglValidateFragmentProgramSharedConstants(); void rglValidateFragmentProgramSharedConstants (void);
void rglValidateClipPlanes(); void rglValidateClipPlanes (void);
void rglInvalidateAttributes(); void rglInvalidateAttributes (void);
GLuint rglValidateAttributes( const GLvoid* indices, GLboolean *isMain ); GLuint rglValidateAttributes (const void* indices, GLboolean *isMain);
GLuint rglValidateAttributesSlow( rglDrawParams *dparams, GLboolean *isMain ); GLuint rglValidateAttributesSlow (rglDrawParams *dparams, GLboolean *isMain);
//---------------------------------------- //----------------------------------------
// Raster/.../PlatformTexture.c // Raster/.../PlatformTexture.c

View File

@ -43,7 +43,6 @@ static inline GLuint rglPlatformGetBitsPerPixel( GLenum internalFormat )
} }
} }
#define SUBPIXEL_BITS 12 #define SUBPIXEL_BITS 12
#define SUBPIXEL_ADJUST (0.5/(1<<SUBPIXEL_BITS)) #define SUBPIXEL_ADJUST (0.5/(1<<SUBPIXEL_BITS))
@ -196,7 +195,7 @@ static inline void rglGcmFifoGlDrawArrays( rglGcmEnum mode, GLint first, GLsizei
} }
} }
static inline void rglGcmFifoGlTransferDataVidToVid static inline void rglGcmFifoGlTransferDataVidToVid
( (
GLuint dstVidId, GLuint dstVidId,
GLuint dstVidIdOffset, GLuint dstVidIdOffset,
@ -298,7 +297,6 @@ static inline GLuint rglGcmMapWrapMode( GLuint mode )
return 0; return 0;
} }
static inline void rglGcmMapTextureFormat( GLuint internalFormat, uint8_t & gcmFormat, uint32_t & remap ) static inline void rglGcmMapTextureFormat( GLuint internalFormat, uint8_t & gcmFormat, uint32_t & remap )
{ {
gcmFormat = 0; gcmFormat = 0;
@ -520,13 +518,13 @@ static inline void rglGcmMapTextureFormat( GLuint internalFormat, uint8_t & gcmF
} }
// Explicitly invalidate the L2 texture cache // Explicitly invalidate the L2 texture cache
static inline void rglGcmFifoGlInvalidateTextureCache( void ) static inline void rglGcmFifoGlInvalidateTextureCache (void)
{ {
GCM_FUNC( cellGcmSetInvalidateTextureCache, CELL_GCM_INVALIDATE_TEXTURE ); GCM_FUNC( cellGcmSetInvalidateTextureCache, CELL_GCM_INVALIDATE_TEXTURE );
} }
// Fast conversion for values between 0.0 and 65535.0 // Fast conversion for values between 0.0 and 65535.0
GLuint inline static RGLGCM_QUICK_FLOAT2UINT( const GLfloat f ) static inline GLuint RGLGCM_QUICK_FLOAT2UINT( const GLfloat f )
{ {
union union
{ {
@ -538,7 +536,7 @@ GLuint inline static RGLGCM_QUICK_FLOAT2UINT( const GLfloat f )
} }
// construct a packed unsigned int ARGB8 color // construct a packed unsigned int ARGB8 color
void inline static RGLGCM_CALC_COLOR_LE_ARGB8( GLuint *color0, const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a ) inline static 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 r2 = RGLGCM_QUICK_FLOAT2UINT( r * 255.0f );
GLuint g2 = RGLGCM_QUICK_FLOAT2UINT( g * 255.0f ); GLuint g2 = RGLGCM_QUICK_FLOAT2UINT( g * 255.0f );
@ -679,7 +677,7 @@ static inline void rglGcmFifoGlBlendFunc( rglGcmEnum sf, rglGcmEnum df, rglGcmEn
// Can be used for printing out macro and constant values. // Can be used for printing out macro and constant values.
// example: rglPrintIt( RGLGCM_3DCONST(SET_SURFACE_FORMAT, COLOR, LE_A8R8G8B8) ); // example: rglPrintIt( RGLGCM_3DCONST(SET_SURFACE_FORMAT, COLOR, LE_A8R8G8B8) );
// 00 00 00 08 : 00000000 00000000 00000000 00001000 */ // 00 00 00 08 : 00000000 00000000 00000000 00001000 */
void static inline rglPrintIt (unsigned int v ) static inline void rglPrintIt (unsigned int v)
{ {
// HEX (space between bytes) // HEX (space between bytes)
printf( "%02x %02x %02x %02x : ", ( v >> 24 )&0xff, ( v >> 16 )&0xff, ( v >> 8 )&0xff, v&0xff ); printf( "%02x %02x %02x %02x : ", ( v >> 24 )&0xff, ( v >> 16 )&0xff, ( v >> 8 )&0xff, v&0xff );
@ -691,14 +689,14 @@ void static inline rglPrintIt (unsigned int v )
} }
// prints the last numWords of the command fifo // prints the last numWords of the command fifo
void static inline rglPrintFifoFromPut( unsigned int numWords ) static inline void rglPrintFifoFromPut( unsigned int numWords )
{ {
for ( int i = -numWords; i <= -1; i++ ) for ( int i = -numWords; i <= -1; i++ )
rglPrintIt((( uint32_t* )rglGcmState_i.fifo.current )[i] ); rglPrintIt((( uint32_t* )rglGcmState_i.fifo.current )[i] );
} }
// prints the last numWords of the command fifo // prints the last numWords of the command fifo
void static inline rglPrintFifoFromGet( unsigned int numWords ) static inline void rglPrintFifoFromGet( unsigned int numWords )
{ {
for ( int i = -numWords; i <= -1; i++ ) for ( int i = -numWords; i <= -1; i++ )
rglPrintIt((( uint32_t* )rglGcmState_i.fifo.lastGetRead )[i] ); rglPrintIt((( uint32_t* )rglGcmState_i.fifo.lastGetRead )[i] );
@ -706,7 +704,7 @@ void static inline rglPrintFifoFromGet( unsigned int numWords )
// Determine whether a given location in a command buffer has been passed, by // Determine whether a given location in a command buffer has been passed, by
// using reference markers. // using reference markers.
GLboolean static inline rglGcmFifoGlTestFenceRef( const GLuint ref ) static inline GLboolean rglGcmFifoGlTestFenceRef (const GLuint ref)
{ {
rglGcmFifo *fifo = &rglGcmState_i.fifo; rglGcmFifo *fifo = &rglGcmState_i.fifo;
return rglGcmFifoReferenceInUse( fifo, ref ); return rglGcmFifoReferenceInUse( fifo, ref );
@ -714,14 +712,14 @@ GLboolean static inline rglGcmFifoGlTestFenceRef( const GLuint ref )
// Add a reference marker to the command buffer to determine whether a location // Add a reference marker to the command buffer to determine whether a location
// in the command buffer has been passed // in the command buffer has been passed
void static inline rglGcmFifoGlIncFenceRef( GLuint *ref ) static inline void rglGcmFifoGlIncFenceRef (GLuint *ref)
{ {
rglGcmFifo *fifo = &rglGcmState_i.fifo; rglGcmFifo *fifo = &rglGcmState_i.fifo;
*ref = rglGcmFifoPutReference( fifo ); *ref = rglGcmFifoPutReference( fifo );
} }
// Flush the current FIFO. // Flush the current FIFO.
void static inline rglGcmFifoGlFlush( void ) static inline void rglGcmFifoGlFlush (void)
{ {
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache ); GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFlush( &rglGcmState_i.fifo ); rglGcmFifoFlush( &rglGcmState_i.fifo );
@ -856,7 +854,7 @@ static inline void rglGcmFifoGlVertexAttribPointer
} }
// set the vertex attribute to the specified value. // set the vertex attribute to the specified value.
void static inline rglGcmFifoGlVertexAttrib4fv( GLuint index, const GLfloat v[4] ) static inline void rglGcmFifoGlVertexAttrib4fv( GLuint index, const GLfloat v[4] )
{ {
GCM_FUNC( cellGcmSetVertexData4f, index, v ); GCM_FUNC( cellGcmSetVertexData4f, index, v );
} }
@ -873,7 +871,7 @@ static inline void rglGcmFifoGlClear( GLbitfield mask )
if ( mask & RGLGCM_COLOR_BUFFER_BIT && rglGcmState_i.renderTarget.colorFormat) if ( mask & RGLGCM_COLOR_BUFFER_BIT && rglGcmState_i.renderTarget.colorFormat)
hwMask = CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | CELL_GCM_CLEAR_B | CELL_GCM_CLEAR_A; hwMask = CELL_GCM_CLEAR_R | CELL_GCM_CLEAR_G | CELL_GCM_CLEAR_B | CELL_GCM_CLEAR_A;
if ( hwMask ) if (hwMask)
{ {
GCM_FUNC( cellGcmSetClearSurface, hwMask ); GCM_FUNC( cellGcmSetClearSurface, hwMask );
} }
@ -881,7 +879,7 @@ static inline void rglGcmFifoGlClear( GLbitfield mask )
static inline void rglGcmFifoGlEnable( rglGcmEnum cap ) static inline void rglGcmFifoGlEnable( rglGcmEnum cap )
{ {
switch ( cap ) switch (cap)
{ {
case RGLGCM_BLEND: case RGLGCM_BLEND:
GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_TRUE ); GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_TRUE );
@ -900,8 +898,7 @@ static inline void rglGcmFifoGlEnable( rglGcmEnum cap )
static inline void rglGcmFifoGlDisable( rglGcmEnum cap ) static inline void rglGcmFifoGlDisable( rglGcmEnum cap )
{ {
switch (cap)
switch ( cap )
{ {
case RGLGCM_BLEND: case RGLGCM_BLEND:
GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_FALSE ); GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_FALSE );
@ -1029,9 +1026,3 @@ static inline GLuint rglGcmGetBufferObjectOrigin (GLuint buffer)
rglGcmBufferObject *gcmBuffer = ( rglGcmBufferObject * ) & bufferObject->platformBufferObject; rglGcmBufferObject *gcmBuffer = ( rglGcmBufferObject * ) & bufferObject->platformBufferObject;
return gcmBuffer->bufferId; return gcmBuffer->bufferId;
} }
static inline rglGcmDriver *rglGetGcmDriver(void)
{
return ( rglGcmDriver * )( _CurrentDevice->rasterDriver );
}

View File

@ -2976,8 +2976,9 @@ static void rglSetDisplayMode( const VideoMode *vm, GLushort bitsPerPixel, GLuin
cellVideoOutConfigure( CELL_VIDEO_OUT_PRIMARY, &videocfg, NULL, 0 ); cellVideoOutConfigure( CELL_VIDEO_OUT_PRIMARY, &videocfg, NULL, 0 );
} }
int rglPlatformCreateDevice( RGLdevice* device ) int rglPlatformCreateDevice (void *data)
{ {
RGLdevice *device = (RGLdevice*)data;
rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice; rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice;
RGLdeviceParameters* params = &device->deviceParameters; RGLdeviceParameters* params = &device->deviceParameters;
rglDuringDestroyDevice = GL_FALSE; rglDuringDestroyDevice = GL_FALSE;
@ -3209,10 +3210,11 @@ int rglPlatformCreateDevice( RGLdevice* device )
return 0; return 0;
} }
void rglPlatformDestroyDevice( RGLdevice* device ) void rglPlatformDestroyDevice (void *data)
{ {
RGLdevice *device = (RGLdevice*)data;
rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice; rglGcmDevice *gcmDevice = ( rglGcmDevice * )device->platformDevice;
RGLdeviceParameters* params = &device->deviceParameters; RGLdeviceParameters *params = &device->deviceParameters;
rglpFifoGlFinish(); rglpFifoGlFinish();
@ -3249,10 +3251,11 @@ void rglPlatformDestroyDevice( RGLdevice* device )
rglDuringDestroyDevice = GL_FALSE; rglDuringDestroyDevice = GL_FALSE;
} }
void rglPlatformSwapBuffers( RGLdevice* device ) void rglPlatformSwapBuffers (void *data)
{ {
gmmUpdateFreeList(CELL_GCM_LOCATION_LOCAL); gmmUpdateFreeList(CELL_GCM_LOCATION_LOCAL);
RGLdevice *device = (RGLdevice*)data;
rglGcmDevice *gcmDevice = (rglGcmDevice *)device->platformDevice; rglGcmDevice *gcmDevice = (rglGcmDevice *)device->platformDevice;
const GLuint drawBuffer = gcmDevice->drawBuffer; const GLuint drawBuffer = gcmDevice->drawBuffer;
@ -3281,7 +3284,8 @@ void rglPlatformSwapBuffers( RGLdevice* device )
if ( res != CELL_OK ) if ( res != CELL_OK )
{ {
//RGL_REPORT_EXTRA(RGL_REPORT_RESC_FLIP_ERROR, "WARNING: RESC cellRescSetConvertAndFlip returned error code %d.\n", res); //RGL_REPORT_EXTRA(RGL_REPORT_RESC_FLIP_ERROR, "WARNING: RESC cellRescSetConvertAndFlip returned error code %d.\n", res);
if ( _CurrentContext ) _CurrentContext->needValidate |= RGL_VALIDATE_FRAMEBUFFER; if ( _CurrentContext )
_CurrentContext->needValidate |= RGL_VALIDATE_FRAMEBUFFER;
return; return;
} }
} }
@ -3296,7 +3300,8 @@ void rglPlatformSwapBuffers( RGLdevice* device )
cellGcmSetWaitFlip(); // GPU will wait until flip actually occurs cellGcmSetWaitFlip(); // GPU will wait until flip actually occurs
} }
const char * __restrict v = rglGetGcmDriver()->sharedVPConstants; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
const char * __restrict v = driver->sharedVPConstants;
GCM_FUNC( cellGcmSetVertexProgramParameterBlock, 0, 8, ( float* )v ); // GCM_PORT_UNTESTED [KHOFF] GCM_FUNC( cellGcmSetVertexProgramParameterBlock, 0, 8, ( float* )v ); // GCM_PORT_UNTESTED [KHOFF]
rglGcmFifoGlEnable( RGLGCM_DITHER ); rglGcmFifoGlEnable( RGLGCM_DITHER );
@ -3330,7 +3335,7 @@ void rglPlatformSwapBuffers( RGLdevice* device )
} }
} }
void rglpValidateViewport(void) void rglpValidateViewport (void)
{ {
RGLcontext* LContext = _CurrentContext; RGLcontext* LContext = _CurrentContext;