(RGL) More cleanups pt. 4

This commit is contained in:
twinaphex 2013-01-04 05:39:31 +01:00
parent 92c6f0aa45
commit e1314a6d32
11 changed files with 145 additions and 143 deletions

View File

@ -2,8 +2,7 @@
#define _cg_internal_h #define _cg_internal_h
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
{
#endif #endif
//Hardware shader settings //Hardware shader settings
@ -152,7 +151,7 @@ extern "C"
CgProgramHeader; CgProgramHeader;
#ifdef __cplusplus #ifdef __cplusplus
} // Close scope of 'extern "C"' declaration that encloses file. }
#endif #endif
#endif #endif

View File

@ -1,29 +1,29 @@
#ifndef _RGLReportInternal_h #ifndef _RGL_REPORT_INTERNAL_H
#define _RGLReportInternal_h #define _RGL_REPORT_INTERNAL_H
#include "../export/RGL/rgl.h" #include "../export/RGL/rgl.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
{
#endif #endif
typedef struct typedef struct
{ {
GLenum e; GLenum e;
const char *s; const char *s;
}RGLenumMap; } RGLenumMap;
const char *rglMapLookupEnum( const RGLenumMap* map, unsigned int count, GLenum e );
GLenum rglMapLookupString( const RGLenumMap* map, unsigned int count, const char *s );
const char *rglMapLookupEnum( const RGLenumMap* map, unsigned int count, GLenum e );
GLenum rglMapLookupString( const RGLenumMap* map, unsigned int count, const char *s );
#define _RGL_MAP_LOOKUP_ENUM(MAP,ENUM) rglMapLookupEnum(MAP,sizeof(MAP)/sizeof(MAP[0]),ENUM) #define _RGL_MAP_LOOKUP_ENUM(MAP,ENUM) rglMapLookupEnum(MAP,sizeof(MAP)/sizeof(MAP[0]),ENUM)
#define _RGL_MAP_LOOKUP_STRING(MAP,STRING) rglMapLookupString(MAP,sizeof(MAP)/sizeof(MAP[0]),STRING) #define _RGL_MAP_LOOKUP_STRING(MAP,STRING) rglMapLookupString(MAP,sizeof(MAP)/sizeof(MAP[0]),STRING)
const char *rglGetGLEnumName( GLenum e ); const char *rglGetGLEnumName( GLenum e );
const char *rglGetGLErrorName( GLenum e ); const char *rglGetGLErrorName( GLenum e );
#ifdef __cplusplus #ifdef __cplusplus
} // Close scope of 'extern "C"' declaration that encloses file. }
#endif #endif
#endif #endif

View File

@ -1,5 +1,5 @@
#ifndef _RGLTypes_h #ifndef _RGL_TYPES_H
#define _RGLTypes_h #define _RGL_TYPES_H
#include <stdlib.h> #include <stdlib.h>
#include <float.h> #include <float.h>
@ -34,20 +34,14 @@ struct rglFramebuffer
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C" {
{
#endif #endif
typedef float RGLFColorComponent;
typedef float RGLCoordinate;
typedef unsigned int rglBitfield;
#define RGLBIT_GET(f,n) ((f) & (1<<(n))) #define RGLBIT_GET(f,n) ((f) & (1<<(n)))
#define RGLBIT_TRUE(f,n) ((f) |= (1<<(n))) #define RGLBIT_TRUE(f,n) ((f) |= (1<<(n)))
#define RGLBIT_FALSE(f,n) ((f) &= ~(1<<(n))) #define RGLBIT_FALSE(f,n) ((f) &= ~(1<<(n)))
#define RGLBIT_ASSIGN(f,n,val) do { if(val) RGLBIT_TRUE(f,n); else RGLBIT_FALSE(f,n); } while(0) #define RGLBIT_ASSIGN(f,n,val) do { if(val) RGLBIT_TRUE(f,n); else RGLBIT_FALSE(f,n); } while(0)
#define ALIGN16 __attribute__((aligned (16))) #define ALIGN16 __attribute__((aligned (16)))
#define _RGL_RESTRICT __restrict #define _RGL_RESTRICT __restrict
@ -288,9 +282,9 @@ extern "C"
rglAttribute attrib[RGL_MAX_VERTEX_ATTRIBS]; rglAttribute attrib[RGL_MAX_VERTEX_ATTRIBS];
// bitfields corresponding to the attrib[] array elements: // bitfields corresponding to the attrib[] array elements:
rglBitfield DirtyMask; // 1 == attribute has changed & needs updating unsigned int DirtyMask; // 1 == attribute has changed & needs updating
rglBitfield EnabledMask; // 1 == attribute is enabled for drawing unsigned int EnabledMask; // 1 == attribute is enabled for drawing
rglBitfield HasVBOMask; // 1 == attribute is in a VBO (ie server-side) unsigned int HasVBOMask; // 1 == attribute is in a VBO (ie server-side)
} ALIGN16 rglAttributeState; } ALIGN16 rglAttributeState;
struct rglBufferObject struct rglBufferObject
@ -432,8 +426,7 @@ extern "C"
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} // Close scope of 'extern "C"' declaration which encloses file. }
#endif #endif
#endif
#endif // _RGLTypes_h

