(PS3) RGL cleanups

This commit is contained in:
Twinaphex 2012-08-02 03:24:14 +02:00
parent 16119d8ad7
commit 1c09aa4fdd
4 changed files with 299 additions and 318 deletions

View File

@ -24,14 +24,14 @@
using namespace cell::Gcm; using namespace cell::Gcm;
#endif #endif
#define _RGL_MAX_TILED_REGIONS 15 #define MAX_TILED_REGIONS 15
#define _RGL_TILED_BUFFER_ALIGNMENT 0x10000 #define TILED_BUFFER_ALIGNMENT 0x10000
#define _RGL_TILED_BUFFER_HEIGHT_ALIGNMENT 64 #define TILED_BUFFER_HEIGHT_ALIGNMENT 64
#define FIFO_SIZE (65536) #define FIFO_SIZE (65536)
#define _RGL_DMA_PUSH_BUFFER_PREFETCH_PADDING 0x1000 #define _RGL_DMA_PUSH_BUFFER_PREFETCH_PADDING 0x1000
#define RGL_UTIL_LABEL_INDEX 253 #define UTIL_LABEL_INDEX 253
extern void _RGLFifoGlSetRenderTarget( RGLRenderTargetEx const * const args ); extern void _RGLFifoGlSetRenderTarget( RGLRenderTargetEx const * const args );
@ -46,7 +46,7 @@ typedef struct
typedef struct typedef struct
{ {
jsTiledRegion region[_RGL_MAX_TILED_REGIONS]; jsTiledRegion region[MAX_TILED_REGIONS];
} jsTiledMemoryManager; } jsTiledMemoryManager;
PSGLdevice *_CurrentDevice = NULL; PSGLdevice *_CurrentDevice = NULL;
@ -319,7 +319,7 @@ GLboolean _RGLInit(PSGLinitOptions* options, RGLResource *resource)
return GL_FALSE; return GL_FALSE;
} }
_RGLState.semaphores->userSemaphores[_RGL_SEMA_FENCE].val = nvFenceCounter; _RGLState.semaphores->userSemaphores[SEMA_FENCE].val = nvFenceCounter;
_RGLState.labelValue = 1; _RGLState.labelValue = 1;
@ -517,7 +517,7 @@ int32_t _RGLOutOfSpaceCallback( struct CellGcmContextData* fifoContext, uint32_t
for(GLuint i = 0; i < nopsAtBegin; i++) for(GLuint i = 0; i < nopsAtBegin; i++)
{ {
fifo->current[0] = RGL_NOP; fifo->current[0] = NOP;
fifo->current++; fifo->current++;
} }
@ -547,9 +547,9 @@ static int _RGLInitRM( RGLResource *gcmResource, unsigned int hostMemorySize, in
{ {
memset(gcmResource, 0, sizeof(RGLResource)); memset(gcmResource, 0, sizeof(RGLResource));
dmaPushBufferSize = _RGLPad( dmaPushBufferSize, _RGL_HOST_BUFFER_ALIGNMENT ); dmaPushBufferSize = _RGLPad(dmaPushBufferSize, HOST_BUFFER_ALIGNMENT);
gcmResource->hostMemorySize = _RGLPad( FIFO_SIZE + hostMemorySize + dmaPushBufferSize + _RGL_DMA_PUSH_BUFFER_PREFETCH_PADDING + (RGL_LM_MAX_TOTAL_QUERIES * sizeof( GLuint )), 1 << 20 ); gcmResource->hostMemorySize = _RGLPad( FIFO_SIZE + hostMemorySize + dmaPushBufferSize + _RGL_DMA_PUSH_BUFFER_PREFETCH_PADDING + (LM_MAX_TOTAL_QUERIES * sizeof( GLuint )), 1 << 20 );
if ( gcmResource->hostMemorySize > 0 ) if ( gcmResource->hostMemorySize > 0 )
gcmResource->hostMemoryBase = ( char * )memalign( 1 << 20, gcmResource->hostMemorySize ); gcmResource->hostMemoryBase = ( char * )memalign( 1 << 20, gcmResource->hostMemorySize );
@ -672,11 +672,11 @@ GLboolean _RGLAllocateColorSurface(
else else
*pitchAllocated = tiledPitch; *pitchAllocated = tiledPitch;
GLuint padSize = _RGL_TILED_BUFFER_ALIGNMENT; GLuint padSize = TILED_BUFFER_ALIGNMENT;
while (( padSize % ( tiledPitch*8 ) ) != 0 ) while (( padSize % ( tiledPitch*8 ) ) != 0 )
padSize += _RGL_TILED_BUFFER_ALIGNMENT; padSize += TILED_BUFFER_ALIGNMENT;
height = _RGLPad( height, _RGL_TILED_BUFFER_HEIGHT_ALIGNMENT ); height = _RGLPad(height, TILED_BUFFER_HEIGHT_ALIGNMENT);
*bytesAllocated = _RGLPad(( *pitchAllocated ) * height, padSize ); *bytesAllocated = _RGLPad(( *pitchAllocated ) * height, padSize );
const GLuint tag = *pitchAllocated | ( 0x0 ); const GLuint tag = *pitchAllocated | ( 0x0 );
@ -685,7 +685,7 @@ GLboolean _RGLAllocateColorSurface(
if ( *id == GMM_ERROR ) if ( *id == GMM_ERROR )
{ {
for ( int i = 0; i < _RGL_MAX_TILED_REGIONS; ++i ) for ( int i = 0; i < MAX_TILED_REGIONS; ++i )
{ {
if ( mm->region[i].size == 0 ) if ( mm->region[i].size == 0 )
{ {
@ -808,7 +808,7 @@ static int _RGLPlatformCreateDevice( PSGLdevice* device )
_RGLDuringDestroyDevice = GL_FALSE; _RGLDuringDestroyDevice = GL_FALSE;
memset( mm->region, 0, sizeof( mm->region ) ); memset( mm->region, 0, sizeof( mm->region ) );
for ( int i = 0;i < _RGL_MAX_TILED_REGIONS;++i ) for(int i = 0; i < MAX_TILED_REGIONS; ++i)
cellGcmUnbindTile( i ); cellGcmUnbindTile( i );
@ -863,12 +863,12 @@ static int _RGLPlatformCreateDevice( PSGLdevice* device )
for ( int i = 0; i < params->bufferingMode; ++i ) for ( int i = 0; i < params->bufferingMode; ++i )
{ {
gcmDevice->color[i].source = _RGL_SURFACE_SOURCE_DEVICE; gcmDevice->color[i].source = SURFACE_SOURCE_DEVICE;
gcmDevice->color[i].width = width; gcmDevice->color[i].width = width;
gcmDevice->color[i].height = height; gcmDevice->color[i].height = height;
gcmDevice->color[i].bpp = 4; gcmDevice->color[i].bpp = 4;
gcmDevice->color[i].format = RGL_ARGB8; gcmDevice->color[i].format = RGL_ARGB8;
gcmDevice->color[i].pool = _RGL_SURFACE_POOL_LINEAR; gcmDevice->color[i].pool = SURFACE_POOL_LINEAR;
GLuint size; GLuint size;
_RGLAllocateColorSurface(width, height, _RGLAllocateColorSurface(width, height,
@ -1131,7 +1131,7 @@ void psglDestroyDevice(PSGLdevice *device)
_RGLDuringDestroyDevice = GL_TRUE; _RGLDuringDestroyDevice = GL_TRUE;
for ( int i = 0; i < params->bufferingMode; ++i ) for ( int i = 0; i < params->bufferingMode; ++i )
{ {
if ( gcmDevice->color[i].pool != _RGL_SURFACE_POOL_NONE ) if (gcmDevice->color[i].pool != SURFACE_POOL_NONE)
gmmFree( gcmDevice->color[i].dataId ); gmmFree( gcmDevice->color[i].dataId );
} }
_RGLDuringDestroyDevice = GL_FALSE; _RGLDuringDestroyDevice = GL_FALSE;
@ -1241,12 +1241,12 @@ GLAPI void psglSwap(void)
LContext->needValidate = PSGL_VALIDATE_ALL; LContext->needValidate = PSGL_VALIDATE_ALL;
for(int unit = 0; unit < _RGL_MAX_TEXTURE_UNITS; unit++) for(int unit = 0; unit < MAX_TEXTURE_UNITS; unit++)
LContext->TextureCoordsUnits[unit].TextureMatrixStack.dirty = GL_TRUE; LContext->TextureCoordsUnits[unit].TextureMatrixStack.dirty = GL_TRUE;
LContext->ModelViewMatrixStack.dirty = GL_TRUE; LContext->ModelViewMatrixStack.dirty = GL_TRUE;
LContext->ProjectionMatrixStack.dirty = GL_TRUE; LContext->ProjectionMatrixStack.dirty = GL_TRUE;
LContext->attribs->DirtyMask = ( 1 << _RGL_MAX_VERTEX_ATTRIBS ) - 1; LContext->attribs->DirtyMask = (1 << MAX_VERTEX_ATTRIBS) - 1;
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo); cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
@ -1280,15 +1280,15 @@ GLAPI void psglSwap(void)
static inline void _RGLUtilWaitForIdle(void) static inline void _RGLUtilWaitForIdle(void)
{ {
cellGcmSetWriteBackEndLabelInline( &_RGLState.fifo, RGL_UTIL_LABEL_INDEX, _RGLState.labelValue); cellGcmSetWriteBackEndLabelInline( &_RGLState.fifo, UTIL_LABEL_INDEX, _RGLState.labelValue);
cellGcmSetWaitLabelInline( &_RGLState.fifo, RGL_UTIL_LABEL_INDEX, _RGLState.labelValue); cellGcmSetWaitLabelInline( &_RGLState.fifo, UTIL_LABEL_INDEX, _RGLState.labelValue);
_RGLState.labelValue++; _RGLState.labelValue++;
cellGcmSetWriteBackEndLabelInline( &_RGLState.fifo, RGL_UTIL_LABEL_INDEX, _RGLState.labelValue); cellGcmSetWriteBackEndLabelInline( &_RGLState.fifo, UTIL_LABEL_INDEX, _RGLState.labelValue);
cellGcmFlush(); cellGcmFlush();
while( *(cellGcmGetLabelAddress( RGL_UTIL_LABEL_INDEX)) != _RGLState.labelValue); while( *(cellGcmGetLabelAddress(UTIL_LABEL_INDEX)) != _RGLState.labelValue);
_RGLState.labelValue++; _RGLState.labelValue++;
} }

View File

@ -24,11 +24,9 @@ extern PSGLdevice *_CurrentDevice;
#define RGL_SETRENDERTARGET_MAXCOUNT 4 #define RGL_SETRENDERTARGET_MAXCOUNT 4
#define RGL_NOP (0x00000000) #define NOP (0x00000000)
#define DEFAULT_FIFO_BLOCK_SIZE (0x10000) #define DEFAULT_FIFO_BLOCK_SIZE (0x10000)
#define RGL_ATTRIB_COUNT 16
#define RGL_F0_DOT_0 12582912.0f #define RGL_F0_DOT_0 12582912.0f
#define RGL_CLAMPF_01(x) ((x) >= 0.0f ? ((x) > 1.0f ? 1.0f : (x)) : 0.0f) #define RGL_CLAMPF_01(x) ((x) >= 0.0f ? ((x) > 1.0f ? 1.0f : (x)) : 0.0f)
@ -38,7 +36,6 @@ extern PSGLdevice *_CurrentDevice;
#define VERTEX_PROFILE_INDEX 0 #define VERTEX_PROFILE_INDEX 0
#define FRAGMENT_PROFILE_INDEX 1 #define FRAGMENT_PROFILE_INDEX 1
typedef union typedef union
{ {
unsigned int i; unsigned int i;
@ -95,8 +92,7 @@ typedef struct
GLuint SET_TEXTURE_CONTROL1; GLuint SET_TEXTURE_CONTROL1;
GLuint SET_TEXTURE_FILTER; GLuint SET_TEXTURE_FILTER;
GLuint SET_TEXTURE_IMAGE_RECT; GLuint SET_TEXTURE_IMAGE_RECT;
} } RGLTextureMethods;
RGLTextureMethods;
struct RGLTextureAddress struct RGLTextureAddress
{ {
@ -160,17 +156,19 @@ typedef struct _tagMODESTRUC
} }
MODESTRUC; MODESTRUC;
enum { enum
_RGL_SURFACE_SOURCE_TEMPORARY, {
_RGL_SURFACE_SOURCE_DEVICE, SURFACE_SOURCE_TEMPORARY,
_RGL_SURFACE_SOURCE_TEXTURE, SURFACE_SOURCE_DEVICE,
_RGL_SURFACE_SOURCE_PBO, SURFACE_SOURCE_TEXTURE,
SURFACE_SOURCE_PBO,
}; };
enum { enum
_RGL_SURFACE_POOL_NONE, {
_RGL_SURFACE_POOL_LINEAR, SURFACE_POOL_NONE,
_RGL_SURFACE_POOL_SYSTEM, SURFACE_POOL_LINEAR,
SURFACE_POOL_SYSTEM,
}; };
@ -232,8 +230,7 @@ void _RGLFifoFinish( RGLFifo *fifo );
fifo->lastSWReferenceFlushed = fifo->lastSWReferenceWritten; \ fifo->lastSWReferenceFlushed = fifo->lastSWReferenceWritten; \
} }
#define RGL_PAGE_SIZE 0x1000 #define LM_MAX_TOTAL_QUERIES 800
#define RGL_LM_MAX_TOTAL_QUERIES 800
typedef struct RGLTextureState RGLTextureState; typedef struct RGLTextureState RGLTextureState;

View File

@ -85,14 +85,6 @@ DECLARE_FORMAT(GL_GREEN,1) \
DECLARE_FORMAT(GL_BLUE,1) \ DECLARE_FORMAT(GL_BLUE,1) \
DECLARE_FORMAT(GL_ALPHA,1) DECLARE_FORMAT(GL_ALPHA,1)
enum
{
M10 = 1, M20, M30,
M01, M11, M21, M31,
M02, M12, M22, M32,
M03, M13, M23, M33
};
static int _RGLInitCompleted = 0; static int _RGLInitCompleted = 0;
static char *_RGLVendorString = "Retro Arch"; static char *_RGLVendorString = "Retro Arch";
static char *_RGLRendererString = "RGL"; static char *_RGLRendererString = "RGL";
@ -317,7 +309,7 @@ static inline void _RGLFifoGlVertexAttribPointer
static void _RGLResetAttributeState( jsAttributeState* as ) static void _RGLResetAttributeState( jsAttributeState* as )
{ {
for ( int i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i ) for(int i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
{ {
as->attrib[i].clientSize = 4; as->attrib[i].clientSize = 4;
as->attrib[i].clientType = GL_FLOAT; as->attrib[i].clientType = GL_FLOAT;
@ -349,7 +341,7 @@ static void _RGLResetAttributeState( jsAttributeState* as )
as->attrib[_RGL_ATTRIB_NORMAL_INDEX].value[1] = 0.f; as->attrib[_RGL_ATTRIB_NORMAL_INDEX].value[1] = 0.f;
as->attrib[_RGL_ATTRIB_NORMAL_INDEX].value[2] = 1.f; as->attrib[_RGL_ATTRIB_NORMAL_INDEX].value[2] = 1.f;
as->DirtyMask = ( 1 << _RGL_MAX_VERTEX_ATTRIBS ) - 1; as->DirtyMask = (1 << MAX_VERTEX_ATTRIBS) - 1;
as->EnabledMask = 0; as->EnabledMask = 0;
as->NeedsConversionMask = 0; as->NeedsConversionMask = 0;
as->HasVBOMask = 0; as->HasVBOMask = 0;
@ -386,7 +378,7 @@ static void _RGLAttribSetDeleteBuffer( PSGLcontext *LContext, GLuint buffName )
{ {
jsAttribSet *attribSet = bufferObject->attribSets[i]; jsAttribSet *attribSet = bufferObject->attribSets[i];
for ( GLuint j = 0; j < _RGL_MAX_VERTEX_ATTRIBS; ++j ) for(GLuint j = 0; j < MAX_VERTEX_ATTRIBS; ++j)
if ( attribSet->attribs.attrib[j].arrayBuffer == buffName ) if ( attribSet->attribs.attrib[j].arrayBuffer == buffName )
attribSet->attribs.attrib[j].arrayBuffer = 0; attribSet->attribs.attrib[j].arrayBuffer = 0;
@ -419,17 +411,17 @@ static void _RGLPlatformDestroyBufferObject( jsBufferObject* bufferObject )
switch ( jsBuffer->pool ) switch ( jsBuffer->pool )
{ {
case _RGL_SURFACE_POOL_SYSTEM: case SURFACE_POOL_SYSTEM:
case _RGL_SURFACE_POOL_LINEAR: case SURFACE_POOL_LINEAR:
gmmFree( jsBuffer->bufferId ); gmmFree( jsBuffer->bufferId );
break; break;
case _RGL_SURFACE_POOL_NONE: case SURFACE_POOL_NONE:
break; break;
default: default:
break; break;
} }
jsBuffer->pool = _RGL_SURFACE_POOL_NONE; jsBuffer->pool = SURFACE_POOL_NONE;
jsBuffer->bufferId = GMM_ERROR; jsBuffer->bufferId = GMM_ERROR;
} }
@ -447,17 +439,6 @@ static void _RGLFreeBufferObject( jsBufferObject *buffer )
static void _RGLUnbindBufferObject( PSGLcontext *LContext, GLuint name ) static void _RGLUnbindBufferObject( PSGLcontext *LContext, GLuint name )
{ {
if ( LContext->ArrayBuffer == name ) LContext->ArrayBuffer = 0;
if ( LContext->PixelUnpackBuffer == name ) LContext->PixelUnpackBuffer = 0;
for ( int i = 0;i < _RGL_MAX_VERTEX_ATTRIBS;++i )
{
if ( LContext->attribs->attrib[i].arrayBuffer == name )
{
LContext->attribs->attrib[i].arrayBuffer = 0;
LContext->attribs->HasVBOMask &= ~( 1 << i );
}
}
_RGLAttribSetDeleteBuffer( LContext, name );
} }
GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name ) GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name )
@ -496,7 +477,23 @@ GLAPI void APIENTRY glDeleteBuffers(GLsizei n, const GLuint *buffers)
continue; continue;
if(buffers[i] ) if(buffers[i] )
_RGLUnbindBufferObject( LContext, buffers[i] ); {
GLuint name = buffers[i];
if(LContext->ArrayBuffer == name)
LContext->ArrayBuffer = 0;
if(LContext->PixelUnpackBuffer == name)
LContext->PixelUnpackBuffer = 0;
for(int i = 0;i < MAX_VERTEX_ATTRIBS; ++i)
{
if(LContext->attribs->attrib[i].arrayBuffer == name)
{
LContext->attribs->attrib[i].arrayBuffer = 0;
LContext->attribs->HasVBOMask &= ~( 1 << i );
}
}
_RGLAttribSetDeleteBuffer( LContext, name );
}
} }
_RGLTexNameSpaceDeleteNames( &LContext->bufferObjectNameSpace, n, buffers ); _RGLTexNameSpaceDeleteNames( &LContext->bufferObjectNameSpace, n, buffers );
} }
@ -522,11 +519,13 @@ static inline void _RGLTextureTouchFBOs( jsTexture *texture )
if(fbCount > 0) if(fbCount > 0)
{ {
jsFramebuffer *contextFramebuffer = LContext->framebuffer ? _RGLGetFramebuffer( LContext, LContext->framebuffer ) : NULL; jsFramebuffer *contextFramebuffer = LContext->framebuffer ? _RGLGetFramebuffer( LContext, LContext->framebuffer ) : NULL;
for (GLuint i = 0; i < fbCount; ++i) for (GLuint i = 0; i < fbCount; ++i)
{ {
jsFramebuffer* framebuffer = texture->framebuffers[i]; jsFramebuffer* framebuffer = texture->framebuffers[i];
framebuffer->needValidate = GL_TRUE; framebuffer->needValidate = GL_TRUE;
if ( RGL_UNLIKELY( framebuffer == contextFramebuffer ) ) LContext->needValidate |= PSGL_VALIDATE_FRAMEBUFFER; if(RGL_UNLIKELY(framebuffer == contextFramebuffer))
LContext->needValidate |= PSGL_VALIDATE_FRAMEBUFFER;
} }
} }
} }
@ -537,12 +536,12 @@ static void _RGLAllocateBuffer( jsBufferObject* bufferObject )
_RGLPlatformDestroyBufferObject( bufferObject ); _RGLPlatformDestroyBufferObject( bufferObject );
jsBuffer->pool = _RGL_SURFACE_POOL_LINEAR; jsBuffer->pool = SURFACE_POOL_LINEAR;
jsBuffer->bufferId = gmmAlloc(0, jsBuffer->bufferSize); jsBuffer->bufferId = gmmAlloc(0, jsBuffer->bufferSize);
jsBuffer->pitch = 0; jsBuffer->pitch = 0;
if ( jsBuffer->bufferId == GMM_ERROR ) if ( jsBuffer->bufferId == GMM_ERROR )
jsBuffer->pool = _RGL_SURFACE_POOL_NONE; jsBuffer->pool = SURFACE_POOL_NONE;
GLuint referenceCount = bufferObject->textureReferences.getCount(); GLuint referenceCount = bufferObject->textureReferences.getCount();
if ( referenceCount > 0 ) if ( referenceCount > 0 )
@ -553,7 +552,7 @@ static void _RGLAllocateBuffer( jsBufferObject* bufferObject )
RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture; RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
gcmTexture->gpuAddressId = jsBuffer->bufferId; gcmTexture->gpuAddressId = jsBuffer->bufferId;
gcmTexture->gpuAddressIdOffset = texture->offset; gcmTexture->gpuAddressIdOffset = texture->offset;
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_PARAMETERS; texture->revalidate |= TEXTURE_REVALIDATE_PARAMETERS;
_RGLTextureTouchFBOs( texture ); _RGLTextureTouchFBOs( texture );
} }
_CurrentContext->needValidate |= PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_VERTEX_TEXTURES_USED ; _CurrentContext->needValidate |= PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_VERTEX_TEXTURES_USED ;
@ -628,7 +627,7 @@ static void _RGLPlatformBufferObjectSetData( jsBufferObject* bufferObject, GLint
switch ( jsBuffer->pool ) switch ( jsBuffer->pool )
{ {
case _RGL_SURFACE_POOL_NONE: case SURFACE_POOL_NONE:
_RGLSetError( GL_OUT_OF_MEMORY ); _RGLSetError( GL_OUT_OF_MEMORY );
return; return;
default: default:
@ -678,7 +677,7 @@ static GLboolean _RGLPlatformCreateBufferObject( jsBufferObject* bufferObject )
{ {
RGLBufferObject *jsBuffer = ( RGLBufferObject * )bufferObject->platformBufferObject; RGLBufferObject *jsBuffer = ( RGLBufferObject * )bufferObject->platformBufferObject;
jsBuffer->pool = _RGL_SURFACE_POOL_NONE; jsBuffer->pool = SURFACE_POOL_NONE;
jsBuffer->bufferId = GMM_ERROR; jsBuffer->bufferId = GMM_ERROR;
jsBuffer->mapCount = 0; jsBuffer->mapCount = 0;
jsBuffer->mapAccess = GL_NONE; jsBuffer->mapAccess = GL_NONE;
@ -767,10 +766,10 @@ static GLvoid _RGLPlatformBufferObjectCopyData( jsBufferObject* bufferObjectDst,
switch ( dst->pool ) switch ( dst->pool )
{ {
case _RGL_SURFACE_POOL_LINEAR: case SURFACE_POOL_LINEAR:
_RGLMemcpy( dst->bufferId, 0, dst->pitch, src->bufferId, src->bufferSize ); _RGLMemcpy( dst->bufferId, 0, dst->pitch, src->bufferId, src->bufferSize );
break; break;
case _RGL_SURFACE_POOL_SYSTEM: case SURFACE_POOL_SYSTEM:
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo); cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
_RGLFifoFinish( &_RGLState.fifo ); _RGLFifoFinish( &_RGLState.fifo );
memcpy( gmmIdToAddress( dst->bufferId ), gmmIdToAddress( src->bufferId ), memcpy( gmmIdToAddress( dst->bufferId ), gmmIdToAddress( src->bufferId ),
@ -838,12 +837,12 @@ static void _RGLFramebufferGetAttachmentTexture(
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
switch ( attachment->type ) switch ( attachment->type )
{ {
case _RGL_FRAMEBUFFER_ATTACHMENT_NONE: case FRAMEBUFFER_ATTACHMENT_NONE:
*texture = NULL; *texture = NULL;
break; break;
case _RGL_FRAMEBUFFER_ATTACHMENT_RENDERBUFFER: case FRAMEBUFFER_ATTACHMENT_RENDERBUFFER:
break; break;
case _RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE: case FRAMEBUFFER_ATTACHMENT_TEXTURE:
*texture = _RGLTexNameSpaceIsName( &LContext->textureNameSpace, attachment->name ) ? ( jsTexture* )LContext->textureNameSpace.data[attachment->name] : NULL; *texture = _RGLTexNameSpaceIsName( &LContext->textureNameSpace, attachment->name ) ? ( jsTexture* )LContext->textureNameSpace.data[attachment->name] : NULL;
break; break;
default: default:
@ -888,10 +887,10 @@ static GLenum _RGLPlatformFramebufferCheckStatus( jsFramebuffer* framebuffer )
{ {
GLuint nBuffers = 0; GLuint nBuffers = 0;
jsImage* image[_RGL_MAX_COLOR_ATTACHMENTS + 2] = {0}; jsImage* image[MAX_COLOR_ATTACHMENTS + 2] = {0};
GLuint colorFormat = 0; GLuint colorFormat = 0;
for ( int i = 0; i < _RGL_MAX_COLOR_ATTACHMENTS; ++i ) for ( int i = 0; i < MAX_COLOR_ATTACHMENTS; ++i )
{ {
jsTexture* colorTexture = NULL; jsTexture* colorTexture = NULL;
_RGLFramebufferGetAttachmentTexture(&framebuffer->color[i], &colorTexture); _RGLFramebufferGetAttachmentTexture(&framebuffer->color[i], &colorTexture);
@ -1173,7 +1172,7 @@ static void _RGLPlatformCopyGPUTexture( jsTexture* texture )
jsImage* image = texture->image; jsImage* image = texture->image;
if ( image->dataState == _RGL_IMAGE_DATASTATE_GPU ) if ( image->dataState == IMAGE_DATASTATE_GPU )
{ {
_RGLImageAllocCPUStorage( image ); _RGLImageAllocCPUStorage( image );
@ -1195,7 +1194,7 @@ static void _RGLPlatformCopyGPUTexture( jsTexture* texture )
_RGLRasterToImage( &raster, image); _RGLRasterToImage( &raster, image);
image->dataState = _RGL_IMAGE_DATASTATE_HOST; image->dataState = IMAGE_DATASTATE_HOST;
} }
} }
@ -1204,10 +1203,10 @@ static void _RGLPlatformFreeGcmTexture( jsTexture* texture )
RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture; RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
switch ( gcmTexture->pool ) switch ( gcmTexture->pool )
{ {
case _RGL_SURFACE_POOL_LINEAR: case SURFACE_POOL_LINEAR:
case _RGL_SURFACE_POOL_SYSTEM: case SURFACE_POOL_SYSTEM:
gmmFree( gcmTexture->gpuAddressId ); gmmFree( gcmTexture->gpuAddressId );
case _RGL_SURFACE_POOL_NONE: case SURFACE_POOL_NONE:
break; break;
default: default:
break; break;
@ -1228,21 +1227,21 @@ void _RGLPlatformDropTexture( jsTexture *texture )
gcmTexture->pbo = NULL; gcmTexture->pbo = NULL;
gcmTexture->gpuAddressId = GMM_ERROR; gcmTexture->gpuAddressId = GMM_ERROR;
gcmTexture->gpuAddressIdOffset = 0; gcmTexture->gpuAddressIdOffset = 0;
gcmTexture->pool = _RGL_SURFACE_POOL_NONE; gcmTexture->pool = SURFACE_POOL_NONE;
gcmTexture->gpuSize = 0; gcmTexture->gpuSize = 0;
} }
if(gcmTexture->pool != _RGL_SURFACE_POOL_NONE) if(gcmTexture->pool != SURFACE_POOL_NONE)
{ {
_RGLPlatformCopyGPUTexture( texture ); _RGLPlatformCopyGPUTexture( texture );
_RGLPlatformFreeGcmTexture( texture ); _RGLPlatformFreeGcmTexture( texture );
} }
gcmTexture->pool = _RGL_SURFACE_POOL_NONE; gcmTexture->pool = SURFACE_POOL_NONE;
gcmTexture->gpuAddressId = GMM_ERROR; gcmTexture->gpuAddressId = GMM_ERROR;
gcmTexture->gpuAddressIdOffset = 0; gcmTexture->gpuAddressIdOffset = 0;
gcmTexture->gpuSize = 0; gcmTexture->gpuSize = 0;
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_IMAGES; texture->revalidate |= TEXTURE_REVALIDATE_IMAGES;
_RGLTextureTouchFBOs(texture); _RGLTextureTouchFBOs(texture);
} }
@ -1329,7 +1328,7 @@ void _RGLPlatformDropUnboundTextures( GLenum pool )
if ( gcmTexture->pbo != NULL && gcmTexture->pbo->refCount > 1 ) if ( gcmTexture->pbo != NULL && gcmTexture->pbo->refCount > 1 )
continue; continue;
if ( pool != _RGL_SURFACE_POOL_NONE && pool != gcmTexture->pool ) if ( pool != SURFACE_POOL_NONE && pool != gcmTexture->pool )
continue; continue;
_RGLPlatformDropTexture( texture ); _RGLPlatformDropTexture( texture );
@ -1360,7 +1359,7 @@ static void _RGLPlatformReallocateGcmTexture( jsTexture* texture )
_RGLPlatformChooseGPUFormatAndLayout( texture, GL_TRUE, 0, &newLayout ); _RGLPlatformChooseGPUFormatAndLayout( texture, GL_TRUE, 0, &newLayout );
size = _RGLPad( newLayout.baseHeight * newLayout.pitch, 1); size = _RGLPad( newLayout.baseHeight * newLayout.pitch, 1);
if ( gcmTexture->pool == _RGL_SURFACE_POOL_LINEAR ) if ( gcmTexture->pool == SURFACE_POOL_LINEAR )
{ {
if ( currentSize >= size && newLayout.pitch == currentLayout.pitch ) if ( currentSize >= size && newLayout.pitch == currentLayout.pitch )
{ {
@ -1376,10 +1375,10 @@ static void _RGLPlatformReallocateGcmTexture( jsTexture* texture )
id = gmmAlloc(0, size); id = gmmAlloc(0, size);
if ( id != GMM_ERROR ) if ( id != GMM_ERROR )
{ {
if ( gcmTexture->pool != _RGL_SURFACE_POOL_NONE ) if ( gcmTexture->pool != SURFACE_POOL_NONE )
_RGLPlatformDropTexture( texture ); _RGLPlatformDropTexture( texture );
gcmTexture->pool = _RGL_SURFACE_POOL_LINEAR; gcmTexture->pool = SURFACE_POOL_LINEAR;
gcmTexture->gpuAddressId = id; gcmTexture->gpuAddressId = id;
gcmTexture->gpuAddressIdOffset = 0; gcmTexture->gpuAddressIdOffset = 0;
gcmTexture->gpuSize = size; gcmTexture->gpuSize = size;
@ -1390,7 +1389,7 @@ static void _RGLPlatformReallocateGcmTexture( jsTexture* texture )
} }
break; break;
case _RGL_TEXTURE_STRATEGY_UNTILED_CLEAR: case _RGL_TEXTURE_STRATEGY_UNTILED_CLEAR:
_RGLPlatformDropUnboundTextures( _RGL_SURFACE_POOL_LINEAR ); _RGLPlatformDropUnboundTextures(SURFACE_POOL_LINEAR);
break; break;
case _RGL_TEXTURE_STRATEGY_END: case _RGL_TEXTURE_STRATEGY_END:
_RGLSetError( GL_OUT_OF_MEMORY ); _RGLSetError( GL_OUT_OF_MEMORY );
@ -1414,7 +1413,7 @@ static void _RGLImageFreeCPUStorage( jsImage *image )
image->mallocStorageSize = 0; image->mallocStorageSize = 0;
image->data = NULL; image->data = NULL;
image->mallocData = NULL; image->mallocData = NULL;
image->dataState &= ~_RGL_IMAGE_DATASTATE_HOST; image->dataState &= ~IMAGE_DATASTATE_HOST;
} }
static void _RGLPlatformValidateTextureResources( jsTexture *texture ) static void _RGLPlatformValidateTextureResources( jsTexture *texture )
@ -1426,8 +1425,8 @@ static void _RGLPlatformValidateTextureResources( jsTexture *texture )
} }
texture->isComplete = GL_TRUE; texture->isComplete = GL_TRUE;
if ( texture->revalidate & _RGL_TEXTURE_REVALIDATE_IMAGES || if ( texture->revalidate & TEXTURE_REVALIDATE_IMAGES ||
texture->revalidate & _RGL_TEXTURE_REVALIDATE_LAYOUT ) texture->revalidate & TEXTURE_REVALIDATE_LAYOUT )
{ {
_RGLPlatformReallocateGcmTexture( texture ); _RGLPlatformReallocateGcmTexture( texture );
RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture; RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
@ -1436,26 +1435,26 @@ static void _RGLPlatformValidateTextureResources( jsTexture *texture )
const GLuint pixelBytes = layout->pixelBits / 8; const GLuint pixelBytes = layout->pixelBits / 8;
RGLSurface src = { RGLSurface src = {
source: _RGL_SURFACE_SOURCE_TEMPORARY, source: SURFACE_SOURCE_TEMPORARY,
width: 0, width: 0,
height: 0, height: 0,
bpp: pixelBytes, bpp: pixelBytes,
pitch: 0, pitch: 0,
format: layout->internalFormat, format: layout->internalFormat,
pool: _RGL_SURFACE_POOL_LINEAR, pool: SURFACE_POOL_LINEAR,
ppuData: NULL, ppuData: NULL,
dataId: GMM_ERROR, dataId: GMM_ERROR,
dataIdOffset:0, dataIdOffset:0,
}; };
RGLSurface dst = { RGLSurface dst = {
source: _RGL_SURFACE_SOURCE_TEXTURE, source: SURFACE_SOURCE_TEXTURE,
width: 0, width: 0,
height: 0, height: 0,
bpp: pixelBytes, bpp: pixelBytes,
pitch: layout->pitch, pitch: layout->pitch,
format: layout->internalFormat, format: layout->internalFormat,
pool: _RGL_SURFACE_POOL_SYSTEM, pool: SURFACE_POOL_SYSTEM,
ppuData: NULL, ppuData: NULL,
dataId: GMM_ERROR, dataId: GMM_ERROR,
dataIdOffset:0, dataIdOffset:0,
@ -1463,7 +1462,7 @@ source: _RGL_SURFACE_SOURCE_TEXTURE,
GLuint bounceBufferId = GMM_ERROR; GLuint bounceBufferId = GMM_ERROR;
jsImage *image = texture->image; jsImage *image = texture->image;
if ( image->dataState == _RGL_IMAGE_DATASTATE_HOST ) if(image->dataState == IMAGE_DATASTATE_HOST)
{ {
src.ppuData = image->data; src.ppuData = image->data;
@ -1491,7 +1490,7 @@ source: _RGL_SURFACE_SOURCE_TEXTURE,
_RGLTransferDataVidToVid( dst.dataId, dst.dataIdOffset, dst.pitch ? dst.pitch : (dst.bpp * dst.width), 0, 0, src.dataId, src.dataIdOffset, src.pitch ? src.pitch : (src.bpp * src.width), 0, 0, src.width, src.height, src.bpp ); _RGLTransferDataVidToVid( dst.dataId, dst.dataIdOffset, dst.pitch ? dst.pitch : (dst.bpp * dst.width), 0, 0, src.dataId, src.dataIdOffset, src.pitch ? src.pitch : (src.bpp * src.width), 0, 0, src.width, src.height, src.bpp );
_RGLImageFreeCPUStorage( image ); _RGLImageFreeCPUStorage( image );
image->dataState |= _RGL_IMAGE_DATASTATE_GPU; image->dataState |= IMAGE_DATASTATE_GPU;
} }
if ( bounceBufferId != GMM_ERROR ) if ( bounceBufferId != GMM_ERROR )
@ -1572,10 +1571,10 @@ static void jsPlatformFramebuffer_validate( jsPlatformFramebuffer * fb, PSGLcont
if ( !colorTexture->isRenderTarget ) if ( !colorTexture->isRenderTarget )
{ {
colorTexture->isRenderTarget = GL_TRUE; colorTexture->isRenderTarget = GL_TRUE;
colorTexture->revalidate |= _RGL_TEXTURE_REVALIDATE_LAYOUT; colorTexture->revalidate |= TEXTURE_REVALIDATE_LAYOUT;
} }
_RGLPlatformValidateTextureResources( colorTexture ); _RGLPlatformValidateTextureResources( colorTexture );
colorTexture->image->dataState = _RGL_IMAGE_DATASTATE_GPU; colorTexture->image->dataState = IMAGE_DATASTATE_GPU;
fb->rt.colorId[i] = nvTexture->gpuAddressId; fb->rt.colorId[i] = nvTexture->gpuAddressId;
fb->rt.colorIdOffset[i] = nvTexture->gpuAddressIdOffset; fb->rt.colorIdOffset[i] = nvTexture->gpuAddressIdOffset;
@ -1698,10 +1697,11 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
GLuint bufferId = gmmAlloc(0, sizeof(_RGLClearVertexBuffer)); GLuint bufferId = gmmAlloc(0, sizeof(_RGLClearVertexBuffer));
memcpy( gmmIdToAddress(bufferId), _RGLClearVertexBuffer, sizeof( _RGLClearVertexBuffer ) ); memcpy( gmmIdToAddress(bufferId), _RGLClearVertexBuffer, sizeof( _RGLClearVertexBuffer ) );
_RGLFifoGlVertexAttribPointer( 0, 3, RGL_FLOAT, CELL_GCM_FALSE, 3*sizeof( GLfloat ), 1, gmmIdToOffset(bufferId) ); GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)bufferId;
_RGLFifoGlVertexAttribPointer( 0, 3, RGL_FLOAT, CELL_GCM_FALSE, 3*sizeof( GLfloat ), 1, gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain));
RGLBIT_TRUE( LContext->attribs->DirtyMask, 0 ); RGLBIT_TRUE( LContext->attribs->DirtyMask, 0 );
for(int i = 1; i < _RGL_MAX_VERTEX_ATTRIBS; ++i) for(int i = 1; i < MAX_VERTEX_ATTRIBS; ++i)
{ {
_RGLFifoGlVertexAttribPointer( i, 0, RGL_FLOAT, 0, 0, 0, 0 ); _RGLFifoGlVertexAttribPointer( i, 0, RGL_FLOAT, 0, 0, 0, 0 );
RGLBIT_TRUE( LContext->attribs->DirtyMask, i ); RGLBIT_TRUE( LContext->attribs->DirtyMask, i );
@ -1840,12 +1840,12 @@ GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum target, GLenum attachment,
if ( texture ) if ( texture )
{ {
attach->type = _RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE; attach->type = FRAMEBUFFER_ATTACHMENT_TEXTURE;
textureObject = ( jsTexture* )LContext->textureNameSpace.data[texture]; textureObject = ( jsTexture* )LContext->textureNameSpace.data[texture];
textureObject->framebuffers.pushBack( framebuffer ); textureObject->framebuffers.pushBack( framebuffer );
} }
else else
attach->type = _RGL_FRAMEBUFFER_ATTACHMENT_NONE; attach->type = FRAMEBUFFER_ATTACHMENT_NONE;
attach->name = texture; attach->name = texture;
attach->textureTarget = GL_TEXTURE_2D; attach->textureTarget = GL_TEXTURE_2D;
@ -2165,7 +2165,6 @@ static void gmmAddFree(GmmAllocator *pAllocator, GmmBlock *pBlock)
{ {
uint8_t freeIndex = gmmSizeToFreeIndex(pBlock->base.size); uint8_t freeIndex = gmmSizeToFreeIndex(pBlock->base.size);
if (pAllocator->pFreeHead[freeIndex]) if (pAllocator->pFreeHead[freeIndex])
{ {
GmmBlock *pInsertBefore = pAllocator->pFreeHead[freeIndex]; GmmBlock *pInsertBefore = pAllocator->pFreeHead[freeIndex];
@ -2209,7 +2208,7 @@ static void gmmAddFree(GmmAllocator *pAllocator, GmmBlock *pBlock)
void gmmUpdateFreeList (const uint8_t location) void gmmUpdateFreeList (const uint8_t location)
{ {
GmmAllocator *pAllocator; GmmAllocator *pAllocator;
const uint32_t fence = _RGLState.semaphores->userSemaphores[_RGL_SEMA_FENCE].val; const uint32_t fence = _RGLState.semaphores->userSemaphores[SEMA_FENCE].val;
GmmBlock *pBlock = NULL; GmmBlock *pBlock = NULL;
GmmBlock *pTemp = NULL; GmmBlock *pTemp = NULL;
@ -2626,7 +2625,8 @@ uint32_t gmmAllocExtendedTileBlock(const uint32_t size, const uint32_t tag)
if (pNewBlock->pPrev->pData != pNewBlock->pNext->pData) if (pNewBlock->pPrev->pData != pNewBlock->pNext->pData)
{ {
resizeSucceed = _RGLTryResizeTileRegion( (GLuint)gmmIdToOffset((uint32_t)pNewBlock), tileSize+newSize, pBlock->pData ); GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)(uint32_t)(pNewBlock);
resizeSucceed = _RGLTryResizeTileRegion((GLuint)gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain), tileSize+newSize, pBlock->pData);
} }
} }
gmmSetTileAttrib( retId, tag, pBlock->pData ); gmmSetTileAttrib( retId, tag, pBlock->pData );
@ -2747,7 +2747,7 @@ static void gmmAddPendingFree(GmmBlock *pBlock)
GLuint* ref = &pBlock->fence; GLuint* ref = &pBlock->fence;
++nvFenceCounter; ++nvFenceCounter;
cellGcmSetWriteBackEndLabelInline( &_RGLState.fifo, _RGL_SEMA_FENCE, nvFenceCounter); cellGcmSetWriteBackEndLabelInline( &_RGLState.fifo, SEMA_FENCE, nvFenceCounter);
*ref = nvFenceCounter; *ref = nvFenceCounter;
} }
@ -3197,7 +3197,7 @@ uint32_t gmmAlloc(const uint8_t isTile, const uint32_t size)
else else
retId = (uint32_t)gmmAllocBlock(pAllocator, newSize); retId = (uint32_t)gmmAllocBlock(pAllocator, newSize);
if (retId == RGL_MEMORY_ALLOC_ERROR) if (retId == MEMORY_ALLOC_ERROR)
{ {
gmmFreeAll(); gmmFreeAll();
@ -3215,7 +3215,7 @@ uint32_t gmmAlloc(const uint8_t isTile, const uint32_t size)
else else
retId = (uint32_t)gmmAllocBlock(pAllocator, newSize); retId = (uint32_t)gmmAllocBlock(pAllocator, newSize);
if (!isTile && retId == RGL_MEMORY_ALLOC_ERROR) if (!isTile && retId == MEMORY_ALLOC_ERROR)
retId = gmmFindFreeBlock(pAllocator, newSize); retId = gmmFindFreeBlock(pAllocator, newSize);
} }
} }
@ -4343,7 +4343,7 @@ static char *_RGLPlatformBufferObjectMap( jsBufferObject* bufferObject, GLenum a
if ( access == GL_WRITE_ONLY ) if ( access == GL_WRITE_ONLY )
{ {
_RGLAllocateBuffer( bufferObject ); _RGLAllocateBuffer( bufferObject );
if ( jsBuffer->pool == _RGL_SURFACE_POOL_NONE ) if ( jsBuffer->pool == SURFACE_POOL_NONE )
{ {
_RGLSetError( GL_OUT_OF_MEMORY ); _RGLSetError( GL_OUT_OF_MEMORY );
return NULL; return NULL;
@ -4396,7 +4396,7 @@ static void _RGLPlatformDestroyTexture( jsTexture* texture )
{ {
_RGLFreeBufferObject( gcmTexture->pbo ); _RGLFreeBufferObject( gcmTexture->pbo );
gcmTexture->pbo = NULL; gcmTexture->pbo = NULL;
gcmTexture->pool = _RGL_SURFACE_POOL_NONE; gcmTexture->pool = SURFACE_POOL_NONE;
gcmTexture->gpuAddressId = GMM_ERROR; gcmTexture->gpuAddressId = GMM_ERROR;
gcmTexture->gpuAddressIdOffset = 0; gcmTexture->gpuAddressIdOffset = 0;
gcmTexture->gpuSize = 0; gcmTexture->gpuSize = 0;
@ -4428,7 +4428,8 @@ static void _RGLPlatformValidateTextureStage( int unit, jsTexture* texture )
if ( RGL_LIKELY( isCompleteCache ) ) if ( RGL_LIKELY( isCompleteCache ) )
{ {
RGLTexture *platformTexture = ( RGLTexture * )texture->platformTexture; RGLTexture *platformTexture = ( RGLTexture * )texture->platformTexture;
const GLuint imageOffset = gmmIdToOffset(platformTexture->gpuAddressId) + platformTexture->gpuAddressIdOffset; GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)platformTexture->gpuAddressId;
const GLuint imageOffset = gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain) + platformTexture->gpuAddressIdOffset;
platformTexture->gcmTexture.offset = imageOffset; platformTexture->gcmTexture.offset = imageOffset;
cellGcmSetTexture( &_RGLState.fifo, unit, &platformTexture->gcmTexture); cellGcmSetTexture( &_RGLState.fifo, unit, &platformTexture->gcmTexture);
@ -4634,10 +4635,10 @@ static void _RGLSetImage( jsImage *image, GLint internalFormat, GLsizei width, G
raster.ystride = ( raster.width * raster.xstride + alignment - 1 ) / alignment * alignment; raster.ystride = ( raster.width * raster.xstride + alignment - 1 ) / alignment * alignment;
_RGLRasterToImage( &raster, image); _RGLRasterToImage( &raster, image);
image->dataState = _RGL_IMAGE_DATASTATE_HOST; image->dataState = IMAGE_DATASTATE_HOST;
} }
else else
image->dataState = _RGL_IMAGE_DATASTATE_UNSET; image->dataState = IMAGE_DATASTATE_UNSET;
} }
static GLboolean _RGLPlatformTexturePBOImage( static GLboolean _RGLPlatformTexturePBOImage(
@ -4652,7 +4653,7 @@ static GLboolean _RGLPlatformTexturePBOImage(
RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture; RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
image->dataState = _RGL_IMAGE_DATASTATE_UNSET; image->dataState = IMAGE_DATASTATE_UNSET;
if ( gcmTexture->pbo != NULL ) if ( gcmTexture->pbo != NULL )
_RGLPlatformDropTexture( texture ); _RGLPlatformDropTexture( texture );
@ -4727,7 +4728,7 @@ static GLboolean _RGLPlatformTexturePBOImage(
gcmTexture->pbo = bufferObject; gcmTexture->pbo = bufferObject;
gcmTexture->gpuAddressId = gpuId; gcmTexture->gpuAddressId = gpuId;
gcmTexture->gpuAddressIdOffset = gpuIdOffset; gcmTexture->gpuAddressIdOffset = gpuIdOffset;
gcmTexture->pool = _RGL_SURFACE_POOL_LINEAR; gcmTexture->pool = SURFACE_POOL_LINEAR;
gcmTexture->gpuSize = _RGLPlatformTextureGetGPUSize( texture ); gcmTexture->gpuSize = _RGLPlatformTextureGetGPUSize( texture );
++bufferObject->refCount; ++bufferObject->refCount;
} }
@ -4736,24 +4737,24 @@ static GLboolean _RGLPlatformTexturePBOImage(
const GLuint bytesPerPixel = newLayout.pixelBits / 8; const GLuint bytesPerPixel = newLayout.pixelBits / 8;
RGLSurface src = RGLSurface src =
{ {
source: _RGL_SURFACE_SOURCE_PBO, source: SURFACE_SOURCE_PBO,
width: image->width, width: image->width,
height: image->height, height: image->height,
bpp: bytesPerPixel, bpp: bytesPerPixel,
pitch: pboPitch, pitch: pboPitch,
format: newLayout.internalFormat, format: newLayout.internalFormat,
pool: _RGL_SURFACE_POOL_LINEAR, pool: SURFACE_POOL_LINEAR,
ppuData: NULL, ppuData: NULL,
dataId: gpuId, dataId: gpuId,
dataIdOffset: gpuIdOffset, dataIdOffset: gpuIdOffset,
}; };
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_LAYOUT; texture->revalidate |= TEXTURE_REVALIDATE_LAYOUT;
_RGLPlatformValidateTextureResources( texture ); _RGLPlatformValidateTextureResources( texture );
RGLSurface dst = RGLSurface dst =
{ {
source: _RGL_SURFACE_SOURCE_TEXTURE, source: SURFACE_SOURCE_TEXTURE,
width: image->width, width: image->width,
height: image->height, height: image->height,
bpp: bytesPerPixel, bpp: bytesPerPixel,
@ -4769,10 +4770,10 @@ static GLboolean _RGLPlatformTexturePBOImage(
} }
_RGLImageFreeCPUStorage( image ); _RGLImageFreeCPUStorage( image );
image->dataState = _RGL_IMAGE_DATASTATE_GPU; image->dataState = IMAGE_DATASTATE_GPU;
texture->revalidate &= ~( _RGL_TEXTURE_REVALIDATE_LAYOUT | _RGL_TEXTURE_REVALIDATE_IMAGES ); texture->revalidate &= ~( TEXTURE_REVALIDATE_LAYOUT | TEXTURE_REVALIDATE_IMAGES );
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_PARAMETERS; texture->revalidate |= TEXTURE_REVALIDATE_PARAMETERS;
_RGLTextureTouchFBOs( texture ); _RGLTextureTouchFBOs( texture );
return GL_TRUE; return GL_TRUE;
@ -4798,8 +4799,8 @@ static GLboolean _RGLPlatformTextureReference( jsTexture *texture, GLuint pitch,
gcmTexture->gpuAddressIdOffset = offset; gcmTexture->gpuAddressIdOffset = offset;
gcmTexture->gpuSize = _RGLPad( newLayout.baseHeight * newLayout.pitch, 1); gcmTexture->gpuSize = _RGLPad( newLayout.baseHeight * newLayout.pitch, 1);
texture->revalidate &= ~( _RGL_TEXTURE_REVALIDATE_LAYOUT | _RGL_TEXTURE_REVALIDATE_IMAGES ); texture->revalidate &= ~( TEXTURE_REVALIDATE_LAYOUT | TEXTURE_REVALIDATE_IMAGES );
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_PARAMETERS; texture->revalidate |= TEXTURE_REVALIDATE_PARAMETERS;
_RGLTextureTouchFBOs( texture ); _RGLTextureTouchFBOs( texture );
return GL_TRUE; return GL_TRUE;
} }
@ -4834,6 +4835,7 @@ static inline void _RGLSetColorDepthBuffers( RGLRenderTarget *rt, RGLRenderTarge
grt->colorLocation[i] = CELL_GCM_LOCATION_MAIN; grt->colorLocation[i] = CELL_GCM_LOCATION_MAIN;
else else
grt->colorLocation[i] = CELL_GCM_LOCATION_LOCAL; grt->colorLocation[i] = CELL_GCM_LOCATION_LOCAL;
grt->colorOffset[i] = gmmIdToOffset(args->colorId[i]) + args->colorIdOffset[i]; grt->colorOffset[i] = gmmIdToOffset(args->colorId[i]) + args->colorIdOffset[i];
grt->colorPitch[i] = args->colorPitch[i]; grt->colorPitch[i] = args->colorPitch[i];
} }
@ -5339,6 +5341,7 @@ static jsTexture *_RGLAllocateTexture (void)
GLuint size = sizeof( jsTexture ) + sizeof( RGLTexture); GLuint size = sizeof( jsTexture ) + sizeof( RGLTexture);
jsTexture *texture = ( jsTexture * )malloc( size ); jsTexture *texture = ( jsTexture * )malloc( size );
memset( texture, 0, size ); memset( texture, 0, size );
texture->target = 0; texture->target = 0;
texture->minFilter = GL_NEAREST_MIPMAP_LINEAR; texture->minFilter = GL_NEAREST_MIPMAP_LINEAR;
texture->magFilter = GL_LINEAR; texture->magFilter = GL_LINEAR;
@ -5406,7 +5409,7 @@ PSGLcontext* psglCreateContext (void)
for ( int i = 0; i < _RGL_MAX_TEXTURE_COORDS; i++ ) for ( int i = 0; i < _RGL_MAX_TEXTURE_COORDS; i++ )
{ {
_RGLMatrixStackInit( &( LContext->TextureCoordsUnits[i].TextureMatrixStack ), _RGL_MAX_TEXTURE_STACK_DEPTH ); _RGLMatrixStackInit(&( LContext->TextureCoordsUnits[i].TextureMatrixStack), MAX_TEXTURE_STACK_DEPTH);
if ( !LContext->TextureCoordsUnits[i].TextureMatrixStack.MatrixStackf ) if ( !LContext->TextureCoordsUnits[i].TextureMatrixStack.MatrixStackf )
{ {
psglDestroyContext( LContext ); psglDestroyContext( LContext );
@ -5529,12 +5532,12 @@ void _RGLAttachContext( PSGLdevice *device, PSGLcontext* context )
} }
context->needValidate = PSGL_VALIDATE_ALL; context->needValidate = PSGL_VALIDATE_ALL;
for ( int unit = 0;unit < _RGL_MAX_TEXTURE_UNITS;unit++ ) for (int unit = 0; unit < MAX_TEXTURE_UNITS; unit++)
context->TextureCoordsUnits[unit].TextureMatrixStack.dirty = GL_TRUE; context->TextureCoordsUnits[unit].TextureMatrixStack.dirty = GL_TRUE;
context->ModelViewMatrixStack.dirty = GL_TRUE; context->ModelViewMatrixStack.dirty = GL_TRUE;
context->ProjectionMatrixStack.dirty = GL_TRUE; context->ProjectionMatrixStack.dirty = GL_TRUE;
context->attribs->DirtyMask = ( 1 << _RGL_MAX_VERTEX_ATTRIBS ) - 1; context->attribs->DirtyMask = ( 1 << MAX_VERTEX_ATTRIBS ) - 1;
} }
GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params ) GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params )
@ -5732,7 +5735,7 @@ GLAPI void APIENTRY glDisableClientState( GLenum array )
} }
} }
GLAPI void APIENTRY glFlush() GLAPI void APIENTRY glFlush(void)
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
RGLFifo *fifo = &_RGLState.fifo; RGLFifo *fifo = &_RGLState.fifo;
@ -5871,7 +5874,6 @@ GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLflo
GLfloat L00, L01, L02, L03, L10, L11, L12, L13, L20, L21, L22, L23, L30, L31, L32, L33; GLfloat L00, L01, L02, L03, L10, L11, L12, L13, L20, L21, L22, L23, L30, L31, L32, L33;
GLfloat m00 = 2.f / ( right - left ); GLfloat m00 = 2.f / ( right - left );
GLfloat m03 = -( right + left ) / ( right - left ); GLfloat m03 = -( right + left ) / ( right - left );
GLfloat m11 = 2.f / ( top - bottom ); GLfloat m11 = 2.f / ( top - bottom );
@ -5880,41 +5882,41 @@ GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLflo
GLfloat m23 = -( zFar + zNear ) / ( zFar - zNear ); GLfloat m23 = -( zFar + zNear ) / ( zFar - zNear );
L00 = LMatrix[0]; L00 = LMatrix[0];
L01 = LMatrix[M01]; L01 = LMatrix[4];
L02 = LMatrix[M02]; L02 = LMatrix[8];
L03 = LMatrix[M03]; L03 = LMatrix[12];
L10 = LMatrix[M10]; L10 = LMatrix[1];
L11 = LMatrix[M11]; L11 = LMatrix[5];
L12 = LMatrix[M12]; L12 = LMatrix[9];
L13 = LMatrix[M13]; L13 = LMatrix[13];
L20 = LMatrix[M20]; L20 = LMatrix[2];
L21 = LMatrix[M21]; L21 = LMatrix[6];
L22 = LMatrix[M22]; L22 = LMatrix[10];
L23 = LMatrix[M23]; L23 = LMatrix[14];
L30 = LMatrix[M30]; L30 = LMatrix[3];
L31 = LMatrix[M31]; L31 = LMatrix[7];
L32 = LMatrix[M32]; L32 = LMatrix[11];
L33 = LMatrix[M33]; L33 = LMatrix[15];
LMatrix[0] = L00 * m00; LMatrix[0] *= m00;
LMatrix[M01] = L01 * m11; LMatrix[4] *= m11;
LMatrix[M02] = L02 * m22; LMatrix[8] *= m22;
LMatrix[M03] = L00 * m03 + L01 * m13 + L02 * m23 + L03; LMatrix[12] = L00 * m03 + L01 * m13 + L02 * m23 + L03;
LMatrix[M10] = L10 * m00; LMatrix[1] *= m00;
LMatrix[M11] = L11 * m11; LMatrix[5] *= m11;
LMatrix[M12] = L12 * m22; LMatrix[9] *= m22;
LMatrix[M13] = L10 * m03 + L11 * m13 + L12 * m23 + L13; LMatrix[13] = L10 * m03 + L11 * m13 + L12 * m23 + L13;
LMatrix[M20] = L20 * m00; LMatrix[2] *= m00;
LMatrix[M21] = L21 * m11; LMatrix[6] *= m11;
LMatrix[M22] = L22 * m22; LMatrix[10] *= m22;
LMatrix[M23] = L20 * m03 + L21 * m13 + L22 * m23 + L23; LMatrix[14] = L20 * m03 + L21 * m13 + L22 * m23 + L23;
LMatrix[M30] = L30 * m00; LMatrix[3] *= m00;
LMatrix[M31] = L31 * m11; LMatrix[7] *= m11;
LMatrix[M32] = L32 * m22; LMatrix[11] *= m22;
LMatrix[M33] = L30 * m03 + L31 * m13 + L32 * m23 + L33; LMatrix[15] = L30 * m03 + L31 * m13 + L32 * m23 + L33;
LMatrixStack->dirty = GL_TRUE; LMatrixStack->dirty = GL_TRUE;
if ( LContext->MatrixMode == GL_MODELVIEW ) if ( LContext->MatrixMode == GL_MODELVIEW )
@ -6040,7 +6042,7 @@ void _RGLVertexAttribPointerNV(
if ( oldArrayBuffer ) if ( oldArrayBuffer )
{ {
int refcount = 0; int refcount = 0;
for(unsigned int i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i ) for(unsigned int i = 0; i < MAX_VERTEX_ATTRIBS; ++i )
{ {
if ( attribSet->attribs.attrib[i].arrayBuffer == oldArrayBuffer ) ++refcount; if ( attribSet->attribs.attrib[i].arrayBuffer == oldArrayBuffer ) ++refcount;
} }
@ -6102,6 +6104,7 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams)
GLuint xferId = GMM_ERROR; GLuint xferId = GMM_ERROR;
GLuint VBOId = GMM_ERROR; GLuint VBOId = GMM_ERROR;
GLuint gpuOffset; GLuint gpuOffset;
if(RGL_UNLIKELY( dparams->xferTotalSize)) if(RGL_UNLIKELY( dparams->xferTotalSize))
{ {
xferId = gmmAlloc(0, dparams->xferTotalSize); xferId = gmmAlloc(0, dparams->xferTotalSize);
@ -6114,7 +6117,7 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams)
if ( needsUpdateMask ) if ( needsUpdateMask )
{ {
for ( GLuint i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i ) for ( GLuint i = 0; i < MAX_VERTEX_ATTRIBS; ++i )
{ {
if(!RGLBIT_GET(needsUpdateMask, i)) if(!RGLBIT_GET(needsUpdateMask, i))
continue; continue;
@ -6127,6 +6130,8 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams)
if ( RGL_UNLIKELY( dparams->attribXferSize[i] ) ) if ( RGL_UNLIKELY( dparams->attribXferSize[i] ) )
{ {
GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)xferId;
GLuint maxElements = dparams->firstVertex + dparams->vertexCount; GLuint maxElements = dparams->firstVertex + dparams->vertexCount;
GLuint offset; GLuint offset;
@ -6136,22 +6141,20 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams)
offset = ( dparams->firstVertex / freq ) * stride; offset = ( dparams->firstVertex / freq ) * stride;
char *b = (char *)xferBuffer + dparams->attribXferOffset[i]; char *b = (char *)xferBuffer + dparams->attribXferOffset[i];
memcpy( b + offset, memcpy( b + offset, ( char * )attrib->clientData + offset,
( char * )attrib->clientData + offset,
dparams->attribXferSize[i] - offset ); dparams->attribXferSize[i] - offset );
gpuOffset = gmmIdToOffset(xferId) + (b - ( char * )xferBuffer); gpuOffset = gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain) + (b - ( char * )xferBuffer);
} }
else else
{ {
VBOId = _RGLGetBufferObjectOrigin( attrib->arrayBuffer ); VBOId = _RGLGetBufferObjectOrigin( attrib->arrayBuffer );
gpuOffset = gmmIdToOffset(VBOId) + (( const GLubyte* )attrib->clientData - ( const GLubyte* )NULL ); GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)VBOId;
gpuOffset = gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain) + (( const GLubyte* )attrib->clientData - ( const GLubyte* )NULL );
} }
_RGLFifoGlVertexAttribPointer( i, attrib->clientSize, _RGLFifoGlVertexAttribPointer( i, attrib->clientSize,
( RGLEnum )attrib->clientType, attrib->normalized, ( RGLEnum )attrib->clientType, attrib->normalized, stride, freq, gpuOffset );
stride, freq, gpuOffset );
} }
else else
{ {
@ -6162,6 +6165,7 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams)
cellGcmSetFrequencyDividerOperationInline( &_RGLState.fifo, as->ModuloMask); cellGcmSetFrequencyDividerOperationInline( &_RGLState.fifo, as->ModuloMask);
driver->invalidateVertexCache = GL_TRUE; driver->invalidateVertexCache = GL_TRUE;
} }
as->DirtyMask = 0; as->DirtyMask = 0;
if ( xferId != GMM_ERROR ) if ( xferId != GMM_ERROR )
@ -6199,7 +6203,7 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
if ( RGL_UNLIKELY( clientSideMask ) ) if ( RGL_UNLIKELY( clientSideMask ) )
{ {
for ( int i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i ) for ( int i = 0; i < MAX_VERTEX_ATTRIBS; ++i )
{ {
dparams->attribXferOffset[i] = 0; dparams->attribXferOffset[i] = 0;
dparams->attribXferSize[i] = 0; dparams->attribXferSize[i] = 0;
@ -6231,7 +6235,7 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
uint32_t totalXfer = 0; uint32_t totalXfer = 0;
for (GLuint i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i) for (GLuint i = 0; i < MAX_VERTEX_ATTRIBS; ++i)
totalXfer += dparams->attribXferSize[i]; totalXfer += dparams->attribXferSize[i];
GLuint gpuOffset = _RGLValidateAttributesSlow( dparams); GLuint gpuOffset = _RGLValidateAttributesSlow( dparams);
@ -6243,7 +6247,8 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
cellGcmSetInvalidateVertexCacheInline ( &_RGLState.fifo); cellGcmSetInvalidateVertexCacheInline ( &_RGLState.fifo);
} }
cellGcmSetUpdateFragmentProgramParameterInline( &_RGLState.fifo, gmmIdToOffset( driver->fpLoadProgramId) +driver->fpLoadProgramOffset ); GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)driver->fpLoadProgramId;
cellGcmSetUpdateFragmentProgramParameterInline( &_RGLState.fifo, gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain) +driver->fpLoadProgramOffset );
cellGcmSetDrawArraysInline( &_RGLState.fifo, CELL_GCM_PRIMITIVE_QUADS, dparams->firstVertex, dparams->vertexCount); cellGcmSetDrawArraysInline( &_RGLState.fifo, CELL_GCM_PRIMITIVE_QUADS, dparams->firstVertex, dparams->vertexCount);
} }
@ -6306,7 +6311,7 @@ GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param )
texture->minFilter = param; texture->minFilter = param;
if ( texture->referenceBuffer == 0 ) if ( texture->referenceBuffer == 0 )
{ {
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_LAYOUT; } texture->revalidate |= TEXTURE_REVALIDATE_LAYOUT; }
break; break;
case GL_TEXTURE_MAG_FILTER: case GL_TEXTURE_MAG_FILTER:
texture->magFilter = param; texture->magFilter = param;
@ -6319,7 +6324,7 @@ GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param )
break; break;
case GL_TEXTURE_ALLOCATION_HINT_SCE: case GL_TEXTURE_ALLOCATION_HINT_SCE:
texture->usage = param; texture->usage = param;
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_LAYOUT; texture->revalidate |= TEXTURE_REVALIDATE_LAYOUT;
break; break;
case GL_TEXTURE_MIN_LOD: case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD: case GL_TEXTURE_MAX_LOD:
@ -6344,7 +6349,7 @@ GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param )
return; return;
} }
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_PARAMETERS; texture->revalidate |= TEXTURE_REVALIDATE_PARAMETERS;
LContext->needValidate |= PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_VERTEX_TEXTURES_USED; LContext->needValidate |= PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_VERTEX_TEXTURES_USED;
} }
@ -6399,7 +6404,7 @@ GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const G
_RGLGetImage( GL_TEXTURE_2D, 0, &texture, &image, MAX( width, height ) ); _RGLGetImage( GL_TEXTURE_2D, 0, &texture, &image, MAX( width, height ) );
image->dataState = _RGL_IMAGE_DATASTATE_UNSET; image->dataState = IMAGE_DATASTATE_UNSET;
GLboolean directPBO = GL_FALSE; GLboolean directPBO = GL_FALSE;
if ( LContext->PixelUnpackBuffer != 0 ) if ( LContext->PixelUnpackBuffer != 0 )
@ -6452,7 +6457,7 @@ GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const G
} }
} }
texture->revalidate |= _RGL_TEXTURE_REVALIDATE_IMAGES; texture->revalidate |= TEXTURE_REVALIDATE_IMAGES;
} }
_RGLTextureTouchFBOs( texture ); _RGLTextureTouchFBOs( texture );
@ -7882,7 +7887,7 @@ CGGL_API void cgGLDisableProfile( CGprofile profile )
case CG_PROFILE_SCE_FP_TYPEB: case CG_PROFILE_SCE_FP_TYPEB:
case CG_PROFILE_SCE_FP_RSX: case CG_PROFILE_SCE_FP_RSX:
LContext->FragmentProgram = GL_FALSE; LContext->FragmentProgram = GL_FALSE;
for ( GLuint unit = 0; unit < _RGL_MAX_TEXTURE_UNITS; ++unit ) for (GLuint unit = 0; unit < MAX_TEXTURE_UNITS; ++unit)
LContext->TextureImageUnits[unit].currentTexture = _RGLGetCurrentTexture( &LContext->TextureImageUnits[unit], GL_TEXTURE_2D ); LContext->TextureImageUnits[unit].currentTexture = _RGLGetCurrentTexture( &LContext->TextureImageUnits[unit], GL_TEXTURE_2D );
LContext->needValidate |= PSGL_VALIDATE_FFX_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED; LContext->needValidate |= PSGL_VALIDATE_FFX_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED;
@ -7966,7 +7971,7 @@ CGGL_API void cgGLUnbindProgram( CGprofile profile )
case CG_PROFILE_SCE_FP_RSX: case CG_PROFILE_SCE_FP_RSX:
case 7006: case 7006:
_CurrentContext->BoundFragmentProgram = NULL; _CurrentContext->BoundFragmentProgram = NULL;
for ( GLuint unit = 0; unit < _RGL_MAX_TEXTURE_UNITS; ++unit ) for (GLuint unit = 0; unit < MAX_TEXTURE_UNITS; ++unit)
_CurrentContext->TextureImageUnits[unit].currentTexture = _RGLGetCurrentTexture( &_CurrentContext->TextureImageUnits[unit], GL_TEXTURE_2D ); _CurrentContext->TextureImageUnits[unit].currentTexture = _RGLGetCurrentTexture( &_CurrentContext->TextureImageUnits[unit], GL_TEXTURE_2D );
_CurrentContext->needValidate |= PSGL_VALIDATE_FFX_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED; _CurrentContext->needValidate |= PSGL_VALIDATE_FFX_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED;

View File

@ -18,7 +18,7 @@ typedef struct _CGcontext *CGcontext;
#include <cell/resc.h> #include <cell/resc.h>
#endif #endif
#define _RGL_MAX_COLOR_ATTACHMENTS 4 #define MAX_COLOR_ATTACHMENTS 4
#define SUBPIXEL_ADJUST (0.5/(1<<12)) #define SUBPIXEL_ADJUST (0.5/(1<<12))
#define gmmIdIsMain(id) (((GmmBaseBlock *)id)->isMain) #define gmmIdIsMain(id) (((GmmBaseBlock *)id)->isMain)
@ -154,7 +154,7 @@ struct jsFramebufferAttachment
struct jsFramebuffer struct jsFramebuffer
{ {
jsFramebufferAttachment color[_RGL_MAX_COLOR_ATTACHMENTS]; jsFramebufferAttachment color[MAX_COLOR_ATTACHMENTS];
GLboolean needValidate; GLboolean needValidate;
jsFramebuffer(): needValidate( GL_TRUE ) {}; jsFramebuffer(): needValidate( GL_TRUE ) {};
virtual ~jsFramebuffer() {}; virtual ~jsFramebuffer() {};
@ -192,13 +192,11 @@ typedef struct
int X, Y, XSize, YSize; int X, Y, XSize, YSize;
} jsViewPort; } jsViewPort;
#define _RGL_IMAGE_STORAGE_RASTER 0 enum
#define _RGL_IMAGE_STORAGE_BLOCK 1 {
IMAGE_DATASTATE_UNSET = 0x0,
enum { IMAGE_DATASTATE_HOST = 0x1,
_RGL_IMAGE_DATASTATE_UNSET = 0x0, IMAGE_DATASTATE_GPU = 0x2
_RGL_IMAGE_DATASTATE_HOST = 0x1,
_RGL_IMAGE_DATASTATE_GPU = 0x2
}; };
typedef struct jsImage_ typedef struct jsImage_
@ -233,9 +231,9 @@ typedef struct
void* data; void* data;
} jsRaster; } jsRaster;
#define _RGL_TEXTURE_REVALIDATE_LAYOUT 0x01 #define TEXTURE_REVALIDATE_LAYOUT 0x01
#define _RGL_TEXTURE_REVALIDATE_IMAGES 0x02 #define TEXTURE_REVALIDATE_IMAGES 0x02
#define _RGL_TEXTURE_REVALIDATE_PARAMETERS 0x04 #define TEXTURE_REVALIDATE_PARAMETERS 0x04
typedef struct jsBufferObject jsBufferObject; typedef struct jsBufferObject jsBufferObject;
@ -267,27 +265,21 @@ jsTexture;
#define _RGL_MAX_TEXTURE_IMAGE_UNITS 16 #define _RGL_MAX_TEXTURE_IMAGE_UNITS 16
#define _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 4 #define _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 4
#define _RGL_MAX_TEXTURE_UNITS 4 #define MAX_TEXTURE_UNITS 4
#define _RGL_MAX_TEXTURE_SIZE_LOG2 12
#define _RGL_MAX_TEXTURE_SIZE (4096)
#define _RGL_MAX_MODELVIEW_STACK_DEPTH 16 #define _RGL_MAX_MODELVIEW_STACK_DEPTH 16
#define _RGL_MAX_PROJECTION_STACK_DEPTH 2 #define _RGL_MAX_PROJECTION_STACK_DEPTH 2
#define _RGL_MAX_TEXTURE_STACK_DEPTH 2 #define MAX_TEXTURE_STACK_DEPTH 2
#define _RGL_MAX_VERTEX_ATTRIBS 16 #define MAX_VERTEX_ATTRIBS 16
typedef struct typedef struct
{ {
GLuint bound2D; GLuint bound2D;
jsTexture* default2D; jsTexture* default2D;
GLenum fragmentTarget; GLenum fragmentTarget;
GLenum envMode; GLenum envMode;
jsColorRGBAf envColor; jsColorRGBAf envColor;
jsTexture* currentTexture; jsTexture* currentTexture;
} jsTextureImageUnit; } jsTextureImageUnit;
@ -299,9 +291,9 @@ typedef struct
enum enum
{ {
_RGL_FRAMEBUFFER_ATTACHMENT_NONE, FRAMEBUFFER_ATTACHMENT_NONE,
_RGL_FRAMEBUFFER_ATTACHMENT_RENDERBUFFER, FRAMEBUFFER_ATTACHMENT_RENDERBUFFER,
_RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE, FRAMEBUFFER_ATTACHMENT_TEXTURE,
}; };
typedef enum PSGLtvStandard typedef enum PSGLtvStandard
@ -406,8 +398,8 @@ typedef struct
GLuint indexXferOffset; GLuint indexXferOffset;
GLuint indexXferSize; GLuint indexXferSize;
GLuint attribXferTotalSize; GLuint attribXferTotalSize;
GLuint attribXferOffset[_RGL_MAX_VERTEX_ATTRIBS]; GLuint attribXferOffset[MAX_VERTEX_ATTRIBS];
GLuint attribXferSize[_RGL_MAX_VERTEX_ATTRIBS]; GLuint attribXferSize[MAX_VERTEX_ATTRIBS];
} jsDrawParams; } jsDrawParams;
#define _RGL_ATTRIB_POSITION_INDEX 0 #define _RGL_ATTRIB_POSITION_INDEX 0
@ -441,7 +433,7 @@ typedef struct
typedef struct typedef struct
{ {
jsAttribute attrib[_RGL_MAX_VERTEX_ATTRIBS]; jsAttribute attrib[MAX_VERTEX_ATTRIBS];
unsigned int DirtyMask; unsigned int DirtyMask;
unsigned int EnabledMask; unsigned int EnabledMask;
unsigned int NeedsConversionMask; unsigned int NeedsConversionMask;
@ -472,13 +464,6 @@ struct jsBufferObject
void *platformBufferObject[]; void *platformBufferObject[];
}; };
#define _RGL_CONTEXT_RED_MASK 0x01
#define _RGL_CONTEXT_GREEN_MASK 0x02
#define _RGL_CONTEXT_BLUE_MASK 0x04
#define _RGL_CONTEXT_ALPHA_MASK 0x08
#define _RGL_CONTEXT_DEPTH_MASK 0x10
#define _RGL_CONTEXT_COLOR_MASK 0x0F
#define ELEMENTS_IN_MATRIX 16 #define ELEMENTS_IN_MATRIX 16
typedef struct jsNameSpace typedef struct jsNameSpace
@ -565,9 +550,6 @@ struct PSGLcontext
#define RGL_LIKELY(COND) (COND) #define RGL_LIKELY(COND) (COND)
#define RGL_UNLIKELY(COND) (COND) #define RGL_UNLIKELY(COND) (COND)
#define _RGL_ALLOC_FIRST_FIT 0
#define _RGL_ALLOC_BEST_FIT 1
static inline float _RGLClampf( const float value ) static inline float _RGLClampf( const float value )
{ {
return MAX( MIN( value, 1.f ), 0.f ); return MAX( MIN( value, 1.f ), 0.f );
@ -636,7 +618,7 @@ void _RGLTexNameSpaceGenNames( jsTexNameSpace *ns, GLsizei n, GLuint *names );
void _RGLTexNameSpaceDeleteNames( jsTexNameSpace *ns, GLsizei n, const GLuint *names ); void _RGLTexNameSpaceDeleteNames( jsTexNameSpace *ns, GLsizei n, const GLuint *names );
void _RGLTexNameSpaceReinit( jsTexNameSpace * saved, jsTexNameSpace * active ); void _RGLTexNameSpaceReinit( jsTexNameSpace * saved, jsTexNameSpace * active );
#define RGL_MEMORY_ALLOC_ERROR 0 #define MEMORY_ALLOC_ERROR 0
#define GMM_ERROR 0xFFFFFFFF #define GMM_ERROR 0xFFFFFFFF
#define GMM_TILE_ALIGNMENT 0x10000 #define GMM_TILE_ALIGNMENT 0x10000
@ -772,10 +754,7 @@ void gmmSetTileAttrib(const uint32_t id, const uint32_t tag, void *pData);
cellGcmSetTransferImageInline( &_RGLState.fifo, CELL_GCM_TRANSFER_LOCAL_TO_LOCAL, dstOffset_tmp, (dstPitch), (dstX), (dstY), (srcOffset_tmp), (srcPitch), (srcX), (srcY), (width), (height), (bytesPerPixel) ); \ cellGcmSetTransferImageInline( &_RGLState.fifo, CELL_GCM_TRANSFER_LOCAL_TO_LOCAL, dstOffset_tmp, (dstPitch), (dstX), (dstY), (srcOffset_tmp), (srcPitch), (srcX), (srcY), (width), (height), (bytesPerPixel) ); \
} }
#define RGL_BIG_ENDIAN #define HOST_BUFFER_ALIGNMENT 128
#define _RGL_LINEAR_BUFFER_ALIGNMENT 128
#define _RGL_HOST_BUFFER_ALIGNMENT 128
#define _RGL_TRANSIENT_MEMORY_DEFAULT (32 << 20) #define _RGL_TRANSIENT_MEMORY_DEFAULT (32 << 20)
#define _RGL_PERSISTENT_MEMORY_DEFAULT (160 << 20) #define _RGL_PERSISTENT_MEMORY_DEFAULT (160 << 20)
@ -903,9 +882,9 @@ struct RGLState
GLboolean _RGLInit( PSGLinitOptions* options, RGLResource *resource ); GLboolean _RGLInit( PSGLinitOptions* options, RGLResource *resource );
#define _RGL_SEMA_NEVENTS 128 #define SEMA_NEVENTS 128
#define _RGL_SEMA_BASE 64 #define SEMA_BASE 64
#define _RGL_SEMA_FENCE (_RGL_SEMA_BASE+_RGL_SEMA_NEVENTS+0) #define SEMA_FENCE (SEMA_BASE + SEMA_NEVENTS)
void _RGLIncFenceRef( GLuint* ref ); void _RGLIncFenceRef( GLuint* ref );