From ec827d862bf394bb7de374092b0d7973aeb581f6 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 23 Jul 2012 14:14:38 +0200 Subject: [PATCH] (RGL) Cleanups --- Makefile.psl1ght | 2 +- console/rgl/ps3/cgbio.hpp | 105 +-- console/rgl/ps3/cgnv2rt.h | 78 +- console/rgl/ps3/device_ctx.cpp | 3 +- console/rgl/ps3/gl.h | 90 +-- console/rgl/ps3/glext.h | 36 +- console/rgl/ps3/private.h | 339 ++++----- console/rgl/ps3/readelf.h | 68 +- console/rgl/ps3/rgl.cpp | 491 +++++------- console/rgl/ps3/rgl.h | 1295 ++++++++++++++++---------------- ps3/sdk_defines.h | 8 + 11 files changed, 1191 insertions(+), 1324 deletions(-) diff --git a/Makefile.psl1ght b/Makefile.psl1ght index 885b01a8f4..0d8c29b044 100644 --- a/Makefile.psl1ght +++ b/Makefile.psl1ght @@ -26,7 +26,7 @@ LIBS := -lretro_psl1ght -laudio -lEGL -lGL -lio -lm -ljpgdec -lpngdec -lsysutil OBJ = console/griffin/griffin.o console/rzlib/rzlib.o -#OBJ += console/rgl/ps3/device_ctx.o console/rgl/ps3/rgl.o console/rgl/ps3/cgbio.o console/rgl/ps3/cgnv2rt.o +OBJ += console/rgl/ps3/device_ctx.o console/rgl/ps3/rgl.o console/rgl/ps3/cgbio.o console/rgl/ps3/cgnv2rt.o ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER diff --git a/console/rgl/ps3/cgbio.hpp b/console/rgl/ps3/cgbio.hpp index 69a8525710..53b3915841 100644 --- a/console/rgl/ps3/cgbio.hpp +++ b/console/rgl/ps3/cgbio.hpp @@ -14,16 +14,17 @@ typedef size_t ptrdiff_t; typedef size_t ptrdiff_t; -typedef struct _Elf32_cgParameter { - unsigned int cgp_name; - unsigned int cgp_semantic; - unsigned short cgp_default; - unsigned short cgp_reloc; - unsigned short cgp_resource; - unsigned short cgp_resource_index; - unsigned char cgp_type; - unsigned short cgp_info; - unsigned char unused; +typedef struct _Elf32_cgParameter +{ + unsigned int cgp_name; + unsigned int cgp_semantic; + unsigned short cgp_default; + unsigned short cgp_reloc; + unsigned short cgp_resource; + unsigned short cgp_resource_index; + unsigned char cgp_type; + unsigned short cgp_info; + unsigned char unused; } Elf32_cgParameter; #define ET_NONE 0 @@ -173,21 +174,22 @@ typedef struct _Elf32_cgParameter { #define R_RSX_NONE 0 #define R_RSX_FLOAT4 1 -struct Elf32_Ehdr { - unsigned char e_ident[EI_NIDENT]; - unsigned short e_type; - unsigned short e_machine; - unsigned int e_version; - unsigned int e_entry; - unsigned int e_phoff; - unsigned int e_shoff; - unsigned int e_flags; - unsigned short e_ehsize; - unsigned short e_phentsize; - unsigned short e_phnum; - unsigned short e_shentsize; - unsigned short e_shnum; - unsigned short e_shstrndx; +struct Elf32_Ehdr +{ + unsigned char e_ident[EI_NIDENT]; + unsigned short e_type; + unsigned short e_machine; + unsigned int e_version; + unsigned int e_entry; + unsigned int e_phoff; + unsigned int e_shoff; + unsigned int e_flags; + unsigned short e_ehsize; + unsigned short e_phentsize; + unsigned short e_phnum; + unsigned short e_shentsize; + unsigned short e_shnum; + unsigned short e_shstrndx; }; struct Elf32_Shdr { @@ -223,30 +225,31 @@ struct Elf32_Sym { unsigned short st_shndx; }; -struct Elf32_Note { - unsigned int n_namesz; /* Name size */ - unsigned int n_descsz; /* Content size */ - unsigned int n_type; /* Content type */ +struct Elf32_Note +{ + unsigned int n_namesz; /* Name size */ + unsigned int n_descsz; /* Content size */ + unsigned int n_type; /* Content type */ }; struct Elf32_Rel { - unsigned int r_offset; - unsigned int r_info; + unsigned int r_offset; + unsigned int r_info; }; struct Elf32_Rela { - unsigned int r_offset; - unsigned int r_info; - signed int r_addend; + unsigned int r_offset; + unsigned int r_info; + signed int r_addend; }; struct Elf32_Dyn { - signed int d_tag; - union { - unsigned int d_val; - unsigned int d_ptr; - } d_un; + signed int d_tag; + union { + unsigned int d_val; + unsigned int d_ptr; + } d_un; }; using std::istream; @@ -255,21 +258,21 @@ namespace cgc { namespace bio { enum CGBIO_ERROR { - CGBIO_ERROR_NO_ERROR, - CGBIO_ERROR_LOADED, - CGBIO_ERROR_FILEIO, - CGBIO_ERROR_FORMAT, - CGBIO_ERROR_INDEX, - CGBIO_ERROR_MEMORY, - CGBIO_ERROR_RELOC, - CGBIO_ERROR_SYMBOL, - CGBIO_ERROR_UNKNOWN_TYPE + CGBIO_ERROR_NO_ERROR, + CGBIO_ERROR_LOADED, + CGBIO_ERROR_FILEIO, + CGBIO_ERROR_FORMAT, + CGBIO_ERROR_INDEX, + CGBIO_ERROR_MEMORY, + CGBIO_ERROR_RELOC, + CGBIO_ERROR_SYMBOL, + CGBIO_ERROR_UNKNOWN_TYPE }; typedef enum { - CGBIODATANONE = ELFDATANONE, - CGBIODATALSB = ELFDATA2LSB, - CGBIODATAMSB = ELFDATA2MSB + CGBIODATANONE = ELFDATANONE, + CGBIODATALSB = ELFDATA2LSB, + CGBIODATAMSB = ELFDATA2MSB } HOST_ENDIANNESS; class elf_reader diff --git a/console/rgl/ps3/cgnv2rt.h b/console/rgl/ps3/cgnv2rt.h index 7f015cfae1..dae42e632f 100644 --- a/console/rgl/ps3/cgnv2rt.h +++ b/console/rgl/ps3/cgnv2rt.h @@ -20,59 +20,61 @@ static unsigned int stringTableAdd( STL_NAMESPACE vector &stringTable, const char* str ) { - unsigned int ret = (unsigned int)stringTable.size(); + unsigned int ret = (unsigned int)stringTable.size(); - if ( ret == 0 ) - { - stringTable.push_back('\0'); - ret = 1; - } + if ( ret == 0 ) + { + stringTable.push_back('\0'); + ret = 1; + } - size_t stringLength = strlen(str) + 1; - stringTable.resize(ret + stringLength); - memcpy(&stringTable[0] + ret,str,stringLength); + size_t stringLength = strlen(str) + 1; + stringTable.resize(ret + stringLength); + memcpy(&stringTable[0] + ret,str,stringLength); - return ret; + return ret; } static unsigned int stringTableFind( STL_NAMESPACE vector &stringTable, const char* str ) { - const char* data = &stringTable[0]; - size_t size = stringTable.size(); - const char *end = data + size; + const char* data = &stringTable[0]; + size_t size = stringTable.size(); + const char *end = data + size; - size_t length = strlen(str); - if (length+1 > size) - return 0; - data += length; + size_t length = strlen(str); - const char *p = (char*)memchr(data,'\0',end-data); - while (p && (end-data)>0) - { - if (!memcmp(p - length, str, length)) - { - return (unsigned int)(p - length - &stringTable[0]); - } - data = p+1; - p = (char*)memchr(data,'\0',end-data); - } - return 0; + if (length+1 > size) + return 0; + + data += length; + + const char *p = (char*)memchr(data,'\0',end-data); + while (p && (end-data)>0) + { + if (!memcmp(p - length, str, length)) + return (unsigned int)(p - length - &stringTable[0]); + + data = p+1; + p = (char*)memchr(data,'\0',end-data); + } + return 0; } static unsigned int stringTableAddUnique( STL_NAMESPACE vector &stringTable, const char* str ) { - if ( stringTable.size() == 0 ) - stringTable.push_back('\0'); - unsigned int ret = stringTableFind(stringTable, str); - if (ret == 0 && str[0] != '\0') - ret = stringTableAdd(stringTable, str); - return ret; + if ( stringTable.size() == 0 ) + stringTable.push_back('\0'); + + unsigned int ret = stringTableFind(stringTable, str); + + if (ret == 0 && str[0] != '\0') + ret = stringTableAdd(stringTable, str); + + return ret; } -int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTableOffset, void **binaryShader, int *size, - STL_NAMESPACE vector &stringTable, STL_NAMESPACE vector &defaultValues); -int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize, - STL_NAMESPACE vector &stringTable, STL_NAMESPACE vector &defaultValues); +int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTableOffset, void **binaryShader, int *size, STL_NAMESPACE vector &stringTable, STL_NAMESPACE vector &defaultValues); +int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize, STL_NAMESPACE vector &stringTable, STL_NAMESPACE vector &defaultValues); int convertNvToElfFreeBinaryShader(void *binaryShader); diff --git a/console/rgl/ps3/device_ctx.cpp b/console/rgl/ps3/device_ctx.cpp index b64d6aec3f..cbd08e8c44 100644 --- a/console/rgl/ps3/device_ctx.cpp +++ b/console/rgl/ps3/device_ctx.cpp @@ -477,9 +477,8 @@ static unsigned int findValidPitch( unsigned int pitch ) else { for ( GLuint i = 0;i < validPitchCount - 1;++i ) - { if (( pitch > validPitch[i] ) && ( pitch <= validPitch[i+1] ) ) return validPitch[i+1]; - } + return validPitch[validPitchCount-1]; } } diff --git a/console/rgl/ps3/gl.h b/console/rgl/ps3/gl.h index dea55764a1..bfba05e1ca 100644 --- a/console/rgl/ps3/gl.h +++ b/console/rgl/ps3/gl.h @@ -57,22 +57,22 @@ extern "C" #define GLAPI extern #endif - typedef unsigned int GLenum; - typedef unsigned char GLboolean; - typedef unsigned int GLbitfield; - typedef signed char GLbyte; - typedef short GLshort; - typedef int GLint; - typedef int GLsizei; - typedef unsigned char GLubyte; - typedef unsigned short GLushort; - typedef unsigned int GLuint; - typedef float GLfloat; - typedef float GLclampf; - typedef void GLvoid; - typedef int GLfixed; - typedef int GLclampx; - typedef void( *_GLfuncptr )(); +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef signed char GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef unsigned char GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef float GLfloat; +typedef float GLclampf; +typedef void GLvoid; +typedef int GLfixed; +typedef int GLclampx; +typedef void( *_GLfuncptr )(); #define GL_OES_VERSION_1_0 1 #define GL_OES_read_format 1 @@ -290,35 +290,35 @@ extern "C" #define GL_REPEAT 0x2901 #define GL_CLAMP_TO_EDGE 0x812F - GLAPI void APIENTRY glActiveTexture( GLenum texture ); - GLAPI void APIENTRY glBindTexture( GLenum target, GLuint texture ); - GLAPI void APIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); - GLAPI void APIENTRY glClear( GLbitfield mask ); - GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); - GLAPI void APIENTRY glClearColorx( GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha ); - GLAPI void APIENTRY glClientActiveTexture( GLenum texture ); - GLAPI void APIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - GLAPI void APIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); - GLAPI void APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures ); - GLAPI void APIENTRY glDisable( GLenum cap ); - GLAPI void APIENTRY glDisableClientState( GLenum array ); - GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); - GLAPI void APIENTRY glEnable( GLenum cap ); - GLAPI void APIENTRY glEnableClientState( GLenum array ); - GLAPI void APIENTRY glFinish( void ); - GLAPI void APIENTRY glFlush( void ); - GLAPI void APIENTRY glGenTextures( GLsizei n, GLuint *textures ); - GLAPI GLenum APIENTRY glGetError( void ); - GLAPI const GLubyte * APIENTRY glGetString( GLenum name ); - GLAPI void APIENTRY glLoadIdentity( void ); - GLAPI void APIENTRY glMatrixMode( GLenum mode ); - GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ); - GLAPI void APIENTRY glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); - GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ); - GLAPI void APIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); - GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - GLAPI void APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); +GLAPI void APIENTRY glActiveTexture( GLenum texture ); +GLAPI void APIENTRY glBindTexture( GLenum target, GLuint texture ); +GLAPI void APIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); +GLAPI void APIENTRY glClear( GLbitfield mask ); +GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); +GLAPI void APIENTRY glClearColorx( GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha ); +GLAPI void APIENTRY glClientActiveTexture( GLenum texture ); +GLAPI void APIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); +GLAPI void APIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); +GLAPI void APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures ); +GLAPI void APIENTRY glDisable( GLenum cap ); +GLAPI void APIENTRY glDisableClientState( GLenum array ); +GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); +GLAPI void APIENTRY glEnable( GLenum cap ); +GLAPI void APIENTRY glEnableClientState( GLenum array ); +GLAPI void APIENTRY glFinish( void ); +GLAPI void APIENTRY glFlush( void ); +GLAPI void APIENTRY glGenTextures( GLsizei n, GLuint *textures ); +GLAPI GLenum APIENTRY glGetError( void ); +GLAPI const GLubyte * APIENTRY glGetString( GLenum name ); +GLAPI void APIENTRY glLoadIdentity( void ); +GLAPI void APIENTRY glMatrixMode( GLenum mode ); +GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ); +GLAPI void APIENTRY glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ); +GLAPI void APIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); +GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); +GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); +GLAPI void APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); #ifdef __cplusplus } diff --git a/console/rgl/ps3/glext.h b/console/rgl/ps3/glext.h index e2d87c6418..5561075f09 100644 --- a/console/rgl/ps3/glext.h +++ b/console/rgl/ps3/glext.h @@ -12,9 +12,9 @@ extern "C" { #endif - typedef intptr_t GLintptr; - typedef intptr_t GLsizeiptr; - typedef unsigned short GLhalfARB; +typedef intptr_t GLintptr; +typedef intptr_t GLsizeiptr; +typedef unsigned short GLhalfARB; #define GL_QUADS 0x0007 #define GL_QUAD_STRIP 0x0008 @@ -248,24 +248,24 @@ extern "C" #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_PITCH_SCE 0x6041 - GLAPI void APIENTRY glBlendEquation( GLenum mode ); - GLAPI void APIENTRY glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); - GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params ); - GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); +GLAPI void APIENTRY glBlendEquation( GLenum mode ); +GLAPI void APIENTRY glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); +GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params ); +GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); - GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name ); - GLAPI void APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers ); - GLAPI void APIENTRY glGenBuffers( GLsizei n, GLuint *buffers ); - GLAPI void APIENTRY glBufferData( GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage ); - GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data ); +GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name ); +GLAPI void APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers ); +GLAPI void APIENTRY glGenBuffers( GLsizei n, GLuint *buffers ); +GLAPI void APIENTRY glBufferData( GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage ); +GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data ); - GLAPI void APIENTRY glBindFramebufferOES( GLenum, GLuint ); - GLAPI void APIENTRY glDeleteFramebuffersOES( GLsizei, const GLuint * ); - GLAPI void APIENTRY glGenFramebuffersOES( GLsizei, GLuint * ); - GLAPI GLenum APIENTRY glCheckFramebufferStatusOES( GLenum ); - GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum, GLenum, GLenum, GLuint, GLint ); +GLAPI void APIENTRY glBindFramebufferOES( GLenum, GLuint ); +GLAPI void APIENTRY glDeleteFramebuffersOES( GLsizei, const GLuint * ); +GLAPI void APIENTRY glGenFramebuffersOES( GLsizei, GLuint * ); +GLAPI GLenum APIENTRY glCheckFramebufferStatusOES( GLenum ); +GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum, GLenum, GLenum, GLuint, GLint ); - GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset ); +GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset ); #ifdef __cplusplus } diff --git a/console/rgl/ps3/private.h b/console/rgl/ps3/private.h index 13886d0a8d..7faf1d6acf 100644 --- a/console/rgl/ps3/private.h +++ b/console/rgl/ps3/private.h @@ -12,7 +12,6 @@ extern "C" { #endif - #ifdef __cplusplus #define _RGL_EXTERN_C extern "C" #else @@ -52,8 +51,8 @@ extern PSGLdevice *_CurrentDevice; typedef union { - unsigned int i; - float f; + unsigned int i; + float f; } jsIntAndFloat; static const jsIntAndFloat _RGLNan = {i: 0x7fc00000U}; @@ -63,39 +62,36 @@ static const jsIntAndFloat _RGLInfinity = {i: 0x7f800000U}; typedef struct RGLRenderTargetEx RGLRenderTargetEx; struct RGLRenderTargetEx { - RGLEnum colorFormat; - GLuint colorBufferCount; - GLuint colorId[RGL_SETRENDERTARGET_MAXCOUNT]; - GLuint colorIdOffset[RGL_SETRENDERTARGET_MAXCOUNT]; - GLuint colorPitch[RGL_SETRENDERTARGET_MAXCOUNT]; - GLboolean yInverted; - GLuint xOffset; - GLuint yOffset; - GLuint width; - GLuint height; + RGLEnum colorFormat; + GLuint colorBufferCount; + GLuint colorId[RGL_SETRENDERTARGET_MAXCOUNT]; + GLuint colorIdOffset[RGL_SETRENDERTARGET_MAXCOUNT]; + GLuint colorPitch[RGL_SETRENDERTARGET_MAXCOUNT]; + GLboolean yInverted; + GLuint xOffset; + GLuint yOffset; + GLuint width; + GLuint height; }; struct jsPlatformFramebuffer: public jsFramebuffer { - RGLRenderTargetEx rt; - GLuint colorBufferMask; - GLboolean complete; - jsPlatformFramebuffer(): jsFramebuffer() - { - memset( &rt, 0, sizeof( rt ) ); - }; - virtual ~jsPlatformFramebuffer() {}; + RGLRenderTargetEx rt; + GLuint colorBufferMask; + GLboolean complete; + jsPlatformFramebuffer(): jsFramebuffer() { memset( &rt, 0, sizeof( rt ) ); }; + virtual ~jsPlatformFramebuffer() {}; }; typedef struct _RGLDriver_ { - RGLRenderTargetEx rt; - GLuint colorBufferMask; - GLboolean rtValid; - GLboolean invalidateVertexCache; - GLuint flushBufferCount; - GLuint fpLoadProgramId; - GLuint fpLoadProgramOffset; + RGLRenderTargetEx rt; + GLuint colorBufferMask; + GLboolean rtValid; + GLboolean invalidateVertexCache; + GLuint flushBufferCount; + GLuint fpLoadProgramId; + GLuint fpLoadProgramOffset; } RGLDriver; @@ -142,99 +138,99 @@ typedef struct typedef struct { - GLenum pool; - RGLTextureMethodParams gcmMethods; - CellGcmTexture gcmTexture; - GLuint gpuAddressId; - GLuint gpuAddressIdOffset; - GLuint gpuSize; - RGLTextureLayout gpuLayout; - jsBufferObject* pbo; + GLenum pool; + RGLTextureMethodParams gcmMethods; + CellGcmTexture gcmTexture; + GLuint gpuAddressId; + GLuint gpuAddressIdOffset; + GLuint gpuSize; + RGLTextureLayout gpuLayout; + jsBufferObject* pbo; } RGLTexture; typedef struct _tagMODESTRUC { - GLushort wHorizVisible; - GLushort wVertVisible; - GLushort wInterlacedMode; - GLushort wRefresh; - GLushort wHorizTotal; - GLushort wHorizBlankStart; - GLushort wHorizSyncStart; - GLushort wHorizSyncEnd; - GLushort wHorizBlankEnd; - GLushort wVertTotal; - GLushort wVertBlankStart; - GLushort wVertSyncStart; - GLushort wVertSyncEnd; - GLushort wVertBlankEnd; - GLuint dwDotClock; - GLushort wHSyncPolarity; - GLushort wVSyncPolarity; + GLushort wHorizVisible; + GLushort wVertVisible; + GLushort wInterlacedMode; + GLushort wRefresh; + GLushort wHorizTotal; + GLushort wHorizBlankStart; + GLushort wHorizSyncStart; + GLushort wHorizSyncEnd; + GLushort wHorizBlankEnd; + GLushort wVertTotal; + GLushort wVertBlankStart; + GLushort wVertSyncStart; + GLushort wVertSyncEnd; + GLushort wVertBlankEnd; + GLuint dwDotClock; + GLushort wHSyncPolarity; + GLushort wVSyncPolarity; } MODESTRUC; enum { - _RGL_SURFACE_SOURCE_TEMPORARY, - _RGL_SURFACE_SOURCE_DEVICE, - _RGL_SURFACE_SOURCE_TEXTURE, - _RGL_SURFACE_SOURCE_PBO, + _RGL_SURFACE_SOURCE_TEMPORARY, + _RGL_SURFACE_SOURCE_DEVICE, + _RGL_SURFACE_SOURCE_TEXTURE, + _RGL_SURFACE_SOURCE_PBO, }; enum { - _RGL_SURFACE_POOL_NONE, - _RGL_SURFACE_POOL_LINEAR, - _RGL_SURFACE_POOL_SYSTEM, + _RGL_SURFACE_POOL_NONE, + _RGL_SURFACE_POOL_LINEAR, + _RGL_SURFACE_POOL_SYSTEM, }; typedef struct { - GLenum source; - GLuint width, height; - GLuint bpp; - GLuint pitch; - RGLEnum format; - GLenum pool; - char* ppuData; - GLuint dataId; - GLuint dataIdOffset; + GLenum source; + GLuint width, height; + GLuint bpp; + GLuint pitch; + RGLEnum format; + GLenum pool; + char* ppuData; + GLuint dataId; + GLuint dataIdOffset; } RGLSurface; typedef struct { - RGLRenderTargetEx rt; - RGLSurface color[3]; - GLuint drawBuffer; - GLuint scanBuffer; - GLuint RescColorBuffersId; - GLuint RescVertexArrayId; - GLuint RescFragmentShaderId; + RGLRenderTargetEx rt; + RGLSurface color[3]; + GLuint drawBuffer; + GLuint scanBuffer; + GLuint RescColorBuffersId; + GLuint RescVertexArrayId; + GLuint RescFragmentShaderId; - const MODESTRUC *ms; - GLboolean vsync; - GLenum deviceType; - GLenum TVStandard; - GLenum TVFormat; - GLuint swapFifoRef; - GLuint swapFifoRef2; - GLboolean setOffset; - GLboolean signal; - GLuint semaValue; - unsigned int syncMethod; + const MODESTRUC *ms; + GLboolean vsync; + GLenum deviceType; + GLenum TVStandard; + GLenum TVFormat; + GLuint swapFifoRef; + GLuint swapFifoRef2; + GLboolean setOffset; + GLboolean signal; + GLuint semaValue; + unsigned int syncMethod; } RGLDevice; int32_t _RGLOutOfSpaceCallback( struct CellGcmContextData *con, uint32_t space ); typedef struct _RGLShader_ { - GLuint loadAddressId; - CgBinaryProgram __attribute__(( aligned( 16 ) ) ) program; + GLuint loadAddressId; + CgBinaryProgram __attribute__(( aligned( 16 ) ) ) program; } RGLShader; -void _RGLFifoFinish( RGLFifo *fifo ); +void _RGLFifoFinish( RGLFifo *fifo ); #define _RGLFifoFlush(fifo) \ { \ @@ -249,17 +245,16 @@ void _RGLFifoFinish( RGLFifo *fifo ); #define RGL_PAGE_SIZE 0x1000 #define RGL_LM_MAX_TOTAL_QUERIES 800 - - typedef struct RGLTextureState RGLTextureState; + struct RGLTextureState { - GLuint hwTexAddress; - GLuint hwTexFilter; - GLuint hwTexControl0; + GLuint hwTexAddress; + GLuint hwTexFilter; + GLuint hwTexControl0; }; -void _RGLDestroy( void ); +void _RGLDestroy( void ); typedef void( * RGLcontextHookFunction )( PSGLcontext *context ); extern RGLcontextHookFunction _RGLContextCreateHook; @@ -283,22 +278,23 @@ extern void _RGLDeviceExit (void); static inline GLuint RGL_QUICK_FLOAT2UINT( const GLfloat f ) { - union - { - GLfloat f; - GLuint ui; - } t; - t.f = f + RGL_F0_DOT_0; - return t.ui & 0xffff; + union + { + GLfloat f; + GLuint ui; + } t; + t.f = f + RGL_F0_DOT_0; + return t.ui & 0xffff; } -static inline void RGL_CALC_COLOR_LE_ARGB8( GLuint *color0, const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a ) +static inline void RGL_CALC_COLOR_LE_ARGB8( GLuint *color0, const GLfloat r, +const GLfloat g, const GLfloat b, const GLfloat a ) { - GLuint r2 = RGL_QUICK_FLOAT2UINT( r * 255.0f ); - GLuint g2 = RGL_QUICK_FLOAT2UINT( g * 255.0f ); - GLuint b2 = RGL_QUICK_FLOAT2UINT( b * 255.0f ); - GLuint a2 = RGL_QUICK_FLOAT2UINT( a * 255.0f ); - *color0 = ( a2 << 24 ) | ( r2 << 16 ) | ( g2 << 8 ) | ( b2 << 0 ); + GLuint r2 = RGL_QUICK_FLOAT2UINT( r * 255.0f ); + GLuint g2 = RGL_QUICK_FLOAT2UINT( g * 255.0f ); + GLuint b2 = RGL_QUICK_FLOAT2UINT( b * 255.0f ); + GLuint a2 = RGL_QUICK_FLOAT2UINT( a * 255.0f ); + *color0 = ( a2 << 24 ) | ( r2 << 16 ) | ( g2 << 8 ) | ( b2 << 0 ); } static inline GLuint _RGLMapMinTextureFilter( GLenum filter ) @@ -323,14 +319,14 @@ static inline GLuint _RGLMapMinTextureFilter( GLenum filter ) static inline GLuint _RGLMapMagTextureFilter( GLenum filter ) { - switch ( filter ) - { - case GL_NEAREST: - return CELL_GCM_TEXTURE_NEAREST; - case GL_LINEAR: - return CELL_GCM_TEXTURE_LINEAR; - } - return filter; + switch ( filter ) + { + case GL_NEAREST: + return CELL_GCM_TEXTURE_NEAREST; + case GL_LINEAR: + return CELL_GCM_TEXTURE_LINEAR; + } + return filter; } static inline void _RGLMapTextureFormat( GLuint internalFormat, uint8_t & gcmFormat, uint32_t & remap ) @@ -339,71 +335,58 @@ static inline void _RGLMapTextureFormat( GLuint internalFormat, uint8_t & gcmFor switch ( internalFormat ) { - case RGL_ALPHA8: // in_rgba = xxAx, out_rgba = 000A - { - gcmFormat = CELL_GCM_TEXTURE_B8; - remap = CELL_GCM_REMAP_MODE( - CELL_GCM_TEXTURE_REMAP_ORDER_XYXY, - CELL_GCM_TEXTURE_REMAP_FROM_B, - CELL_GCM_TEXTURE_REMAP_FROM_R, - CELL_GCM_TEXTURE_REMAP_FROM_B, - CELL_GCM_TEXTURE_REMAP_FROM_B, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_ZERO, - CELL_GCM_TEXTURE_REMAP_ZERO, - CELL_GCM_TEXTURE_REMAP_ZERO ); + case RGL_ALPHA8: // in_rgba = xxAx, out_rgba = 000A + gcmFormat = CELL_GCM_TEXTURE_B8; + remap = CELL_GCM_REMAP_MODE( + CELL_GCM_TEXTURE_REMAP_ORDER_XYXY, + CELL_GCM_TEXTURE_REMAP_FROM_B, + CELL_GCM_TEXTURE_REMAP_FROM_R, + CELL_GCM_TEXTURE_REMAP_FROM_B, + CELL_GCM_TEXTURE_REMAP_FROM_B, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_ZERO, + CELL_GCM_TEXTURE_REMAP_ZERO, + CELL_GCM_TEXTURE_REMAP_ZERO ); - } break; - case RGL_ARGB8: // in_rgba = RGBA, out_rgba = RGBA - { - gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8; - remap = CELL_GCM_REMAP_MODE( - CELL_GCM_TEXTURE_REMAP_ORDER_XYXY, - CELL_GCM_TEXTURE_REMAP_FROM_A, - CELL_GCM_TEXTURE_REMAP_FROM_R, - CELL_GCM_TEXTURE_REMAP_FROM_G, - CELL_GCM_TEXTURE_REMAP_FROM_B, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP ); - - } + case RGL_ARGB8: // in_rgba = RGBA, out_rgba = RGBA + gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8; + remap = CELL_GCM_REMAP_MODE( + CELL_GCM_TEXTURE_REMAP_ORDER_XYXY, + CELL_GCM_TEXTURE_REMAP_FROM_A, + CELL_GCM_TEXTURE_REMAP_FROM_R, + CELL_GCM_TEXTURE_REMAP_FROM_G, + CELL_GCM_TEXTURE_REMAP_FROM_B, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP ); break; - case RGL_RGB5_A1_SCE: // in_rgba = RGBA, out_rgba = RGBA - { - gcmFormat = CELL_GCM_TEXTURE_A1R5G5B5; - remap = CELL_GCM_REMAP_MODE( - CELL_GCM_TEXTURE_REMAP_ORDER_XXXY, - CELL_GCM_TEXTURE_REMAP_FROM_A, - CELL_GCM_TEXTURE_REMAP_FROM_R, - CELL_GCM_TEXTURE_REMAP_FROM_G, - CELL_GCM_TEXTURE_REMAP_FROM_B, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP ); - - } + case RGL_RGB5_A1_SCE: // in_rgba = RGBA, out_rgba = RGBA + gcmFormat = CELL_GCM_TEXTURE_A1R5G5B5; + remap = CELL_GCM_REMAP_MODE( + CELL_GCM_TEXTURE_REMAP_ORDER_XXXY, + CELL_GCM_TEXTURE_REMAP_FROM_A, + CELL_GCM_TEXTURE_REMAP_FROM_R, + CELL_GCM_TEXTURE_REMAP_FROM_G, + CELL_GCM_TEXTURE_REMAP_FROM_B, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP ); break; - case RGL_RGB565_SCE: // in_rgba = RGBA, out_rgba = RGBA - { - gcmFormat = CELL_GCM_TEXTURE_R5G6B5; - remap = CELL_GCM_REMAP_MODE( - CELL_GCM_TEXTURE_REMAP_ORDER_XXXY, - CELL_GCM_TEXTURE_REMAP_FROM_A, - CELL_GCM_TEXTURE_REMAP_FROM_R, - CELL_GCM_TEXTURE_REMAP_FROM_G, - CELL_GCM_TEXTURE_REMAP_FROM_B, - CELL_GCM_TEXTURE_REMAP_ONE, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP, - CELL_GCM_TEXTURE_REMAP_REMAP ); - - } - break; - default: + case RGL_RGB565_SCE: // in_rgba = RGBA, out_rgba = RGBA + gcmFormat = CELL_GCM_TEXTURE_R5G6B5; + remap = CELL_GCM_REMAP_MODE( + CELL_GCM_TEXTURE_REMAP_ORDER_XXXY, + CELL_GCM_TEXTURE_REMAP_FROM_A, + CELL_GCM_TEXTURE_REMAP_FROM_R, + CELL_GCM_TEXTURE_REMAP_FROM_G, + CELL_GCM_TEXTURE_REMAP_FROM_B, + CELL_GCM_TEXTURE_REMAP_ONE, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP, + CELL_GCM_TEXTURE_REMAP_REMAP ); break; }; diff --git a/console/rgl/ps3/readelf.h b/console/rgl/ps3/readelf.h index c33dd3373b..21c65c72d8 100644 --- a/console/rgl/ps3/readelf.h +++ b/console/rgl/ps3/readelf.h @@ -9,61 +9,61 @@ extern "C" { typedef struct _ELF_section_t { - Elf32_Shdr header; - const char* name; - char* data; + Elf32_Shdr header; + const char *name; + char *data; } ELF_section_t; typedef struct _ELF_segment_t { - Elf32_Phdr header; - unsigned char* pointer; - unsigned char* data; + Elf32_Phdr header; + unsigned char *pointer; + unsigned char *data; } ELF_segment_t; typedef struct { - const char* name; - unsigned int vma; - unsigned int size; - int section; - unsigned char resolved; - unsigned char foreign; + const char *name; + unsigned int vma; + unsigned int size; + int section; + unsigned char resolved; + unsigned char foreign; } ELF_symbol_t; typedef struct _ELF_t { - unsigned int endian; - unsigned int relocatable; - unsigned int sectionCount; - unsigned int segmentCount; - unsigned int symbolCount; - unsigned int entrypoint; - ELF_section_t* sections; - ELF_segment_t* segments; - ELF_symbol_t* symbols; - unsigned int symbolsSection; - unsigned int symbolNamesSection; - unsigned int paramSection; + unsigned int endian; + unsigned int relocatable; + unsigned int sectionCount; + unsigned int segmentCount; + unsigned int symbolCount; + unsigned int entrypoint; + ELF_section_t *sections; + ELF_segment_t *segments; + ELF_symbol_t *symbols; + unsigned int symbolsSection; + unsigned int symbolNamesSection; + unsigned int paramSection; } ELF_t; typedef struct { - unsigned int relative; - unsigned int shift; - unsigned int size; - unsigned int position; - unsigned int mask; + unsigned int relative; + unsigned int shift; + unsigned int size; + unsigned int position; + unsigned int mask; } ELF_rel_type_t; -ELF_section_t* findSection(const ELF_t* elf,const char* name); -int lookupSymbol(const ELF_t* elf,const char* name); -const Elf32_Sym* getSymbolByIndex(const ELF_t* elf,int idx); +ELF_section_t *findSection(const ELF_t *elf, const char *name); +int lookupSymbol(const ELF_t *elf, const char *name); +const Elf32_Sym *getSymbolByIndex(const ELF_t *elf, int idx); const char *findSectionInPlace(const char* memory,unsigned int size,const char *name,size_t *sectionSize); const char *findSymbolSectionInPlace(const char *memory, unsigned int size, size_t *symbolSize, size_t *symbolCount, const char **symbolstrtab); -int lookupSymbolValueInPlace(const char* symbolSection, size_t symbolSize, size_t symbolCount, const char *symbolstrtab, const char *name); -const char *getSymbolByIndexInPlace(const char* symbolSection, size_t symbolSize, size_t symbolCount, const char *symbolstrtab, int index); +int lookupSymbolValueInPlace(const char *symbolSection, size_t symbolSize, size_t symbolCount, const char *symbolstrtab, const char *name); +const char *getSymbolByIndexInPlace(const char *symbolSection, size_t symbolSize, size_t symbolCount, const char *symbolstrtab, int index); #ifdef __cplusplus } diff --git a/console/rgl/ps3/rgl.cpp b/console/rgl/ps3/rgl.cpp index 807a260f60..a27fedf933 100644 --- a/console/rgl/ps3/rgl.cpp +++ b/console/rgl/ps3/rgl.cpp @@ -133,9 +133,9 @@ typedef GLhalfARB type_GL_HALF_FLOAT_ARB; static const char *_getStringTable(const Elf32_Ehdr *ehdr) { - const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff; - const Elf32_Shdr *shstrtabHeader = (const Elf32_Shdr*)sectionHeaderStart + ehdr->e_shstrndx; - return (const char*)ehdr + shstrtabHeader->sh_offset; + const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff; + const Elf32_Shdr *shstrtabHeader = (const Elf32_Shdr*)sectionHeaderStart + ehdr->e_shstrndx; + return (const char*)ehdr + shstrtabHeader->sh_offset; } const char *findSectionInPlace(const char* memory,unsigned int /*size*/,const char *name, size_t *sectionSize) @@ -205,14 +205,14 @@ const char *getSymbolByIndexInPlace(const char* symbolSection, size_t symbolSize static inline type_GL_HALF_FLOAT_ARB _RGLFloatTo_GL_HALF_FLOAT_ARB( float x ) { - jsIntAndFloat V = {f: x}; - unsigned int S = ( V.i >> 31 ) & 1; - int E = (( V.i >> 23 ) & 0xff ) - 0x7f; - unsigned int M = V.i & 0x007fffff; - if (( E == 0x80 ) && ( M ) ) return 0x7fff; - else if ( E >= 15 ) return( S << 15 ) | 0x7c00; - else if ( E <= -14 ) return( S << 15 ) | (( 0x800000 + M ) >> ( -14 - E ) ); - else return( S << 15 ) | ((( E + 15 )&0x1f ) << 10 ) | ( M >> 13 ); + jsIntAndFloat V = {f: x}; + unsigned int S = ( V.i >> 31 ) & 1; + int E = (( V.i >> 23 ) & 0xff ) - 0x7f; + unsigned int M = V.i & 0x007fffff; + if (( E == 0x80 ) && ( M ) ) return 0x7fff; + else if ( E >= 15 ) return( S << 15 ) | 0x7c00; + else if ( E <= -14 ) return( S << 15 ) | (( 0x800000 + M ) >> ( -14 - E ) ); + else return( S << 15 ) | ((( E + 15 )&0x1f ) << 10 ) | ( M >> 13 ); } static inline float _RGLFloatFrom_GL_HALF_FLOAT_ARB( type_GL_HALF_FLOAT_ARB x ) @@ -1912,7 +1912,7 @@ void _RGLFreeNameSpace( jsNameSpace * ns ) jsName _RGLCreateName( jsNameSpace * ns, void* object ) { - if ( NULL == ns->firstFree ) + if ( ns->firstFree == NULL ) { int newCapacity = ns->capacity + NAME_INCREMENT; @@ -1946,7 +1946,7 @@ jsName _RGLCreateName( jsNameSpace * ns, void* object ) unsigned int _RGLIsName( jsNameSpace* ns, jsName name ) { - if ( RGL_UNLIKELY( 0 == name ) ) + if ( RGL_UNLIKELY( name == 0 ) ) return 0; --name; @@ -1956,7 +1956,7 @@ unsigned int _RGLIsName( jsNameSpace* ns, jsName name ) void** value = ( void** )ns->data[name]; - if ( RGL_UNLIKELY( NULL == value || + if ( RGL_UNLIKELY( value == NULL || ( value >= ns->data && value < ns->data + ns->capacity ) ) ) return 0; @@ -2060,7 +2060,7 @@ void _RGLTexNameSpaceDeleteNames( jsTexNameSpace *ns, GLsizei n, const GLuint *n static inline unsigned int endianSwapWordByHalf( unsigned int v ) { - return ( v&0xffff ) << 16 | v >> 16; + return ( v&0xffff ) << 16 | v >> 16; } static uint32_t gmmInitFixedAllocator (void) @@ -2132,97 +2132,52 @@ static uint8_t gmmSizeToFreeIndex( ) { if (size >= GMM_FREE_BIN_0 && size < GMM_FREE_BIN_1) - { return 0; - } else if (size >= GMM_FREE_BIN_1 && size < GMM_FREE_BIN_2) - { return 1; - } else if (size >= GMM_FREE_BIN_2 && size < GMM_FREE_BIN_3) - { return 2; - } else if (size >= GMM_FREE_BIN_3 && size < GMM_FREE_BIN_4) - { return 3; - } else if (size >= GMM_FREE_BIN_4 && size < GMM_FREE_BIN_5) - { return 4; - } else if (size >= GMM_FREE_BIN_5 && size < GMM_FREE_BIN_6) - { return 5; - } else if (size >= GMM_FREE_BIN_6 && size < GMM_FREE_BIN_7) - { return 6; - } else if (size >= GMM_FREE_BIN_7 && size < GMM_FREE_BIN_8) - { return 7; - } else if (size >= GMM_FREE_BIN_8 && size < GMM_FREE_BIN_9) - { return 8; - } else if (size >= GMM_FREE_BIN_9 && size < GMM_FREE_BIN_10) - { return 9; - } else if (size >= GMM_FREE_BIN_10 && size < GMM_FREE_BIN_11) - { return 10; - } else if (size >= GMM_FREE_BIN_11 && size < GMM_FREE_BIN_12) - { return 11; - } else if (size >= GMM_FREE_BIN_12 && size < GMM_FREE_BIN_13) - { return 12; - } else if (size >= GMM_FREE_BIN_13 && size < GMM_FREE_BIN_14) - { return 13; - } else if (size >= GMM_FREE_BIN_14 && size < GMM_FREE_BIN_15) - { return 14; - } else if (size >= GMM_FREE_BIN_15 && size < GMM_FREE_BIN_16) - { return 15; - } else if (size >= GMM_FREE_BIN_16 && size < GMM_FREE_BIN_17) - { return 16; - } else if (size >= GMM_FREE_BIN_17 && size < GMM_FREE_BIN_18) - { return 17; - } else if (size >= GMM_FREE_BIN_18 && size < GMM_FREE_BIN_19) - { return 18; - } else if (size >= GMM_FREE_BIN_19 && size < GMM_FREE_BIN_20) - { return 19; - } else if (size >= GMM_FREE_BIN_20 && size < GMM_FREE_BIN_21) - { return 20; - } else return 21; } -static void gmmAddFree( - GmmAllocator *pAllocator, - GmmBlock *pBlock -) +static void gmmAddFree(GmmAllocator *pAllocator, GmmBlock *pBlock) { uint8_t freeIndex = gmmSizeToFreeIndex(pBlock->base.size); @@ -2432,22 +2387,18 @@ uint32_t gmmInit( return gmmInitFixedAllocator(); } -void gmmSetTileAttrib( - const uint32_t id, - const uint32_t tag, - void *pData -) +void gmmSetTileAttrib(const uint32_t id, const uint32_t tag, void *pData) { - GmmTileBlock *pTileBlock = (GmmTileBlock *)id; + GmmTileBlock *pTileBlock = (GmmTileBlock *)id; - pTileBlock->tileTag = tag; - pTileBlock->pData = pData; + pTileBlock->tileTag = tag; + pTileBlock->pData = pData; } uint32_t gmmIdToOffset(const uint32_t id) { - GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id; - return gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain); + GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)id; + return gmmAddressToOffset(pBaseBlock->address, pBaseBlock->isMain); } char *gmmIdToAddress(const uint32_t id) @@ -2577,9 +2528,7 @@ static GmmTileBlock *gmmCreateTileBlock( if (pAllocator->pTail && pAllocator->pTail->base.address + pAllocator->pTail->base.size > address) - { return NULL; - } pAllocator->size = address - pAllocator->startAddress; pAllocator->tileSize = pAllocator->tileStartAddress + pAllocator->tileSize - address; @@ -2587,9 +2536,7 @@ static GmmTileBlock *gmmCreateTileBlock( pNewBlock = (GmmTileBlock *)gmmAllocFixed(1); if (pNewBlock == NULL) - { return NULL; - } memset(pNewBlock, 0, sizeof(GmmTileBlock)); @@ -2600,15 +2547,11 @@ static GmmTileBlock *gmmCreateTileBlock( pNewBlock->pNext = pAllocator->pTileHead; if (pAllocator->pTileHead) - { pAllocator->pTileHead->pPrev = pNewBlock; - pAllocator->pTileHead = pNewBlock; - } else - { - pAllocator->pTileHead = pNewBlock; pAllocator->pTileTail = pNewBlock; - } + + pAllocator->pTileHead = pNewBlock; return pNewBlock; } @@ -2764,9 +2707,7 @@ static GmmTileBlock *gmmAllocTileBlock( return pBlock; } -static void gmmFreeBlock( - GmmBlock *pBlock -) +static void gmmFreeBlock (GmmBlock *pBlock) { GmmAllocator *pAllocator; @@ -2852,7 +2793,6 @@ uint32_t gmmFree(const uint32_t freeId) { GmmBaseBlock *pBaseBlock = (GmmBaseBlock *)freeId; - if (pBaseBlock->isTile) { GmmTileBlock *pTileBlock = (GmmTileBlock *)pBaseBlock; @@ -2966,18 +2906,16 @@ static inline void gmmLocalMemcpy( static inline void gmmMemcpy(const uint32_t dstOffset, const uint32_t srcOffset, const uint32_t moveSize) { - if (dstOffset + moveSize <= srcOffset) - { - gmmLocalMemcpy(dstOffset, srcOffset, moveSize); - } - else - { - uint32_t moveBlockSize = srcOffset-dstOffset; - uint32_t iterations = (moveSize+moveBlockSize-1)/moveBlockSize; + if (dstOffset + moveSize <= srcOffset) + gmmLocalMemcpy(dstOffset, srcOffset, moveSize); + else + { + uint32_t moveBlockSize = srcOffset-dstOffset; + uint32_t iterations = (moveSize+moveBlockSize-1)/moveBlockSize; - for (uint32_t i=0; ipNextFree; } else if (++freeIndex < GMM_NUM_FREE_BINS) - { pBlock = pAllocator->pFreeHead[freeIndex]; - } } if (found) @@ -3248,10 +3184,10 @@ static uint32_t gmmFindFreeBlock( pNewBlock->base.size = pBlock->base.size - size; pNewBlock->pNext = pBlock->pNext; pNewBlock->pPrev = pBlock; + if (pBlock->pNext) - { pBlock->pNext->pPrev = pNewBlock; - } + pBlock->pNext = pNewBlock; if (pBlock == pAllocator->pTail) @@ -3376,22 +3312,10 @@ RGLparamUID getParamUIDByIndex( const RGLparamUIDTable* st, int index ) return st->uids[index]; } -void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * __restrict v ) -{ -} - -void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v ) -{ -} - - -void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * __restrict v ) -{ -} - -void _RGLPlatformSetFragmentRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v ) -{ -} +void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * __restrict v ) {} +void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v ) {} +void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * __restrict v ) {} +void _RGLPlatformSetFragmentRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v ) {} template inline static void swapandsetfp( int ucodeSize, unsigned int loadProgramId, unsigned int loadProgramOffset, unsigned short *ec, const unsigned int * __restrict v ) { @@ -3431,13 +3355,10 @@ template static void setVectorTypefp( CgRuntimeParameter* __restrict p } } -template static void setVectorTypeSharedfpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int ) -{ -} +template static void setVectorTypeSharedfpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int ) {} + +template static void setVectorTypeSharedfpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) {} -template static void setVectorTypeSharedfpIndexArray( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int index ) -{ -} template static void setVectorTypeSharedvpIndex( CgRuntimeParameter* __restrict ptr, const void* __restrict v, const int ) { const float * __restrict f = ( const float * __restrict )v; @@ -4479,11 +4400,6 @@ int _RGLPlatformCopyProgram( _CGprogram* source, _CGprogram* destination ) return _RGLGenerateProgram( destination, profileIndex, &source->header, source->ucode, ¶meterHeader, source->parametersEntries, source->stringTable, source->defaultValues ); } - - - - - static char *_RGLPlatformBufferObjectMap( jsBufferObject* bufferObject, GLenum access ) { RGLBufferObject *jsBuffer = ( RGLBufferObject * )bufferObject->platformBufferObject; @@ -4712,21 +4628,21 @@ static void _RGLPlatformExpandInternalFormat( GLenum internalFormat, GLenum *for static GLenum _RGLPlatformChooseInternalStorage( jsImage* image, GLenum internalFormat ) { - image->storageSize = 0; + image->storageSize = 0; - GLenum platformInternalFormat = _RGLPlatformChooseInternalFormat( internalFormat ); + GLenum platformInternalFormat = _RGLPlatformChooseInternalFormat( internalFormat ); - if ( platformInternalFormat == GL_INVALID_ENUM ) - return GL_INVALID_ENUM; + if ( platformInternalFormat == GL_INVALID_ENUM ) + return GL_INVALID_ENUM; - image->internalFormat = platformInternalFormat; - _RGLPlatformExpandInternalFormat( platformInternalFormat, &image->format, &image->type ); + image->internalFormat = platformInternalFormat; + _RGLPlatformExpandInternalFormat( platformInternalFormat, &image->format, &image->type ); - image->storageSize = _RGLGetStorageSize( - image->format, image->type, - image->width, image->height, 1 ); + image->storageSize = _RGLGetStorageSize( + image->format, image->type, + image->width, image->height, 1 ); - return GL_NO_ERROR; + return GL_NO_ERROR; } static inline GLuint _RGLGetBufferObjectOrigin( GLuint buffer ) @@ -4884,7 +4800,7 @@ static GLboolean _RGLPlatformTexturePBOImage( const GLuint bytesPerPixel = newLayout.pixelBits / 8; RGLSurface src = { -source: _RGL_SURFACE_SOURCE_PBO, + source: _RGL_SURFACE_SOURCE_PBO, width: image->width, height: image->height, bpp: bytesPerPixel, @@ -4901,7 +4817,7 @@ source: _RGL_SURFACE_SOURCE_PBO, RGLSurface dst = { -source: _RGL_SURFACE_SOURCE_TEXTURE, + source: _RGL_SURFACE_SOURCE_TEXTURE, width: image->width, height: image->height, bpp: bytesPerPixel, @@ -5064,9 +4980,7 @@ void _RGLFifoGlSetRenderTarget( RGLRenderTargetEx const * const args ) cellGcmSetDepthTestEnableInline( &_RGLState.fifo, CELL_GCM_FALSE); } -void _RGLSetError( GLenum error ) -{ -} +void _RGLSetError( GLenum error ) {} GLAPI GLenum APIENTRY glGetError() { @@ -5367,17 +5281,17 @@ PSGLcontext *psglGetCurrentContext() const GLfloat _RGLIdentityMatrixf[ELEMENTS_IN_MATRIX] = { - 1.f, 0.f, 0.f, 0.f, - 0.f, 1.f, 0.f, 0.f, - 0.f, 0.f, 1.f, 0.f, - 0.f, 0.f, 0.f, 1.f + 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f }; static void _RGLMatrixStackReset( jsMatrixStack* LMatrixStack ) { - LMatrixStack->MatrixStackPtr = 0; - memcpy( LMatrixStack->MatrixStackf, _RGLIdentityMatrixf, jsMATRIX_SIZEf ); - LMatrixStack->dirty = GL_TRUE; + LMatrixStack->MatrixStackPtr = 0; + memcpy( LMatrixStack->MatrixStackf, _RGLIdentityMatrixf, jsMATRIX_SIZEf ); + LMatrixStack->dirty = GL_TRUE; } static void _RGLResetContext( PSGLcontext *LContext ) @@ -5601,7 +5515,8 @@ PSGLcontext* psglCreateContext (void) _RGLResetContext( LContext ); - if ( _RGLContextCreateHook ) _RGLContextCreateHook( LContext ); + if ( _RGLContextCreateHook ) + _RGLContextCreateHook( LContext ); return( LContext ); } @@ -5960,19 +5875,19 @@ void psglExit (void) GLAPI void APIENTRY glLoadIdentity() { - PSGLcontext* LContext = _CurrentContext; - jsMatrixStack* LMatrixStack = NULL; + PSGLcontext* LContext = _CurrentContext; + jsMatrixStack* LMatrixStack = NULL; - jsContextGetMatrixStack(LContext, LContext->MatrixMode, LMatrixStack); - memcpy( LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr*ELEMENTS_IN_MATRIX, _RGLIdentityMatrixf, jsMATRIX_SIZEf ); + jsContextGetMatrixStack(LContext, LContext->MatrixMode, LMatrixStack); + memcpy( LMatrixStack->MatrixStackf + LMatrixStack->MatrixStackPtr*ELEMENTS_IN_MATRIX, _RGLIdentityMatrixf, jsMATRIX_SIZEf ); - LMatrixStack->dirty = GL_TRUE; + LMatrixStack->dirty = GL_TRUE; } GLAPI void APIENTRY glMatrixMode( GLenum mode ) { - PSGLcontext* LContext = _CurrentContext; - LContext->MatrixMode = mode; + PSGLcontext* LContext = _CurrentContext; + LContext->MatrixMode = mode; } GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ) @@ -6289,11 +6204,13 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ) 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 = c_rounded_size_of_RGLDrawParams >> 7; + do{ - --_tmp_clear_loop; - __dcbz(s_dparams_buff+(_tmp_clear_loop<<7)); + --_tmp_clear_loop; + __dcbz(s_dparams_buff+(_tmp_clear_loop << 7)); }while(_tmp_clear_loop); + jsDrawParams *dparams = (jsDrawParams *)s_dparams_buff; dparams->mode = mode; dparams->firstVertex = first; @@ -6307,6 +6224,9 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ) { for ( int i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i ) { + dparams->attribXferOffset[i] = 0; + dparams->attribXferSize[i] = 0; + if ( clientSideMask & ( 1 << i ) ) { jsAttribute* attrib = as->attrib + i; @@ -6324,11 +6244,6 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ) dparams->xferTotalSize += numBytesPadded; dparams->attribXferTotalSize += numBytesPadded; } - else - { - dparams->attribXferOffset[i] = 0; - dparams->attribXferSize[i] = 0; - } } } @@ -6338,12 +6253,11 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ) GLboolean isMain = 0; if ( LContext->attribSetDirty && LContext->attribSetName ) - { - jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName ); - } + jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName ); + uint32_t totalXfer = 0; for ( GLuint i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i ) - totalXfer += dparams->attribXferSize[i]; + totalXfer += dparams->attribXferSize[i]; GLuint gpuOffset = _RGLValidateAttributesSlow( dparams, &isMain ); (void)gpuOffset; @@ -6611,43 +6525,43 @@ GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ) GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset ) { - PSGLcontext* LContext = _CurrentContext; + PSGLcontext* LContext = _CurrentContext; - jsTexture *texture = _RGLGetCurrentTexture( LContext->CurrentImageUnit, GL_TEXTURE_2D); - jsBufferObject *bufferObject = _RGLGetBufferObject( LContext, LContext->TextureBuffer ); - _RGLReallocateImages( texture, MAX( baseWidth, MAX( baseHeight, baseDepth ) ) ); + jsTexture *texture = _RGLGetCurrentTexture( LContext->CurrentImageUnit, GL_TEXTURE_2D); + jsBufferObject *bufferObject = _RGLGetBufferObject( LContext, LContext->TextureBuffer ); + _RGLReallocateImages( texture, MAX( baseWidth, MAX( baseHeight, baseDepth ) ) ); - GLuint width = baseWidth; - GLuint height = baseHeight; - _RGLSetImage(texture->image, GL_RGB5_A1, width, height, 0, LContext->unpackAlignment, - 0, 0, NULL ); - width = MAX( 1U, width / 2 ); - height = MAX( 1U, height / 2 ); - texture->usage = GL_TEXTURE_LINEAR_GPU_SCE; + GLuint width = baseWidth; + GLuint height = baseHeight; + _RGLSetImage(texture->image, GL_RGB5_A1, width, height, 0, LContext->unpackAlignment, + 0, 0, NULL ); + width = MAX( 1U, width / 2 ); + height = MAX( 1U, height / 2 ); + texture->usage = GL_TEXTURE_LINEAR_GPU_SCE; - GLboolean r = _RGLPlatformTextureReference( texture, pitch, bufferObject, offset ); + GLboolean r = _RGLPlatformTextureReference( texture, pitch, bufferObject, offset ); - if(!r) - return; + if(!r) + return; - bufferObject->textureReferences.pushBack( texture ); - texture->referenceBuffer = bufferObject; - texture->offset = offset; - _RGLTextureTouchFBOs( texture ); - LContext->needValidate |= PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_VERTEX_TEXTURES_USED ; + bufferObject->textureReferences.pushBack( texture ); + texture->referenceBuffer = bufferObject; + texture->offset = offset; + _RGLTextureTouchFBOs( texture ); + LContext->needValidate |= PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_VERTEX_TEXTURES_USED ; } GLAPI void APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ) { + PSGLcontext* LContext = _CurrentContext; - PSGLcontext* LContext = _CurrentContext; + LContext->ViewPort.X = x; + LContext->ViewPort.Y = y; + LContext->ViewPort.XSize = width; + LContext->ViewPort.YSize = height; - LContext->ViewPort.X = x; - LContext->ViewPort.Y = y; - LContext->ViewPort.XSize = width; - LContext->ViewPort.YSize = height; - _RGLFifoGlViewport(LContext->ViewPort.X, LContext->ViewPort.Y, - LContext->ViewPort.XSize, LContext->ViewPort.YSize, 0.0f, 1.0f); + _RGLFifoGlViewport(LContext->ViewPort.X, LContext->ViewPort.Y, + LContext->ViewPort.XSize, LContext->ViewPort.YSize, 0.0f, 1.0f); } jsTexture *_RGLGetCurrentTexture( const jsTextureImageUnit *unit, GLenum target ) @@ -6677,30 +6591,27 @@ CgparameterHookFunction _cgParameterDestroyHook = NULL; typedef struct RGLcgProfileMapType { - CGprofile id; - char* string; - int is_vertex_program; -} -RGLcgProfileMapType; + CGprofile id; + char* string; + int is_vertex_program; +} RGLcgProfileMapType; static void _RGLCgProgramPushFront( _CGcontext* ctx, _CGprogram* prog ) { - prog->next = ctx->programList; - ctx->programList = prog; - prog->parentContext = ctx; - ctx->programCount++; + prog->next = ctx->programList; + ctx->programList = prog; + prog->parentContext = ctx; + ctx->programCount++; } static _CGprogram* _RGLCgProgramFindPrev( _CGcontext* ctx, _CGprogram* prog ) { - _CGprogram* ptr = ctx->programList; + _CGprogram* ptr = ctx->programList; - while ( NULL != ptr && prog != ptr->next ) - { - ptr = ptr->next; - } + while ( NULL != ptr && prog != ptr->next ) + ptr = ptr->next; - return ptr; + return ptr; } void _RGLCgProgramErase( _CGprogram* prog ) @@ -6761,32 +6672,30 @@ bool _RGLCgCreateProgramChecks( CGcontext ctx, CGprofile profile, CGenum program typedef struct { - const char* elfFile; - size_t elfFileSize; + const char* elfFile; + size_t elfFileSize; - const char *symtab; - size_t symbolSize; - size_t symbolCount; - const char *symbolstrtab; + const char *symtab; + size_t symbolSize; + size_t symbolCount; + const char *symbolstrtab; - const char* shadertab; - size_t shadertabSize; - const char* strtab; - size_t strtabSize; - const char* consttab; - size_t consttabSize; -} -CGELFBinary; + const char* shadertab; + size_t shadertabSize; + const char* strtab; + size_t strtabSize; + const char* consttab; + size_t consttabSize; +} CGELFBinary; typedef struct { - const char *texttab; - size_t texttabSize; - const char *paramtab; - size_t paramtabSize; - int index; -} -CGELFProgram; + const char *texttab; + size_t texttabSize; + const char *paramtab; + size_t paramtabSize; + int index; +} CGELFProgram; static bool cgOpenElf( const void *ptr, size_t size, CGELFBinary *elfBinary ) { @@ -6882,7 +6791,7 @@ static CGprogram _RGLCgCreateProgram( CGcontext ctx, CGprofile profile, const Cg // The parameters and the actual program are generated from the ABI specific calls. _CGprogram* prog = ( _CGprogram* )malloc( sizeof( _CGprogram ) ); - if ( NULL == prog ) + if ( prog == NULL ) { _RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR ); return NULL; @@ -6935,7 +6844,7 @@ static CGprogram _RGLCgCreateProgram( CGcontext ctx, CGprofile profile, const Cg // if the creation failed, free all resources. // the error was raised when the error was encoutered. - if ( 0 == success ) + if ( success == 0 ) { // free the program object free( prog ); @@ -7011,9 +6920,7 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx, } } else - { binaryBuffer = program; - } bool bConvertedToElf = false; @@ -7134,8 +7041,6 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx, return prog; } - - CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx, CGenum program_type, const char* program_file, @@ -7192,7 +7097,7 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx, { fp = fopen( program_file, "rb" ); - if ( NULL == fp ) + if ( fp == NULL ) { _RGLCgRaiseError( CG_FILE_READ_ERROR ); return ( CGprogram )NULL; @@ -7244,7 +7149,7 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx, if ( !fp ) { fp = fopen( program_file, "rb" ); - if ( NULL == fp ) + if ( fp == NULL ) { _RGLCgRaiseError( CG_FILE_READ_ERROR ); return ( CGprogram )NULL; @@ -7257,7 +7162,7 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx, rewind( fp ); char* ptr = ( char* )malloc( file_size + 1 ); - if ( NULL == ptr ) + if ( ptr == NULL ) { _RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR ); fclose( fp ); @@ -7287,7 +7192,7 @@ CG_API CGprogram cgCopyProgram( CGprogram program ) return NULL; } _CGprogram* prog = _cgGetProgPtr( program ); - if ( NULL == prog ) + if ( prog == NULL ) { _RGLCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR ); return ( CGprogram )NULL; @@ -7308,7 +7213,7 @@ CG_API CGprogram cgCopyProgram( CGprogram program ) newprog = ( _CGprogram* )malloc( sizeof( _CGprogram ) ); } - if ( NULL == newprog ) + if ( newprog == NULL ) { _RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR ); return ( CGprogram )NULL; @@ -7371,7 +7276,7 @@ CG_API void cgDestroyProgram( CGprogram program ) return; } _CGprogram* ptr = _cgGetProgPtr( program ); - if ( NULL == ptr ) + if ( ptr == NULL ) { _RGLCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR ); return; @@ -7489,7 +7394,7 @@ CGprogramGroup _RGLCgCreateProgramGroupFromFile( CGcontext ctx, const char *grou { FILE* fp = fopen( group_file, "rb" ); - if ( NULL == fp ) + if ( fp == NULL ) { _RGLCgRaiseError( CG_FILE_READ_ERROR ); return ( CGprogramGroup )NULL; @@ -7501,7 +7406,7 @@ CGprogramGroup _RGLCgCreateProgramGroupFromFile( CGcontext ctx, const char *grou rewind( fp ); char* ptr = ( char* )malloc( file_size + 1 ); - if ( NULL == ptr ) + if ( ptr == NULL ) { _RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR ); return ( CGprogramGroup )NULL; @@ -7651,16 +7556,14 @@ int _RGLCgGetProgramCount( CGprogramGroup group ) } static const RGLcgProfileMapType RGLcgProfileMap[] = - { - {( CGprofile )6144, "CG_PROFILE_START", 1 }, - {( CGprofile )6145, "unknown", 1 }, - +{ + {( CGprofile )6144, "CG_PROFILE_START", 1 }, + {( CGprofile )6145, "unknown", 1 }, #define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \ - {CG_PROFILE_ ## compiler_id_caps, compiler_opt, vertex_profile}, + {CG_PROFILE_ ## compiler_id_caps, compiler_opt, vertex_profile}, #include - - {( CGprofile )0, "", 0 } - }; + {( CGprofile )0, "", 0 } +}; CG_API const char* cgGetProfileString( CGprofile profile ) { @@ -7683,7 +7586,7 @@ CG_API CGprofile cgGetProfile( const char* profile_string ) unsigned int i = 0; while ( i < arraysize ) { - if ( 0 == strcmp( RGLcgProfileMap[i].string, profile_string ) ) + if ( strcmp( RGLcgProfileMap[i].string, profile_string ) == 0 ) { return RGLcgProfileMap[i].id; } @@ -8063,7 +7966,7 @@ CGGL_API void cgGLLoadProgram( CGprogram program ) CGGL_API CGbool cgGLIsProgramLoaded( CGprogram program ) { - return CG_TRUE; + return CG_TRUE; } @@ -8132,43 +8035,34 @@ CGGL_API void cgGLUnbindProgram( CGprofile profile ) CGGL_API GLuint cgGLGetProgramID( CGprogram program ) { - - return 0; -} - -CGGL_API void cgGLEnableProgramProfiles( CGprogram program ) -{ - return; -} - -CGGL_API void cgGLDisableProgramProfiles( CGprogram program ) -{ - return; + return 0; } +CGGL_API void cgGLEnableProgramProfiles( CGprogram program ) {} +CGGL_API void cgGLDisableProgramProfiles( CGprogram program ) {} CGGL_API void cgGLSetParameter1f( CGparameter param, float x ) { + CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param ); - CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param ); - - float v[4] = {x, x, x, x}; - ptr->setterIndex( ptr, v, CG_GETINDEX( param ) ); + float v[4] = {x, x, x, x}; + ptr->setterIndex( ptr, v, CG_GETINDEX( param ) ); } CGGL_API void cgGLSetParameter2f( CGparameter param, float x, float y ) { - CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param ); + CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param ); - float v[4] = {x, y, y, y}; - ptr->setterIndex( ptr, v, CG_GETINDEX( param ) ); + float v[4] = {x, y, y, y}; + ptr->setterIndex( ptr, v, CG_GETINDEX( param ) ); } -CGGL_API void cgGLSetParameterPointer( CGparameter param, - GLint fsize, - GLenum type, - GLsizei stride, - const GLvoid *pointer ) +CGGL_API void cgGLSetParameterPointer +( CGparameter param, + GLint fsize, + GLenum type, + GLsizei stride, + const GLvoid *pointer ) { CgRuntimeParameter *_ptr = _RGLCgGLTestParameter( param ); @@ -8187,13 +8081,12 @@ CGGL_API void cgGLSetParameterPointer( CGparameter param, CGGL_API void cgGLEnableClientState( 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 ); - _RGLEnableVertexAttribArrayNV( index ); + GLuint index = ( GLuint )( parameterResource->resource - CG_ATTR0 ); + _RGLEnableVertexAttribArrayNV( index ); } CGGL_API void cgGLDisableClientState( CGparameter param ) @@ -8278,9 +8171,8 @@ CGGL_API void cgGLEnableTextureParameter( CGparameter param ) static void _RGLCgContextZero( _CGcontext* p ) { - memset( p, 0, sizeof( *p ) ); - p->compileType = CG_UNKNOWN; - + memset( p, 0, sizeof( *p ) ); + p->compileType = CG_UNKNOWN; } static void _RGLCgContextPushFront( _CGcontext* ctx ) @@ -8306,7 +8198,7 @@ CG_API CGcontext cgCreateContext( void ) _CGcontext* ptr = NULL; ptr = ( _CGcontext* )malloc( sizeof( _CGcontext ) ); - if ( NULL == ptr ) + if ( ptr == NULL ) { _RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR ); return ( CGcontext )NULL; @@ -8608,33 +8500,30 @@ unsigned int _RGLCountFloatsInCgType( CGtype type ) void _cgRaiseInvalidParam( CgRuntimeParameter*p, const void*v ) { - _RGLCgRaiseError( CG_INVALID_PARAMETER_ERROR ); + _RGLCgRaiseError( CG_INVALID_PARAMETER_ERROR ); } void _cgRaiseInvalidParamIndex( CgRuntimeParameter*p, const void*v, const int index ) { - _RGLCgRaiseError( CG_INVALID_PARAMETER_ERROR ); + _RGLCgRaiseError( CG_INVALID_PARAMETER_ERROR ); } void _cgRaiseNotMatrixParam( CgRuntimeParameter*p, const void*v ) { - _RGLCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR ); -} -void _cgRaiseNotMatrixParamIndex( CgRuntimeParameter*p, const void*v, const int index ) -{ - _RGLCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR ); + _RGLCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR ); } -void _cgIgnoreSetParam( CgRuntimeParameter*p, const void*v ) -{ -} -void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index ) +void _cgRaiseNotMatrixParamIndex( CgRuntimeParameter*p, const void*v, const int index ) { + _RGLCgRaiseError( CG_NOT_MATRIX_PARAM_ERROR ); } +void _cgIgnoreSetParam( CgRuntimeParameter*p, const void*v ) {} +void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index ) {} + CgRuntimeParameter* _cgGLTestTextureParameter( CGparameter param ) { - CgRuntimeParameter* ptr = _RGLCgGLTestParameter( param ); - return ptr; + CgRuntimeParameter* ptr = _RGLCgGLTestParameter( param ); + return ptr; } diff --git a/console/rgl/ps3/rgl.h b/console/rgl/ps3/rgl.h index 14da606342..632f719cbd 100644 --- a/console/rgl/ps3/rgl.h +++ b/console/rgl/ps3/rgl.h @@ -6,8 +6,10 @@ #include "base.hpp" #ifdef __PSL1GHT__ +#include #include #include +#include #include "../../../ps3/sdk_defines.h" #define CGerror int typedef void (* CGerrorCallbackFunc)(void); @@ -30,104 +32,104 @@ extern "C" typedef enum RGLEnum { - RGL_NONE = 0x0000, - RGL_COLOR_BUFFER_BIT = 0x4000, - RGL_ZERO = 0, - RGL_ONE = 1, - RGL_SRC_COLOR = 0x0300, - RGL_ONE_MINUS_SRC_COLOR = 0x0301, - RGL_SRC_ALPHA = 0x0302, - RGL_ONE_MINUS_SRC_ALPHA = 0x0303, - RGL_DST_ALPHA = 0x0304, - RGL_ONE_MINUS_DST_ALPHA = 0x0305, - RGL_DST_COLOR = 0x0306, - RGL_ONE_MINUS_DST_COLOR = 0x0307, - RGL_SRC_ALPHA_SATURATE = 0x0308, - RGL_ONE_MINUS_CONSTANT_COLOR = 0x8002, - RGL_CONSTANT_ALPHA = 0x8003, - RGL_ONE_MINUS_CONSTANT_ALPHA = 0x8004, - RGL_MIN = 0x8007, - RGL_MAX = 0x8008, - RGL_FUNC_SUBTRACT = 0x800A, - RGL_FUNC_REVERSE_SUBTRACT = 0x800B, - RGL_LUMINANCE8 = 0x8040, - RGL_LUMINANCE16 = 0x8042, - RGL_ALPHA8 = 0x803C, - RGL_ALPHA16 = 0x803E, - RGL_INTENSITY8 = 0x804B, - RGL_INTENSITY16 = 0x804D, - RGL_LUMINANCE8_ALPHA8 = 0x8045, - RGL_LUMINANCE16_ALPHA16 = 0x8048, - RGL_HILO8 = 0x885E, - RGL_HILO16 = 0x86F8, - RGL_ARGB8 = 0x6007, - RGL_BGRA8 = 0xff01, - RGL_RGBA8 = 0x8058, - RGL_ABGR8 = 0xff02, - RGL_XBGR8 = 0xff03, - RGL_RGBX8 = 0xff07, - RGL_FLOAT_R32 = 0x8885, - RGL_FLOAT_RGBA16 = 0x888A, - RGL_FLOAT_RGBA32 = 0x888B, - RGL_FLOAT_RGBX16 = 0xff04, - RGL_FLOAT_RGBX32 = 0xff05, - RGL_LUMINANCE32F_ARB = 0x8818, - RGL_ALPHA_LUMINANCE16F_SCE = 0x600B, - RGL_RGB5_A1_SCE = 0x600C, - RGL_RGB565_SCE = 0x600D, - RGL_DITHER = 0x0bd0, - RGL_PSHADER_SRGB_REMAPPING = 0xff06, - RGL_VERTEX_ATTRIB_ARRAY0 = 0x8650, - RGL_VERTEX_ATTRIB_ARRAY1 = 0x8651, - RGL_VERTEX_ATTRIB_ARRAY2 = 0x8652, - RGL_VERTEX_ATTRIB_ARRAY3 = 0x8653, - RGL_VERTEX_ATTRIB_ARRAY4 = 0x8654, - RGL_VERTEX_ATTRIB_ARRAY5 = 0x8655, - RGL_VERTEX_ATTRIB_ARRAY6 = 0x8656, - RGL_VERTEX_ATTRIB_ARRAY7 = 0x8657, - RGL_VERTEX_ATTRIB_ARRAY8 = 0x8658, - RGL_VERTEX_ATTRIB_ARRAY9 = 0x8659, - RGL_VERTEX_ATTRIB_ARRAY10 = 0x865a, - RGL_VERTEX_ATTRIB_ARRAY11 = 0x865b, - RGL_VERTEX_ATTRIB_ARRAY12 = 0x865c, - RGL_VERTEX_ATTRIB_ARRAY13 = 0x865d, - RGL_VERTEX_ATTRIB_ARRAY14 = 0x865e, - RGL_VERTEX_ATTRIB_ARRAY15 = 0x865f, - RGL_CLAMP = 0x2900, - RGL_REPEAT = 0x2901, - RGL_CLAMP_TO_EDGE = 0x812F, - RGL_CLAMP_TO_BORDER = 0x812D, - RGL_MIRRORED_REPEAT = 0x8370, - RGL_MIRROR_CLAMP = 0x8742, - RGL_MIRROR_CLAMP_TO_EDGE = 0x8743, - RGL_MIRROR_CLAMP_TO_BORDER = 0x8912, - RGL_GAMMA_REMAP_RED_BIT = 0x0001, - RGL_GAMMA_REMAP_GREEN_BIT = 0x0002, - RGL_GAMMA_REMAP_BLUE_BIT = 0x0004, - RGL_GAMMA_REMAP_ALPHA_BIT = 0x0008, - RGL_TEXTURE_WRAP_S = 0x2802, - RGL_TEXTURE_WRAP_T = 0x2803, - RGL_TEXTURE_WRAP_R = 0x8072, - RGL_TEXTURE_MIN_FILTER = 0x2801, - RGL_TEXTURE_MAG_FILTER = 0x2800, - RGL_TEXTURE_MAX_ANISOTROPY = 0x84FE, - RGL_TEXTURE_COMPARE_FUNC = 0x884D, - RGL_TEXTURE_MIN_LOD = 0x813A, - RGL_TEXTURE_MAX_LOD = 0x813B, - RGL_TEXTURE_LOD_BIAS = 0x8501, - RGL_TEXTURE_BORDER_COLOR = 0x1004, - RGL_TEXTURE_GAMMA_REMAP = 0xff30, - RGL_VERTEX_PROGRAM = 0x8620, - RGL_FRAGMENT_PROGRAM = 0x8804, - RGL_FLOAT = 0x1406, - RGL_HALF_FLOAT = 0x140B, - RGL_SHORT = 0x1402, - RGL_UNSIGNED_BYTE = 0x1401, - RGL_UNSIGNED_SHORT = 0x1403, - RGL_UNSIGNED_INT = 0x1405, - RGL_BYTE = 0x1400, - RGL_INT = 0x1404, - RGL_CMP = 0x6020, + RGL_NONE = 0x0000, + RGL_COLOR_BUFFER_BIT = 0x4000, + RGL_ZERO = 0, + RGL_ONE = 1, + RGL_SRC_COLOR = 0x0300, + RGL_ONE_MINUS_SRC_COLOR = 0x0301, + RGL_SRC_ALPHA = 0x0302, + RGL_ONE_MINUS_SRC_ALPHA = 0x0303, + RGL_DST_ALPHA = 0x0304, + RGL_ONE_MINUS_DST_ALPHA = 0x0305, + RGL_DST_COLOR = 0x0306, + RGL_ONE_MINUS_DST_COLOR = 0x0307, + RGL_SRC_ALPHA_SATURATE = 0x0308, + RGL_ONE_MINUS_CONSTANT_COLOR = 0x8002, + RGL_CONSTANT_ALPHA = 0x8003, + RGL_ONE_MINUS_CONSTANT_ALPHA = 0x8004, + RGL_MIN = 0x8007, + RGL_MAX = 0x8008, + RGL_FUNC_SUBTRACT = 0x800A, + RGL_FUNC_REVERSE_SUBTRACT = 0x800B, + RGL_LUMINANCE8 = 0x8040, + RGL_LUMINANCE16 = 0x8042, + RGL_ALPHA8 = 0x803C, + RGL_ALPHA16 = 0x803E, + RGL_INTENSITY8 = 0x804B, + RGL_INTENSITY16 = 0x804D, + RGL_LUMINANCE8_ALPHA8 = 0x8045, + RGL_LUMINANCE16_ALPHA16 = 0x8048, + RGL_HILO8 = 0x885E, + RGL_HILO16 = 0x86F8, + RGL_ARGB8 = 0x6007, + RGL_BGRA8 = 0xff01, + RGL_RGBA8 = 0x8058, + RGL_ABGR8 = 0xff02, + RGL_XBGR8 = 0xff03, + RGL_RGBX8 = 0xff07, + RGL_FLOAT_R32 = 0x8885, + RGL_FLOAT_RGBA16 = 0x888A, + RGL_FLOAT_RGBA32 = 0x888B, + RGL_FLOAT_RGBX16 = 0xff04, + RGL_FLOAT_RGBX32 = 0xff05, + RGL_LUMINANCE32F_ARB = 0x8818, + RGL_ALPHA_LUMINANCE16F_SCE = 0x600B, + RGL_RGB5_A1_SCE = 0x600C, + RGL_RGB565_SCE = 0x600D, + RGL_DITHER = 0x0bd0, + RGL_PSHADER_SRGB_REMAPPING = 0xff06, + RGL_VERTEX_ATTRIB_ARRAY0 = 0x8650, + RGL_VERTEX_ATTRIB_ARRAY1 = 0x8651, + RGL_VERTEX_ATTRIB_ARRAY2 = 0x8652, + RGL_VERTEX_ATTRIB_ARRAY3 = 0x8653, + RGL_VERTEX_ATTRIB_ARRAY4 = 0x8654, + RGL_VERTEX_ATTRIB_ARRAY5 = 0x8655, + RGL_VERTEX_ATTRIB_ARRAY6 = 0x8656, + RGL_VERTEX_ATTRIB_ARRAY7 = 0x8657, + RGL_VERTEX_ATTRIB_ARRAY8 = 0x8658, + RGL_VERTEX_ATTRIB_ARRAY9 = 0x8659, + RGL_VERTEX_ATTRIB_ARRAY10 = 0x865a, + RGL_VERTEX_ATTRIB_ARRAY11 = 0x865b, + RGL_VERTEX_ATTRIB_ARRAY12 = 0x865c, + RGL_VERTEX_ATTRIB_ARRAY13 = 0x865d, + RGL_VERTEX_ATTRIB_ARRAY14 = 0x865e, + RGL_VERTEX_ATTRIB_ARRAY15 = 0x865f, + RGL_CLAMP = 0x2900, + RGL_REPEAT = 0x2901, + RGL_CLAMP_TO_EDGE = 0x812F, + RGL_CLAMP_TO_BORDER = 0x812D, + RGL_MIRRORED_REPEAT = 0x8370, + RGL_MIRROR_CLAMP = 0x8742, + RGL_MIRROR_CLAMP_TO_EDGE = 0x8743, + RGL_MIRROR_CLAMP_TO_BORDER = 0x8912, + RGL_GAMMA_REMAP_RED_BIT = 0x0001, + RGL_GAMMA_REMAP_GREEN_BIT = 0x0002, + RGL_GAMMA_REMAP_BLUE_BIT = 0x0004, + RGL_GAMMA_REMAP_ALPHA_BIT = 0x0008, + RGL_TEXTURE_WRAP_S = 0x2802, + RGL_TEXTURE_WRAP_T = 0x2803, + RGL_TEXTURE_WRAP_R = 0x8072, + RGL_TEXTURE_MIN_FILTER = 0x2801, + RGL_TEXTURE_MAG_FILTER = 0x2800, + RGL_TEXTURE_MAX_ANISOTROPY = 0x84FE, + RGL_TEXTURE_COMPARE_FUNC = 0x884D, + RGL_TEXTURE_MIN_LOD = 0x813A, + RGL_TEXTURE_MAX_LOD = 0x813B, + RGL_TEXTURE_LOD_BIAS = 0x8501, + RGL_TEXTURE_BORDER_COLOR = 0x1004, + RGL_TEXTURE_GAMMA_REMAP = 0xff30, + RGL_VERTEX_PROGRAM = 0x8620, + RGL_FRAGMENT_PROGRAM = 0x8804, + RGL_FLOAT = 0x1406, + RGL_HALF_FLOAT = 0x140B, + RGL_SHORT = 0x1402, + RGL_UNSIGNED_BYTE = 0x1401, + RGL_UNSIGNED_SHORT = 0x1403, + RGL_UNSIGNED_INT = 0x1405, + RGL_BYTE = 0x1400, + RGL_INT = 0x1404, + RGL_CMP = 0x6020, } RGLEnum; typedef struct PSGLdevice PSGLdevice; @@ -138,30 +140,26 @@ extern RGLState _RGLState; struct RGLViewportState { - GLint x, y, w, h; - - GLfloat xScale, xCenter; - GLfloat yScale, yCenter; + GLint x, y, w, h; + GLfloat xScale, xCenter; + GLfloat yScale, yCenter; }; struct jsFramebufferAttachment { - GLenum type; - GLuint name; - GLenum textureTarget; - jsFramebufferAttachment(): type( GL_NONE ), name( 0 ), textureTarget( GL_NONE ) - {}; + GLenum type; + GLuint name; + GLenum textureTarget; + jsFramebufferAttachment(): type( GL_NONE ), name( 0 ), textureTarget( GL_NONE ) {}; }; struct jsFramebuffer { - jsFramebufferAttachment color[_RGL_MAX_COLOR_ATTACHMENTS]; - GLboolean needValidate; - jsFramebuffer(): needValidate( GL_TRUE ) - {}; - virtual ~jsFramebuffer() - {}; + jsFramebufferAttachment color[_RGL_MAX_COLOR_ATTACHMENTS]; + GLboolean needValidate; + jsFramebuffer(): needValidate( GL_TRUE ) {}; + virtual ~jsFramebuffer() {}; }; #define RGLBIT_GET(f,n) ((f) & (1<<(n))) @@ -170,125 +168,115 @@ struct jsFramebuffer #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 - -#if defined(_WIN64) - typedef __int64 RGLintptr; - typedef __int64 RGLsizeiptr; #else - typedef long RGLintptr; - typedef long RGLsizeiptr; -#endif - -#else - #define ALIGN16 #define _RGL_RESTRICT #pragma warning( push ) #pragma warning ( disable : 4200 ) - typedef intptr_t RGLintptr; - typedef size_t RGLsizeiptr; #endif +typedef intptr_t RGLintptr; +typedef size_t RGLsizeiptr; + typedef struct { - GLfloat X, Y , Z, W; + GLfloat X, Y , Z, W; } jsPositionXYZW; typedef struct { - GLfloat X, Y , Z; + GLfloat X, Y , Z; } jsPositionXYZ; typedef struct { - GLfloat R, G, B, A; + GLfloat R, G, B, A; } jsColorRGBAf; typedef struct { - GLfloat * MatrixStackf; - int MatrixStackPtr; - GLboolean dirty; + GLfloat * MatrixStackf; + int MatrixStackPtr; + GLboolean dirty; } jsMatrixStack; typedef struct { - int X, Y, XSize, YSize; + int X, Y, XSize, YSize; } jsViewPort; #define _RGL_IMAGE_STORAGE_RASTER 0 #define _RGL_IMAGE_STORAGE_BLOCK 1 enum { - _RGL_IMAGE_DATASTATE_UNSET = 0x0, - _RGL_IMAGE_DATASTATE_HOST = 0x1, - _RGL_IMAGE_DATASTATE_GPU = 0x2 + _RGL_IMAGE_DATASTATE_UNSET = 0x0, + _RGL_IMAGE_DATASTATE_HOST = 0x1, + _RGL_IMAGE_DATASTATE_GPU = 0x2 }; typedef struct jsImage_ { - GLboolean isSet; + GLboolean isSet; - GLenum internalFormat; - GLenum format; - GLenum type; - GLsizei width; - GLsizei height; - GLsizei alignment; + GLenum internalFormat; + GLenum format; + GLenum type; + GLsizei width; + GLsizei height; + GLsizei alignment; - GLsizei storageSize; - GLsizei xstride, ystride; - GLuint xblk, yblk; + GLsizei storageSize; + GLsizei xstride, ystride; + GLuint xblk, yblk; - char *data; - char *mallocData; - GLsizei mallocStorageSize; - GLenum dataState; + char *data; + char *mallocData; + GLsizei mallocStorageSize; + GLenum dataState; } jsImage; typedef struct { - GLenum format; - GLenum type; - GLsizei width; - GLsizei height; - GLsizei xstride; - GLsizei ystride; - void* data; + GLenum format; + GLenum type; + GLsizei width; + GLsizei height; + GLsizei xstride; + GLsizei ystride; + void* data; } jsRaster; #define _RGL_TEXTURE_REVALIDATE_LAYOUT 0x01 #define _RGL_TEXTURE_REVALIDATE_IMAGES 0x02 #define _RGL_TEXTURE_REVALIDATE_PARAMETERS 0x04 - typedef struct jsBufferObject jsBufferObject; +typedef struct jsBufferObject jsBufferObject; - typedef struct - { - GLuint revalidate; - GLuint target; +typedef struct +{ + GLuint revalidate; + GLuint target; - GLuint minFilter; - GLuint magFilter; - GLuint gammaRemap; - GLenum usage; + GLuint minFilter; + GLuint magFilter; + GLuint gammaRemap; + GLenum usage; - GLboolean isRenderTarget; - GLboolean isComplete; + GLboolean isRenderTarget; + GLboolean isComplete; - jsBufferObject *referenceBuffer; - GLintptr offset; + jsBufferObject *referenceBuffer; + GLintptr offset; - RGL::Vector framebuffers; + RGL::Vector framebuffers; - GLuint imageCount; - jsImage* image; - void * platformTexture[]; - } - jsTexture; + GLuint imageCount; + jsImage* image; + void * platformTexture[]; +} +jsTexture; #define _RGL_MAX_TEXTURE_COORDS 8 #define _RGL_MAX_TEXTURE_IMAGE_UNITS 16 @@ -308,146 +296,145 @@ typedef struct typedef struct { - GLuint bound2D; + GLuint bound2D; - jsTexture* default2D; + jsTexture* default2D; - GLenum fragmentTarget; + GLenum fragmentTarget; - GLenum envMode; - jsColorRGBAf envColor; + GLenum envMode; + jsColorRGBAf envColor; - jsTexture* currentTexture; + jsTexture* currentTexture; } jsTextureImageUnit; typedef struct { - GLuint revalidate; - jsMatrixStack TextureMatrixStack; + GLuint revalidate; + jsMatrixStack TextureMatrixStack; } jsTextureCoordsUnit; enum { - _RGL_FRAMEBUFFER_ATTACHMENT_NONE, - _RGL_FRAMEBUFFER_ATTACHMENT_RENDERBUFFER, - _RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE, + _RGL_FRAMEBUFFER_ATTACHMENT_NONE, + _RGL_FRAMEBUFFER_ATTACHMENT_RENDERBUFFER, + _RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE, }; typedef enum PSGLtvStandard { - PSGL_TV_STANDARD_NONE, - PSGL_TV_STANDARD_NTSC_M, - PSGL_TV_STANDARD_NTSC_J, - PSGL_TV_STANDARD_PAL_M, - PSGL_TV_STANDARD_PAL_B, - PSGL_TV_STANDARD_PAL_D, - PSGL_TV_STANDARD_PAL_G, - PSGL_TV_STANDARD_PAL_H, - PSGL_TV_STANDARD_PAL_I, - PSGL_TV_STANDARD_PAL_N, - PSGL_TV_STANDARD_PAL_NC, - PSGL_TV_STANDARD_HD480I, - PSGL_TV_STANDARD_HD480P, - PSGL_TV_STANDARD_HD576I, - PSGL_TV_STANDARD_HD576P, - PSGL_TV_STANDARD_HD720P, - PSGL_TV_STANDARD_HD1080I, - PSGL_TV_STANDARD_HD1080P, - PSGL_TV_STANDARD_1280x720_ON_VESA_1280x768 = 128, - PSGL_TV_STANDARD_1280x720_ON_VESA_1280x1024, - PSGL_TV_STANDARD_1920x1080_ON_VESA_1920x1200, + PSGL_TV_STANDARD_NONE, + PSGL_TV_STANDARD_NTSC_M, + PSGL_TV_STANDARD_NTSC_J, + PSGL_TV_STANDARD_PAL_M, + PSGL_TV_STANDARD_PAL_B, + PSGL_TV_STANDARD_PAL_D, + PSGL_TV_STANDARD_PAL_G, + PSGL_TV_STANDARD_PAL_H, + PSGL_TV_STANDARD_PAL_I, + PSGL_TV_STANDARD_PAL_N, + PSGL_TV_STANDARD_PAL_NC, + PSGL_TV_STANDARD_HD480I, + PSGL_TV_STANDARD_HD480P, + PSGL_TV_STANDARD_HD576I, + PSGL_TV_STANDARD_HD576P, + PSGL_TV_STANDARD_HD720P, + PSGL_TV_STANDARD_HD1080I, + PSGL_TV_STANDARD_HD1080P, + PSGL_TV_STANDARD_1280x720_ON_VESA_1280x768 = 128, + PSGL_TV_STANDARD_1280x720_ON_VESA_1280x1024, + PSGL_TV_STANDARD_1920x1080_ON_VESA_1920x1200, } PSGLtvStandard; typedef enum PSGLdeviceConnector { - PSGL_DEVICE_CONNECTOR_NONE, - PSGL_DEVICE_CONNECTOR_VGA, - PSGL_DEVICE_CONNECTOR_DVI, - PSGL_DEVICE_CONNECTOR_HDMI, - PSGL_DEVICE_CONNECTOR_COMPOSITE, - PSGL_DEVICE_CONNECTOR_SVIDEO, - PSGL_DEVICE_CONNECTOR_COMPONENT, + PSGL_DEVICE_CONNECTOR_NONE, + PSGL_DEVICE_CONNECTOR_VGA, + PSGL_DEVICE_CONNECTOR_DVI, + PSGL_DEVICE_CONNECTOR_HDMI, + PSGL_DEVICE_CONNECTOR_COMPOSITE, + PSGL_DEVICE_CONNECTOR_SVIDEO, + PSGL_DEVICE_CONNECTOR_COMPONENT, } PSGLdeviceConnector; typedef enum PSGLbufferingMode { - PSGL_BUFFERING_MODE_SINGLE = 1, - PSGL_BUFFERING_MODE_DOUBLE = 2, - PSGL_BUFFERING_MODE_TRIPLE = 3, + PSGL_BUFFERING_MODE_SINGLE = 1, + PSGL_BUFFERING_MODE_DOUBLE = 2, + PSGL_BUFFERING_MODE_TRIPLE = 3, } PSGLbufferingMode; typedef enum RescRatioMode { - RESC_RATIO_MODE_FULLSCREEN, - RESC_RATIO_MODE_LETTERBOX, - RESC_RATIO_MODE_PANSCAN, + RESC_RATIO_MODE_FULLSCREEN, + RESC_RATIO_MODE_LETTERBOX, + RESC_RATIO_MODE_PANSCAN, } RescRatioMode; typedef enum RescPalTemporalMode { - RESC_PAL_TEMPORAL_MODE_50_NONE, - RESC_PAL_TEMPORAL_MODE_60_DROP, - RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE, - RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE_30_DROP, - RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE_DROP_FLEXIBLE, + RESC_PAL_TEMPORAL_MODE_50_NONE, + RESC_PAL_TEMPORAL_MODE_60_DROP, + RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE, + RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE_30_DROP, + RESC_PAL_TEMPORAL_MODE_60_INTERPOLATE_DROP_FLEXIBLE, } RescPalTemporalMode; typedef enum RescInterlaceMode { - RESC_INTERLACE_MODE_NORMAL_BILINEAR, - RESC_INTERLACE_MODE_INTERLACE_FILTER, + RESC_INTERLACE_MODE_NORMAL_BILINEAR, + RESC_INTERLACE_MODE_INTERLACE_FILTER, } RescInterlaceMode; typedef struct { - GLuint enable; - GLenum colorFormat; - GLenum depthFormat; - GLenum multisamplingMode; - PSGLtvStandard TVStandard; - PSGLdeviceConnector connector; - PSGLbufferingMode bufferingMode; - GLuint width; - GLuint height; - GLuint renderWidth; - GLuint renderHeight; - RescRatioMode rescRatioMode; - RescPalTemporalMode rescPalTemporalMode; - RescInterlaceMode rescInterlaceMode; - GLfloat horizontalScale; - GLfloat verticalScale; + GLuint enable; + GLenum colorFormat; + GLenum depthFormat; + GLenum multisamplingMode; + PSGLtvStandard TVStandard; + PSGLdeviceConnector connector; + PSGLbufferingMode bufferingMode; + GLuint width; + GLuint height; + GLuint renderWidth; + GLuint renderHeight; + RescRatioMode rescRatioMode; + RescPalTemporalMode rescPalTemporalMode; + RescInterlaceMode rescInterlaceMode; + GLfloat horizontalScale; + GLfloat verticalScale; } PSGLdeviceParameters; struct PSGLdevice { - PSGLdeviceParameters deviceParameters; - - GLvoid* rasterDriver; - char platformDevice[]; + PSGLdeviceParameters deviceParameters; + GLvoid* rasterDriver; + char platformDevice[]; }; typedef struct { - GLenum mode; - GLint firstVertex; - GLsizei vertexCount; + GLenum mode; + GLint firstVertex; + GLsizei vertexCount; - GLuint xferTotalSize; - GLuint indexXferOffset; - GLuint indexXferSize; - GLuint attribXferTotalSize; - GLuint attribXferOffset[_RGL_MAX_VERTEX_ATTRIBS]; - GLuint attribXferSize[_RGL_MAX_VERTEX_ATTRIBS]; + GLuint xferTotalSize; + GLuint indexXferOffset; + GLuint indexXferSize; + GLuint attribXferTotalSize; + GLuint attribXferOffset[_RGL_MAX_VERTEX_ATTRIBS]; + GLuint attribXferSize[_RGL_MAX_VERTEX_ATTRIBS]; } jsDrawParams; #define _RGL_ATTRIB_POSITION_INDEX 0 -#define _RGL_ATTRIB_WEIGHT_INDEX 1 -#define _RGL_ATTRIB_NORMAL_INDEX 2 -#define _RGL_ATTRIB_PRIMARY_COLOR_INDEX 3 -#define _RGL_ATTRIB_SECONDARY_COLOR_INDEX 4 +#define _RGL_ATTRIB_WEIGHT_INDEX 1 +#define _RGL_ATTRIB_NORMAL_INDEX 2 +#define _RGL_ATTRIB_PRIMARY_COLOR_INDEX 3 +#define _RGL_ATTRIB_SECONDARY_COLOR_INDEX 4 #define _RGL_ATTRIB_FOG_COORD_INDEX 5 #define _RGL_ATTRIB_POINT_SIZE_INDEX 6 -#define _RGL_ATTRIB_BLEND_INDICES_INDEX 7 +#define _RGL_ATTRIB_BLEND_INDICES_INDEX 7 #define _RGL_ATTRIB_TEX_COORD0_INDEX 8 #define _RGL_ATTRIB_TEX_COORD1_INDEX 9 #define _RGL_ATTRIB_TEX_COORD2_INDEX 10 @@ -457,54 +444,53 @@ typedef struct #define _RGL_ATTRIB_TEX_COORD6_INDEX 14 #define _RGL_ATTRIB_TEX_COORD7_INDEX 15 - typedef struct - { - GLvoid* clientData; - GLuint clientSize; - GLenum clientType; - GLsizei clientStride; - GLuint arrayBuffer; - GLfloat value[4]; - GLuint frequency; - GLboolean normalized; - } - ALIGN16 jsAttribute; +typedef struct +{ + GLvoid* clientData; + GLuint clientSize; + GLenum clientType; + GLsizei clientStride; + GLuint arrayBuffer; + GLfloat value[4]; + GLuint frequency; + GLboolean normalized; +} +ALIGN16 jsAttribute; - typedef struct - { - jsAttribute attrib[_RGL_MAX_VERTEX_ATTRIBS]; - unsigned int DirtyMask; - unsigned int EnabledMask; - unsigned int NeedsConversionMask; - unsigned int HasVBOMask; - unsigned int ModuloMask; - } - ALIGN16 jsAttributeState; +typedef struct +{ + jsAttribute attrib[_RGL_MAX_VERTEX_ATTRIBS]; + unsigned int DirtyMask; + unsigned int EnabledMask; + unsigned int NeedsConversionMask; + unsigned int HasVBOMask; + unsigned int ModuloMask; +} +ALIGN16 jsAttributeState; - typedef struct - { - jsAttributeState attribs; - GLboolean dirty; - unsigned int beenUpdatedMask; - GLvoid* cmdBuffer; - GLuint cmdNumWords; - } - ALIGN16 jsAttribSet; - - struct jsBufferObject - { - GLuint refCount; - GLsizeiptr size; - GLenum usage; - GLboolean mapped; - GLenum internalFormat; - GLuint width; - GLuint height; - RGL::Vector textureReferences; - RGL::Vector attribSets; - void *platformBufferObject[]; - }; +typedef struct +{ + jsAttributeState attribs; + GLboolean dirty; + unsigned int beenUpdatedMask; + GLvoid* cmdBuffer; + GLuint cmdNumWords; +} +ALIGN16 jsAttribSet; +struct jsBufferObject +{ + GLuint refCount; + GLsizeiptr size; + GLenum usage; + GLboolean mapped; + GLenum internalFormat; + GLuint width; + GLuint height; + RGL::Vector textureReferences; + RGL::Vector attribSets; + void *platformBufferObject[]; +}; #define _RGL_CONTEXT_RED_MASK 0x01 #define _RGL_CONTEXT_GREEN_MASK 0x02 @@ -515,86 +501,86 @@ typedef struct #define ELEMENTS_IN_MATRIX 16 - typedef struct jsNameSpace - { - void** data; - void** firstFree; - unsigned long capacity; - } - jsNameSpace; +typedef struct jsNameSpace +{ + void** data; + void** firstFree; + unsigned long capacity; +} +jsNameSpace; - typedef void *( *jsTexNameSpaceCreateFunction )( void ); - typedef void( *jsTexNameSpaceDestroyFunction )( void * ); +typedef void *( *jsTexNameSpaceCreateFunction )( void ); +typedef void( *jsTexNameSpaceDestroyFunction )( void * ); - typedef struct jsTexNameSpace - { - void** data; - GLuint capacity; - jsTexNameSpaceCreateFunction create; - jsTexNameSpaceDestroyFunction destroy; - } - jsTexNameSpace; +typedef struct jsTexNameSpace +{ + void** data; + GLuint capacity; + jsTexNameSpaceCreateFunction create; + jsTexNameSpaceDestroyFunction destroy; +} +jsTexNameSpace; - struct PSGLcontext - { - GLenum error; - int MatrixMode; - jsMatrixStack ModelViewMatrixStack; - jsMatrixStack ProjectionMatrixStack; - GLfloat LocalToScreenMatrixf[ELEMENTS_IN_MATRIX]; - GLfloat InverseModelViewMatrixf[ELEMENTS_IN_MATRIX]; - GLboolean InverseModelViewValid; - GLfloat ScalingFactor; - jsViewPort ViewPort; - jsAttributeState defaultAttribs0; - jsAttributeState *attribs; - jsTexNameSpace attribSetNameSpace; - GLuint attribSetName; - GLboolean attribSetDirty; - jsColorRGBAf ClearColor; - jsColorRGBAf AccumClearColor; - GLboolean ShaderSRGBRemap; - GLboolean Blending; - GLboolean BlendingMrt[3]; - GLenum BlendEquationRGB; - GLenum BlendEquationAlpha; - GLenum BlendFactorSrcRGB; - GLenum BlendFactorDestRGB; - GLenum BlendFactorSrcAlpha; - GLenum BlendFactorDestAlpha; - jsColorRGBAf BlendColor; - GLboolean Dithering; - jsTexNameSpace textureNameSpace; - GLuint ActiveTexture; - GLuint CS_ActiveTexture; - jsTextureImageUnit TextureImageUnits[_RGL_MAX_TEXTURE_IMAGE_UNITS]; - jsTextureImageUnit* CurrentImageUnit; - jsTextureCoordsUnit TextureCoordsUnits[_RGL_MAX_TEXTURE_COORDS]; - jsTextureCoordsUnit* CurrentCoordsUnit; - jsTexture *VertexTextureImages[_RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; - GLsizei packAlignment; - GLsizei unpackAlignment; - jsTexNameSpace bufferObjectNameSpace; - GLuint ArrayBuffer; - GLuint PixelUnpackBuffer; - GLuint TextureBuffer; - GLuint framebuffer; - jsTexNameSpace framebufferNameSpace; - GLboolean VertexProgram; - struct _CGprogram* BoundVertexProgram; - GLboolean FragmentProgram; - struct _CGprogram* BoundFragmentProgram; - GLboolean AllowTXPDemotion; - GLboolean VSync; - GLuint needValidate; - GLboolean everAttached; - CGerror RGLcgLastError; - CGerrorCallbackFunc RGLcgErrorCallbackFunction; - CGcontext RGLcgContextHead; - jsNameSpace cgContextNameSpace; - jsNameSpace cgProgramNameSpace; - jsNameSpace cgParameterNameSpace; - }; +struct PSGLcontext +{ + GLenum error; + int MatrixMode; + jsMatrixStack ModelViewMatrixStack; + jsMatrixStack ProjectionMatrixStack; + GLfloat LocalToScreenMatrixf[ELEMENTS_IN_MATRIX]; + GLfloat InverseModelViewMatrixf[ELEMENTS_IN_MATRIX]; + GLboolean InverseModelViewValid; + GLfloat ScalingFactor; + jsViewPort ViewPort; + jsAttributeState defaultAttribs0; + jsAttributeState *attribs; + jsTexNameSpace attribSetNameSpace; + GLuint attribSetName; + GLboolean attribSetDirty; + jsColorRGBAf ClearColor; + jsColorRGBAf AccumClearColor; + GLboolean ShaderSRGBRemap; + GLboolean Blending; + GLboolean BlendingMrt[3]; + GLenum BlendEquationRGB; + GLenum BlendEquationAlpha; + GLenum BlendFactorSrcRGB; + GLenum BlendFactorDestRGB; + GLenum BlendFactorSrcAlpha; + GLenum BlendFactorDestAlpha; + jsColorRGBAf BlendColor; + GLboolean Dithering; + jsTexNameSpace textureNameSpace; + GLuint ActiveTexture; + GLuint CS_ActiveTexture; + jsTextureImageUnit TextureImageUnits[_RGL_MAX_TEXTURE_IMAGE_UNITS]; + jsTextureImageUnit* CurrentImageUnit; + jsTextureCoordsUnit TextureCoordsUnits[_RGL_MAX_TEXTURE_COORDS]; + jsTextureCoordsUnit* CurrentCoordsUnit; + jsTexture *VertexTextureImages[_RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; + GLsizei packAlignment; + GLsizei unpackAlignment; + jsTexNameSpace bufferObjectNameSpace; + GLuint ArrayBuffer; + GLuint PixelUnpackBuffer; + GLuint TextureBuffer; + GLuint framebuffer; + jsTexNameSpace framebufferNameSpace; + GLboolean VertexProgram; + struct _CGprogram* BoundVertexProgram; + GLboolean FragmentProgram; + struct _CGprogram* BoundFragmentProgram; + GLboolean AllowTXPDemotion; + GLboolean VSync; + GLuint needValidate; + GLboolean everAttached; + CGerror RGLcgLastError; + CGerrorCallbackFunc RGLcgErrorCallbackFunction; + CGcontext RGLcgContextHead; + jsNameSpace cgContextNameSpace; + jsNameSpace cgProgramNameSpace; + jsNameSpace cgParameterNameSpace; +}; #define jsContextGetMatrixStack(mContext, mMatrixMode, mMatrixStack) do \ {\ @@ -633,74 +619,73 @@ typedef struct #define _RGL_ALLOC_FIRST_FIT 0 #define _RGL_ALLOC_BEST_FIT 1 - static inline float _RGLClampf( const float value ) - { - return MAX( MIN( value, 1.f ), 0.f ); - } +static inline float _RGLClampf( const float value ) +{ + return MAX( MIN( value, 1.f ), 0.f ); +} - static inline unsigned int endianSwapWord( unsigned int v ) - { - return ( v&0xff ) << 24 | ( v&0xff00 ) << 8 | - ( v&0xff0000 ) >> 8 | ( v&0xff000000 ) >> 24; - } +static inline unsigned int endianSwapWord( unsigned int v ) +{ + return ( v&0xff ) << 24 | ( v&0xff00 ) << 8 | + ( v&0xff0000 ) >> 8 | ( v&0xff000000 ) >> 24; +} - static inline int _RGLLog2( unsigned int i ) - { - int l = 0; - while ( i ) - { - ++l; - i >>= 1; - } - return l -1; - } +static inline int _RGLLog2( unsigned int i ) +{ + int l = 0; + while ( i ) + { + ++l; + i >>= 1; + } + return l -1; +} - static inline unsigned long _RGLPad( unsigned long x, unsigned long pad ) - { - return ( x + pad - 1 ) / pad*pad; - } +static inline unsigned long _RGLPad( unsigned long x, unsigned long pad ) +{ + return ( x + pad - 1 ) / pad*pad; +} - static inline char* _RGLPadPtr( const char* p, unsigned int pad ) - { - RGLintptr x = ( RGLintptr )p; - x = ( x + pad - 1 ) / pad * pad; - return ( char* )x; - } +static inline char* _RGLPadPtr( const char* p, unsigned int pad ) +{ + RGLintptr x = ( RGLintptr )p; + x = ( x + pad - 1 ) / pad * pad; + return ( char* )x; +} - typedef struct MemoryBlockManager_t_ - { - char *memory; - GLuint size; - GLuint minAlignment; - GLenum method; - GLuint *book; - GLint bookSize; - GLint bookAlloc; - } - MemoryBlockManager_t; +typedef struct MemoryBlockManager_t_ +{ + char *memory; + GLuint size; + GLuint minAlignment; + GLenum method; + GLuint *book; + GLint bookSize; + GLint bookAlloc; +} MemoryBlockManager_t; +typedef unsigned long jsName; - typedef unsigned long jsName; +void _RGLInitNameSpace( struct jsNameSpace * name ); +void _RGLFreeNameSpace( struct jsNameSpace * name ); +jsName _RGLCreateName( struct jsNameSpace * ns, void* object ); +unsigned int _RGLIsName( struct jsNameSpace* ns, jsName name ); +void _RGLEraseName( struct jsNameSpace* ns, jsName name ); - void _RGLInitNameSpace( struct jsNameSpace * name ); - void _RGLFreeNameSpace( struct jsNameSpace * name ); - jsName _RGLCreateName( struct jsNameSpace * ns, void* object ); - unsigned int _RGLIsName( struct jsNameSpace* ns, jsName name ); - void _RGLEraseName( struct jsNameSpace* ns, jsName name ); - static inline void * _RGLGetNamedValue( struct jsNameSpace* ns, jsName name ) - { - return ns->data[name - 1]; - } +static inline void * _RGLGetNamedValue( struct jsNameSpace* ns, jsName name ) +{ + return ns->data[name - 1]; +} - void _RGLTexNameSpaceInit( jsTexNameSpace *ns, jsTexNameSpaceCreateFunction create, jsTexNameSpaceDestroyFunction destroy ); - void _RGLTexNameSpaceFree( jsTexNameSpace *ns ); - void _RGLTexNameSpaceResetNames( jsTexNameSpace *ns ); - GLuint _RGLTexNameSpaceGetFree( jsTexNameSpace *ns ); - GLboolean _RGLTexNameSpaceCreateNameLazy( jsTexNameSpace *ns, GLuint name ); - GLboolean _RGLTexNameSpaceIsName( jsTexNameSpace *ns, GLuint name ); - void _RGLTexNameSpaceGenNames( jsTexNameSpace *ns, GLsizei n, GLuint *names ); - void _RGLTexNameSpaceDeleteNames( jsTexNameSpace *ns, GLsizei n, const GLuint *names ); - void _RGLTexNameSpaceReinit( jsTexNameSpace * saved, jsTexNameSpace * active ); +void _RGLTexNameSpaceInit( jsTexNameSpace *ns, jsTexNameSpaceCreateFunction create, jsTexNameSpaceDestroyFunction destroy ); +void _RGLTexNameSpaceFree( jsTexNameSpace *ns ); +void _RGLTexNameSpaceResetNames( jsTexNameSpace *ns ); +GLuint _RGLTexNameSpaceGetFree( jsTexNameSpace *ns ); +GLboolean _RGLTexNameSpaceCreateNameLazy( jsTexNameSpace *ns, GLuint name ); +GLboolean _RGLTexNameSpaceIsName( jsTexNameSpace *ns, GLuint name ); +void _RGLTexNameSpaceGenNames( jsTexNameSpace *ns, GLsizei n, GLuint *names ); +void _RGLTexNameSpaceDeleteNames( jsTexNameSpace *ns, GLsizei n, const GLuint *names ); +void _RGLTexNameSpaceReinit( jsTexNameSpace * saved, jsTexNameSpace * active ); #define RGL_MEMORY_ALLOC_ERROR 0 @@ -738,62 +723,63 @@ typedef struct typedef struct GmmFixedAllocData { - char **ppBlockList[2]; - uint16_t **ppFreeBlockList[2]; - uint16_t *pBlocksUsed[2]; - uint16_t BlockListCount[2]; -}GmmFixedAllocData; + char **ppBlockList[2]; + uint16_t **ppFreeBlockList[2]; + uint16_t *pBlocksUsed[2]; + uint16_t BlockListCount[2]; +} GmmFixedAllocData; typedef struct GmmBaseBlock { - uint8_t isTile; - uint8_t isMain; - uint32_t address; - uint32_t size; -}GmmBaseBlock; + uint8_t isTile; + uint8_t isMain; + uint32_t address; + uint32_t size; +} GmmBaseBlock; typedef struct GmmBlock { - GmmBaseBlock base; - struct GmmBlock *pPrev; - struct GmmBlock *pNext; - uint8_t isPinned; - struct GmmBlock *pPrevFree; - struct GmmBlock *pNextFree; - uint32_t fence; -}GmmBlock; + GmmBaseBlock base; + struct GmmBlock *pPrev; + struct GmmBlock *pNext; + uint8_t isPinned; + struct GmmBlock *pPrevFree; + struct GmmBlock *pNextFree; + uint32_t fence; +} GmmBlock; typedef struct GmmTileBlock { - GmmBaseBlock base; - struct GmmTileBlock *pPrev; - struct GmmTileBlock *pNext; + GmmBaseBlock base; + struct GmmTileBlock *pPrev; + struct GmmTileBlock *pNext; - uint32_t tileTag; - void *pData; -}GmmTileBlock; + uint32_t tileTag; + void *pData; +} GmmTileBlock; -typedef struct GmmAllocator{ - uint32_t memoryBase; +typedef struct GmmAllocator +{ + uint32_t memoryBase; - uint32_t startAddress; - uint32_t size; - uint32_t freeAddress; + uint32_t startAddress; + uint32_t size; + uint32_t freeAddress; - GmmBlock *pHead; - GmmBlock *pTail; - GmmBlock *pSweepHead; - uint32_t freedSinceSweep; - uint32_t tileStartAddress; - uint32_t tileSize; - GmmTileBlock *pTileHead; - GmmTileBlock *pTileTail; - GmmBlock *pPendingFreeHead; - GmmBlock *pPendingFreeTail; - GmmBlock *pFreeHead[GMM_NUM_FREE_BINS]; - GmmBlock *pFreeTail[GMM_NUM_FREE_BINS]; - uint32_t totalSize; -}GmmAllocator; + GmmBlock *pHead; + GmmBlock *pTail; + GmmBlock *pSweepHead; + uint32_t freedSinceSweep; + uint32_t tileStartAddress; + uint32_t tileSize; + GmmTileBlock *pTileHead; + GmmTileBlock *pTileTail; + GmmBlock *pPendingFreeHead; + GmmBlock *pPendingFreeTail; + GmmBlock *pFreeHead[GMM_NUM_FREE_BINS]; + GmmBlock *pFreeTail[GMM_NUM_FREE_BINS]; + uint32_t totalSize; +} GmmAllocator; uint32_t gmmInit( const void *localMemoryBase, @@ -865,73 +851,73 @@ void gmmSetTileAttrib( typedef struct PSGLinitOptions { - GLuint enable; - int errorConsole; - GLuint fifoSize; - GLuint hostMemorySize; + GLuint enable; + int errorConsole; + GLuint fifoSize; + GLuint hostMemorySize; } PSGLinitOptions; struct RGLSemaphore { - GLuint val; - GLuint pad0; - GLuint pad1; - GLuint pad2; + GLuint val; + GLuint pad0; + GLuint pad1; + GLuint pad2; }; struct RGLSemaphoreMemory { - RGLSemaphore userSemaphores[256]; + RGLSemaphore userSemaphores[256]; }; struct RGLResource { - char *localAddress; - GLuint localSize; - GLuint MemoryClock; - GLuint GraphicsClock; - char * hostMemoryBase; - GLuint hostMemorySize; - GLuint hostMemoryReserved; - unsigned long dmaPushBufferOffset; - char * dmaPushBuffer; - GLuint dmaPushBufferSize; - void* dmaControl; - RGLSemaphoreMemory *semaphores; + char *localAddress; + GLuint localSize; + GLuint MemoryClock; + GLuint GraphicsClock; + char * hostMemoryBase; + GLuint hostMemorySize; + GLuint hostMemoryReserved; + unsigned long dmaPushBufferOffset; + char * dmaPushBuffer; + GLuint dmaPushBufferSize; + void* dmaControl; + RGLSemaphoreMemory *semaphores; }; typedef volatile struct { - GLuint Ignored00[0x010]; - GLuint Put; - GLuint Get; - GLuint Reference; - GLuint Ignored01[0x1]; - GLuint SetReference; - GLuint TopLevelGet; - GLuint Ignored02[0x2]; - GLuint SetContextDmaSemaphore; - GLuint SetSemaphoreOffset; - GLuint SetSemaphoreAcquire; - GLuint SetSemaphoreRelease; - GLuint Ignored03[0x7e4]; + GLuint Ignored00[0x010]; + GLuint Put; + GLuint Get; + GLuint Reference; + GLuint Ignored01[0x1]; + GLuint SetReference; + GLuint TopLevelGet; + GLuint Ignored02[0x2]; + GLuint SetContextDmaSemaphore; + GLuint SetSemaphoreOffset; + GLuint SetSemaphoreAcquire; + GLuint SetSemaphoreRelease; + GLuint Ignored03[0x7e4]; } RGLControlDma; struct RGLFifo: public CellGcmContextData { - RGLControlDma *dmaControl; - uint32_t *dmaPushBufferBegin; - uint32_t *dmaPushBufferEnd; - GLuint fifoBlockSize; - unsigned long dmaPushBufferOffset; - GLuint dmaPushBufferSizeInWords; - uint32_t *lastPutWritten; - uint32_t *lastGetRead; - GLuint lastSWReferenceWritten; - GLuint lastSWReferenceFlushed; - GLuint lastHWReferenceRead; - uint32_t *dmaPushBufferGPU; - int spuid; + RGLControlDma *dmaControl; + uint32_t *dmaPushBufferBegin; + uint32_t *dmaPushBufferEnd; + GLuint fifoBlockSize; + unsigned long dmaPushBufferOffset; + GLuint dmaPushBufferSizeInWords; + uint32_t *lastPutWritten; + uint32_t *lastGetRead; + GLuint lastSWReferenceWritten; + GLuint lastSWReferenceFlushed; + GLuint lastHWReferenceRead; + uint32_t *dmaPushBufferGPU; + int spuid; }; typedef struct RGLRenderTarget RGLRenderTarget; @@ -941,44 +927,42 @@ typedef struct RGLInterpolantState RGLInterpolantState; struct RGLInterpolantState { - GLuint vertexProgramAttribMask; - GLuint fragmentProgramAttribMask; + GLuint vertexProgramAttribMask; + GLuint fragmentProgramAttribMask; }; struct RGLBlendState { - GLuint alphaFunc; - GLfloat alphaRef; + GLuint alphaFunc; + GLfloat alphaRef; }; struct RGLRenderTarget { - GLuint colorFormat; - GLuint colorBufferCount; - - GLuint yInverted; - - CellGcmSurface gcmRenderTarget; + GLuint colorFormat; + GLuint colorBufferCount; + GLuint yInverted; + CellGcmSurface gcmRenderTarget; }; struct RGLCachedState { - RGLBlendState blend; - RGLViewportState viewport; - RGLInterpolantState interpolant; + RGLBlendState blend; + RGLViewportState viewport; + RGLInterpolantState interpolant; }; struct RGLState { - char *localAddress; - void *hostMemoryBase; - GLuint hostMemorySize; - RGLSemaphoreMemory *semaphores; - RGLFifo fifo; - RGLRenderTarget renderTarget; - RGLCachedState state; - CellGcmConfig config; - GLuint labelValue; + char *localAddress; + void *hostMemoryBase; + GLuint hostMemorySize; + RGLSemaphoreMemory *semaphores; + RGLFifo fifo; + RGLRenderTarget renderTarget; + RGLCachedState state; + CellGcmConfig config; + GLuint labelValue; }; GLboolean _RGLInit( PSGLinitOptions* options, RGLResource *resource ); @@ -991,99 +975,101 @@ void _RGLIncFenceRef( GLuint* ref ); typedef struct { - GLenum pool; - unsigned int bufferId; - unsigned int bufferSize; - unsigned int pitch; + GLenum pool; + unsigned int bufferId; + unsigned int bufferSize; + unsigned int pitch; - GLuint mapCount; - GLenum mapAccess; + GLuint mapCount; + GLenum mapAccess; } RGLBufferObject; void _RGLSetNativeCgVertexProgram( const void *header ); void _RGLSetNativeCgFragmentProgram( const void *header ); - GLboolean _RGLTryResizeTileRegion( GLuint address, GLuint size, void* data ); - void _RGLGetTileRegionInfo( void* data, GLuint *address, GLuint *size ); +GLboolean _RGLTryResizeTileRegion( GLuint address, GLuint size, void* data ); +void _RGLGetTileRegionInfo( void* data, GLuint *address, GLuint *size ); - static inline GLuint _RGLPlatformGetBitsPerPixel( GLenum internalFormat ) - { - switch ( internalFormat ) - { - case RGL_HILO8: - case RGL_RGB5_A1_SCE: - case RGL_RGB565_SCE: - return 16; - case RGL_ALPHA8: - return 8; - case RGL_RGBX8: - case RGL_RGBA8: - case RGL_ABGR8: - case RGL_ARGB8: - case RGL_BGRA8: - return 32; - default: - return 0; - } - } +static inline GLuint _RGLPlatformGetBitsPerPixel( GLenum internalFormat ) +{ + switch ( internalFormat ) + { + case RGL_HILO8: + case RGL_RGB5_A1_SCE: + case RGL_RGB565_SCE: + return 16; + case RGL_ALPHA8: + return 8; + case RGL_RGBX8: + case RGL_RGBA8: + case RGL_ABGR8: + case RGL_ARGB8: + case RGL_BGRA8: + return 32; + default: + return 0; + } +} - void static inline _RGLFifoGlViewport( GLint x, GLint y, GLsizei width, GLsizei height, GLclampf zNear = 0.0f, GLclampf zFar = 1.0f ) - { - RGLViewportState *vp = &_RGLState.state.viewport; - RGLRenderTarget *rt = &_RGLState.renderTarget; - GLint clipX0, clipX1, clipY0, clipY1; +void static inline _RGLFifoGlViewport( GLint x, GLint y, GLsizei width, GLsizei height, GLclampf zNear = 0.0f, GLclampf zFar = 1.0f ) +{ + RGLViewportState *vp = &_RGLState.state.viewport; + RGLRenderTarget *rt = &_RGLState.renderTarget; + GLint clipX0, clipX1, clipY0, clipY1; - vp->x = x; - vp->y = y; - vp->w = width; - vp->h = height; + vp->x = x; + vp->y = y; + vp->w = width; + vp->h = height; - clipX0 = x; - clipX1 = x + width; - clipY0 = y; - clipY1 = y + height; + clipX0 = x; + clipX1 = x + width; + clipY0 = y; + clipY1 = y + height; - if ( rt->yInverted ) - { - clipY0 = rt->gcmRenderTarget.height - ( y + height ); - clipY1 = rt->gcmRenderTarget.height - y; - } + if ( rt->yInverted ) + { + clipY0 = rt->gcmRenderTarget.height - ( y + height ); + clipY1 = rt->gcmRenderTarget.height - y; + } - if ( clipX0 < 0 ) - clipX0 = 0; + if ( clipX0 < 0 ) + clipX0 = 0; - if ( clipY0 < 0 ) - clipY0 = 0; + if ( clipY0 < 0 ) + clipY0 = 0; - if ( clipX1 >= CELL_GCM_MAX_RT_DIMENSION ) - clipX1 = CELL_GCM_MAX_RT_DIMENSION; + if ( clipX1 >= CELL_GCM_MAX_RT_DIMENSION ) + clipX1 = CELL_GCM_MAX_RT_DIMENSION; - if ( clipY1 >= CELL_GCM_MAX_RT_DIMENSION ) - clipY1 = CELL_GCM_MAX_RT_DIMENSION; + if ( clipY1 >= CELL_GCM_MAX_RT_DIMENSION ) + clipY1 = CELL_GCM_MAX_RT_DIMENSION; - if (( clipX1 <= clipX0 ) || ( clipY1 <= clipY0 ) ) - clipX0 = clipY0 = clipX1 = clipY1 = 0; + if (( clipX1 <= clipX0 ) || ( clipY1 <= clipY0 ) ) + clipX0 = clipY0 = clipX1 = clipY1 = 0; - vp->xScale = width * 0.5f; - vp->xCenter = ( GLfloat )( x + vp->xScale + RGL_SUBPIXEL_ADJUST ); - if ( rt->yInverted ) - { - vp->yScale = height * -0.5f; - vp->yCenter = ( GLfloat )( rt->gcmRenderTarget.height - RGL_VIEWPORT_EPSILON - y + vp->yScale + RGL_SUBPIXEL_ADJUST ); - } - else - { - vp->yScale = height * 0.5f; - vp->yCenter = ( GLfloat )( y + vp->yScale + RGL_SUBPIXEL_ADJUST ); - } + vp->xScale = width * 0.5f; + vp->xCenter = ( GLfloat )( x + vp->xScale + RGL_SUBPIXEL_ADJUST ); + vp->yScale = height; - float scale[4] = { vp->xScale, vp->yScale, 0.5f, 0.0f }; - float offset[4] = { vp->xCenter, vp->yCenter, 0.5f, 0.0f }; + if ( rt->yInverted ) + { + vp->yScale *= -0.5f; + vp->yCenter = ( GLfloat )( rt->gcmRenderTarget.height - RGL_VIEWPORT_EPSILON - y + vp->yScale + RGL_SUBPIXEL_ADJUST ); + } + else + { + vp->yScale *= 0.5f; + vp->yCenter = ( GLfloat )( y + vp->yScale + RGL_SUBPIXEL_ADJUST ); + } - cellGcmSetViewportInline( &_RGLState.fifo, clipX0, clipY0, clipX1 - clipX0, - clipY1 - clipY0, zNear, zFar, scale, offset ); - } + float scale[4] = { vp->xScale, vp->yScale, 0.5f, 0.0f }; + float offset[4] = { vp->xCenter, vp->yCenter, 0.5f, 0.0f }; + + cellGcmSetViewportInline( &_RGLState.fifo, clipX0, clipY0, clipX1 - clipX0, + clipY1 - clipY0, zNear, zFar, scale, offset ); +} #define PSGL_DEVICE_PARAMETERS_COLOR_FORMAT 0x0001 #define PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT 0x0002 @@ -1103,35 +1089,35 @@ void _RGLSetNativeCgFragmentProgram( const void *header ); #define PSGL_VALIDATE_FRAMEBUFFER 0x00000001 #define PSGL_VALIDATE_TEXTURES_USED 0x00000002 #define PSGL_VALIDATE_VERTEX_PROGRAM 0x00000004 -#define PSGL_VALIDATE_VERTEX_CONSTANTS 0x00000008 -#define PSGL_VALIDATE_VERTEX_TEXTURES_USED 0x00000010 -#define PSGL_VALIDATE_FFX_VERTEX_PROGRAM 0x00000020 -#define PSGL_VALIDATE_FRAGMENT_PROGRAM 0x00000040 -#define PSGL_VALIDATE_FFX_FRAGMENT_PROGRAM 0x00000080 -#define PSGL_VALIDATE_VIEWPORT 0x00000200 -#define PSGL_VALIDATE_FACE_CULL 0x00010000 -#define PSGL_VALIDATE_BLENDING 0x00020000 -#define PSGL_VALIDATE_POINT_RASTER 0x00040000 -#define PSGL_VALIDATE_LINE_RASTER 0x00080000 -#define PSGL_VALIDATE_POLYGON_OFFSET 0x00100000 -#define PSGL_VALIDATE_SHADE_MODEL 0x00200000 -#define PSGL_VALIDATE_LOGIC_OP 0x00400000 -#define PSGL_VALIDATE_MULTISAMPLING 0x00800000 -#define PSGL_VALIDATE_POLYGON_MODE 0x01000000 -#define PSGL_VALIDATE_PRIMITIVE_RESTART 0x02000000 -#define PSGL_VALIDATE_CLIP_PLANES 0x04000000 -#define PSGL_VALIDATE_SHADER_SRGB_REMAP 0x08000000 -#define PSGL_VALIDATE_POINT_SPRITE 0x10000000 -#define PSGL_VALIDATE_TWO_SIDE_COLOR 0x20000000 -#define PSGL_VALIDATE_ALL 0x3FFFFFFF +#define PSGL_VALIDATE_VERTEX_CONSTANTS 0x00000008 +#define PSGL_VALIDATE_VERTEX_TEXTURES_USED 0x00000010 +#define PSGL_VALIDATE_FFX_VERTEX_PROGRAM 0x00000020 +#define PSGL_VALIDATE_FRAGMENT_PROGRAM 0x00000040 +#define PSGL_VALIDATE_FFX_FRAGMENT_PROGRAM 0x00000080 +#define PSGL_VALIDATE_VIEWPORT 0x00000200 +#define PSGL_VALIDATE_FACE_CULL 0x00010000 +#define PSGL_VALIDATE_BLENDING 0x00020000 +#define PSGL_VALIDATE_POINT_RASTER 0x00040000 +#define PSGL_VALIDATE_LINE_RASTER 0x00080000 +#define PSGL_VALIDATE_POLYGON_OFFSET 0x00100000 +#define PSGL_VALIDATE_SHADE_MODEL 0x00200000 +#define PSGL_VALIDATE_LOGIC_OP 0x00400000 +#define PSGL_VALIDATE_MULTISAMPLING 0x00800000 +#define PSGL_VALIDATE_POLYGON_MODE 0x01000000 +#define PSGL_VALIDATE_PRIMITIVE_RESTART 0x02000000 +#define PSGL_VALIDATE_CLIP_PLANES 0x04000000 +#define PSGL_VALIDATE_SHADER_SRGB_REMAP 0x08000000 +#define PSGL_VALIDATE_POINT_SPRITE 0x10000000 +#define PSGL_VALIDATE_TWO_SIDE_COLOR 0x20000000 +#define PSGL_VALIDATE_ALL 0x3FFFFFFF #define PSGL_INIT_PERSISTENT_MEMORY_SIZE 0x0004 -#define PSGL_INIT_TRANSIENT_MEMORY_SIZE 0x0008 +#define PSGL_INIT_TRANSIENT_MEMORY_SIZE 0x0008 #define PSGL_INIT_ERROR_CONSOLE 0x0010 -#define PSGL_INIT_FIFO_SIZE 0x0020 -#define PSGL_INIT_HOST_MEMORY_SIZE 0x0040 -#define PSGL_INIT_USE_PMQUERIES 0x0080 +#define PSGL_INIT_FIFO_SIZE 0x0020 +#define PSGL_INIT_HOST_MEMORY_SIZE 0x0040 +#define PSGL_INIT_USE_PMQUERIES 0x0080 extern void psglInit( PSGLinitOptions* options ); @@ -1152,9 +1138,6 @@ PSGLcontext* psglGetCurrentContext(); PSGLdevice* psglGetCurrentDevice(); void psglSwap( void ); -static inline void psglRescAdjustAspectRatio( const float horizontalScale, const float verticalScale ) - { cellRescAdjustAspectRatio( horizontalScale, verticalScale ); } - #ifdef __cplusplus } #endif diff --git a/ps3/sdk_defines.h b/ps3/sdk_defines.h index 389e79b46b..ad30eee473 100644 --- a/ps3/sdk_defines.h +++ b/ps3/sdk_defines.h @@ -289,6 +289,14 @@ #endif +/*============================================================ + TIMER PROTOTYPES +============================================================ */ + +#ifdef __PSL1GHT__ +#define sys_timer_usleep usleep +#endif + /*============================================================ THREADING PROTOTYPES ============================================================ */