View File

@ -14,11 +14,11 @@
extern "C" { extern "C" {
#endif #endif
extern RGL_EXPORT RGLcontext* _CurrentContext; extern RGL_EXPORT RGLcontext* _CurrentContext;
extern RGLdevice* _CurrentDevice; extern RGLdevice* _CurrentDevice;
extern RGL_EXPORT char* rglVersion; extern RGL_EXPORT char* rglVersion;
// only for internal purpose // only for internal purpose
#define GL_UNSIGNED_BYTE_4_4 0x4A00 #define GL_UNSIGNED_BYTE_4_4 0x4A00
#define GL_UNSIGNED_BYTE_4_4_REV 0x4A01 #define GL_UNSIGNED_BYTE_4_4_REV 0x4A01
#define GL_UNSIGNED_BYTE_6_2 0x4A02 #define GL_UNSIGNED_BYTE_6_2 0x4A02
@ -137,10 +137,8 @@ static inline rglFramebuffer *rglGetFramebufferSafe( RGLcontext *LContext, GLuin
} }
void rglFramebufferGetAttachmentTexture( RGLcontext* LContext, const rglFramebufferAttachment* attachment, rglTexture** texture, GLuint* face ); void rglFramebufferGetAttachmentTexture( RGLcontext* LContext, const rglFramebufferAttachment* attachment, rglTexture** texture, GLuint* face );
GLenum rglPlatformFramebufferCheckStatus( rglFramebuffer* framebuffer ); GLenum rglPlatformFramebufferCheckStatus (void *data);
GLboolean rglPlatformGenerateMipmap( rglTexture* texture, GLuint face );
void rglPlatformFramebufferGetParameteriv( GLenum pname, GLint* params ); void rglPlatformFramebufferGetParameteriv( GLenum pname, GLint* params );
void rglPlatformResolveFramebuffer();
void rglGetFramebufferSize( GLuint* width, GLuint* height ); void rglGetFramebufferSize( GLuint* width, GLuint* height );
//---------------------------------------- //----------------------------------------
@ -249,12 +247,11 @@ void rglValidateVertexConstants (void);
//---------------------------------------- //----------------------------------------
int rglPlatformBufferObjectSize (void); int rglPlatformBufferObjectSize (void);
GLboolean rglPlatformCreateBufferObject( rglBufferObject* bufferObject ); GLboolean rglPlatformCreateBufferObject( rglBufferObject* bufferObject );
void rglPlatformDestroyBufferObject( rglBufferObject* bufferObject ); void rglPlatformDestroyBufferObject (void *data);
void rglPlatformBufferObjectSetData( rglBufferObject* bufferObject, GLintptr offset, GLsizeiptr size, const GLvoid *data, GLboolean tryImmediateCopy ); void rglPlatformBufferObjectSetData (void *buf_data, GLintptr offset, GLsizeiptr size, const GLvoid *data, GLboolean tryImmediateCopy );
GLvoid rglPlatformBufferObjectCopyData (void *dst, void *src); GLvoid rglPlatformBufferObjectCopyData (void *dst, void *src);
// map / unmap buffers. Internally refcounted char *rglPlatformBufferObjectMap (void *data, GLenum access );
char *rglPlatformBufferObjectMap( rglBufferObject* bufferObject, GLenum access ); GLboolean rglPlatformBufferObjectUnmap (void *data);
GLboolean rglPlatformBufferObjectUnmap( rglBufferObject* bufferObject );
void rglPlatformGetBufferParameteriv( rglBufferObject *bufferObject, GLenum pname, int *params ); void rglPlatformGetBufferParameteriv( rglBufferObject *bufferObject, GLenum pname, int *params );
// this is shared in glBindTexture and cgGL code // this is shared in glBindTexture and cgGL code

View File

@ -1,10 +1,10 @@
void rglGcmFifoFinish (rglGcmFifo *fifo); void rglGcmFifoFinish (void *data);
GLboolean rglGcmFifoReferenceInUse (rglGcmFifo *fifo, GLuint reference); GLboolean rglGcmFifoReferenceInUse (void *data, GLuint reference);
GLuint rglGcmFifoPutReference (rglGcmFifo *fifo); GLuint rglGcmFifoPutReference (void *data);
void rglGcmFifoFlush (rglGcmFifo *fifo); void rglGcmFifoFlush (void *data);
uint32_t * rglGcmFifoWaitForFreeSpace (rglGcmFifo *fifo, GLuint spaceInWords); uint32_t *rglGcmFifoWaitForFreeSpace (void *data, GLuint spaceInWords);
void rglGcmGetTileRegionInfo (void* data, GLuint *address, GLuint *size); void rglGcmGetTileRegionInfo (void *data, GLuint *address, GLuint *size);
GLboolean rglGcmTryResizeTileRegion( GLuint address, GLuint size, void* data ); GLboolean rglGcmTryResizeTileRegion( GLuint address, GLuint size, void *data);
void rglGcmTransferData (GLuint dstId, GLuint dstIdOffset, void rglGcmTransferData (GLuint dstId, GLuint dstIdOffset,
GLint dstPitch, GLuint srcId, GLuint srcIdOffset, GLint dstPitch, GLuint srcId, GLuint srcIdOffset,
@ -14,8 +14,8 @@ int32_t rglOutOfSpaceCallback (struct CellGcmContextData* fifoContext, uint32_t
void rglGcmFifoGlSetRenderTarget (rglGcmRenderTargetEx const * const args); void rglGcmFifoGlSetRenderTarget (rglGcmRenderTargetEx const * const args);
void rglpFifoGlFinish (void); void rglpFifoGlFinish (void);
void rglCreatePushBuffer (void *data); void rglCreatePushBuffer (void *data);
void rglSetDefaultValuesFP( _CGprogram *program ); void rglSetDefaultValuesFP (void *data);
void rglSetDefaultValuesVP( _CGprogram *program ); void rglSetDefaultValuesVP (void *data);
void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch, const char *src, unsigned int size ); void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch, const char *src, unsigned int size );
void rglGcmMemcpy( const GLuint dstId, unsigned dstOffset, unsigned int pitch, const GLuint srcId, GLuint srcOffset, unsigned int size ); void rglGcmMemcpy( const GLuint dstId, unsigned dstOffset, unsigned int pitch, const GLuint srcId, GLuint srcOffset, unsigned int size );
void rglPlatformValidateTextureResources (void *data); void rglPlatformValidateTextureResources (void *data);

View File

@ -6,9 +6,9 @@
// incorrect in the case of NaN. // incorrect in the case of NaN.
#define RGLGCM_CLAMPF_01(x) ((x) >= 0.0f ? ((x) > 1.0f ? 1.0f : (x)) : 0.0f) #define RGLGCM_CLAMPF_01(x) ((x) >= 0.0f ? ((x) > 1.0f ? 1.0f : (x)) : 0.0f)
static inline GLboolean rglIsDrawableColorFormat( GLenum colorFormat ) static inline GLboolean rglIsDrawableColorFormat (GLenum colorFormat)
{ {
switch ( colorFormat ) switch (colorFormat)
{ {
case RGLGCM_ARGB8: case RGLGCM_ARGB8:
case RGLGCM_FLOAT_R32: case RGLGCM_FLOAT_R32:
@ -18,9 +18,9 @@ static inline GLboolean rglIsDrawableColorFormat( GLenum colorFormat )
} }
} }
static inline GLuint rglPlatformGetBitsPerPixel( GLenum internalFormat ) static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat)
{ {
switch ( internalFormat ) switch (internalFormat)
{ {
case RGLGCM_ALPHA16: case RGLGCM_ALPHA16:
case RGLGCM_HILO8: case RGLGCM_HILO8:
@ -485,7 +485,7 @@ static inline void rglGcmMapTextureFormat( GLuint internalFormat, uint8_t *gcmFo
} }
// Fast conversion for values between 0.0 and 65535.0 // Fast conversion for values between 0.0 and 65535.0
static inline GLuint RGLGCM_QUICK_FLOAT2UINT( const GLfloat f ) static inline GLuint RGLGCM_QUICK_FLOAT2UINT (const GLfloat f)
{ {
union union
{ {
@ -871,7 +871,7 @@ static inline void rglFifoGlProgramParameterfvVP (const void *data, const CgPara
const _CGprogram *program = (const _CGprogram*)data; const _CGprogram *program = (const _CGprogram*)data;
const CgParameterResource *parameterResource = rglGetParameterResource( program, parameterEntry ); const CgParameterResource *parameterResource = rglGetParameterResource( program, parameterEntry );
if ( parameterResource->resource != ( unsigned short ) - 1 ) if (parameterResource->resource != (unsigned short) - 1)
{ {
switch ( parameterResource->type ) switch ( parameterResource->type )
{ {
@ -974,6 +974,6 @@ static inline void rglFifoGlProgramParameterfvVP (const void *data, const CgPara
static inline GLuint rglGcmGetBufferObjectOrigin (GLuint buffer) static inline GLuint rglGcmGetBufferObjectOrigin (GLuint buffer)
{ {
rglBufferObject *bufferObject = (rglBufferObject*)_CurrentContext->bufferObjectNameSpace.data[buffer]; rglBufferObject *bufferObject = (rglBufferObject*)_CurrentContext->bufferObjectNameSpace.data[buffer];
rglGcmBufferObject *gcmBuffer = ( rglGcmBufferObject * ) & bufferObject->platformBufferObject; rglGcmBufferObject *gcmBuffer = (rglGcmBufferObject *)bufferObject->platformBufferObject;
return gcmBuffer->bufferId; return gcmBuffer->bufferId;
} }

View File

@ -119,7 +119,7 @@ struct rglPlatformFramebuffer: public rglFramebuffer
memset( &rt, 0, sizeof( rt ) ); memset( &rt, 0, sizeof( rt ) );
}; };
virtual ~rglPlatformFramebuffer() {}; virtual ~rglPlatformFramebuffer() {};
void validate( PSGLcontext *LContext ); void validate (void *data);
}; };
typedef struct typedef struct

View File

@ -1601,24 +1601,22 @@ void rglGcmCopySurface(
const uint32_t c_rounded_size_ofrglDrawParams = (sizeof(rglDrawParams)+0x7f)&~0x7f; const uint32_t c_rounded_size_ofrglDrawParams = (sizeof(rglDrawParams)+0x7f)&~0x7f;
void rglGcmFifoFinish( rglGcmFifo *fifo ) void rglGcmFifoFinish (void *data)
{ {
rglGcmFifo *fifo = (rglGcmFifo*)data;
GLuint ref = rglGcmFifoPutReference( fifo ); GLuint ref = rglGcmFifoPutReference( fifo );
rglGcmFifoFlush( fifo ); rglGcmFifoFlush( fifo );
for ( ;; ) while (rglGcmFifoReferenceInUse(fifo, ref))
{ sys_timer_usleep(10);
if ( !rglGcmFifoReferenceInUse( fifo, ref ) )
break;
sys_timer_usleep( 10 );
}
} }
void rglGcmFifoFlush( rglGcmFifo *fifo ) void rglGcmFifoFlush (void *data)
{ {
rglGcmFifo *fifo = (rglGcmFifo*)data;
unsigned int offsetInBytes = 0; unsigned int offsetInBytes = 0;
cellGcmAddressToOffset( fifo->current, ( uint32_t * )&offsetInBytes ); cellGcmAddressToOffset( fifo->current, ( uint32_t * )&offsetInBytes );
cellGcmFlush(); cellGcmFlush();
@ -1629,16 +1627,15 @@ void rglGcmFifoFlush( rglGcmFifo *fifo )
fifo->lastSWReferenceFlushed = fifo->lastSWReferenceWritten; fifo->lastSWReferenceFlushed = fifo->lastSWReferenceWritten;
} }
GLuint rglGcmFifoPutReference( rglGcmFifo *fifo ) GLuint rglGcmFifoPutReference (void *data)
{ {
rglGcmFifo *fifo = (rglGcmFifo*)data;
fifo->lastSWReferenceWritten++; fifo->lastSWReferenceWritten++;
GCM_FUNC( cellGcmSetReferenceCommand, fifo->lastSWReferenceWritten ); GCM_FUNC( cellGcmSetReferenceCommand, fifo->lastSWReferenceWritten );
if (( fifo->lastSWReferenceWritten & 0x7fffffff ) == 0 ) if (( fifo->lastSWReferenceWritten & 0x7fffffff ) == 0 )
{
rglGcmFifoFinish( fifo ); rglGcmFifoFinish( fifo );
}
return fifo->lastSWReferenceWritten; return fifo->lastSWReferenceWritten;
} }
@ -1650,17 +1647,16 @@ GLuint rglGcmFifoReadReference( rglGcmFifo *fifo )
return ref; return ref;
} }
GLboolean rglGcmFifoReferenceInUse( rglGcmFifo *fifo, GLuint reference ) GLboolean rglGcmFifoReferenceInUse (void *data, GLuint reference)
{ {
rglGcmFifo *fifo = (rglGcmFifo*)data;
// compare against cached hw ref value (accounting wrap) // compare against cached hw ref value (accounting wrap)
if ( !(( fifo->lastHWReferenceRead - reference ) & 0x80000000 ) ) if ( !(( fifo->lastHWReferenceRead - reference ) & 0x80000000 ) )
return GL_FALSE; return GL_FALSE;
// has the reference already been flushed out ? // has the reference already been flushed out ?
if (( fifo->lastSWReferenceFlushed - reference ) & 0x80000000 ) if (( fifo->lastSWReferenceFlushed - reference ) & 0x80000000 )
{
rglGcmFifoFlush( fifo ); rglGcmFifoFlush( fifo );
}
// read current hw reference // read current hw reference
rglGcmFifoReadReference( fifo ); rglGcmFifoReadReference( fifo );
@ -1675,17 +1671,22 @@ GLboolean rglGcmFifoReferenceInUse( rglGcmFifo *fifo, GLuint reference )
// 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
uint32_t * rglGcmFifoWaitForFreeSpace( rglGcmFifo *fifo, GLuint spaceInWords )
uint32_t * rglGcmFifoWaitForFreeSpace (void *data, GLuint spaceInWords)
{ {
rglGcmFifo *fifo = (rglGcmFifo*)data;
if ( fifo->current + spaceInWords + 1024 > fifo->end ) if ( fifo->current + spaceInWords + 1024 > fifo->end )
rglOutOfSpaceCallback( fifo, spaceInWords ); rglOutOfSpaceCallback( fifo, spaceInWords );
return rglGcmState_i.fifo.current; return rglGcmState_i.fifo.current;
} }
void rglGcmFifoInit( rglGcmFifo *fifo, void *dmaControl, unsigned long dmaPushBufferOffset, uint32_t*dmaPushBuffer, void rglGcmFifoInit (void *data, void *dmaControl, unsigned long dmaPushBufferOffset, uint32_t*dmaPushBuffer,
GLuint dmaPushBufferSize ) GLuint dmaPushBufferSize )
{ {
rglGcmFifo *fifo = (rglGcmFifo*)data;
// init fifoBlockSize // init fifoBlockSize
fifo->fifoBlockSize = DEFAULT_FIFO_BLOCK_SIZE; fifo->fifoBlockSize = DEFAULT_FIFO_BLOCK_SIZE;
@ -1735,9 +1736,9 @@ void rglGcmFifoInit( rglGcmFifo *fifo, void *dmaControl, unsigned long dmaPushBu
GL INITIALIZATION GL INITIALIZATION
============================================================ */ ============================================================ */
void rglGcmSetOpenGLState (void *data)
void rglGcmSetOpenGLState( rglGcmState *rglGcmSt )
{ {
rglGcmState *rglGcmSt = (rglGcmState*)data;
GLuint i; GLuint i;
// initialize the default OpenGL state // initialize the default OpenGL state
@ -1797,15 +1798,14 @@ GLboolean rglGcmInitFromRM( rglGcmResource *rmResource )
rglGcmFifoFinish( &rglGcmSt->fifo ); rglGcmFifoFinish( &rglGcmSt->fifo );
// Set the GPU to a known state // Set the GPU to a known state
rglGcmSetOpenGLState( rglGcmSt ); rglGcmSetOpenGLState(rglGcmSt);
// wait for setup to complete // wait for setup to complete
rglGcmFifoFinish( &rglGcmSt->fifo ); rglGcmFifoFinish(&rglGcmSt->fifo);
return GL_TRUE; return GL_TRUE;
} }
void rglGcmDestroy(void) void rglGcmDestroy(void)
{ {
rglGcmState *rglGcmSt = &rglGcmState_i; rglGcmState *rglGcmSt = &rglGcmState_i;

View File

@ -170,9 +170,9 @@ int rglGcmGenerateProgram( _CGprogram *program, int profileIndex, const CgProgra
rglCreatePushBuffer( program ); rglCreatePushBuffer( program );
if ( profileIndex == FRAGMENT_PROFILE_INDEX ) if ( profileIndex == FRAGMENT_PROFILE_INDEX )
rglSetDefaultValuesFP( program ); // modifies the ucode rglSetDefaultValuesFP(program); // modifies the ucode
else else
rglSetDefaultValuesVP( program ); // modifies the push buffer rglSetDefaultValuesVP(program); // modifies the push buffer
// not loaded yet // not loaded yet
program->loadProgramId = GMM_ERROR; program->loadProgramId = GMM_ERROR;

View File

@ -1070,11 +1070,12 @@ void rglCreatePushBuffer(void *data)
//this function sets the embedded constant to their default value in the ucode of a fragment shader //this function sets the embedded constant to their default value in the ucode of a fragment shader
//it's called at setup time right after loading the program. this function could be removed if the //it's called at setup time right after loading the program. this function could be removed if the
//default values were already in the shader code //default values were already in the shader code
void rglSetDefaultValuesVP( _CGprogram *program ) void rglSetDefaultValuesVP (void *data)
{ {
_CGprogram *program = (_CGprogram*)data;
int count = program->defaultValuesIndexCount; int count = program->defaultValuesIndexCount;
for ( int i = 0;i < count;i++ )
for (int i = 0; i < count; i++)
{ {
int index = ( int )program->defaultValuesIndices[i].entryIndex; int index = ( int )program->defaultValuesIndices[i].entryIndex;
CgRuntimeParameter *rtParameter = program->runtimeParameters + index; CgRuntimeParameter *rtParameter = program->runtimeParameters + index;
@ -1113,9 +1114,11 @@ void rglSetDefaultValuesVP( _CGprogram *program )
} }
} }
void rglSetDefaultValuesFP( _CGprogram *program ) void rglSetDefaultValuesFP (void *data)
{ {
_CGprogram *program = (_CGprogram*)data;
int count = program->defaultValuesIndexCount; int count = program->defaultValuesIndexCount;
for ( int i = 0;i < count;i++ ) for ( int i = 0;i < count;i++ )
{ {
const void * __restrict pItemDefaultValues = program->defaultValues + program->defaultValuesIndices[i].defaultValueIndex; const void * __restrict pItemDefaultValues = program->defaultValues + program->defaultValuesIndices[i].defaultValueIndex;
@ -1218,10 +1221,14 @@ static void rglpsAllocateBuffer(rglBufferObject* bufferObject)
} }
} }
int rglpBufferObjectSize(void) { return sizeof(rglGcmBufferObject); } int rglpBufferObjectSize(void)
GLboolean rglpCreateBufferObject( rglBufferObject* bufferObject )
{ {
return sizeof(rglGcmBufferObject);
}
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->pool = RGLGCM_SURFACE_POOL_NONE;
@ -1236,20 +1243,21 @@ GLboolean rglpCreateBufferObject( rglBufferObject* bufferObject )
return rglBuffer->bufferId != GMM_ERROR; return rglBuffer->bufferId != GMM_ERROR;
} }
void rglPlatformDestroyBufferObject( rglBufferObject* bufferObject ) void rglPlatformDestroyBufferObject (void *data)
{ {
rglBufferObject *bufferObject = (rglBufferObject*)data;
rglDeallocateBuffer( bufferObject ); rglDeallocateBuffer( bufferObject );
} }
void rglPlatformBufferObjectSetData( rglBufferObject* bufferObject, GLintptr offset, GLsizeiptr size, const GLvoid *data, GLboolean tryImmediateCopy ) void rglPlatformBufferObjectSetData(void *buf_data, GLintptr offset, GLsizeiptr size, const GLvoid *data, GLboolean tryImmediateCopy)
{ {
rglBufferObject *bufferObject = (rglBufferObject*)buf_data;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject;
if ( size == bufferObject->size && tryImmediateCopy ) if ( size == bufferObject->size && tryImmediateCopy )
__builtin_memcpy( gmmIdToAddress( rglBuffer->bufferId ) + offset, data, size ); __builtin_memcpy( gmmIdToAddress( rglBuffer->bufferId ) + offset, data, size );
else else if ( size >= bufferObject->size )
if ( size >= bufferObject->size )
{ {
// reallocate the buffer // reallocate the buffer
// To avoid waiting for the GPU to finish with the buffer, just // To avoid waiting for the GPU to finish with the buffer, just
@ -1296,22 +1304,20 @@ GLvoid rglPlatformBufferObjectCopyData(void *bufferObjectDst, void *bufferObject
rglGcmBufferObject* dst = (rglGcmBufferObject*)in_dst->platformBufferObject; rglGcmBufferObject* dst = (rglGcmBufferObject*)in_dst->platformBufferObject;
rglGcmBufferObject* src = (rglGcmBufferObject*)in_src->platformBufferObject; rglGcmBufferObject* src = (rglGcmBufferObject*)in_src->platformBufferObject;
// copy data
// There is currently no requirement to copy from one pool to another.
rglGcmMemcpy( dst->bufferId, 0, dst->pitch, src->bufferId, 0, src->bufferSize ); rglGcmMemcpy( dst->bufferId, 0, dst->pitch, src->bufferId, 0, src->bufferSize );
// be conservative here. Whenever we write to any Buffer Object, invalidate the vertex cache // be conservative here. Whenever we write to any Buffer Object, invalidate the vertex cache
driver->invalidateVertexCache = GL_TRUE; driver->invalidateVertexCache = GL_TRUE;
} }
char *rglPlatformBufferObjectMap( rglBufferObject* bufferObject, GLenum access ) char *rglPlatformBufferObjectMap (void *data, GLenum access)
{ {
rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; rglBufferObject *bufferObject = (rglBufferObject*)data;
rglGcmBufferObject *rglBuffer = (rglGcmBufferObject*)bufferObject->platformBufferObject;
if ( rglBuffer->mapCount++ == 0 ) if (rglBuffer->mapCount++ == 0)
{ {
if ( access == GL_WRITE_ONLY ) if (access == GL_WRITE_ONLY)
{ {
// replace entire buffer // replace entire buffer
// To avoid waiting for the GPU to finish using the buffer, // To avoid waiting for the GPU to finish using the buffer,
@ -1344,10 +1350,11 @@ char *rglPlatformBufferObjectMap( rglBufferObject* bufferObject, GLenum access )
return gmmIdToAddress( rglBuffer->bufferId ); return gmmIdToAddress( rglBuffer->bufferId );
} }
GLboolean rglPlatformBufferObjectUnmap( rglBufferObject* bufferObject ) GLboolean rglPlatformBufferObjectUnmap (void *data)
{ {
// can't unmap if not mapped rglBufferObject *bufferObject = (rglBufferObject*)data;
rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject; rglGcmBufferObject *rglBuffer = ( rglGcmBufferObject * )bufferObject->platformBufferObject;
// can't unmap if not mapped
if ( --rglBuffer->mapCount == 0 ) if ( --rglBuffer->mapCount == 0 )
{ {
@ -1459,7 +1466,7 @@ void rglFBClear( GLbitfield mask )
PLATFORM FRAMEBUFFER PLATFORM FRAMEBUFFER
============================================================ */ ============================================================ */
rglFramebuffer* rglCreateFramebuffer( void ) rglFramebuffer* rglCreateFramebuffer (void)
{ {
rglFramebuffer* framebuffer = new rglPlatformFramebuffer(); rglFramebuffer* framebuffer = new rglPlatformFramebuffer();
return framebuffer; return framebuffer;
@ -1473,8 +1480,9 @@ void rglDestroyFramebuffer (void *data)
delete framebuffer; delete framebuffer;
} }
GLenum rglPlatformFramebufferCheckStatus( rglFramebuffer* framebuffer ) GLenum rglPlatformFramebufferCheckStatus (void *data)
{ {
rglFramebuffer *framebuffer = (rglFramebuffer*)data;
RGLcontext* LContext = _CurrentContext; RGLcontext* LContext = _CurrentContext;
GLuint nBuffers = 0; // number of attached buffers GLuint nBuffers = 0; // number of attached buffers
@ -1595,8 +1603,9 @@ static GLuint rglGetGcmImageOffset (void *data, GLuint face, GLuint level)
return 0; return 0;
} }
void rglPlatformFramebuffer::validate( RGLcontext *LContext ) void rglPlatformFramebuffer::validate (void *data)
{ {
RGLcontext *LContext = (RGLcontext*)data;
complete = (rglPlatformFramebufferCheckStatus(this) == GL_FRAMEBUFFER_COMPLETE_OES); complete = (rglPlatformFramebufferCheckStatus(this) == GL_FRAMEBUFFER_COMPLETE_OES);
if (!complete) if (!complete)
@ -1746,11 +1755,11 @@ void rglPlatformRasterExit (void *data)
gmmFree( driver->sharedFPConstantsId ); gmmFree( driver->sharedFPConstantsId );
free( driver->sharedVPConstants ); free( driver->sharedVPConstants );
if ( driver ) if (driver)
free( driver ); free(driver);
} }
void rglDumpFifo( char * name ); void rglDumpFifo (char *name);
// Fast rendering path called by several glDraw calls: // Fast rendering path called by several glDraw calls:
// glDrawElements, glDrawRangeElements, glDrawArrays // glDrawElements, glDrawRangeElements, glDrawArrays
@ -1856,7 +1865,7 @@ void rglPlatformRasterFlush (void)
rglGcmFifoGlFlush(); rglGcmFifoGlFlush();
} }
void rglpFifoGlFinish( void ) void rglpFifoGlFinish (void)
{ {
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache ); GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFinish( &rglGcmState_i.fifo ); rglGcmFifoFinish( &rglGcmState_i.fifo );
@ -1889,12 +1898,12 @@ GLuint rglValidateAttributesSlow (void *data, GLboolean *isMain)
// which attributes are known to need updating? // which attributes are known to need updating?
// (due to being dirty or enabled client-side arrays) // (due to being dirty or enabled client-side arrays)
rglBitfield needsUpdateMask = ( as->DirtyMask | ( as->EnabledMask & ~as->HasVBOMask ) ); unsigned int needsUpdateMask = (as->DirtyMask | (as->EnabledMask & ~as->HasVBOMask));
// for any remaining attributes that need updating, do it now. // for any remaining attributes that need updating, do it now.
if(needsUpdateMask) if(needsUpdateMask)
{ {
for(GLuint i = 0; i < RGL_MAX_VERTEX_ATTRIBS; ++i) for (GLuint i = 0; i < RGL_MAX_VERTEX_ATTRIBS; ++i)
{ {
// skip this attribute if not needing update // skip this attribute if not needing update
if (!RGLBIT_GET( needsUpdateMask, i)) if (!RGLBIT_GET( needsUpdateMask, i))
@ -1998,14 +2007,15 @@ GLuint rglGetGcmTextureSize (void *data)
// Get size of a texture // Get size of a texture
int rglPlatformTextureSize() int rglPlatformTextureSize (void)
{ {
return sizeof( rglGcmTexture ); return sizeof(rglGcmTexture);
} }
// Calculate pitch for a texture // Calculate pitch for a texture
static GLuint _getTexturePitch(const rglTexture * texture) static GLuint _getTexturePitch (const void *data)
{ {
const rglTexture *texture = (const rglTexture*)data;
return rglPad( rglGetStorageSize( texture->image->format, texture->image->type, texture->image->width, 1, 1 ), 64 ); // TransferVid2Vid needs 64byte pitch alignment return rglPad( rglGetStorageSize( texture->image->format, texture->image->type, texture->image->width, 1, 1 ), 64 ); // TransferVid2Vid needs 64byte pitch alignment
} }
@ -2128,13 +2138,13 @@ static inline GLenum unFilter( GLenum filter )
// Choose a texture layout and store it to newLayout, based on texture's filtering mode, swizzling, and size // Choose a texture layout and store it to newLayout, based on texture's filtering mode, swizzling, and size
void rglPlatformChooseGPUFormatAndLayout( void rglPlatformChooseGPUFormatAndLayout(
const rglTexture* texture, const void *data, GLboolean forceLinear,
GLboolean forceLinear, GLuint pitch, rglGcmTextureLayout* newLayout )
GLuint pitch,
rglGcmTextureLayout* newLayout )
{ {
const rglTexture *texture = (const rglTexture*)data;
rglImage *image = texture->image + texture->baseLevel; rglImage *image = texture->image + texture->baseLevel;
#if 0
GLuint levels = rglLog2( MAX( MAX( image->width, image->height ), image->depth ) ) + 1; GLuint levels = rglLog2( MAX( MAX( image->width, image->height ), image->depth ) ) + 1;
levels = MIN( levels, texture->maxLevel + 1 ); levels = MIN( levels, texture->maxLevel + 1 );
@ -2142,6 +2152,9 @@ void rglPlatformChooseGPUFormatAndLayout(
// This is to avoid a big cost when switching from mipmaps to non-mipmaps. // This is to avoid a big cost when switching from mipmaps to non-mipmaps.
if (( texture->minFilter == GL_LINEAR ) || ( texture->minFilter == GL_NEAREST ) ) if (( texture->minFilter == GL_LINEAR ) || ( texture->minFilter == GL_NEAREST ) )
levels = 1; levels = 1;
#else
GLuint levels = 1;
#endif
newLayout->levels = levels; newLayout->levels = levels;
newLayout->faces = texture->faceCount; newLayout->faces = texture->faceCount;
@ -2150,7 +2163,7 @@ void rglPlatformChooseGPUFormatAndLayout(
newLayout->baseDepth = image->depth; newLayout->baseDepth = image->depth;
newLayout->internalFormat = ( rglGcmEnum )image->internalFormat; newLayout->internalFormat = ( rglGcmEnum )image->internalFormat;
newLayout->pixelBits = rglPlatformGetBitsPerPixel( newLayout->internalFormat ); newLayout->pixelBits = rglPlatformGetBitsPerPixel( newLayout->internalFormat );
newLayout->pitch = pitch ? pitch : _getTexturePitch( texture ); newLayout->pitch = pitch ? pitch : _getTexturePitch(texture);
} }
// texture strategy actions // texture strategy actions
@ -2493,7 +2506,7 @@ static inline void rglGcmUpdateGcmTexture (void *data_tex, void *data_layout, vo
} }
// map RGL internal types to GCM // map RGL internal types to GCM
void rglGcmUpdateMethods(void *data) void rglGcmUpdateMethods (void *data)
{ {
rglTexture *texture = (rglTexture*)data; rglTexture *texture = (rglTexture*)data;
rglGcmTexture *platformTexture = ( rglGcmTexture * )texture->platformTexture; rglGcmTexture *platformTexture = ( rglGcmTexture * )texture->platformTexture;

View File

@ -27,8 +27,8 @@ extern void rglpValidateBlending(void);
extern void rglpValidateShaderSRGBRemap(void); extern void rglpValidateShaderSRGBRemap(void);
extern int rglpBufferObjectSize(void); extern int rglpBufferObjectSize(void);
extern GLboolean rglpCreateBufferObject(rglBufferObject* bufferObject); extern GLboolean rglpCreateBufferObject (void *data);
void rglpFifoGlFinish( void ); void rglpFifoGlFinish (void);
#endif #endif