diff --git a/Makefile.ps3.rgl b/Makefile.ps3.rgl index 7f1a768e7a..5129816bea 100644 --- a/Makefile.ps3.rgl +++ b/Makefile.ps3.rgl @@ -21,8 +21,6 @@ INCDIRS = -I. -Ips3/rgl/include RGL_DIR = ps3/rgl/src PPU_SRCS = $(RGL_DIR)/Utils/NameSpace.cpp \ - $(RGL_DIR)/Utils/TexNameSpace.cpp \ - $(RGL_DIR)/Utils/EnumMap.cpp \ $(RGL_DIR)/libelf/readelf.cpp \ $(RGL_DIR)/ps3/rgl_ps3_raster.cpp \ $(RGL_DIR)/ps3/rgl_ps3.cpp diff --git a/gfx/shader_cg.c b/gfx/shader_cg.c index e92859fd06..869767f6db 100644 --- a/gfx/shader_cg.c +++ b/gfx/shader_cg.c @@ -1212,8 +1212,10 @@ bool gl_cg_init(const char *path) RARCH_ERR("Invalid profile type\n"); return false; } +#ifndef HAVE_RGL RARCH_LOG("[Cg]: Vertex profile: %s\n", cgGetProfileString(cgVProf)); RARCH_LOG("[Cg]: Fragment profile: %s\n", cgGetProfileString(cgFProf)); +#endif cgGLSetOptimalOptions(cgFProf); cgGLSetOptimalOptions(cgVProf); cgGLEnableProfile(cgFProf); diff --git a/ps3/rgl/include/Cg/CgCommon.h b/ps3/rgl/include/Cg/CgCommon.h index 13d2342cb7..ee08d8429d 100644 --- a/ps3/rgl/include/Cg/CgCommon.h +++ b/ps3/rgl/include/Cg/CgCommon.h @@ -275,7 +275,7 @@ extern RGL_EXPORT CgprogramHookFunction _cgProgramCreateHook; extern RGL_EXPORT CgprogramHookFunction _cgProgramDestroyHook; extern RGL_EXPORT CgprogramCopyHookFunction _cgProgramCopyHook; -typedef int (*cgRTCgcCompileHookFunction) (const char*, const char *, const char*, const char**, char**); +typedef int (*cgRTCgcCompileHookFunction) (const char*, const char*, const char*, const char**, char**); typedef void(*cgRTCgcFreeHookFunction) (char*); extern RGL_EXPORT cgRTCgcCompileHookFunction _cgRTCgcCompileProgramHook; extern RGL_EXPORT cgRTCgcFreeHookFunction _cgRTCgcFreeCompiledProgramHook; diff --git a/ps3/rgl/include/RGL/ReportInternal.h b/ps3/rgl/include/RGL/ReportInternal.h deleted file mode 100644 index fe453c28bf..0000000000 --- a/ps3/rgl/include/RGL/ReportInternal.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _RGL_REPORT_INTERNAL_H -#define _RGL_REPORT_INTERNAL_H - -#include "../export/RGL/rgl.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - GLenum e; - const char *s; -} RGLenumMap; - -const char *rglMapLookupEnum(const void *data, unsigned int count, GLenum e); -GLenum rglMapLookupString(const void *data, unsigned int count, const char *s); - -#define _RGL_MAP_LOOKUP_ENUM(MAP,ENUM) rglMapLookupEnum(MAP,sizeof(MAP)/sizeof(MAP[0]),ENUM) -#define _RGL_MAP_LOOKUP_STRING(MAP,STRING) rglMapLookupString(MAP,sizeof(MAP)/sizeof(MAP[0]),STRING) - -const char *rglGetGLEnumName(GLenum e); -const char *rglGetGLErrorName(GLenum e); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ps3/rgl/include/RGL/private.h b/ps3/rgl/include/RGL/private.h index 08fc6388ea..4b6cc5c653 100644 --- a/ps3/rgl/include/RGL/private.h +++ b/ps3/rgl/include/RGL/private.h @@ -4,7 +4,6 @@ #include "../export/RGL/rgl.h" #include "Types.h" #include "Utils.h" -#include "ReportInternal.h" #ifndef OS_VERSION_NUMERIC #define OS_VERSION_NUMERIC 0x160 diff --git a/ps3/rgl/src/Utils/EnumMap.cpp b/ps3/rgl/src/Utils/EnumMap.cpp deleted file mode 100644 index b908d23c2d..0000000000 --- a/ps3/rgl/src/Utils/EnumMap.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "../../include/export/RGL/rgl.h" -#include "../../include/RGL/private.h" -#include - -const char *rglMapLookupEnum(const void *data, unsigned int count, GLenum e ) -{ - const RGLenumMap *map = (const RGLenumMap*)data; - - for (GLuint i = 0; i < count; ++i) - if (map[i].e == e) - return map[i].s; - - return NULL; -} - -GLenum rglMapLookupString(const void *data, unsigned int count, const char *s ) -{ - const RGLenumMap *map = (const RGLenumMap*)data; - - if (s != NULL) - for (GLuint i = 0;i < count;++i) - if ( strcmp( map[i].s, s) == 0) - return map[i].e; - - return -1U; -} - diff --git a/ps3/rgl/src/Utils/NameSpace.cpp b/ps3/rgl/src/Utils/NameSpace.cpp index 1c8f435438..72ffac60d6 100644 --- a/ps3/rgl/src/Utils/NameSpace.cpp +++ b/ps3/rgl/src/Utils/NameSpace.cpp @@ -5,6 +5,9 @@ #include +#define NAME_INCREMENT 4 +#define CAPACITY_INCREMENT 16 + void rglInitNameSpace(void *data) { rglNameSpace *name = (rglNameSpace*)data; @@ -25,8 +28,6 @@ void rglFreeNameSpace(void *data) name->firstFree = NULL; } -static const int NAME_INCREMENT = 4; - unsigned int rglCreateName(void *data, void* object) { rglNameSpace *name = (rglNameSpace*)data; @@ -79,7 +80,7 @@ unsigned int rglCreateName(void *data, void* object) unsigned int rglIsName (void *data, unsigned int name ) { rglNameSpace *ns = (rglNameSpace*)data; - // there should always be a namesepace + // there should always be a namespace // 0 is never valid. if (RGL_UNLIKELY(name == 0)) return 0; @@ -114,3 +115,117 @@ void rglEraseName(void *data, unsigned int name ) ns->firstFree = ns->data + name; } } + +// Initialize texture namespace ns with creation and destruction functions +void rglTexNameSpaceInit(void *data, rglTexNameSpaceCreateFunction create, rglTexNameSpaceDestroyFunction destroy) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + ns->capacity = CAPACITY_INCREMENT; + ns->data = (void **)malloc( ns->capacity * sizeof( void* ) ); + memset( ns->data, 0, ns->capacity*sizeof( void* ) ); + ns->create = create; + ns->destroy = destroy; +} + +// Free texture namespace ns +void rglTexNameSpaceFree(void *data) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + for (GLuint i = 1;i < ns->capacity; ++i) + if (ns->data[i]) + ns->destroy( ns->data[i] ); + + free( ns->data ); + ns->data = NULL; +} + +// Reset all names in namespace ns to NULL +void rglTexNameSpaceResetNames(void *data) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + for ( GLuint i = 1;i < ns->capacity;++i ) + { + if ( ns->data[i] ) + { + ns->destroy( ns->data[i] ); + ns->data[i] = NULL; + } + } +} + +// Get an index of the first free name in namespace ns +GLuint rglTexNameSpaceGetFree(void *data) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + GLuint i; + + for (i = 1;i < ns->capacity;++i) + if (!ns->data[i]) + break; + return i; +} + +// Add name to namespace by increasing capacity and calling creation call back function +// Return GL_TRUE for success, GL_FALSE for failure +GLboolean rglTexNameSpaceCreateNameLazy(void *data, GLuint name ) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + if (name >= ns->capacity) + { + int newCapacity = name >= ns->capacity + CAPACITY_INCREMENT ? name + 1 : ns->capacity + CAPACITY_INCREMENT; + void **newData = ( void ** )realloc( ns->data, newCapacity * sizeof( void * ) ); + memset( newData + ns->capacity, 0, ( newCapacity - ns->capacity )*sizeof( void * ) ); + ns->data = newData; + ns->capacity = newCapacity; + } + if ( !ns->data[name] ) + { + ns->data[name] = ns->create(); + if ( ns->data[name] ) return GL_TRUE; + } + return GL_FALSE; +} + +// Check if name is a valid name in namespace ns +// Return GL_TRUE if so, GL_FALSE otherwise +GLboolean rglTexNameSpaceIsName(void *data, GLuint name ) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + if ((name > 0) && (name < ns->capacity)) + return( ns->data[name] != 0 ); + else return GL_FALSE; +} + +// Generate new n names in namespace ns +void rglTexNameSpaceGenNames(void *data, GLsizei n, GLuint *names ) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + for ( int i = 0;i < n;++i ) + { + GLuint name = rglTexNameSpaceGetFree( ns ); + names[i] = name; + if (name) + rglTexNameSpaceCreateNameLazy( ns, name ); + } +} + +// Delete n names from namespace ns +void rglTexNameSpaceDeleteNames(void *data, GLsizei n, const GLuint *names ) +{ + rglTexNameSpace *ns = (rglTexNameSpace*)data; + + for ( int i = 0;i < n;++i ) + { + GLuint name = names[i]; + if (!rglTexNameSpaceIsName(ns, name)) + continue; + ns->destroy( ns->data[name] ); + ns->data[name] = NULL; + } +} diff --git a/ps3/rgl/src/Utils/TexNameSpace.cpp b/ps3/rgl/src/Utils/TexNameSpace.cpp deleted file mode 100644 index 3d3d8d2964..0000000000 --- a/ps3/rgl/src/Utils/TexNameSpace.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include "../../include/export/RGL/rgl.h" -#include "../../include/RGL/Types.h" -#include "../../include/RGL/Utils.h" -#include "../../include/RGL/private.h" - -static const unsigned int capacityIncr = 16; - -// Initialize texture namespace ns with creation and destruction functions -void rglTexNameSpaceInit(void *data, rglTexNameSpaceCreateFunction create, rglTexNameSpaceDestroyFunction destroy) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - ns->capacity = capacityIncr; - ns->data = (void **)malloc( ns->capacity * sizeof( void* ) ); - memset( ns->data, 0, ns->capacity*sizeof( void* ) ); - ns->create = create; - ns->destroy = destroy; -} - -// Free texture namespace ns -void rglTexNameSpaceFree(void *data) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - for (GLuint i = 1;i < ns->capacity; ++i) - if (ns->data[i]) - ns->destroy( ns->data[i] ); - - free( ns->data ); - ns->data = NULL; -} - -// Reset all names in namespace ns to NULL -void rglTexNameSpaceResetNames(void *data) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - for ( GLuint i = 1;i < ns->capacity;++i ) - { - if ( ns->data[i] ) - { - ns->destroy( ns->data[i] ); - ns->data[i] = NULL; - } - } -} - -// Get an index of the first free name in namespace ns -GLuint rglTexNameSpaceGetFree(void *data) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - GLuint i; - - for (i = 1;i < ns->capacity;++i) - if (!ns->data[i]) - break; - return i; -} - -// Add name to namespace by increasing capacity and calling creation call back function -// Return GL_TRUE for success, GL_FALSE for failure -GLboolean rglTexNameSpaceCreateNameLazy(void *data, GLuint name ) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - if (name >= ns->capacity) - { - int newCapacity = name >= ns->capacity + capacityIncr ? name + 1 : ns->capacity + capacityIncr; - void **newData = ( void ** )realloc( ns->data, newCapacity * sizeof( void * ) ); - memset( newData + ns->capacity, 0, ( newCapacity - ns->capacity )*sizeof( void * ) ); - ns->data = newData; - ns->capacity = newCapacity; - } - if ( !ns->data[name] ) - { - ns->data[name] = ns->create(); - if ( ns->data[name] ) return GL_TRUE; - } - return GL_FALSE; -} - -// Check if name is a valid name in namespace ns -// Return GL_TRUE if so, GL_FALSE otherwise -GLboolean rglTexNameSpaceIsName(void *data, GLuint name ) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - if ((name > 0) && (name < ns->capacity)) - return( ns->data[name] != 0 ); - else return GL_FALSE; -} - -// Generate new n names in namespace ns -void rglTexNameSpaceGenNames(void *data, GLsizei n, GLuint *names ) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - for ( int i = 0;i < n;++i ) - { - GLuint name = rglTexNameSpaceGetFree( ns ); - names[i] = name; - if (name) - rglTexNameSpaceCreateNameLazy( ns, name ); - } -} - -// Delete n names from namespace ns -void rglTexNameSpaceDeleteNames(void *data, GLsizei n, const GLuint *names ) -{ - rglTexNameSpace *ns = (rglTexNameSpace*)data; - - for ( int i = 0;i < n;++i ) - { - GLuint name = names[i]; - if (!rglTexNameSpaceIsName(ns, name)) - continue; - ns->destroy( ns->data[name] ); - ns->data[name] = NULL; - } -} diff --git a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp index 991afced32..ee75d0f2de 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_cg.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_cg.cpp @@ -1709,53 +1709,6 @@ static const RGLcgTypeMapType RGLcgTypeMap[] = { CGtype( 0 ), "", CG_PARAMETERCLASS_UNKNOWN } }; -static const RGLenumMap RGLcgResourceMap[] = -{ - -#define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,enum_int,addressable,param_type) \ - { enum_name, compiler_name }, -#include - - { CG_UNDEFINED, "undefined" }, - { 0, "" } -}; - -static const RGLenumMap RGLcgEnumMap[] = -{ - -#define CG_ENUM_MACRO(enum_name, enum_val) \ - { enum_val, #enum_name }, -#include - - { 0, "" } -}; - -static const RGLcgProfileMapType RGLcgProfileMap[] = -{ - {( 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}, - //#include -#include - - {( CGprofile )0, "", 0 } -}; - -static const RGLenumMap RGLcgErrorMap[] = -{ - -#define CG_ERROR_MACRO(code, enum_name, message) \ - { enum_name, message }, -#include - - { 0, "" } -}; - - - - // templated map lookup functions --------- @@ -1858,75 +1811,9 @@ CG_API CGbool cgIsInterfaceType( CGtype type ) return CG_FALSE; } - -// Resource Functions ----------------------- - -CG_API const char* cgGetResourceString( CGresource resource ) -{ - return _RGL_MAP_LOOKUP_ENUM( RGLcgResourceMap, resource ); -} - -CG_API CGresource cgGetResource( const char* resource_string ) -{ - GLenum r = _RGL_MAP_LOOKUP_STRING( RGLcgResourceMap, resource_string ); - return ( r == -1U ) ? CG_UNDEFINED : ( CGresource )r; -} - - -// Enum Functions ---------------------------- - -CG_API const char* cgGetEnumString( CGenum en ) -{ - return _RGL_MAP_LOOKUP_ENUM( RGLcgEnumMap, en ); -} - -CG_API CGenum cgGetEnum( const char* enum_string ) -{ - if ( !enum_string ) { rglCgRaiseError( CG_INVALID_PARAMETER_ERROR ); return CG_UNKNOWN; } - GLenum r = _RGL_MAP_LOOKUP_STRING( RGLcgEnumMap, enum_string ); - return ( r == -1U ) ? CG_UNKNOWN : ( CGenum )r; -} - - // Profile functions ------------------------- -// profiles are the only tokens not stored in a RGLenumMap. Instead -// they use a RGLcgProfileMap which contains extra information about -// whether the profile is a vertex or a fragment program. - -CG_API const char* cgGetProfileString( CGprofile profile ) -{ - const size_t arraysize = sizeof( RGLcgProfileMap ) / sizeof( RGLcgProfileMapType ); - unsigned int i = 0; - while ( i < arraysize ) - { - if ( profile == RGLcgProfileMap[i].id ) - { - // id found. - return RGLcgProfileMap[i].string; - } - ++i; - } - // id not found, return an empty string - return ""; -} - -CG_API CGprofile cgGetProfile( const char* profile_string ) -{ - size_t arraysize = sizeof( RGLcgProfileMap ) / sizeof( RGLcgProfileMapType ); - unsigned int i = 0; - while ( i < arraysize ) - { - if (strcmp( RGLcgProfileMap[i].string, profile_string) == 0) - return RGLcgProfileMap[i].id; // string found. - ++i; - } - // string not found, return fail code. - return CG_PROFILE_UNKNOWN; -} - - // ErrorFunctions ---------------------------- CG_API CGerror cgGetError( void ) { @@ -1937,16 +1824,7 @@ CG_API CGerror cgGetError( void ) CG_API const char* cgGetErrorString( CGerror error ) { - return _RGL_MAP_LOOKUP_ENUM( RGLcgErrorMap, error ); -} - -CG_API const char* cgGetLastErrorString( CGerror* error ) -{ - // return both the error id and string. - *error = _CurrentContext->RGLcgLastError; - _CurrentContext->RGLcgLastError = CG_NO_ERROR; - const char * result = _RGL_MAP_LOOKUP_ENUM( RGLcgErrorMap, *error ); - return result; + return "cgGetErrorString not implemented.\n"; } CG_API void cgSetErrorCallback( CGerrorCallbackFunc func ) @@ -1976,31 +1854,6 @@ CG_API const char* cgGetString( CGenum sname ) return NULL; } - - -CG_API CGdomain cgGetProfileDomain( CGprofile profile ) -{ - const size_t arraysize = sizeof( RGLcgProfileMap ) / sizeof( RGLcgProfileMapType ); - unsigned int i = 0; - while ( i < arraysize ) - { - if ( profile == RGLcgProfileMap[i].id ) - { - // id found, check whether this is a vertex or fragment program - if ( RGLcgProfileMap[i].is_vertex_program ) - return CG_VERTEX_DOMAIN; - else - return CG_FRAGMENT_DOMAIN; - } - ++i; - } - // id not found, return an unknown domain - rglCgRaiseError( CG_UNKNOWN_PROFILE_ERROR ); - return CG_UNKNOWN_DOMAIN; -} - - - CG_API CGparameterclass cgGetTypeClass( CGtype type ) { const RGLcgTypeMapType *ptr = rglLookupEnum( RGLcgTypeMap, type ); @@ -3717,7 +3570,7 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx, { if ( _cgRTCgcCompileProgramHook ) { - _cgRTCgcCompileProgramHook( program, cgGetProfileString( profile ), entry, args, &compiled_program ); + _cgRTCgcCompileProgramHook( program, (profile == CG_PROFILE_SCE_FP_RSX) ? "sce_fp_rsx" : "sce_vp_rsx", entry, args, &compiled_program ); if ( !compiled_program ) { rglCgRaiseError( CG_COMPILER_ERROR ); @@ -4292,63 +4145,6 @@ CG_API CGbool cgIsProgramCompiled( CGprogram program ) return CG_TRUE; } -CG_API const char* cgGetProgramString( CGprogram prog, CGenum pname ) -{ - // check the program input - if ( !CG_IS_PROGRAM( prog ) ) - { - rglCgRaiseError( CG_INVALID_PROGRAM_HANDLE_ERROR ); - return NULL; - } - - //hack to counter change of defines for program_type at r5294 - // previously CG_PROGRAM_FILENAME was defined the same as CG_COLUMN_MAJOR - // if those values are passed in here, move them to the new values and remove this hack after we have - // an sdk that incorporates these changes so that prebuild libs (aka debugfont) can be used meanwhile - if ( pname == CG_COLUMN_MAJOR ) - pname = CG_PROGRAM_FILENAME; - - switch ( pname ) - { - case CG_PROGRAM_SOURCE: - // the original Cg source program is returned - // all programs in our API are pre-compiled and come without source. - return NULL; - - case CG_PROGRAM_ENTRY: - // the main entry point for the program is returned - // TODO *********** return the name of the entry point - return NULL; - - case CG_PROGRAM_PROFILE: - // the profile for the program is returned - { - const char *result = cgGetProfileString(( CGprofile )_cgGetProgPtr( prog )->header.profile ); - return result; - } - - case CG_COMPILED_PROGRAM: - // the string for the object program is returned - return NULL; - - case CG_PROGRAM_FILENAME: - // TODO *************** - // Return the filename of the source ELF this program came from - return ( char* )_cgGetProgPtr( prog )->platformProgram; - - case CG_BINARY: - // TODO *************** - // Create a whole new function for handling binaries - return charand length. - // we'll return an image pointer for now... - return ( char* )_cgGetProgPtr( prog )->platformProgram; - - default: - rglCgRaiseError( CG_INVALID_ENUMERANT_ERROR ); - } - - return NULL; -} - CG_API void CGENTRY cgSetLastListing( CGhandle handle, const char *listing ) { return;