(RGL) Cleanups

This commit is contained in:
Twinaphex 2012-07-29 01:10:15 +02:00
parent c9607c4684
commit a75ca75fd1
5 changed files with 924 additions and 994 deletions

View File

@ -186,9 +186,9 @@ typedef struct CgProgramHeader
} }
CgProgramHeader; CgProgramHeader;
typedef void( *_cgSetFunction )( struct CgRuntimeParameter* _RGL_RESTRICT, const void* _RGL_RESTRICT ); typedef void( *_cgSetFunction )( struct CgRuntimeParameter* __restrict, const void* __restrict);
typedef void( *_cgSetArrayIndexFunction )( struct CgRuntimeParameter* _RGL_RESTRICT, const void* _RGL_RESTRICT, const int index ); typedef void( *_cgSetArrayIndexFunction )( struct CgRuntimeParameter* __restrict, const void* __restrict, const int index );
typedef struct _CgUniform typedef struct _CgUniform
{ {
@ -394,17 +394,14 @@ int _RGLPlatformCopyProgram( _CGprogram* source, _CGprogram* destination );
void _RGLPlatformProgramErase( void* platformProgram ); void _RGLPlatformProgramErase( void* platformProgram );
int _RGLPlatformGenerateVertexProgram( _CGprogram *program, const CgProgramHeader *programHeader, const void *ucode, const CgParameterTableHeader *parameterHeader, const char *stringTable, const float *defaultValues );
int _RGLPlatformGenerateFragmentProgram( _CGprogram *program, const CgProgramHeader *programHeader, const void *ucode, const CgParameterTableHeader *parameterHeader, const char *stringTable, const float *defaultValues );
CGbool _RGLPlatformSupportsFragmentProgram( CGprofile p ); CGbool _RGLPlatformSupportsFragmentProgram( CGprofile p );
void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * _RGL_RESTRICT v ); void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * __restrict v );
void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * _RGL_RESTRICT v ); void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v );
void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * _RGL_RESTRICT v ); void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * __restrict v );
void _RGLPlatformSetFragmentRegisterBlock( unsigned int reg, unsigned int count, const float * _RGL_RESTRICT v ); void _RGLPlatformSetFragmentRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v );
unsigned int _cgHashString( const char *str ); unsigned int _cgHashString( const char *str );

View File

