(RGL) Tweaks

This commit is contained in:
Twinaphex 2012-08-06 05:05:16 +02:00
parent fd3ee5a9dd
commit 7fb25a76c8
2 changed files with 256 additions and 273 deletions

View File

@ -107,7 +107,7 @@ GLuint nvFenceCounter = 0;
#define DECLARE_TYPE(TYPE,CTYPE,MAXVAL) \ #define DECLARE_TYPE(TYPE,CTYPE,MAXVAL) \
typedef CTYPE type_##TYPE; \ typedef CTYPE type_##TYPE; \
static inline type_##TYPE _RGLFloatTo_##TYPE(float v) { return (type_##TYPE)(_RGLClampf(v)*MAXVAL); } \ static inline type_##TYPE _RGLFloatTo_##TYPE(float v) { return (type_##TYPE)((MAX(MIN(v, 1.f), 0.f)) * MAXVAL); } \
static inline float _RGLFloatFrom_##TYPE(type_##TYPE v) { return ((float)v)/MAXVAL; } static inline float _RGLFloatFrom_##TYPE(type_##TYPE v) { return ((float)v)/MAXVAL; }
DECLARE_C_TYPES DECLARE_C_TYPES
#undef DECLARE_TYPE #undef DECLARE_TYPE
@ -256,6 +256,7 @@ static inline void _RGLFifoGlVertexAttribPointer
GLuint offset GLuint offset
) )
{ {
switch(size) switch(size)
{ {
case 0: case 0:
@ -282,24 +283,19 @@ static inline void _RGLFifoGlVertexAttribPointer
else else
gcmType = CELL_GCM_VERTEX_UB256; gcmType = CELL_GCM_VERTEX_UB256;
break; break;
case RGL_SHORT: case RGL_SHORT:
gcmType = normalized ? CELL_GCM_VERTEX_S1 : CELL_GCM_VERTEX_S32K; gcmType = normalized ? CELL_GCM_VERTEX_S1 : CELL_GCM_VERTEX_S32K;
break; break;
case RGL_FLOAT: case RGL_FLOAT:
gcmType = CELL_GCM_VERTEX_F; gcmType = CELL_GCM_VERTEX_F;
break; break;
case RGL_HALF_FLOAT: case RGL_HALF_FLOAT:
gcmType = CELL_GCM_VERTEX_SF; gcmType = CELL_GCM_VERTEX_SF;
break; break;
case RGL_CMP: case RGL_CMP:
size = 1; size = 1;
gcmType = CELL_GCM_VERTEX_CMP; gcmType = CELL_GCM_VERTEX_CMP;
break; break;
default: default:
break; break;
} }
@ -379,8 +375,10 @@ static void _RGLAttribSetDeleteBuffer( PSGLcontext *LContext, GLuint buffName )
jsAttribSet *attribSet = bufferObject->attribSets[i]; jsAttribSet *attribSet = bufferObject->attribSets[i];
for(GLuint j = 0; j < 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;
}
attribSet->dirty = GL_TRUE; attribSet->dirty = GL_TRUE;
} }
@ -432,6 +430,7 @@ static void _RGLFreeBufferObject( jsBufferObject *buffer )
_RGLPlatformDestroyBufferObject( buffer ); _RGLPlatformDestroyBufferObject( buffer );
buffer->textureReferences.~Vector<jsTexture *>(); buffer->textureReferences.~Vector<jsTexture *>();
buffer->attribSets.~Vector<jsAttribSet *>(); buffer->attribSets.~Vector<jsAttribSet *>();
if(buffer != NULL) if(buffer != NULL)
free( buffer ); free( buffer );
} }
@ -479,8 +478,10 @@ GLAPI void APIENTRY glDeleteBuffers(GLsizei n, const GLuint *buffers)
if(buffers[i] ) if(buffers[i] )
{ {
GLuint name = buffers[i]; GLuint name = buffers[i];
if(LContext->ArrayBuffer == name) if(LContext->ArrayBuffer == name)
LContext->ArrayBuffer = 0; LContext->ArrayBuffer = 0;
if(LContext->PixelUnpackBuffer == name) if(LContext->PixelUnpackBuffer == name)
LContext->PixelUnpackBuffer = 0; LContext->PixelUnpackBuffer = 0;
@ -504,11 +505,6 @@ GLAPI void APIENTRY glGenBuffers(GLsizei n, GLuint *buffers)
_RGLTexNameSpaceGenNames( &LContext->bufferObjectNameSpace, n, buffers ); _RGLTexNameSpaceGenNames( &LContext->bufferObjectNameSpace, n, buffers );
} }
static inline jsFramebuffer *_RGLGetFramebuffer(PSGLcontext *LContext, GLuint name)
{
return (jsFramebuffer *)LContext->framebufferNameSpace.data[name];
}
static inline void _RGLTextureTouchFBOs(jsTexture *texture) static inline void _RGLTextureTouchFBOs(jsTexture *texture)
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
@ -516,9 +512,10 @@ static inline void _RGLTextureTouchFBOs(jsTexture *texture)
return; return;
GLuint fbCount = texture->framebuffers.getCount(); GLuint fbCount = texture->framebuffers.getCount();
if(fbCount > 0) if(fbCount > 0)
{ {
jsFramebuffer *contextFramebuffer = LContext->framebuffer ? _RGLGetFramebuffer( LContext, LContext->framebuffer ) : NULL; jsFramebuffer *contextFramebuffer = LContext->framebuffer ? (jsFramebuffer *)LContext->framebufferNameSpace.data[LContext->framebuffer] : NULL;
for (GLuint i = 0; i < fbCount; ++i) for (GLuint i = 0; i < fbCount; ++i)
{ {
@ -644,6 +641,7 @@ static void _RGLPlatformBufferObjectSetData( jsBufferObject* bufferObject, GLint
unsigned int dstId = jsBuffer->bufferId; unsigned int dstId = jsBuffer->bufferId;
unsigned int pitch = jsBuffer->pitch; unsigned int pitch = jsBuffer->pitch;
const char *src = (const char *)data; const char *src = (const char *)data;
switch ( bufferObject->usage ) switch ( bufferObject->usage )
{ {
case GL_STREAM_DRAW: case GL_STREAM_DRAW:
@ -835,6 +833,7 @@ static void _RGLFramebufferGetAttachmentTexture(
jsTexture** texture) jsTexture** texture)
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
switch ( attachment->type ) switch ( attachment->type )
{ {
case FRAMEBUFFER_ATTACHMENT_NONE: case FRAMEBUFFER_ATTACHMENT_NONE:
@ -857,13 +856,16 @@ static GLboolean _RGLTextureIsValid( const jsTexture* texture )
return GL_FALSE; return GL_FALSE;
if ( !texture->image ) if ( !texture->image )
return GL_FALSE; return GL_FALSE;
const jsImage* image = texture->image; const jsImage* image = texture->image;
int width = image->width; int width = image->width;
int height = image->height; int height = image->height;
GLenum format = image->format; GLenum format = image->format;
GLenum type = image->type; GLenum type = image->type;
GLenum internalFormat = image->internalFormat; GLenum internalFormat = image->internalFormat;
if (( internalFormat == 0 ) || ( format == 0 ) || ( type == 0 ) ) if (( internalFormat == 0 ) || ( format == 0 ) || ( type == 0 ) )
return GL_FALSE; return GL_FALSE;
@ -933,29 +935,36 @@ static GLenum _RGLPlatformFramebufferCheckStatus(jsFramebuffer* framebuffer)
return GL_FRAMEBUFFER_COMPLETE_OES; return GL_FRAMEBUFFER_COMPLETE_OES;
} }
enum _RGLTextureStrategy { enum _RGLTextureStrategy
_RGL_TEXTURE_STRATEGY_END, {
_RGL_TEXTURE_STRATEGY_UNTILED_ALLOC, TEXTURE_STRATEGY_END,
_RGL_TEXTURE_STRATEGY_UNTILED_CLEAR, TEXTURE_STRATEGY_UNTILED_ALLOC,
TEXTURE_STRATEGY_UNTILED_CLEAR,
}; };
static enum _RGLTextureStrategy linearGPUStrategy[] = static enum _RGLTextureStrategy linearGPUStrategy[] =
{ {
_RGL_TEXTURE_STRATEGY_UNTILED_ALLOC, TEXTURE_STRATEGY_UNTILED_ALLOC,
_RGL_TEXTURE_STRATEGY_UNTILED_CLEAR, TEXTURE_STRATEGY_UNTILED_CLEAR,
_RGL_TEXTURE_STRATEGY_UNTILED_ALLOC, TEXTURE_STRATEGY_UNTILED_ALLOC,
_RGL_TEXTURE_STRATEGY_END, TEXTURE_STRATEGY_END,
}; };
static void _RGLImageAllocCPUStorage( jsImage *image ) static void _RGLImageAllocCPUStorage( jsImage *image )
{ {
if((image->storageSize > image->mallocStorageSize) || (!image->mallocData)) if((image->storageSize > image->mallocStorageSize) || (!image->mallocData))
{ {
if ( image->mallocData ) free( image->mallocData ); if(image->mallocData)
free( image->mallocData );
image->mallocData = ( char * )malloc( image->storageSize + 128 ); image->mallocData = ( char * )malloc( image->storageSize + 128 );
image->mallocStorageSize = image->storageSize; image->mallocStorageSize = image->storageSize;
} }
image->data = _RGLPadPtr( image->mallocData, 128 );
intptr_t x = (intptr_t)image->mallocData;
x = ( x + 128 - 1 ) / 128 * 128;
image->data = (char*)x;
} }
static inline int _RGLGetComponentCount( GLenum format ) static inline int _RGLGetComponentCount( GLenum format )
@ -1272,11 +1281,6 @@ int _RGLGetPixelSize( GLenum format, GLenum type )
return _RGLGetComponentCount( format )*componentSize; return _RGLGetComponentCount( format )*componentSize;
} }
static inline int _RGLGetStorageSize( GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth )
{
return _RGLGetPixelSize( format, type )*width*height*depth;
}
static void _RGLPlatformChooseGPUFormatAndLayout( static void _RGLPlatformChooseGPUFormatAndLayout(
const jsTexture* texture, const jsTexture* texture,
GLboolean forceLinear, GLboolean forceLinear,
@ -1289,18 +1293,20 @@ static void _RGLPlatformChooseGPUFormatAndLayout(
newLayout->baseHeight = image->height; newLayout->baseHeight = image->height;
newLayout->internalFormat = ( RGLEnum )image->internalFormat; newLayout->internalFormat = ( RGLEnum )image->internalFormat;
newLayout->pixelBits = _RGLPlatformGetBitsPerPixel( newLayout->internalFormat ); newLayout->pixelBits = _RGLPlatformGetBitsPerPixel( newLayout->internalFormat );
newLayout->pitch = pitch ? pitch : _RGLPad( _RGLGetStorageSize( texture->image->format, texture->image->type, texture->image->width, 1, 1 ), 64 ); newLayout->pitch = pitch ? pitch : _RGLPad( _RGLGetPixelSize( texture->image->format, texture->image->type )*texture->image->width, 64);
} }
void _RGLPlatformDropUnboundTextures(GLenum pool) void _RGLPlatformDropUnboundTextures(GLenum pool)
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
GLuint i, j; GLuint i, j;
for (i = 0; i < LContext->textureNameSpace.capacity; ++i) for (i = 0; i < LContext->textureNameSpace.capacity; ++i)
{ {
GLboolean bound = GL_FALSE; GLboolean bound = GL_FALSE;
jsTexture *texture = ( jsTexture * )LContext->textureNameSpace.data[i]; jsTexture *texture = ( jsTexture * )LContext->textureNameSpace.data[i];
if ( !texture || ( texture->referenceBuffer != 0 ) ) continue; if(!texture || (texture->referenceBuffer != 0))
continue;
for (j = 0; j < _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++j) for (j = 0; j < _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++j)
{ {
@ -1355,7 +1361,7 @@ static void _RGLPlatformReallocateGcmTexture( jsTexture* texture )
switch ( *step++ ) switch ( *step++ )
{ {
case _RGL_TEXTURE_STRATEGY_UNTILED_ALLOC: case TEXTURE_STRATEGY_UNTILED_ALLOC:
_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);
@ -1388,10 +1394,10 @@ static void _RGLPlatformReallocateGcmTexture( jsTexture* texture )
} }
} }
break; break;
case _RGL_TEXTURE_STRATEGY_UNTILED_CLEAR: case TEXTURE_STRATEGY_UNTILED_CLEAR:
_RGLPlatformDropUnboundTextures(SURFACE_POOL_LINEAR); _RGLPlatformDropUnboundTextures(SURFACE_POOL_LINEAR);
break; break;
case _RGL_TEXTURE_STRATEGY_END: case TEXTURE_STRATEGY_END:
_RGLSetError( GL_OUT_OF_MEMORY ); _RGLSetError( GL_OUT_OF_MEMORY );
done = GL_TRUE; done = GL_TRUE;
break; break;
@ -1558,6 +1564,7 @@ static void jsPlatformFramebuffer_validate( jsPlatformFramebuffer * fb, PSGLcont
GLuint defaultPitch = 0; GLuint defaultPitch = 0;
GLuint defaultId = GMM_ERROR; GLuint defaultId = GMM_ERROR;
GLuint defaultIdOffset = 0; GLuint defaultIdOffset = 0;
for(int i = 0; i < RGL_SETRENDERTARGET_MAXCOUNT; ++i) for(int i = 0; i < RGL_SETRENDERTARGET_MAXCOUNT; ++i)
{ {
jsTexture* colorTexture = NULL; jsTexture* colorTexture = NULL;
@ -1618,7 +1625,7 @@ static void _RGLValidateFramebuffer( void )
if(LContext->framebuffer) if(LContext->framebuffer)
{ {
jsPlatformFramebuffer* framebuffer = static_cast<jsPlatformFramebuffer *>( _RGLGetFramebuffer( LContext, LContext->framebuffer ) ); jsPlatformFramebuffer* framebuffer = static_cast<jsPlatformFramebuffer *>((jsFramebuffer *)LContext->framebufferNameSpace.data[LContext->framebuffer] );
if ( framebuffer->needValidate ) if ( framebuffer->needValidate )
jsPlatformFramebuffer_validate( framebuffer, LContext ); jsPlatformFramebuffer_validate( framebuffer, LContext );
@ -1721,10 +1728,10 @@ GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, G
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
LContext->ClearColor.R = _RGLClampf( red ); LContext->ClearColor.R = MAX(MIN(red, 1.f), 0.f);
LContext->ClearColor.G = _RGLClampf( green ); LContext->ClearColor.G = MAX(MIN(green, 1.f), 0.f);
LContext->ClearColor.B = _RGLClampf( blue ); LContext->ClearColor.B = MAX(MIN(blue, 1.f), 0.f);
LContext->ClearColor.A = _RGLClampf( alpha ); LContext->ClearColor.A = MAX(MIN(alpha, 1.f), 0.f);
} }
GLAPI void APIENTRY glBlendEquation( GLenum mode ) GLAPI void APIENTRY glBlendEquation( GLenum mode )
@ -1738,15 +1745,14 @@ GLAPI void APIENTRY glBlendEquation( GLenum mode )
GLAPI void APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) GLAPI void APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
LContext->BlendColor.R = _RGLClampf( red ); LContext->BlendColor.R = MAX(MIN(red, 1.f), 0.f);
LContext->BlendColor.G = _RGLClampf( green ); LContext->BlendColor.G = MAX(MIN(green, 1.f), 0.f);
LContext->BlendColor.B = _RGLClampf( blue ); LContext->BlendColor.B = MAX(MIN(blue, 1.f), 0.f);
LContext->BlendColor.A = _RGLClampf( alpha ); LContext->BlendColor.A = MAX(MIN(alpha, 1.f), 0.f);
LContext->needValidate |= PSGL_VALIDATE_BLENDING; LContext->needValidate |= PSGL_VALIDATE_BLENDING;
} }
GLAPI void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) GLAPI void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
@ -1814,7 +1820,7 @@ GLAPI GLenum APIENTRY glCheckFramebufferStatusOES( GLenum target )
if ( LContext->framebuffer ) if ( LContext->framebuffer )
{ {
jsFramebuffer* framebuffer = _RGLGetFramebuffer( LContext, LContext->framebuffer ); jsFramebuffer* framebuffer = (jsFramebuffer *)LContext->framebufferNameSpace.data[LContext->framebuffer];
return _RGLPlatformFramebufferCheckStatus( framebuffer ); return _RGLPlatformFramebufferCheckStatus( framebuffer );
} }
@ -1825,7 +1831,7 @@ GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum target, GLenum attachment,
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
jsFramebuffer* framebuffer = _RGLGetFramebuffer( LContext, LContext->framebuffer ); jsFramebuffer* framebuffer = (jsFramebuffer *)LContext->framebufferNameSpace.data[LContext->framebuffer];
jsFramebufferAttachment* attach = _RGLFramebufferGetAttachment( framebuffer, GL_COLOR_ATTACHMENT0_EXT ); jsFramebufferAttachment* attach = _RGLFramebufferGetAttachment( framebuffer, GL_COLOR_ATTACHMENT0_EXT );
@ -2095,10 +2101,7 @@ static uint32_t gmmInitFixedAllocator (void)
return CELL_OK; return CELL_OK;
} }
static void gmmRemovePendingFree( static void gmmRemovePendingFree(GmmAllocator *pAllocator, GmmBlock *pBlock)
GmmAllocator *pAllocator,
GmmBlock *pBlock
)
{ {
if (pBlock == pAllocator->pPendingFreeHead) if (pBlock == pAllocator->pPendingFreeHead)
pAllocator->pPendingFreeHead = pBlock->pNextFree; pAllocator->pPendingFreeHead = pBlock->pNextFree;
@ -3268,10 +3271,10 @@ template<int SIZE> inline static void swapandsetfp( int ucodeSize, unsigned int
unsigned short count = *( ec++ ); unsigned short count = *( ec++ );
for ( unsigned long offsetIndex = 0; offsetIndex < count; ++offsetIndex ) for ( unsigned long offsetIndex = 0; offsetIndex < count; ++offsetIndex )
{ {
void *pointer=NULL; void *ptr = NULL;
const int paddedSIZE = (SIZE + 1) & ~1; const int paddedSIZE = (SIZE + 1) & ~1;
cellGcmSetInlineTransferPointerInline( &_RGLState.fifo, gmmIdToOffset( loadProgramId ) + loadProgramOffset + *(ec++), paddedSIZE, &pointer); cellGcmSetInlineTransferPointerInline( &_RGLState.fifo, gmmIdToOffset( loadProgramId ) + loadProgramOffset + *(ec++), paddedSIZE, &ptr);
float *fp = (float*)pointer; float *fp = (float*)ptr;
float *src = (float*)v; float *src = (float*)v;
for (uint32_t j=0; j<SIZE;j++) for (uint32_t j=0; j<SIZE;j++)
{ {
@ -3294,6 +3297,7 @@ template<int SIZE> static void setVectorTypefp( CgRuntimeParameter* __restrict p
CgParameterResource *parameterResource = _RGLGetParameterResource( ptr->program, ptr->parameterEntry ); CgParameterResource *parameterResource = _RGLGetParameterResource( ptr->program, ptr->parameterEntry );
unsigned short resource = parameterResource->resource; unsigned short resource = parameterResource->resource;
unsigned short *ec = ( unsigned short * )( ptr->program->resources ) + resource + 1; unsigned short *ec = ( unsigned short * )( ptr->program->resources ) + resource + 1;
if ( RGL_LIKELY( *ec ) ) if ( RGL_LIKELY( *ec ) )
{ {
swapandsetfp<SIZE>(program->header.instructionCount*16, program->loadProgramId, program->loadProgramOffset, ec, (unsigned int *)data); swapandsetfp<SIZE>(program->header.instructionCount*16, program->loadProgramId, program->loadProgramOffset, ec, (unsigned int *)data);
@ -3408,10 +3412,9 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedvpIndex( CgR
for ( long row = 0; row < ROWS; ++row ) for ( long row = 0; row < ROWS; ++row )
{ {
for(long col = 0; col < COLS; ++col) for(long col = 0; col < COLS; ++col)
{
tmp[row*4 + col] = dst[row * 4 + col] = ( ORDER == ROW_MAJOR ) ? f[row * COLS + col] : f[col * ROWS + row]; tmp[row*4 + col] = dst[row * 4 + col] = ( ORDER == ROW_MAJOR ) ? f[row * COLS + col] : f[col * ROWS + row];
} for(long col = COLS; col < 4; ++col)
for ( long col = COLS; col < 4; ++col ) tmp[row*4 + col] = dst[row*4+col]; tmp[row*4 + col] = dst[row*4+col];
} }
cellGcmSetVertexProgramParameterBlockInline( &_RGLState.fifo, resource, ROWS, (const float*)tmp); cellGcmSetVertexProgramParameterBlockInline( &_RGLState.fifo, resource, ROWS, (const float*)tmp);
@ -4407,13 +4410,6 @@ static void _RGLPlatformDestroyTexture( jsTexture* texture )
_RGLTextureTouchFBOs( texture ); _RGLTextureTouchFBOs( texture );
} }
// Get size of texture in GPU layout
static inline GLuint _RGLPlatformTextureGetGPUSize( const jsTexture* texture )
{
RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
return _RGLPad( gcmTexture->gpuLayout.baseHeight * gcmTexture->gpuLayout.pitch, 1);
}
#include <cell/gcm/gcm_method_data.h> #include <cell/gcm/gcm_method_data.h>
static void _RGLPlatformValidateTextureStage( int unit, jsTexture* texture ) static void _RGLPlatformValidateTextureStage( int unit, jsTexture* texture )
@ -4573,9 +4569,7 @@ static GLenum _RGLPlatformChooseInternalStorage( jsImage* image, GLenum internal
image->internalFormat = platformInternalFormat; image->internalFormat = platformInternalFormat;
_RGLPlatformExpandInternalFormat( platformInternalFormat, &image->format, &image->type ); _RGLPlatformExpandInternalFormat( platformInternalFormat, &image->format, &image->type );
image->storageSize = _RGLGetStorageSize( image->storageSize = _RGLGetPixelSize(image->format, image->type) * image->width * image->height;
image->format, image->type,
image->width, image->height, 1 );
return GL_NO_ERROR; return GL_NO_ERROR;
} }
@ -4662,9 +4656,7 @@ static GLboolean _RGLPlatformTexturePBOImage(
if ( LContext->PixelUnpackBuffer == 0 ) if ( LContext->PixelUnpackBuffer == 0 )
return GL_FALSE; return GL_FALSE;
const GLuint pboPitch = _RGLPad( const GLuint pboPitch = _RGLPad(_RGLGetPixelSize(format, type) * width, LContext->unpackAlignment );
_RGLGetStorageSize( format, type, width, 1, 1 ),
LContext->unpackAlignment );
if (( pboPitch&3 ) != 0 ) if (( pboPitch&3 ) != 0 )
{ {
RARCH_WARN("PBO image pitch not a multiple of 4, using slow path.\n" ); RARCH_WARN("PBO image pitch not a multiple of 4, using slow path.\n" );
@ -4722,14 +4714,15 @@ static GLboolean _RGLPlatformTexturePBOImage(
{ {
gcmTexture->gpuLayout = newLayout; gcmTexture->gpuLayout = newLayout;
if ( gcmTexture->gpuAddressId != GMM_ERROR && gcmTexture->pbo == NULL ) if ( gcmTexture->gpuAddressId != GMM_ERROR && gcmTexture->pbo == NULL )
{
_RGLPlatformFreeGcmTexture( texture ); _RGLPlatformFreeGcmTexture( texture );
}
gcmTexture->pbo = bufferObject; gcmTexture->pbo = bufferObject;
gcmTexture->gpuAddressId = gpuId; gcmTexture->gpuAddressId = gpuId;
gcmTexture->gpuAddressIdOffset = gpuIdOffset; gcmTexture->gpuAddressIdOffset = gpuIdOffset;
gcmTexture->pool = SURFACE_POOL_LINEAR; gcmTexture->pool = SURFACE_POOL_LINEAR;
gcmTexture->gpuSize = _RGLPlatformTextureGetGPUSize( texture ); RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
// Get size of texture in GPU layout
gcmTexture->gpuSize = _RGLPad( gcmTexture->gpuLayout.baseHeight * gcmTexture->gpuLayout.pitch, 1);
++bufferObject->refCount; ++bufferObject->refCount;
} }
else else
@ -6584,7 +6577,7 @@ static _CGprogram* _RGLCgProgramFindPrev( _CGcontext* ctx, _CGprogram* prog )
{ {
_CGprogram* ptr = ctx->programList; _CGprogram* ptr = ctx->programList;
while ( NULL != ptr && prog != ptr->next ) while ( ptr != NULL && prog != ptr->next )
ptr = ptr->next; ptr = ptr->next;
return ptr; return ptr;
@ -6838,7 +6831,9 @@ static CGprogram _RGLCgCreateProgram( CGcontext ctx, CGprofile profile, const Cg
// success! add the program to the program list in the context. // success! add the program to the program list in the context.
_RGLCgProgramPushFront(prog->parentContext, prog); _RGLCgProgramPushFront(prog->parentContext, prog);
if ( _cgProgramCreateHook ) _cgProgramCreateHook( prog );
if(_cgProgramCreateHook)
_cgProgramCreateHook(prog);
// everything worked. // everything worked.
return id; return id;
@ -7235,7 +7230,8 @@ CG_API CGprogram cgCopyProgram( CGprogram program )
_RGLCgProgramPushFront(newprog->parentContext, newprog); _RGLCgProgramPushFront(newprog->parentContext, newprog);
if ( _cgProgramCopyHook ) _cgProgramCopyHook( newprog, prog ); if(_cgProgramCopyHook)
_cgProgramCopyHook(newprog, prog);
return newprog->id; return newprog->id;
} }
@ -7248,7 +7244,9 @@ CG_API void cgDestroyProgram( CGprogram program )
_RGLCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR ); _RGLCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR );
return; return;
} }
_CGprogram* ptr = _cgGetProgPtr( program ); _CGprogram* ptr = _cgGetProgPtr( program );
if ( ptr == NULL ) if ( ptr == NULL )
{ {
_RGLCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR ); _RGLCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR );
@ -8109,12 +8107,6 @@ CGGL_API void cgGLEnableTextureParameter( CGparameter param )
ptr->samplerSetter( ptr, NULL, 0 ); ptr->samplerSetter( ptr, NULL, 0 );
} }
static void _RGLCgContextZero( _CGcontext* p )
{
memset( p, 0, sizeof( *p ) );
p->compileType = CG_UNKNOWN;
}
static void _RGLCgContextPushFront(_CGcontext* ctx) static void _RGLCgContextPushFront(_CGcontext* ctx)
{ {
if(_CurrentContext->RGLcgContextHead) if(_CurrentContext->RGLcgContextHead)
@ -8131,7 +8123,9 @@ static void destroy_context(_CGcontext*ctx)
_cgContextDestroyHook(ctx); _cgContextDestroyHook(ctx);
_RGLEraseName( &_CurrentContext->cgContextNameSpace, ( jsName )ctx->id ); _RGLEraseName( &_CurrentContext->cgContextNameSpace, ( jsName )ctx->id );
_RGLCgContextZero( ctx ); memset(ctx, 0, sizeof( *ctx ) );
ctx->compileType = CG_UNKNOWN;
free( ctx ); free( ctx );
} }
@ -8146,7 +8140,8 @@ CG_API CGcontext cgCreateContext(void)
return ( CGcontext )NULL; return ( CGcontext )NULL;
} }
_RGLCgContextZero( ptr ); memset( ptr, 0, sizeof( *ptr ) );
ptr->compileType = CG_UNKNOWN;
CGcontext result = ( CGcontext )_RGLCreateName( &_CurrentContext->cgContextNameSpace, ptr ); CGcontext result = ( CGcontext )_RGLCreateName( &_CurrentContext->cgContextNameSpace, ptr );
if ( !result ) if ( !result )

View File

@ -550,11 +550,6 @@ struct PSGLcontext
#define RGL_LIKELY(COND) (COND) #define RGL_LIKELY(COND) (COND)
#define RGL_UNLIKELY(COND) (COND) #define RGL_UNLIKELY(COND) (COND)
static inline float _RGLClampf( const float value )
{
return MAX( MIN( value, 1.f ), 0.f );
}
static inline unsigned int endianSwapWord( unsigned int v ) static inline unsigned int endianSwapWord( unsigned int v )
{ {
return ( v&0xff ) << 24 | ( v&0xff00 ) << 8 | return ( v&0xff ) << 24 | ( v&0xff00 ) << 8 |
@ -577,13 +572,6 @@ static inline unsigned long _RGLPad(unsigned long x, unsigned long pad)
return ( x + pad - 1 ) / pad*pad; return ( x + pad - 1 ) / pad*pad;
} }
static inline char* _RGLPadPtr(const char* p, unsigned int pad)
{
intptr_t x = (intptr_t)p;
x = ( x + pad - 1 ) / pad * pad;
return ( char* )x;
}
typedef struct MemoryBlockManager_t_ typedef struct MemoryBlockManager_t_
{ {
char *memory; char *memory;
@ -927,7 +915,7 @@ static inline GLuint _RGLPlatformGetBitsPerPixel( GLenum internalFormat )
} }
void static inline _RGLFifoGlViewport( GLint x, GLint y, GLsizei width, GLsizei height, GLclampf zNear = 0.0f, GLclampf zFar = 1.0f ) static inline void _RGLFifoGlViewport( GLint x, GLint y, GLsizei width, GLsizei height, GLclampf zNear = 0.0f, GLclampf zFar = 1.0f )
{ {
RGLViewportState *vp = &_RGLState.state.viewport; RGLViewportState *vp = &_RGLState.state.viewport;
RGLRenderTarget *rt = &_RGLState.renderTarget; RGLRenderTarget *rt = &_RGLState.renderTarget;