@ -29,7 +29,7 @@ using namespace cell::Gcm;
#define _RGL_TILED_BUFFER_ALIGNMENT 0x10000 #define _RGL_TILED_BUFFER_ALIGNMENT 0x10000
#define _RGL_TILED_BUFFER_HEIGHT_ALIGNMENT 64 #define _RGL_TILED_BUFFER_HEIGHT_ALIGNMENT 64
#define _RGL_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 RGL_UTIL_LABEL_INDEX 253
@ -153,9 +153,7 @@ static GLboolean _RGLFifoReferenceInUse( RGLFifo *fifo, GLuint reference )
return GL_FALSE; return GL_FALSE;
if ((fifo->lastSWReferenceFlushed - reference) & 0x80000000) if ((fifo->lastSWReferenceFlushed - reference) & 0x80000000)
{
_RGLFifoFlush( fifo ); _RGLFifoFlush( fifo );
}
_RGLFifoReadReference( fifo ); _RGLFifoReadReference( fifo );
@ -172,9 +170,7 @@ static GLuint _RGLFifoPutReference( RGLFifo *fifo )
cellGcmSetReferenceCommandInline(&_RGLState.fifo, fifo->lastSWReferenceWritten); cellGcmSetReferenceCommandInline(&_RGLState.fifo, fifo->lastSWReferenceWritten);
if ((fifo->lastSWReferenceWritten & 0x7fffffff) == 0) if ((fifo->lastSWReferenceWritten & 0x7fffffff) == 0)
{
_RGLFifoFinish(fifo); _RGLFifoFinish(fifo);
}
return fifo->lastSWReferenceWritten; return fifo->lastSWReferenceWritten;
} }
@ -331,7 +327,6 @@ GLboolean _RGLInit( PSGLinitOptions* options, RGLResource *resource )
return GL_TRUE; return GL_TRUE;
} }
void _RGLDestroy(void) void _RGLDestroy(void)
{ {
RGLState *RGLSt = &_RGLState; RGLState *RGLSt = &_RGLState;
@ -553,16 +548,14 @@ static int _RGLInitRM( RGLResource *gcmResource, unsigned int hostMemorySize, in
{ {
memset( gcmResource, 0, sizeof( RGLResource ) ); memset( gcmResource, 0, sizeof( RGLResource ) );
const unsigned int iDPM2DataAreaSize = 0;
dmaPushBufferSize = _RGLPad( dmaPushBufferSize, _RGL_HOST_BUFFER_ALIGNMENT ); dmaPushBufferSize = _RGLPad( dmaPushBufferSize, _RGL_HOST_BUFFER_ALIGNMENT );
gcmResource->hostMemorySize = _RGLPad( _RGL_FIFO_SIZE + hostMemorySize + dmaPushBufferSize + _RGL_DMA_PUSH_BUFFER_PREFETCH_PADDING + iDPM2DataAreaSize + (RGL_LM_MAX_TOTAL_QUERIES * sizeof( GLuint )), 1 << 20 ); gcmResource->hostMemorySize = _RGLPad( FIFO_SIZE + hostMemorySize + dmaPushBufferSize + _RGL_DMA_PUSH_BUFFER_PREFETCH_PADDING + (RGL_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 );
if ( cellGcmInit( _RGL_FIFO_SIZE, gcmResource->hostMemorySize, gcmResource->hostMemoryBase ) != 0 ) if ( cellGcmInit(FIFO_SIZE, gcmResource->hostMemorySize, gcmResource->hostMemoryBase ) != 0 )
{ {
RARCH_ERR("RSXIF failed initialization.\n"); RARCH_ERR("RSXIF failed initialization.\n");
return GL_FALSE; return GL_FALSE;
@ -588,7 +581,7 @@ static int _RGLInitRM( RGLResource *gcmResource, unsigned int hostMemorySize, in
gcmResource->dmaPushBuffer = gcmResource->hostMemoryBase + gcmResource->hostMemorySize; gcmResource->dmaPushBuffer = gcmResource->hostMemoryBase + gcmResource->hostMemorySize;
gcmResource->dmaPushBufferOffset = ( char * )gcmResource->dmaPushBuffer - ( char * )gcmResource->hostMemoryBase; gcmResource->dmaPushBufferOffset = ( char * )gcmResource->dmaPushBuffer - ( char * )gcmResource->hostMemoryBase;
gcmResource->dmaPushBufferSize = dmaPushBufferSize; gcmResource->dmaPushBufferSize = dmaPushBufferSize;
gcmResource->hostMemoryReserved = _RGL_FIFO_SIZE; gcmResource->hostMemoryReserved = FIFO_SIZE;
cellGcmSetJumpCommand(( char * )gcmResource->dmaPushBuffer - ( char * )gcmResource->hostMemoryBase ); cellGcmSetJumpCommand(( char * )gcmResource->dmaPushBuffer - ( char * )gcmResource->hostMemoryBase );
@ -807,7 +800,6 @@ static void _RGLSetDisplayMode( const VideoMode *vm, GLushort bitsPerPixel, GLui
cellVideoOutConfigure( CELL_VIDEO_OUT_PRIMARY, &videocfg, NULL, 0 ); cellVideoOutConfigure( CELL_VIDEO_OUT_PRIMARY, &videocfg, NULL, 0 );
} }
static int _RGLPlatformCreateDevice( PSGLdevice* device ) static int _RGLPlatformCreateDevice( PSGLdevice* device )
{ {
RGLDevice *gcmDevice = ( RGLDevice * )device->platformDevice; RGLDevice *gcmDevice = ( RGLDevice * )device->platformDevice;
@ -825,19 +817,28 @@ static int _RGLPlatformCreateDevice( PSGLdevice* device )
if ( params->enable & PSGL_DEVICE_PARAMETERS_TV_STANDARD ) if ( params->enable & PSGL_DEVICE_PARAMETERS_TV_STANDARD )
{ {
vm = findModeByEnum( params->TVStandard ); vm = findModeByEnum( params->TVStandard );
if ( !vm ) return -1;
if(!vm)
return -1;
params->width = vm->width; params->width = vm->width;
params->height = vm->height; params->height = vm->height;
} }
else if ( params->enable & PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT ) else if ( params->enable & PSGL_DEVICE_PARAMETERS_WIDTH_HEIGHT )
{ {
vm = findModeByResolution( params->width, params->height ); vm = findModeByResolution( params->width, params->height );
if ( !vm ) return -1;
if(!vm)
return -1;
} }
else else
{ {
vm = _RGLDetectVideoMode(); vm = _RGLDetectVideoMode();
if ( !vm ) return -1;
if(!vm)
return -1;
params->width = vm->width; params->width = vm->width;
params->height = vm->height; params->height = vm->height;
} }
@ -983,7 +984,6 @@ static int _RGLPlatformCreateDevice( PSGLdevice* device )
} }
gcmDevice->swapFifoRef = _RGLFifoPutReference( &_RGLState.fifo ); gcmDevice->swapFifoRef = _RGLFifoPutReference( &_RGLState.fifo );
gcmDevice->swapFifoRef2 = gcmDevice->swapFifoRef; gcmDevice->swapFifoRef2 = gcmDevice->swapFifoRef;
return 0; return 0;
@ -1176,7 +1176,7 @@ void psglMakeCurrent( PSGLcontext *context, PSGLdevice *device )
} }
} }
PSGLdevice *psglGetCurrentDevice() PSGLdevice *psglGetCurrentDevice(void)
{ {
return _CurrentDevice; return _CurrentDevice;
} }
@ -1220,7 +1220,10 @@ GLAPI void psglSwap( void )
if ( res != CELL_OK ) if ( res != CELL_OK )
{ {
RARCH_WARN("RESC cellRescSetConvertAndFlip returned error code %d.\n", res); RARCH_WARN("RESC cellRescSetConvertAndFlip returned error code %d.\n", res);
if ( _CurrentContext ) _CurrentContext->needValidate |= PSGL_VALIDATE_FRAMEBUFFER;
if(_CurrentContext)
_CurrentContext->needValidate |= PSGL_VALIDATE_FRAMEBUFFER;
return; return;
} }
} }

View File

@ -3,21 +3,11 @@
#include "rgl.h" #include "rgl.h"
#ifndef OS_VERSION_NUMERIC
#define OS_VERSION_NUMERIC 0x160
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
#ifdef __cplusplus
#define _RGL_EXTERN_C extern "C"
#else
#define _RGL_EXTERN_C
#endif
extern PSGLcontext *_CurrentContext; extern PSGLcontext *_CurrentContext;
extern PSGLdevice *_CurrentDevice; extern PSGLdevice *_CurrentDevice;

View File

@ -27,6 +27,7 @@
#define ENDIAN_32(X, F) ((F) ? endianSwapWord(X) : (X)) #define ENDIAN_32(X, F) ((F) ? endianSwapWord(X) : (X))
#define SWAP_IF_BIG_ENDIAN(arg) endianSwapWordByHalf(arg) #define SWAP_IF_BIG_ENDIAN(arg) endianSwapWordByHalf(arg)
#define ROW_MAJOR 0 #define ROW_MAJOR 0
#define COL_MAJOR 1 #define COL_MAJOR 1
@ -86,8 +87,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)
#define jsMATRIX_SIZEf (sizeof(GLfloat)*ELEMENTS_IN_MATRIX)
enum enum
{ {
M10 = 1, M20, M30, M10 = 1, M20, M30,
@ -98,14 +97,11 @@ enum
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";
static char *_RGLExtensionsString = ""; static char *_RGLExtensionsString = "";
static char *_RGLVersionNumber = "1.0"; static char *_RGLVersionNumber = "1.0";
PSGLcontext* _CurrentContext = NULL; PSGLcontext* _CurrentContext = NULL;
RGLcontextHookFunction _RGLContextCreateHook = NULL; RGLcontextHookFunction _RGLContextCreateHook = NULL;
RGLcontextHookFunction _RGLContextDestroyHook = NULL; RGLcontextHookFunction _RGLContextDestroyHook = NULL;
@ -115,8 +111,9 @@ static volatile uint32_t *pLock = NULL;
static uint32_t cachedLockValue = 0; static uint32_t cachedLockValue = 0;
static GmmFixedAllocData *pGmmFixedAllocData = NULL; static GmmFixedAllocData *pGmmFixedAllocData = NULL;
GLuint nvFenceCounter = 0; GLuint nvFenceCounter = 0;
static const unsigned int capacityIncr = 16;
static const int NAME_INCREMENT = 4; #define CAPACITY_INCR 16
#define NAME_INCREMENT 4
#define DECLARE_TYPE(TYPE,CTYPE,MAXVAL) \ #define DECLARE_TYPE(TYPE,CTYPE,MAXVAL) \
typedef CTYPE type_##TYPE; \ typedef CTYPE type_##TYPE; \
@ -126,8 +123,16 @@ DECLARE_C_TYPES
#undef DECLARE_TYPE #undef DECLARE_TYPE
typedef GLfloat type_GL_FLOAT; typedef GLfloat type_GL_FLOAT;
static inline type_GL_FLOAT _RGLFloatTo_GL_FLOAT( float v ) {return v;}
static inline float _RGLFloatFrom_GL_FLOAT( type_GL_FLOAT v ) {return v;} static inline type_GL_FLOAT _RGLFloatTo_GL_FLOAT(float v)
{
return v;
}
static inline float _RGLFloatFrom_GL_FLOAT(type_GL_FLOAT v)
{
return v;
}
typedef GLhalfARB type_GL_HALF_FLOAT_ARB; typedef GLhalfARB type_GL_HALF_FLOAT_ARB;
@ -146,6 +151,7 @@ const char *findSectionInPlace(const char* memory,unsigned int /*size*/,const ch
size_t sectionCount = ehdr->e_shnum; size_t sectionCount = ehdr->e_shnum;
const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff; const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff;
for(size_t i=0; i < sectionCount; i++) for(size_t i=0; i < sectionCount; i++)
{ {
const Elf32_Shdr *sectionHeader = (const Elf32_Shdr *)sectionHeaderStart + i; const Elf32_Shdr *sectionHeader = (const Elf32_Shdr *)sectionHeaderStart + i;
@ -165,6 +171,7 @@ const char *findSymbolSectionInPlace(const char *memory, unsigned int /*size*/,
size_t sectionCount = ehdr->e_shnum; size_t sectionCount = ehdr->e_shnum;
const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff; const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff;
for(size_t i = 0; i<sectionCount; i++) for(size_t i = 0; i<sectionCount; i++)
{ {
const Elf32_Shdr *sectionHeader = (const Elf32_Shdr *)sectionHeaderStart + i; const Elf32_Shdr *sectionHeader = (const Elf32_Shdr *)sectionHeaderStart + i;
@ -189,9 +196,8 @@ int lookupSymbolValueInPlace(const char* symbolSection, size_t symbolSize, size_
Elf32_Sym* elf_sym = (Elf32_Sym*)symbolSection; Elf32_Sym* elf_sym = (Elf32_Sym*)symbolSection;
if (!strcmp(symbolstrtab + elf_sym->st_name, name)) if (!strcmp(symbolstrtab + elf_sym->st_name, name))
{
return elf_sym->st_value; return elf_sym->st_value;
}
symbolSection += symbolSize; symbolSection += symbolSize;
} }
return -1; return -1;
@ -491,11 +497,14 @@ static void _RGLUnbindBufferObject( PSGLcontext *LContext, GLuint name )
GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name ) GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name )
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
if ( name ) _RGLTexNameSpaceCreateNameLazy( &LContext->bufferObjectNameSpace, name );
if(name)
_RGLTexNameSpaceCreateNameLazy( &LContext->bufferObjectNameSpace, name );
switch ( target ) switch ( target )
{ {
case GL_ARRAY_BUFFER: LContext->ArrayBuffer = name; case GL_ARRAY_BUFFER:
LContext->ArrayBuffer = name;
break; break;
case GL_ELEMENT_ARRAY_BUFFER: case GL_ELEMENT_ARRAY_BUFFER:
break; break;
@ -519,6 +528,7 @@ GLAPI void APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers )
{ {
if ( !_RGLTexNameSpaceIsName( &LContext->bufferObjectNameSpace, buffers[i] ) ) if ( !_RGLTexNameSpaceIsName( &LContext->bufferObjectNameSpace, buffers[i] ) )
continue; continue;
if ( buffers[i] ) if ( buffers[i] )
_RGLUnbindBufferObject( LContext, buffers[i] ); _RGLUnbindBufferObject( LContext, buffers[i] );
} }
@ -539,7 +549,9 @@ static inline jsFramebuffer *_RGLGetFramebuffer( PSGLcontext *LContext, GLuint n
static inline void _RGLTextureTouchFBOs( jsTexture *texture ) static inline void _RGLTextureTouchFBOs( jsTexture *texture )
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
if ( !LContext ) return; if(!LContext)
return;
GLuint fbCount = texture->framebuffers.getCount(); GLuint fbCount = texture->framebuffers.getCount();
if(fbCount > 0) if(fbCount > 0)
{ {
@ -745,7 +757,9 @@ GLAPI void APIENTRY glBufferData( GLenum target, GLsizeiptr size, const GLvoid *
bufferObject = _RGLGetBufferObject( LContext, name ); bufferObject = _RGLGetBufferObject( LContext, name );
} }
if ( bufferObject->size > 0 ) _RGLPlatformDestroyBufferObject( bufferObject ); if (bufferObject->size > 0)
_RGLPlatformDestroyBufferObject( bufferObject );
bufferObject->usage = usage; bufferObject->usage = usage;
bufferObject->size = size; bufferObject->size = size;
bufferObject->width = 0; bufferObject->width = 0;
@ -1169,11 +1183,8 @@ static void _RGLRasterToImage(const jsRaster* raster, jsImage* image)
for ( int j = 0; j < raster->height; ++j ) for ( int j = 0; j < raster->height; ++j )
{ {
const unsigned char *src = ( const unsigned char * )raster->data + const unsigned char *src = ( const unsigned char * )raster->data + j * raster->ystride;
j * raster->ystride; unsigned char *dst = ( unsigned char * )image->data + (j) * image->ystride;
unsigned char *dst = ( unsigned char * )image->data +
( j ) * image->ystride +
0 * image->xstride;
for ( int k = 0; k < raster->width; ++k ) for ( int k = 0; k < raster->width; ++k )
{ {
@ -1286,6 +1297,7 @@ void _RGLPlatformDropTexture( jsTexture *texture )
int _RGLGetPixelSize( GLenum format, GLenum type ) int _RGLGetPixelSize( GLenum format, GLenum type )
{ {
int componentSize; int componentSize;
switch ( type ) switch ( type )
{ {
@ -1305,6 +1317,7 @@ int _RGLGetPixelSize( GLenum format, GLenum type )
default: default:
return 0; return 0;
} }
return _RGLGetComponentCount( format )*componentSize; return _RGLGetComponentCount( format )*componentSize;
} }
@ -1346,6 +1359,7 @@ void _RGLPlatformDropUnboundTextures( GLenum pool )
break; break;
} }
} }
for ( j = 0; j < _RGL_MAX_TEXTURE_IMAGE_UNITS; ++j) for ( j = 0; j < _RGL_MAX_TEXTURE_IMAGE_UNITS; ++j)
{ {
jsTextureImageUnit *tu = LContext->TextureImageUnits + j; jsTextureImageUnit *tu = LContext->TextureImageUnits + j;
@ -1355,6 +1369,7 @@ void _RGLPlatformDropUnboundTextures( GLenum pool )
break; break;
} }
} }
if ( bound ) if ( bound )
continue; continue;
@ -1362,8 +1377,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 && if ( pool != _RGL_SURFACE_POOL_NONE && pool != gcmTexture->pool )
pool != gcmTexture->pool )
continue; continue;
_RGLPlatformDropTexture( texture ); _RGLPlatformDropTexture( texture );
@ -1439,9 +1453,12 @@ static void _RGLPlatformReallocateGcmTexture( jsTexture* texture )
static void _RGLImageFreeCPUStorage( jsImage *image ) static void _RGLImageFreeCPUStorage( jsImage *image )
{ {
if ( !image->mallocData ) return; if (!image->mallocData)
return;
if (image->mallocData != NULL) if (image->mallocData != NULL)
free( image->mallocData ); free( image->mallocData );
image->mallocStorageSize = 0; image->mallocStorageSize = 0;
image->data = NULL; image->data = NULL;
image->mallocData = NULL; image->mallocData = NULL;
@ -1576,7 +1593,9 @@ source: _RGL_SURFACE_SOURCE_TEXTURE,
static void jsPlatformFramebuffer_validate( jsPlatformFramebuffer * fb, PSGLcontext *LContext ) static void jsPlatformFramebuffer_validate( jsPlatformFramebuffer * fb, PSGLcontext *LContext )
{ {
fb->complete = ( _RGLPlatformFramebufferCheckStatus(fb) == GL_FRAMEBUFFER_COMPLETE_OES ); fb->complete = ( _RGLPlatformFramebufferCheckStatus(fb) == GL_FRAMEBUFFER_COMPLETE_OES );
if ( !fb->complete ) return;
if(!fb->complete)
return;
GLuint width = CELL_GCM_MAX_RT_DIMENSION; GLuint width = CELL_GCM_MAX_RT_DIMENSION;
GLuint height = CELL_GCM_MAX_RT_DIMENSION; GLuint height = CELL_GCM_MAX_RT_DIMENSION;
@ -1592,7 +1611,9 @@ static void jsPlatformFramebuffer_validate( jsPlatformFramebuffer * fb, PSGLcont
jsTexture* colorTexture = NULL; jsTexture* colorTexture = NULL;
GLuint face = 0; GLuint face = 0;
_RGLFramebufferGetAttachmentTexture(&fb->color[i], &colorTexture, &face ); _RGLFramebufferGetAttachmentTexture(&fb->color[i], &colorTexture, &face );
if ( colorTexture == NULL ) continue;
if(colorTexture == NULL)
continue;
RGLTexture* nvTexture = ( RGLTexture * )colorTexture->platformTexture; RGLTexture* nvTexture = ( RGLTexture * )colorTexture->platformTexture;
@ -1837,7 +1858,6 @@ GLAPI GLenum APIENTRY glCheckFramebufferStatusOES( GLenum target )
{ {
PSGLcontext *LContext = _CurrentContext; PSGLcontext *LContext = _CurrentContext;
if ( LContext->framebuffer ) if ( LContext->framebuffer )
{ {
jsFramebuffer* framebuffer = _RGLGetFramebuffer( LContext, LContext->framebuffer ); jsFramebuffer* framebuffer = _RGLGetFramebuffer( LContext, LContext->framebuffer );
@ -1975,7 +1995,7 @@ void _RGLEraseName( jsNameSpace* ns, jsName name )
void _RGLTexNameSpaceInit( jsTexNameSpace *ns, jsTexNameSpaceCreateFunction create, jsTexNameSpaceDestroyFunction destroy ) void _RGLTexNameSpaceInit( jsTexNameSpace *ns, jsTexNameSpaceCreateFunction create, jsTexNameSpaceDestroyFunction destroy )
{ {
ns->capacity = capacityIncr; ns->capacity = CAPACITY_INCR;
ns->data = ( void ** )malloc( ns->capacity * sizeof( void* ) ); ns->data = ( void ** )malloc( ns->capacity * sizeof( void* ) );
memset( ns->data, 0, ns->capacity*sizeof( void* ) ); memset( ns->data, 0, ns->capacity*sizeof( void* ) );
ns->create = create; ns->create = create;
@ -2008,8 +2028,11 @@ void _RGLTexNameSpaceResetNames( jsTexNameSpace *ns )
GLuint _RGLTexNameSpaceGetFree( jsTexNameSpace *ns ) GLuint _RGLTexNameSpaceGetFree( jsTexNameSpace *ns )
{ {
GLuint i; GLuint i;
for(i = 1; i < ns->capacity; ++i) for(i = 1; i < ns->capacity; ++i)
if ( !ns->data[i] ) break; if ( !ns->data[i] )
break;
return i; return i;
} }
@ -2017,7 +2040,7 @@ GLboolean _RGLTexNameSpaceCreateNameLazy( jsTexNameSpace *ns, GLuint name )
{ {
if ( name >= ns->capacity ) if ( name >= ns->capacity )
{ {
int newCapacity = name >= ns->capacity + capacityIncr ? name + 1 : ns->capacity + capacityIncr; int newCapacity = name >= ns->capacity + CAPACITY_INCR ? name + 1 : ns->capacity + CAPACITY_INCR;
void **newData = ( void ** )realloc( ns->data, newCapacity * sizeof( void * ) ); void **newData = ( void ** )realloc( ns->data, newCapacity * sizeof( void * ) );
memset( newData + ns->capacity, 0, ( newCapacity - ns->capacity )*sizeof( void * ) ); memset( newData + ns->capacity, 0, ( newCapacity - ns->capacity )*sizeof( void * ) );
ns->data = newData; ns->data = newData;
@ -2033,8 +2056,10 @@ GLboolean _RGLTexNameSpaceCreateNameLazy( jsTexNameSpace *ns, GLuint name )
GLboolean _RGLTexNameSpaceIsName( jsTexNameSpace *ns, GLuint name ) GLboolean _RGLTexNameSpaceIsName( jsTexNameSpace *ns, GLuint name )
{ {
if (( name > 0 ) && ( name < ns->capacity ) ) return( ns->data[name] != 0 ); if (( name > 0 ) && (name < ns->capacity))
else return GL_FALSE; return( ns->data[name] != 0 );
else
return GL_FALSE;
} }
void _RGLTexNameSpaceGenNames( jsTexNameSpace *ns, GLsizei n, GLuint *names ) void _RGLTexNameSpaceGenNames( jsTexNameSpace *ns, GLsizei n, GLuint *names )
@ -2043,7 +2068,9 @@ void _RGLTexNameSpaceGenNames( jsTexNameSpace *ns, GLsizei n, GLuint *names )
{ {
GLuint name = _RGLTexNameSpaceGetFree( ns ); GLuint name = _RGLTexNameSpaceGetFree( ns );
names[i] = name; names[i] = name;
if ( name ) _RGLTexNameSpaceCreateNameLazy( ns, name );
if(name)
_RGLTexNameSpaceCreateNameLazy( ns, name );
} }
} }
@ -2052,7 +2079,10 @@ void _RGLTexNameSpaceDeleteNames( jsTexNameSpace *ns, GLsizei n, const GLuint *n
for ( int i = 0;i < n;++i ) for ( int i = 0;i < n;++i )
{ {
GLuint name = names[i]; GLuint name = names[i];
if ( !_RGLTexNameSpaceIsName( ns, name ) ) continue;
if(!_RGLTexNameSpaceIsName(ns, name))
continue;
ns->destroy( ns->data[name] ); ns->destroy( ns->data[name] );
ns->data[name] = NULL; ns->data[name] = NULL;
} }
@ -2078,29 +2108,32 @@ static uint32_t gmmInitFixedAllocator (void)
int blockSize = (i==0) ? sizeof(GmmBlock): sizeof(GmmTileBlock); int blockSize = (i==0) ? sizeof(GmmBlock): sizeof(GmmTileBlock);
pGmmFixedAllocData->ppBlockList[i] = (char **)malloc(sizeof(char *)); pGmmFixedAllocData->ppBlockList[i] = (char **)malloc(sizeof(char *));
if (pGmmFixedAllocData->ppBlockList[i] == NULL) if (pGmmFixedAllocData->ppBlockList[i] == NULL)
return GMM_ERROR; return GMM_ERROR;
pGmmFixedAllocData->ppBlockList[i][0] = (char *)malloc(blockSize * blockCount); pGmmFixedAllocData->ppBlockList[i][0] = (char *)malloc(blockSize * blockCount);
if (pGmmFixedAllocData->ppBlockList[i][0] == NULL) if (pGmmFixedAllocData->ppBlockList[i][0] == NULL)
return GMM_ERROR; return GMM_ERROR;
pGmmFixedAllocData->ppFreeBlockList[i] = (uint16_t **)malloc(sizeof(uint16_t *)); pGmmFixedAllocData->ppFreeBlockList[i] = (uint16_t **)malloc(sizeof(uint16_t *));
if (pGmmFixedAllocData->ppFreeBlockList[i] == NULL) if (pGmmFixedAllocData->ppFreeBlockList[i] == NULL)
return GMM_ERROR; return GMM_ERROR;
pGmmFixedAllocData->ppFreeBlockList[i][0] = (uint16_t *)malloc(sizeof(uint16_t) * blockCount); pGmmFixedAllocData->ppFreeBlockList[i][0] = (uint16_t *)malloc(sizeof(uint16_t) * blockCount);
if (pGmmFixedAllocData->ppFreeBlockList[i][0] == NULL) if (pGmmFixedAllocData->ppFreeBlockList[i][0] == NULL)
return GMM_ERROR; return GMM_ERROR;
pGmmFixedAllocData->pBlocksUsed[i] = (uint16_t *)malloc(sizeof(uint16_t)); pGmmFixedAllocData->pBlocksUsed[i] = (uint16_t *)malloc(sizeof(uint16_t));
if (pGmmFixedAllocData->pBlocksUsed[i] == NULL) if (pGmmFixedAllocData->pBlocksUsed[i] == NULL)
return GMM_ERROR; return GMM_ERROR;
for (int j=0; j<blockCount; j++) for (int j=0; j<blockCount; j++)
{
pGmmFixedAllocData->ppFreeBlockList[i][0][j] = j; pGmmFixedAllocData->ppFreeBlockList[i][0][j] = j;
}
pGmmFixedAllocData->pBlocksUsed[i][0] = 0; pGmmFixedAllocData->pBlocksUsed[i][0] = 0;
pGmmFixedAllocData->BlockListCount[i] = 1; pGmmFixedAllocData->BlockListCount[i] = 1;
@ -2127,9 +2160,7 @@ static void gmmRemovePendingFree(
pBlock->pPrevFree->pNextFree = pBlock->pNextFree; pBlock->pPrevFree->pNextFree = pBlock->pNextFree;
} }
static uint8_t gmmSizeToFreeIndex( static uint8_t gmmSizeToFreeIndex(uint32_t size)
uint32_t size
)
{ {
if (size >= GMM_FREE_BIN_0 && size < GMM_FREE_BIN_1) if (size >= GMM_FREE_BIN_0 && size < GMM_FREE_BIN_1)
return 0; return 0;
@ -2302,9 +2333,7 @@ static void *gmmAllocFixed(uint8_t isTile)
pGmmFixedAllocData->pBlocksUsed[isTile] = pBlocksUsed; pGmmFixedAllocData->pBlocksUsed[isTile] = pBlocksUsed;
for (int i=0; i<blockCount; i++) for (int i=0; i<blockCount; i++)
{
pGmmFixedAllocData->ppFreeBlockList[isTile][listCount][i] = i; pGmmFixedAllocData->ppFreeBlockList[isTile][listCount][i] = i;
}
pGmmFixedAllocData->pBlocksUsed[isTile][listCount] = 0; pGmmFixedAllocData->pBlocksUsed[isTile][listCount] = 0;
pGmmFixedAllocData->BlockListCount[isTile]++; pGmmFixedAllocData->BlockListCount[isTile]++;
@ -2457,10 +2486,7 @@ static GmmBlock *gmmAllocBlock(GmmAllocator *pAllocator, uint32_t size)
return pNewBlock; return pNewBlock;
} }
static GmmTileBlock *gmmFindFreeTileBlock( static GmmTileBlock *gmmFindFreeTileBlock(GmmAllocator *pAllocator, const uint32_t size)
GmmAllocator *pAllocator,
const uint32_t size
)
{ {
GmmTileBlock *pBlock = pAllocator->pTileHead; GmmTileBlock *pBlock = pAllocator->pTileHead;
GmmTileBlock *pBestAfterBlock = NULL; GmmTileBlock *pBestAfterBlock = NULL;
@ -2506,15 +2532,10 @@ static GmmTileBlock *gmmFindFreeTileBlock(
return pNewBlock; return pNewBlock;
} }
else else
{
return NULL; return NULL;
} }
}
static GmmTileBlock *gmmCreateTileBlock( static GmmTileBlock *gmmCreateTileBlock(GmmAllocator *pAllocator, const uint32_t size)
GmmAllocator *pAllocator,
const uint32_t size
)
{ {
GmmTileBlock *pNewBlock; GmmTileBlock *pNewBlock;
uint32_t address; uint32_t address;
@ -2554,9 +2575,7 @@ static GmmTileBlock *gmmCreateTileBlock(
return pNewBlock; return pNewBlock;
} }
static void gmmFreeTileBlock( static void gmmFreeTileBlock(GmmTileBlock *pTileBlock)
GmmTileBlock *pTileBlock
)
{ {
GmmAllocator *pAllocator; GmmAllocator *pAllocator;
@ -2576,9 +2595,7 @@ static void gmmFreeTileBlock(
pAllocator->pTileHead = pTileBlock->pNext; pAllocator->pTileHead = pTileBlock->pNext;
if (pAllocator->pTileHead) if (pAllocator->pTileHead)
{
pAllocator->pTileHead->pPrev = NULL; pAllocator->pTileHead->pPrev = NULL;
}
pAllocator->size = pAllocator->pTileHead ? pAllocator->size = pAllocator->pTileHead ?
pAllocator->pTileHead->base.address - pAllocator->startAddress : pAllocator->pTileHead->base.address - pAllocator->startAddress :
@ -2594,10 +2611,8 @@ static void gmmFreeTileBlock(
pAllocator->pTileTail = pTileBlock->pPrev; pAllocator->pTileTail = pTileBlock->pPrev;
if (pAllocator->pTileTail) if (pAllocator->pTileTail)
{
pAllocator->pTileTail->pNext = NULL; pAllocator->pTileTail->pNext = NULL;
} }
}
gmmFreeFixed(1, pTileBlock); gmmFreeFixed(1, pTileBlock);
} }
@ -2751,9 +2766,7 @@ static void gmmFreeBlock (GmmBlock *pBlock)
gmmFreeFixed(0, pBlock); gmmFreeFixed(0, pBlock);
} }
static void gmmAddPendingFree( static void gmmAddPendingFree(GmmBlock *pBlock)
GmmBlock *pBlock
)
{ {
GmmAllocator *pAllocator; GmmAllocator *pAllocator;
@ -3216,7 +3229,6 @@ uint32_t gmmAlloc(const uint8_t isTile, const uint32_t size)
if (!isTile) if (!isTile)
{ {
newSize = pad(size, GMM_ALIGNMENT); newSize = pad(size, GMM_ALIGNMENT);
retId = gmmFindFreeBlock(pAllocator, newSize); retId = gmmFindFreeBlock(pAllocator, newSize);
} }
else else
@ -3679,9 +3691,7 @@ static void setSamplerfp( CgRuntimeParameter*ptr, const void*v, int )
const CgParameterResource *parameterResource = _RGLGetParameterResource( program, (( CgRuntimeParameter* )ptr )->parameterEntry ); const CgParameterResource *parameterResource = _RGLGetParameterResource( program, (( CgRuntimeParameter* )ptr )->parameterEntry );
if ( v ) if ( v )
{
*( GLuint* )ptr->pushBufferPointer = *( GLuint* )v; *( GLuint* )ptr->pushBufferPointer = *( GLuint* )v;
}
else else
{ {
jsTextureImageUnit *unit = _CurrentContext->TextureImageUnits + ( parameterResource->resource - CG_TEXUNIT0 ); jsTextureImageUnit *unit = _CurrentContext->TextureImageUnits + ( parameterResource->resource - CG_TEXUNIT0 );
@ -3811,9 +3821,7 @@ static void _RGLCreatePushBuffer( _CGprogram *program )
} }
if (( profileIndex == FRAGMENT_PROFILE_INDEX ) && ( hasSharedParams ) ) if (( profileIndex == FRAGMENT_PROFILE_INDEX ) && ( hasSharedParams ) )
{
bufferSize += 8 + 3 + 2; bufferSize += 8 + 3 + 2;
}
bufferSize = _RGLPad( bufferSize, 4 ); bufferSize = _RGLPad( bufferSize, 4 );
@ -4252,6 +4260,7 @@ static int _RGLGenerateProgram( _CGprogram *program, int profileIndex, const CgP
const CgParameterResource *parameterResource = _RGLGetParameterResource( program, parameterEntry ); const CgParameterResource *parameterResource = _RGLGetParameterResource( program, parameterEntry );
const float *itemDefaultValues = program->defaultValues + program->defaultValuesIndices[i].defaultValueIndex; const float *itemDefaultValues = program->defaultValues + program->defaultValuesIndices[i].defaultValueIndex;
int registerStride = isMatrix(( CGtype )parameterResource->type ) ? _RGLGetTypeRowCount(( CGtype )parameterResource->type ) : 1; int registerStride = isMatrix(( CGtype )parameterResource->type ) ? _RGLGetTypeRowCount(( CGtype )parameterResource->type ) : 1;
if ( parameterEntry->flags & CGP_CONTIGUOUS ) if ( parameterEntry->flags & CGP_CONTIGUOUS )
memcpy( rtParameter->pushBufferPointer, itemDefaultValues, arrayCount * registerStride *4*sizeof( float ) ); memcpy( rtParameter->pushBufferPointer, itemDefaultValues, arrayCount * registerStride *4*sizeof( float ) );
else else
@ -4287,14 +4296,6 @@ static int _RGLGenerateProgram( _CGprogram *program, int profileIndex, const CgP
return 1; return 1;
} }
int _RGLPlatformGenerateFragmentProgram( _CGprogram *program, const CgProgramHeader *programHeader, const void *ucode,
const CgParameterTableHeader *parameterHeader, const char *stringTable, const float *defaultValues )
{
return _RGLGenerateProgram( program, FRAGMENT_PROFILE_INDEX, programHeader, ucode, parameterHeader, NULL, stringTable, defaultValues );
}
void _RGLPlatformVertexProgramErase( void* platformProgram ) void _RGLPlatformVertexProgramErase( void* platformProgram )
{ {
_CGprogram* program = ( _CGprogram* )platformProgram; _CGprogram* program = ( _CGprogram* )platformProgram;
@ -5276,7 +5277,6 @@ PSGLcontext *psglGetCurrentContext()
return _CurrentContext; return _CurrentContext;
} }
const GLfloat _RGLIdentityMatrixf[ELEMENTS_IN_MATRIX] = const GLfloat _RGLIdentityMatrixf[ELEMENTS_IN_MATRIX] =
{ {
1.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f,
@ -5288,7 +5288,7 @@ const GLfloat _RGLIdentityMatrixf[ELEMENTS_IN_MATRIX] =
static void _RGLMatrixStackReset( jsMatrixStack* LMatrixStack ) static void _RGLMatrixStackReset( jsMatrixStack* LMatrixStack )
{ {
LMatrixStack->MatrixStackPtr = 0; LMatrixStack->MatrixStackPtr = 0;
memcpy( LMatrixStack->MatrixStackf, _RGLIdentityMatrixf, jsMATRIX_SIZEf ); memcpy( LMatrixStack->MatrixStackf, _RGLIdentityMatrixf, sizeof(GLfloat)*ELEMENTS_IN_MATRIX );
LMatrixStack->dirty = GL_TRUE; LMatrixStack->dirty = GL_TRUE;
} }
@ -5359,9 +5359,7 @@ static void _RGLResetContext( PSGLcontext *LContext )
tu->currentTexture = NULL; tu->currentTexture = NULL;
} }
for ( int i = 0;i < _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;++i ) for ( int i = 0;i < _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;++i )
{
LContext->VertexTextureImages[i] = NULL; LContext->VertexTextureImages[i] = NULL;
}
LContext->ActiveTexture = 0; LContext->ActiveTexture = 0;
LContext->CurrentImageUnit = LContext->TextureImageUnits; LContext->CurrentImageUnit = LContext->TextureImageUnits;
@ -5396,8 +5394,10 @@ static void _RGLResetContext( PSGLcontext *LContext )
static void _RGLMatrixStackInit( jsMatrixStack* LMatrixStack, GLuint depth ) static void _RGLMatrixStackInit( jsMatrixStack* LMatrixStack, GLuint depth )
{ {
LMatrixStack->MatrixStackf = ( GLfloat * )malloc( jsMATRIX_SIZEf * depth ); LMatrixStack->MatrixStackf = (GLfloat *)malloc( sizeof(GLfloat)*ELEMENTS_IN_MATRIX * depth );
if ( !LMatrixStack->MatrixStackf ) return;
if (!LMatrixStack->MatrixStackf)
return;
_RGLMatrixStackReset( LMatrixStack ); _RGLMatrixStackReset( LMatrixStack );
} }
@ -5573,9 +5573,7 @@ void psglDestroyContext( PSGLcontext* LContext )
_RGLTexNameSpaceFree( &LContext->attribSetNameSpace ); _RGLTexNameSpaceFree( &LContext->attribSetNameSpace );
if ( _CurrentContext == LContext ) if ( _CurrentContext == LContext )
{
psglMakeCurrent( NULL, NULL ); psglMakeCurrent( NULL, NULL );
}
if(LContext != NULL) if(LContext != NULL)
free( LContext ); free( LContext );
@ -5626,7 +5624,7 @@ GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params )
_RGLSetError( GL_INVALID_ENUM ); _RGLSetError( GL_INVALID_ENUM );
return; return;
} }
memcpy( params, LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr * ELEMENTS_IN_MATRIX, jsMATRIX_SIZEf ); memcpy( params, LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr * ELEMENTS_IN_MATRIX, sizeof(GLfloat)*ELEMENTS_IN_MATRIX );
} }
GLAPI void APIENTRY glEnable( GLenum cap ) GLAPI void APIENTRY glEnable( GLenum cap )
@ -5646,22 +5644,18 @@ GLAPI void APIENTRY glEnable( GLenum cap )
LContext->BlendingMrt[2] = GL_TRUE; LContext->BlendingMrt[2] = GL_TRUE;
LContext->needValidate |= PSGL_VALIDATE_BLENDING; LContext->needValidate |= PSGL_VALIDATE_BLENDING;
break; break;
case GL_BLEND_MRT0_SCE: case GL_BLEND_MRT0_SCE:
LContext->Blending = GL_TRUE; LContext->Blending = GL_TRUE;
LContext->needValidate |= PSGL_VALIDATE_BLENDING; LContext->needValidate |= PSGL_VALIDATE_BLENDING;
break; break;
case GL_BLEND_MRT1_SCE: case GL_BLEND_MRT1_SCE:
LContext->BlendingMrt[0] = GL_TRUE; LContext->BlendingMrt[0] = GL_TRUE;
LContext->needValidate |= PSGL_VALIDATE_BLENDING; LContext->needValidate |= PSGL_VALIDATE_BLENDING;
break; break;
case GL_BLEND_MRT2_SCE: case GL_BLEND_MRT2_SCE:
LContext->BlendingMrt[1] = GL_TRUE; LContext->BlendingMrt[1] = GL_TRUE;
LContext->needValidate |= PSGL_VALIDATE_BLENDING; LContext->needValidate |= PSGL_VALIDATE_BLENDING;
break; break;
case GL_BLEND_MRT3_SCE: case GL_BLEND_MRT3_SCE:
LContext->BlendingMrt[2] = GL_TRUE; LContext->BlendingMrt[2] = GL_TRUE;
LContext->needValidate |= PSGL_VALIDATE_BLENDING; LContext->needValidate |= PSGL_VALIDATE_BLENDING;
@ -5871,13 +5865,14 @@ void psglExit (void)
#undef __STRICT_ANSI__ #undef __STRICT_ANSI__
GLAPI void APIENTRY glLoadIdentity() GLAPI void APIENTRY glLoadIdentity(void)
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
jsMatrixStack* LMatrixStack = NULL; jsMatrixStack* LMatrixStack = NULL;
jsContextGetMatrixStack(LContext, LContext->MatrixMode, LMatrixStack); jsContextGetMatrixStack(LContext, LContext->MatrixMode, LMatrixStack);
memcpy( LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr*ELEMENTS_IN_MATRIX, _RGLIdentityMatrixf, jsMATRIX_SIZEf );
memcpy( LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr * ELEMENTS_IN_MATRIX, _RGLIdentityMatrixf, sizeof(GLfloat)*ELEMENTS_IN_MATRIX );
LMatrixStack->dirty = GL_TRUE; LMatrixStack->dirty = GL_TRUE;
} }
@ -5895,6 +5890,7 @@ GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLflo
GLfloat *LMatrix = NULL; GLfloat *LMatrix = NULL;
jsContextGetMatrixStack(LContext, LContext->MatrixMode, LMatrixStack); jsContextGetMatrixStack(LContext, LContext->MatrixMode, LMatrixStack);
if (LMatrixStack) if (LMatrixStack)
LMatrix = LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr * ELEMENTS_IN_MATRIX; LMatrix = LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr * ELEMENTS_IN_MATRIX;
@ -5950,8 +5946,6 @@ GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLflo
LContext->InverseModelViewValid = GL_FALSE; LContext->InverseModelViewValid = GL_FALSE;
} }
const uint32_t c_rounded_size_of_RGLDrawParams = (sizeof(jsDrawParams)+0x7f)&~0x7f;
static uint8_t s_dparams_buff[ c_rounded_size_of_RGLDrawParams ] __attribute__((aligned(128)));
int _psglCheckDrawElementsVBOBounds = 0; int _psglCheckDrawElementsVBOBounds = 0;
@ -6195,6 +6189,8 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams, GLboolean *isMa
GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ) GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
{ {
static uint8_t s_dparams_buff[ (sizeof(jsDrawParams) + 0x7f) & ~0x7f ] __attribute__((aligned(128)));
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
jsAttributeState* as = LContext->attribs; jsAttributeState* as = LContext->attribs;
RGLDriver *driver= (RGLDriver *)_CurrentDevice->rasterDriver; RGLDriver *driver= (RGLDriver *)_CurrentDevice->rasterDriver;
@ -6202,7 +6198,7 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
if ( RGL_UNLIKELY( ! RGLBIT_GET( LContext->attribs->EnabledMask, _RGL_ATTRIB_POSITION_INDEX ) ) ) return; if ( RGL_UNLIKELY( ! RGLBIT_GET( LContext->attribs->EnabledMask, _RGL_ATTRIB_POSITION_INDEX ) ) ) return;
uint32_t _tmp_clear_loop = c_rounded_size_of_RGLDrawParams >> 7; uint32_t _tmp_clear_loop = ((sizeof(jsDrawParams) + 0x7f) & ~0x7f) >> 7;
do{ do{
--_tmp_clear_loop; --_tmp_clear_loop;
@ -6230,8 +6226,10 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
jsAttribute* attrib = as->attrib + i; jsAttribute* attrib = as->attrib + i;
const GLuint freq = attrib->frequency; const GLuint freq = attrib->frequency;
GLuint count; GLuint count;
if (RGLBIT_GET(as->ModuloMask, i)) if (RGLBIT_GET(as->ModuloMask, i))
count = maxElements > freq ? freq : maxElements; else count = maxElements > freq ? freq : maxElements;
else
count = ( maxElements + freq - 1 ) / freq; count = ( maxElements + freq - 1 ) / freq;
const GLuint numBytes = attrib->clientStride * count; const GLuint numBytes = attrib->clientStride * count;
@ -6254,6 +6252,7 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName ); jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName );
uint32_t totalXfer = 0; uint32_t totalXfer = 0;
for (GLuint i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i) for (GLuint i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i)
totalXfer += dparams->attribXferSize[i]; totalXfer += dparams->attribXferSize[i];
@ -6382,11 +6381,17 @@ GLAPI void APIENTRY glBindTexture( GLenum target, GLuint name )
static void _RGLReallocateImages( jsTexture *texture, GLsizei dimension ) static void _RGLReallocateImages( jsTexture *texture, GLsizei dimension )
{ {
GLuint oldCount = texture->imageCount; GLuint oldCount = texture->imageCount;
if ( dimension <= 0 ) dimension = 1;
if ( dimension <= 0 )
dimension = 1;
GLuint n = 1 + _RGLLog2( dimension ); GLuint n = 1 + _RGLLog2( dimension );
n = MAX( n, oldCount ); n = MAX( n, oldCount );
jsImage *images = ( jsImage * )realloc( texture->image, n * sizeof( jsImage ) ); jsImage *images = ( jsImage * )realloc( texture->image, n * sizeof( jsImage ) );
memset( images + oldCount, 0, ( n - oldCount )*sizeof( jsImage ) ); memset( images + oldCount, 0, ( n - oldCount )*sizeof( jsImage ) );
texture->image = images; texture->image = images;
texture->imageCount = n; texture->imageCount = n;
} }
@ -6408,8 +6413,7 @@ static int _RGLGetImage( GLenum target, GLint level, jsTexture **texture, jsImag
GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalFormat, GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLint border, GLenum format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
GLenum type, const GLvoid *pixels )
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
jsTexture *texture; jsTexture *texture;
@ -6441,14 +6445,8 @@ GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalForm
(( const GLubyte* )pixels - ( const GLubyte* )NULL ); (( const GLubyte* )pixels - ( const GLubyte* )NULL );
} }
_RGLSetImage( _RGLSetImage(image, internalFormat, width, height, 1, LContext->unpackAlignment,
image, format, type, pixels);
internalFormat,
width, height, 1,
LContext->unpackAlignment,
format, type,
pixels );
if ( LContext->PixelUnpackBuffer != 0 ) if ( LContext->PixelUnpackBuffer != 0 )
{ {
@ -6471,7 +6469,6 @@ GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalForm
if (!pBaseBlock->isTile) if (!pBaseBlock->isTile)
{ {
GmmBlock *pBlock = (GmmBlock *)jsBuffer->bufferId; GmmBlock *pBlock = (GmmBlock *)jsBuffer->bufferId;
pBlock->isPinned = 0; pBlock->isPinned = 0;
} }
} }
@ -6494,14 +6491,12 @@ GLAPI void APIENTRY glActiveTexture( GLenum texture )
LContext->CurrentCoordsUnit = unit < _RGL_MAX_TEXTURE_COORDS ? LContext->TextureCoordsUnits + unit : NULL; LContext->CurrentCoordsUnit = unit < _RGL_MAX_TEXTURE_COORDS ? LContext->TextureCoordsUnits + unit : NULL;
} }
GLAPI void APIENTRY glClientActiveTexture( GLenum texture ) GLAPI void APIENTRY glClientActiveTexture( GLenum texture )
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
LContext->CS_ActiveTexture = texture - GL_TEXTURE0; LContext->CS_ActiveTexture = texture - GL_TEXTURE0;
} }
GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ) GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param )
{ {
PSGLcontext* LContext = _CurrentContext; PSGLcontext* LContext = _CurrentContext;
@ -6628,7 +6623,9 @@ void _RGLCgProgramErase( _CGprogram* prog )
break; break;
} }
if ( prog->id ) _RGLEraseName( &_CurrentContext->cgProgramNameSpace, ( jsName )prog->id ); if ( prog->id )
_RGLEraseName( &_CurrentContext->cgProgramNameSpace, ( jsName )prog->id );
if ( prog->runtimeElf ) if ( prog->runtimeElf )
free( prog->runtimeElf ); free( prog->runtimeElf );
@ -6699,22 +6696,27 @@ static bool cgOpenElf( const void *ptr, size_t size, CGELFBinary *elfBinary )
{ {
while(1) while(1)
{ {
size_t shadertabSize;
size_t consttabSize;
size_t strtabSize;
size_t symbolSize; size_t symbolSize;
size_t symbolCount; size_t symbolCount;
const char *symbolstrtab; const char *symbolstrtab;
const char *symtab = findSymbolSectionInPlace(( const char * )ptr, size, &symbolSize, &symbolCount, &symbolstrtab ); const char *symtab = findSymbolSectionInPlace(( const char * )ptr, size, &symbolSize, &symbolCount, &symbolstrtab );
if ( !symtab ) if ( !symtab )
break; break;
size_t shadertabSize;
const char *shadertab = findSectionInPlace(( const char* )ptr, size, ".shadertab", &shadertabSize ); const char *shadertab = findSectionInPlace(( const char* )ptr, size, ".shadertab", &shadertabSize );
if ( !shadertab ) if ( !shadertab )
break; break;
size_t strtabSize;
const char *strtab = findSectionInPlace(( const char* )ptr, size, ".strtab", &strtabSize ); const char *strtab = findSectionInPlace(( const char* )ptr, size, ".strtab", &strtabSize );
if ( !strtab ) if ( !strtab )
break; break;
size_t consttabSize;
const char *consttab = findSectionInPlace(( const char* )ptr, size, ".const", &consttabSize ); const char *consttab = findSectionInPlace(( const char* )ptr, size, ".const", &consttabSize );
if ( !consttab ) if ( !consttab )
break; break;
@ -6770,6 +6772,7 @@ static bool cgGetElfProgramByName( CGELFBinary *elfBinary, const char *name, CGE
{ {
//if no name try to return the first program //if no name try to return the first program
int res; int res;
if ( name == NULL || name[0] == '\0' ) if ( name == NULL || name[0] == '\0' )
res = 0; res = 0;
else else
@ -6814,7 +6817,6 @@ static CGprogram _RGLCgCreateProgram( CGcontext ctx, CGprofile profile, const Cg
} }
prog->id = id; prog->id = id;
//hack to counter removal of TypeC during beta
if ( profile == ( CGprofile )7005 ) if ( profile == ( CGprofile )7005 )
profile = CG_PROFILE_SCE_VP_RSX; profile = CG_PROFILE_SCE_VP_RSX;
if ( profile == ( CGprofile )7006 ) if ( profile == ( CGprofile )7006 )
@ -6833,7 +6835,7 @@ static CGprogram _RGLCgCreateProgram( CGcontext ctx, CGprofile profile, const Cg
case CG_PROFILE_SCE_FP_TYPEB: case CG_PROFILE_SCE_FP_TYPEB:
//case CG_PROFILE_SCE_FP_TYPEC: //case CG_PROFILE_SCE_FP_TYPEC:
case CG_PROFILE_SCE_FP_RSX: case CG_PROFILE_SCE_FP_RSX:
success = _RGLPlatformGenerateFragmentProgram( prog, programHeader, ucode, parameterHeader, stringTable, defaultValues ); success = _RGLGenerateProgram( prog, FRAGMENT_PROFILE_INDEX, programHeader, ucode, parameterHeader, NULL, stringTable, defaultValues );
break; break;
default: default:
// should never reach here // should never reach here
@ -6869,19 +6871,12 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx,
const char** args ) const char** args )
{ {
// Load a program from a memory pointer. // Load a program from a memory pointer.
// NOTE: in our API all programs are pre-compiled binaries
// so entry point and compiler arguments are ignored.
//hack to counter removal of TypeC during beta
if ( profile == ( CGprofile )7005 ) if ( profile == ( CGprofile )7005 )
profile = CG_PROFILE_SCE_VP_RSX; profile = CG_PROFILE_SCE_VP_RSX;
if ( profile == ( CGprofile )7006 ) if ( profile == ( CGprofile )7006 )
profile = CG_PROFILE_SCE_FP_RSX; profile = CG_PROFILE_SCE_FP_RSX;
//hack to counter change of defines for program_type at r5294
// previously CG_BINARY was defined the same as CG_ROW_MAJOR
// if those values are passed in here, move them to the new values and remove this hack after we have
// an sdk that incorporates these changes so that prebuild libs (aka debugfont) can be used meanwhile
if ( program_type == CG_ROW_MAJOR ) if ( program_type == CG_ROW_MAJOR )
program_type = CG_BINARY; program_type = CG_BINARY;
@ -6924,12 +6919,11 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx,
//At that point we have a binary file which is either any ELF or an NV format file //At that point we have a binary file which is either any ELF or an NV format file
const unsigned int ElfTag = 0x7F454C46; // == MAKEFOURCC(0x7F,'E','L','F'); const unsigned int ElfTag = 0x7F454C46; // == MAKEFOURCC(0x7F,'E','L','F');
if (!(*( unsigned int* )binaryBuffer == ElfTag)) if (!(*( unsigned int* )binaryBuffer == ElfTag))
{ {
//we have an NV file, convert it to the runtime format //convert NV file to the runtime format
// if it was initially binary, throw warning about old format and recommend conversion to new with cgnv2elf
// don't throw the warning if it was source, cause clearly that would have been on purpose.
if ( program_type == CG_BINARY ) if ( program_type == CG_BINARY )
{ {
RARCH_WARN("A binary shader is being loaded using a deprecated binary format. Please use the cgnv2elf tool to convert to the new, memory-saving, faster-loading format.\n"); RARCH_WARN("A binary shader is being loaded using a deprecated binary format. Please use the cgnv2elf tool to convert to the new, memory-saving, faster-loading format.\n");
@ -6941,8 +6935,10 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx,
STL_NAMESPACE vector<float> defaultValuesArray; STL_NAMESPACE vector<float> defaultValuesArray;
CgBinaryProgram* nvProgram = ( CgBinaryProgram* )binaryBuffer; CgBinaryProgram* nvProgram = ( CgBinaryProgram* )binaryBuffer;
char *runtimeElfShader = NULL; char *runtimeElfShader = NULL;
//check the endianness //check the endianness
int totalSize; int totalSize;
if (( nvProgram->profile != CG_PROFILE_SCE_FP_TYPEB ) && ( nvProgram->profile != CG_PROFILE_SCE_VP_TYPEB ) && if (( nvProgram->profile != CG_PROFILE_SCE_FP_TYPEB ) && ( nvProgram->profile != CG_PROFILE_SCE_VP_TYPEB ) &&
( nvProgram->profile != ( CGprofile )7006 ) && ( nvProgram->profile != ( CGprofile )7005 ) && ( nvProgram->profile != ( CGprofile )7006 ) && ( nvProgram->profile != ( CGprofile )7005 ) &&
( nvProgram->profile != CG_PROFILE_SCE_FP_RSX ) && ( nvProgram->profile != CG_PROFILE_SCE_VP_RSX ) ) ( nvProgram->profile != CG_PROFILE_SCE_FP_RSX ) && ( nvProgram->profile != CG_PROFILE_SCE_VP_RSX ) )
@ -6951,6 +6947,7 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx,
} }
else else
totalSize = nvProgram->totalSize; totalSize = nvProgram->totalSize;
int res = convertNvToElfFromMemory( binaryBuffer, totalSize, 2, 0, ( void** ) & runtimeElfShader, &compiled_program_size, stringTableArray, defaultValuesArray ); int res = convertNvToElfFromMemory( binaryBuffer, totalSize, 2, 0, ( void** ) & runtimeElfShader, &compiled_program_size, stringTableArray, defaultValuesArray );
if ( res != 0 ) if ( res != 0 )
{ {
@ -6969,6 +6966,7 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx,
int paddedSize = _RGLPad( compiled_program_size, 4 ); int paddedSize = _RGLPad( compiled_program_size, 4 );
char *runtimeElf = (char*)memalign( 16, paddedSize + stringTableSize + defaultTableSize ); char *runtimeElf = (char*)memalign( 16, paddedSize + stringTableSize + defaultTableSize );
if ( !runtimeElf ) if ( !runtimeElf )
{ {
_RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR ); _RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR );
@ -7122,10 +7120,8 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx,
if ( entry == NULL ) if ( entry == NULL )
{ {
if ( group->programCount == 1 ) if ( group->programCount == 1 )
{
ret = _RGLCgUpdateProgramAtIndex( group, 0, 1 ); ret = _RGLCgUpdateProgramAtIndex( group, 0, 1 );
} }
}
else else
{ {
int index = _RGLCgGetProgramIndex( group, entry ); int index = _RGLCgGetProgramIndex( group, entry );
@ -7134,11 +7130,9 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx,
RARCH_ERR("Couldn't find the shader entry in the CG binary.\n"); RARCH_ERR("Couldn't find the shader entry in the CG binary.\n");
} }
else else
{
ret = _RGLCgUpdateProgramAtIndex( group, index, 1 ); ret = _RGLCgUpdateProgramAtIndex( group, index, 1 );
} }
} }
}
return ret; return ret;
} }
} }
@ -7171,9 +7165,7 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx,
fclose( fp ); fclose( fp );
if ( program_type == CG_SOURCE ) if ( program_type == CG_SOURCE )
{
ptr[file_size] = '\0'; ptr[file_size] = '\0';
}
CGprogram ret = cgCreateProgram( ctx, program_type, ptr, profile, entry, args ); CGprogram ret = cgCreateProgram( ctx, program_type, ptr, profile, entry, args );
@ -7578,21 +7570,6 @@ CG_API const char* cgGetProfileString( CGprofile profile )
return ""; return "";
} }
CG_API CGprofile cgGetProfile( const char* profile_string )
{
size_t arraysize = sizeof( RGLcgProfileMap ) / sizeof( RGLcgProfileMapType );
unsigned int i = 0;
while ( i < arraysize )
{
if ( strcmp( RGLcgProfileMap[i].string, profile_string ) == 0 )
{
return RGLcgProfileMap[i].id;
}
++i;
}
return CG_PROFILE_UNKNOWN;
}
CG_API CGerror cgGetError(void) CG_API CGerror cgGetError(void)
{ {
CGerror err = _CurrentContext->RGLcgLastError; CGerror err = _CurrentContext->RGLcgLastError;
@ -7623,7 +7600,6 @@ static int _RGLGetSizeofSubArray( const short *dimensions, int count )
return res; return res;
} }
static _CGparameter *_cgGetNamedParameter( _CGprogram* progPtr, const char* name, CGenum name_space, int *arrayIndex, const CgParameterEntry *_startEntry = NULL, int _entryCount = -1 ) static _CGparameter *_cgGetNamedParameter( _CGprogram* progPtr, const char* name, CGenum name_space, int *arrayIndex, const CgParameterEntry *_startEntry = NULL, int _entryCount = -1 )
{ {
if ( name == NULL ) if ( name == NULL )
@ -7891,7 +7867,6 @@ CGGL_API void cgGLEnableProfile( CGprofile profile )
LContext->VertexProgram = GL_TRUE; LContext->VertexProgram = GL_TRUE;
LContext->needValidate |= PSGL_VALIDATE_VERTEX_PROGRAM | PSGL_VALIDATE_VERTEX_TEXTURES_USED; LContext->needValidate |= PSGL_VALIDATE_VERTEX_PROGRAM | PSGL_VALIDATE_VERTEX_TEXTURES_USED;
break; break;
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_TRUE; LContext->FragmentProgram = GL_TRUE;
@ -7962,12 +7937,6 @@ CGGL_API void cgGLLoadProgram( CGprogram program )
{ {
} }
CGGL_API CGbool cgGLIsProgramLoaded( CGprogram program )
{
return CG_TRUE;
}
CGGL_API void cgGLBindProgram( CGprogram program ) CGGL_API void cgGLBindProgram( CGprogram program )
{ {
_CGprogram* ptr = _cgGetProgPtr( program ); _CGprogram* ptr = _cgGetProgPtr( program );
@ -8031,14 +8000,6 @@ CGGL_API void cgGLUnbindProgram( CGprofile profile )
} }
CGGL_API GLuint cgGLGetProgramID( CGprogram program )
{
return 0;
}
CGGL_API void cgGLEnableProgramProfiles( CGprogram program ) {}
CGGL_API void cgGLDisableProgramProfiles( CGprogram program ) {}
CGGL_API void cgGLSetParameter1f( CGparameter param, float x ) CGGL_API void cgGLSetParameter1f( CGparameter param, float x )
{ {
CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param ); CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param );
@ -8091,10 +8052,8 @@ CGGL_API void cgGLDisableClientState( CGparameter param )
{ {
CgRuntimeParameter *_ptr = _RGLCgGLTestParameter( param ); CgRuntimeParameter *_ptr = _RGLCgGLTestParameter( param );
const CgParameterResource *parameterResource = _RGLGetParameterResource( _ptr->program, _ptr->parameterEntry ); const CgParameterResource *parameterResource = _RGLGetParameterResource( _ptr->program, _ptr->parameterEntry );
GLuint index = ( GLuint )( parameterResource->resource - CG_ATTR0 ); GLuint index = ( GLuint )( parameterResource->resource - CG_ATTR0 );
_RGLDisableVertexAttribArrayNV( index ); _RGLDisableVertexAttribArrayNV( index );
} }
@ -8185,7 +8144,9 @@ static void _RGLCgContextPushFront( _CGcontext* ctx )
static void destroy_context(_CGcontext*ctx) static void destroy_context(_CGcontext*ctx)
{ {
if ( _cgContextDestroyHook ) _cgContextDestroyHook( ctx ); if (_cgContextDestroyHook)
_cgContextDestroyHook(ctx);
_RGLEraseName( &_CurrentContext->cgContextNameSpace, ( jsName )ctx->id ); _RGLEraseName( &_CurrentContext->cgContextNameSpace, ( jsName )ctx->id );
_RGLCgContextZero( ctx ); _RGLCgContextZero( ctx );
free( ctx ); free( ctx );

View File

@ -167,19 +167,6 @@ struct jsFramebuffer
#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)
#ifndef MSVC
#define ALIGN16 __attribute__((aligned (16)))
#define _RGL_RESTRICT __restrict
#else
#define ALIGN16
#define _RGL_RESTRICT
#pragma warning( push )
#pragma warning ( disable : 4200 )
#endif
typedef intptr_t RGLintptr;
typedef size_t RGLsizeiptr;
typedef struct typedef struct
{ {
GLfloat X, Y , Z, W; GLfloat X, Y , Z, W;
@ -454,8 +441,7 @@ typedef struct
GLfloat value[4]; GLfloat value[4];
GLuint frequency; GLuint frequency;
GLboolean normalized; GLboolean normalized;
} } __attribute__((aligned (16))) jsAttribute;
ALIGN16 jsAttribute;
typedef struct typedef struct
{ {
@ -465,8 +451,7 @@ typedef struct
unsigned int NeedsConversionMask; unsigned int NeedsConversionMask;
unsigned int HasVBOMask; unsigned int HasVBOMask;
unsigned int ModuloMask; unsigned int ModuloMask;
} } __attribute__((aligned (16))) jsAttributeState;
ALIGN16 jsAttributeState;
typedef struct typedef struct
{ {
@ -475,8 +460,7 @@ typedef struct
unsigned int beenUpdatedMask; unsigned int beenUpdatedMask;
GLvoid* cmdBuffer; GLvoid* cmdBuffer;
GLuint cmdNumWords; GLuint cmdNumWords;
} } __attribute__((aligned (16))) jsAttribSet;
ALIGN16 jsAttribSet;
struct jsBufferObject struct jsBufferObject
{ {
@ -506,8 +490,7 @@ typedef struct jsNameSpace
void** data; void** data;
void** firstFree; void** firstFree;
unsigned long capacity; unsigned long capacity;
} } jsNameSpace;
jsNameSpace;
typedef void *( *jsTexNameSpaceCreateFunction )( void ); typedef void *( *jsTexNameSpaceCreateFunction )( void );
typedef void( *jsTexNameSpaceDestroyFunction )( void * ); typedef void( *jsTexNameSpaceDestroyFunction )( void * );
@ -607,10 +590,6 @@ struct PSGLcontext
if (mMatrixStack) mMatrix = (mMatrixStack)->MatrixStackf+(mMatrixStack)->MatrixStackPtr*ELEMENTS_IN_MATRIX;\ if (mMatrixStack) mMatrix = (mMatrixStack)->MatrixStackf+(mMatrixStack)->MatrixStackPtr*ELEMENTS_IN_MATRIX;\
} while (0) } while (0)
#if defined(MSVC)
#pragma warning ( pop )
#endif
#define MAX(A,B) ((A)>(B)?(A):(B)) #define MAX(A,B) ((A)>(B)?(A):(B))
#define MIN(A,B) ((A)<(B)?(A):(B)) #define MIN(A,B) ((A)<(B)?(A):(B))
#define RGL_LIKELY(COND) (COND) #define RGL_LIKELY(COND) (COND)
@ -648,7 +627,7 @@ static inline unsigned long _RGLPad( unsigned long x, unsigned long pad )
static inline char* _RGLPadPtr(const char* p, unsigned int pad) static inline char* _RGLPadPtr(const char* p, unsigned int pad)
{ {
RGLintptr x = ( RGLintptr )p; intptr_t x = (intptr_t)p;
x = ( x + pad - 1 ) / pad * pad; x = ( x + pad - 1 ) / pad * pad;
return ( char* )x; return ( char* )x;
} }