mirror of
https://github.com/libretro/RetroArch
synced 2025-02-01 09:32:58 +00:00
(PS3) Add RGL video driver - compile with Makefile.ps3.rgl before
compiling RetroArch itself
This commit is contained in:
parent
3c9d4cf73b
commit
77bfce7cc7
10
Makefile.ps3
10
Makefile.ps3
@ -9,7 +9,7 @@ CELL_PSGL_VERSION = ultra-opt
|
||||
DEBUG = 0
|
||||
DOWNLOAD_SHADERS = 1
|
||||
STRIPPING_ENABLE = 0
|
||||
HAVE_RARCH_GL = 0
|
||||
HAVE_RGL = 1
|
||||
HAVE_LOGGER = 0
|
||||
|
||||
CONTENT_ID_FULL = UP0001-SSNE10000_00-0000000000000001
|
||||
@ -48,9 +48,9 @@ endif
|
||||
PPU_SRCS = console/griffin/griffin.c \
|
||||
console/szlib/szlib.c
|
||||
|
||||
ifeq ($(HAVE_RARCH_GL), 1)
|
||||
DEFINES = -DHAVE_RARCH_GL
|
||||
GL_LIBS := -lRARCHGL -lRARCHGLcgc
|
||||
ifeq ($(HAVE_RGL), 1)
|
||||
DEFINES = -DHAVE_RGL
|
||||
GL_LIBS := -lrgl
|
||||
else
|
||||
GL_LIBS := -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt -lPSGL -lPSGLcgc
|
||||
endif
|
||||
@ -68,7 +68,7 @@ endif
|
||||
|
||||
PPU_LDLIBS = -ldbgfont $(GL_LIBS) -lretro -lcgc -lgcm_cmd -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -ljpgdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread
|
||||
|
||||
DEFINES += -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_EXEC -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
DEFINES += -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_CG -DHAVE_FBO -DHAVE_RARCH_MAIN_WRAP -DHAVE_RARCH_EXEC -DHAVE_RGL -DHAVE_LIBRETRO_MANAGEMENT -DHAVE_RSOUND -DHAVE_ZLIB -D__CELLOS_LV2__ -DHAVE_CONFIGFILE=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_GRIFFIN=1 -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -Dmain=rarch_main -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
PPU_OPTIMIZE_LV := -O0 -g
|
||||
|
70
Makefile.ps3.rgl
Normal file
70
Makefile.ps3.rgl
Normal file
@ -0,0 +1,70 @@
|
||||
#which compiler to build with - GCC or SNC
|
||||
#set to GCC for debug builds for use with debugger
|
||||
CELL_BUILD_TOOLS = SNC
|
||||
CELL_GPU_TYPE = RSX
|
||||
|
||||
DEBUG = 0
|
||||
STRIPPING_ENABLE = 0
|
||||
|
||||
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
|
||||
PC_DEVELOPMENT_UDP_PORT = 3490
|
||||
|
||||
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
|
||||
include $(CELL_MK_DIR)/sdk.makedef.mk
|
||||
|
||||
PPU_LIB_TARGET = librgl.a
|
||||
|
||||
LDDIRS = -L.
|
||||
INCDIRS = -I.
|
||||
|
||||
PKG_SCRIPT = ps3/ps3py/pkg.py
|
||||
ifeq ($(shell uname), Linux)
|
||||
PKG_FINALIZE = package_finalize
|
||||
MAKE_SELF_WC = make_self_wc
|
||||
MAKE_SELF = make_self_npdrm
|
||||
PYTHON2 = python2
|
||||
GIT = git
|
||||
else
|
||||
PKG_FINALIZE = package_finalize.exe
|
||||
MAKE_SELF_WC = make_self_wc.exe
|
||||
MAKE_SELF = make_self_npdrm.exe
|
||||
PYTHON2 = python2.exe
|
||||
GIT = git.exe
|
||||
endif
|
||||
|
||||
PPU_SRCS = console/rgl/ps3/device_ctx.cpp \
|
||||
console/rgl/ps3/rgl.cpp \
|
||||
console/rgl/ps3/cgbio.cpp \
|
||||
console/rgl/ps3/cgnv2rt.cpp
|
||||
|
||||
ifeq ($(CELL_BUILD_TOOLS), SNC)
|
||||
PPU_CXXLD = $(CELL_SDK)/host-win32/sn/bin/ps3ppuld.exe
|
||||
PPU_CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
|
||||
PPU_CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
|
||||
SNC_PPU_AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
|
||||
else
|
||||
PPU_CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
|
||||
PPU_CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
|
||||
PPU_CXXLD = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ld.exe
|
||||
PPU_AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
|
||||
endif
|
||||
|
||||
|
||||
PPU_LDLIBS = -lio_stub
|
||||
|
||||
DEFINES += -D__CELLOS_LV2__
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
PPU_OPTIMIZE_LV := -O0 -g
|
||||
else
|
||||
PPU_OPTIMIZE_LV := -O3
|
||||
endif
|
||||
|
||||
PPU_CFLAGS = $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
|
||||
PPU_CXXFLAGS = $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
|
||||
|
||||
include $(CELL_MK_DIR)/sdk.target.mk
|
||||
|
||||
MAKE_FSELF = $(CELL_SDK)/host-win32/bin/make_fself.exe
|
||||
MAKE_FSELF_NPDRM = $(CELL_SDK)/host-win32/bin/make_fself_npdrm.exe
|
||||
MAKE_PACKAGE_NPDRM = $(CELL_SDK)/host-win32/bin/make_package_npdrm.exe
|
87
console/rgl/ps3/base.hpp
Normal file
87
console/rgl/ps3/base.hpp
Normal file
@ -0,0 +1,87 @@
|
||||
#ifndef _BASE_H_
|
||||
#define _BASE_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
|
||||
namespace RGL
|
||||
{
|
||||
class Base
|
||||
{
|
||||
public:
|
||||
void * operator new( size_t size ) { return malloc( size ); }
|
||||
void * operator new( size_t /*size*/, void *p ) { return p; }
|
||||
void operator delete( void *ptr ) { return free( ptr ); }
|
||||
void operator delete( void * /*ptr*/, void * /*p*/ ) { }};
|
||||
|
||||
template<class T> class Vector: public Base
|
||||
{
|
||||
T* array;
|
||||
unsigned int count;
|
||||
unsigned int capacity;
|
||||
unsigned int increment;
|
||||
public:
|
||||
Vector(): array( 0 ), count( 0 ), capacity( 0 ), increment( 4 ) {}
|
||||
~Vector() { clear(); reallocArray( 0 ); }
|
||||
|
||||
inline unsigned int getCount() { return count; }
|
||||
|
||||
inline void reallocArray( unsigned int newCapacity )
|
||||
{
|
||||
if ( newCapacity == capacity ) return;
|
||||
if ( newCapacity > capacity ) newCapacity = ( newCapacity > capacity + increment ) ? newCapacity : ( capacity + increment );
|
||||
if ( newCapacity == 0 )
|
||||
{
|
||||
free( array );
|
||||
array = 0;
|
||||
}
|
||||
else array = static_cast<T*>( realloc( static_cast<void *>( array ), sizeof( T ) * newCapacity ) );
|
||||
capacity = newCapacity;
|
||||
}
|
||||
|
||||
inline void clear()
|
||||
{
|
||||
if ( !array ) return;
|
||||
for ( unsigned int i = 0;i < count;++i )( array + i )->~T();
|
||||
count = 0;
|
||||
}
|
||||
|
||||
inline unsigned int pushBack( const T &element )
|
||||
{
|
||||
if ( count + 1 > capacity )
|
||||
reallocArray( count + 1 );
|
||||
new(( void * )( array + count ) ) T( element );
|
||||
return ++count;
|
||||
}
|
||||
|
||||
inline unsigned int appendUnique( const T &element )
|
||||
{
|
||||
for ( unsigned int i = 0;i < count;++i ) if ( array[i] == element ) return i;
|
||||
return pushBack( element );
|
||||
}
|
||||
|
||||
inline void removeElement( const T &element )
|
||||
{
|
||||
for ( unsigned int i = count; i > 0; --i )
|
||||
{
|
||||
if ( array[i-1] == element )
|
||||
{
|
||||
remove( i - 1 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void remove( unsigned int index )
|
||||
{
|
||||
( array + index )->~T();
|
||||
--count;
|
||||
if ( count > index ) memmove( array + index, array + index + 1, ( count - index )*sizeof( T ) );
|
||||
}
|
||||
|
||||
inline T& operator []( int i ) const { return array[i]; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
501
console/rgl/ps3/cg.h
Normal file
501
console/rgl/ps3/cg.h
Normal file
@ -0,0 +1,501 @@
|
||||
#ifndef _cg_common_h
|
||||
#define _cg_common_h
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <Cg/cgGL.h>
|
||||
|
||||
#include "rgl.h"
|
||||
#include "private.h"
|
||||
|
||||
#ifndef STL_NAMESPACE
|
||||
#define STL_NAMESPACE std::
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define RGL_BOOLEAN_REGISTERS_COUNT 32
|
||||
#define VERTEX_PROFILE_INDEX 0
|
||||
#define FRAGMENT_PROFILE_INDEX 1
|
||||
|
||||
#define CGF_OUTPUTFROMH0 0x01
|
||||
#define CGF_DEPTHREPLACE 0x02
|
||||
#define CGF_PIXELKILL 0x04
|
||||
|
||||
#define CGPV_MASK 0x03
|
||||
#define CGPV_VARYING 0x00
|
||||
#define CGPV_UNIFORM 0x01
|
||||
#define CGPV_CONSTANT 0x02
|
||||
#define CGPV_MIXED 0x03
|
||||
|
||||
#define CGPF_REFERENCED 0x10
|
||||
#define CGPF_SHARED 0x20
|
||||
#define CGPF_GLOBAL 0x40
|
||||
#define CGP_INTERNAL 0x80
|
||||
|
||||
#define CGP_INTRINSIC 0x0000
|
||||
#define CGP_STRUCTURE 0x100
|
||||
#define CGP_ARRAY 0x200
|
||||
#define CGP_TYPE_MASK (CGP_STRUCTURE + CGP_ARRAY)
|
||||
|
||||
#define CGP_UNROLLED 0x400
|
||||
#define CGP_UNPACKED 0x800
|
||||
#define CGP_CONTIGUOUS 0x1000
|
||||
|
||||
#define CGP_NORMALIZE 0x2000
|
||||
#define CGP_RTCREATED 0x4000
|
||||
|
||||
#define CGP_SCF_BOOL (CG_TYPE_START_ENUM + 1024)
|
||||
#define CG_BINARY_FORMAT_REVISION 0x00000006
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef unsigned int CgBinaryOffset;
|
||||
typedef CgBinaryOffset CgBinaryEmbeddedConstantOffset;
|
||||
typedef CgBinaryOffset CgBinaryFloatOffset;
|
||||
typedef CgBinaryOffset CgBinaryStringOffset;
|
||||
typedef CgBinaryOffset CgBinaryParameterOffset;
|
||||
|
||||
typedef struct CgBinaryVertexProgram CgBinaryVertexProgram;
|
||||
typedef struct CgBinaryFragmentProgram CgBinaryFragmentProgram;
|
||||
typedef struct CgBinaryProgram CgBinaryProgram;
|
||||
|
||||
typedef struct _CGnamedProgram
|
||||
{
|
||||
const char *name;
|
||||
CGprogram program;
|
||||
int refCount;
|
||||
} _CGnamedProgram;
|
||||
|
||||
typedef struct _CGprogramGroup
|
||||
{
|
||||
struct _CGprogramGroup *next;
|
||||
CGcontext ctx;
|
||||
unsigned int *constantTable;
|
||||
unsigned int *stringTable;
|
||||
unsigned int programCount;
|
||||
_CGnamedProgram *programs;
|
||||
int refCount;
|
||||
bool userCreated;
|
||||
char *filedata;
|
||||
char *name;
|
||||
} _CGprogramGroup;
|
||||
|
||||
typedef struct _CGprogramGroup *CGprogramGroup;
|
||||
|
||||
CGprogramGroup _RGLCgCreateProgramGroup( CGcontext ctx, const char *name, void *ptr, int size );
|
||||
CGprogramGroup _RGLCgCreateProgramGroupFromFile( CGcontext ctx, const char *group_file );
|
||||
void _RGLCgDestroyProgramGroup( CGprogramGroup group );
|
||||
|
||||
int _RGLCgGetProgramCount( CGprogramGroup group );
|
||||
CGprogram _RGLCgGetProgram( CGprogramGroup group, const char *name );
|
||||
int _RGLCgGetProgramIndex( CGprogramGroup group, const char *name );
|
||||
CGprogram _RGLCgGetProgramAtIndex( CGprogramGroup group, unsigned int index );
|
||||
const char *_RGLCgGetProgramGroupName( CGprogramGroup group );
|
||||
|
||||
typedef struct _CgParameterTableHeader
|
||||
{
|
||||
unsigned short entryCount;
|
||||
unsigned short resourceTableOffset;
|
||||
unsigned short defaultValueIndexTableOffset;
|
||||
unsigned short defaultValueIndexCount;
|
||||
unsigned short semanticIndexTableOffset;
|
||||
unsigned short semanticIndexCount;
|
||||
} CgParameterTableHeader;
|
||||
|
||||
typedef struct _CgParameterEntry
|
||||
{
|
||||
unsigned int nameOffset;
|
||||
unsigned short typeIndex;
|
||||
unsigned short flags;
|
||||
} CgParameterEntry;
|
||||
|
||||
#ifdef MSVC
|
||||
#pragma warning( push )
|
||||
#pragma warning ( disable : 4200 )
|
||||
#endif
|
||||
|
||||
typedef struct _CgParameterArray
|
||||
{
|
||||
unsigned short arrayType;
|
||||
unsigned short dimensionCount;
|
||||
unsigned short dimensions[];
|
||||
} CgParameterArray;
|
||||
|
||||
#ifdef MSVC
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
typedef struct _CgParameterStructure
|
||||
{
|
||||
unsigned short memberCount;
|
||||
unsigned short reserved;
|
||||
}
|
||||
CgParameterStructure;
|
||||
|
||||
typedef struct _CgParameterResource
|
||||
{
|
||||
unsigned short type;
|
||||
unsigned short resource;
|
||||
}
|
||||
CgParameterResource;
|
||||
|
||||
typedef struct _CgParameterSemantic
|
||||
{
|
||||
unsigned short entryIndex;
|
||||
unsigned short reserved;
|
||||
unsigned int semanticOffset;
|
||||
}
|
||||
CgParameterSemantic;
|
||||
|
||||
typedef struct _CgParameterDefaultValue
|
||||
{
|
||||
unsigned short entryIndex;
|
||||
unsigned short defaultValueIndex;
|
||||
}
|
||||
CgParameterDefaultValue;
|
||||
|
||||
typedef struct CgProgramHeader
|
||||
{
|
||||
unsigned short profile;
|
||||
unsigned short compilerVersion;
|
||||
unsigned int instructionCount;
|
||||
unsigned int attributeInputMask;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned int instructionSlot;
|
||||
unsigned int registerCount;
|
||||
unsigned int attributeOutputMask;
|
||||
} vertexProgram;
|
||||
struct
|
||||
{
|
||||
unsigned int partialTexType;
|
||||
unsigned short texcoordInputMask;
|
||||
unsigned short texcoord2d;
|
||||
unsigned short texcoordCentroid;
|
||||
unsigned char registerCount;
|
||||
unsigned char flags;
|
||||
} fragmentProgram;
|
||||
};
|
||||
}
|
||||
CgProgramHeader;
|
||||
|
||||
typedef void( *_cgSetFunction )( struct CgRuntimeParameter* _RGL_RESTRICT, const void* _RGL_RESTRICT );
|
||||
|
||||
typedef void( *_cgSetArrayIndexFunction )( struct CgRuntimeParameter* _RGL_RESTRICT, const void* _RGL_RESTRICT, const int index );
|
||||
|
||||
typedef struct _CgUniform
|
||||
{
|
||||
void *pushBufferPtr;
|
||||
} _CgUniform;
|
||||
|
||||
typedef struct _CGprogram _CGprogram;
|
||||
|
||||
typedef struct CgRuntimeParameter
|
||||
{
|
||||
_cgSetArrayIndexFunction samplerSetter;
|
||||
|
||||
_cgSetArrayIndexFunction setterIndex;
|
||||
_cgSetArrayIndexFunction settercIndex;
|
||||
_cgSetArrayIndexFunction setterrIndex;
|
||||
|
||||
void *pushBufferPointer;
|
||||
const CgParameterEntry *parameterEntry;
|
||||
_CGprogram *program;
|
||||
int glType;
|
||||
CGparameter id;
|
||||
} CgRuntimeParameter;
|
||||
|
||||
struct _CGprogram
|
||||
{
|
||||
struct _CGprogram* next;
|
||||
CGprogram id;
|
||||
struct _CGcontext* parentContext;
|
||||
void* parentEffect;
|
||||
bool inLocalMemory;
|
||||
unsigned int constantPushBufferWordSize;
|
||||
unsigned int* constantPushBuffer;
|
||||
void* platformProgram;
|
||||
void* platformProgramBinary;
|
||||
unsigned int samplerCount;
|
||||
unsigned int * samplerIndices;
|
||||
unsigned int * samplerUnits;
|
||||
unsigned int controlFlowBools;
|
||||
CgProgramHeader header;
|
||||
const char *name;
|
||||
const void *ucode;
|
||||
GLuint loadProgramId;
|
||||
GLuint loadProgramOffset;
|
||||
int version;
|
||||
char *parameterResources;
|
||||
int rtParametersCount;
|
||||
CgRuntimeParameter *runtimeParameters;
|
||||
const CgParameterEntry *parametersEntries;
|
||||
unsigned short *resources;
|
||||
unsigned short *pushBufferPointers;
|
||||
int defaultValuesIndexCount;
|
||||
const CgParameterDefaultValue *defaultValuesIndices;
|
||||
int defaultValueCount;
|
||||
const float *defaultValues;
|
||||
const char *stringTable;
|
||||
unsigned int **constantPushBufferPointers;
|
||||
unsigned int *samplerValuesLocation;
|
||||
void *memoryBlock;
|
||||
_CGprogramGroup *programGroup;
|
||||
int programIndexInGroup;
|
||||
void *runtimeElf;
|
||||
};
|
||||
|
||||
typedef struct _CGcontext
|
||||
{
|
||||
struct _CGcontext* next;
|
||||
CGcontext id;
|
||||
unsigned int programCount;
|
||||
struct _CGprogram* programList;
|
||||
CGenum compileType;
|
||||
unsigned int controlFlowBoolsSharedMask;
|
||||
unsigned int controlFlowBoolsShared;
|
||||
_CGprogram defaultProgram;
|
||||
CGprogramGroup groupList;
|
||||
double currentParameterValue[16];
|
||||
char currentParameterName[128];
|
||||
} _CGcontext;
|
||||
|
||||
|
||||
void _RGLCgRaiseError( CGerror error );
|
||||
extern void _RGLCgProgramDestroyAll( _CGcontext* c );
|
||||
extern void _RGLCgDestroyContextParam( CgRuntimeParameter* p );
|
||||
CgRuntimeParameter*_RGLCgCreateParameterInternal( _CGprogram *program, const char* name, CGtype type );
|
||||
void _RGLCgProgramErase( _CGprogram* prog );
|
||||
|
||||
void _cgRaiseInvalidParam( CgRuntimeParameter*p, const void*v );
|
||||
void _cgRaiseNotMatrixParam( CgRuntimeParameter*p, const void*v );
|
||||
void _cgIgnoreSetParam( CgRuntimeParameter*p, const void*v );
|
||||
void _cgRaiseInvalidParamIndex( CgRuntimeParameter*p, const void*v, const int index );
|
||||
void _cgRaiseNotMatrixParamIndex( CgRuntimeParameter*p, const void*v, const int index );
|
||||
void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index );
|
||||
|
||||
#define CG_IS_CONTEXT(_ctx) _RGLIsName(&_CurrentContext->cgContextNameSpace, (jsName)_ctx)
|
||||
#define CG_IS_PROGRAM(_program) _RGLIsName(&_CurrentContext->cgProgramNameSpace, (jsName)_program)
|
||||
#define CG_IS_PARAMETER(_param) _RGLIsName(&_CurrentContext->cgParameterNameSpace, (jsName)(((unsigned int)_param)&CG_PARAMETERMASK))
|
||||
|
||||
#define CG_PARAMETERSIZE 22
|
||||
#define CG_PARAMETERMASK ((1<<CG_PARAMETERSIZE)-1)
|
||||
#define CG_GETINDEX(param) (int)((unsigned int)(param)>>CG_PARAMETERSIZE)
|
||||
|
||||
static inline bool isMatrix( CGtype type )
|
||||
{
|
||||
if (( type >= CG_FLOAT1x1 && type <= CG_FLOAT4x4 ) ||
|
||||
( type >= CG_HALF1x1 && type <= CG_HALF4x4 ) ||
|
||||
( type >= CG_INT1x1 && type <= CG_INT4x4 ) ||
|
||||
( type >= CG_BOOL1x1 && type <= CG_BOOL4x4 ) ||
|
||||
( type >= CG_FIXED1x1 && type <= CG_FIXED4x4 ))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool isSampler( CGtype type )
|
||||
{
|
||||
return ( type >= CG_SAMPLER1D && type <= CG_SAMPLERCUBE );
|
||||
}
|
||||
|
||||
|
||||
unsigned int _RGLCountFloatsInCgType( CGtype type );
|
||||
CGbool _cgMatrixDimensions( CGtype type, unsigned int* nrows, unsigned int* ncols );
|
||||
|
||||
unsigned int _RGLGetTypeRowCount( CGtype parameterType );
|
||||
unsigned int _RGLGetTypeColCount( CGtype parameterType );
|
||||
|
||||
inline static CgRuntimeParameter* _cgGetParamPtr( CGparameter p )
|
||||
{
|
||||
return ( CgRuntimeParameter* )_RGLGetNamedValue( &_CurrentContext->cgParameterNameSpace, ( jsName )((( unsigned int )p )&CG_PARAMETERMASK ) );
|
||||
}
|
||||
|
||||
inline static _CGprogram* _cgGetProgPtr( CGprogram p )
|
||||
{
|
||||
return ( _CGprogram* )_RGLGetNamedValue( &_CurrentContext->cgProgramNameSpace, ( jsName )p );
|
||||
}
|
||||
|
||||
inline static _CGcontext* _cgGetContextPtr( CGcontext c )
|
||||
{
|
||||
return ( _CGcontext* )_RGLGetNamedValue( &_CurrentContext->cgContextNameSpace, ( jsName )c );
|
||||
}
|
||||
|
||||
inline static CgRuntimeParameter* _RGLCgGLTestParameter( CGparameter param )
|
||||
{
|
||||
return _cgGetParamPtr( param );
|
||||
}
|
||||
|
||||
CgRuntimeParameter* _cgGLTestArrayParameter( CGparameter paramIn, long offset, long nelements );
|
||||
CgRuntimeParameter* _cgGLTestTextureParameter( CGparameter param );
|
||||
|
||||
inline static int _RGLGetSizeofSubArray( const unsigned short *dimensions, unsigned short count )
|
||||
{
|
||||
int res = 1;
|
||||
for ( int i = 0;i < count;i++ )
|
||||
res *= ( int )( *( dimensions++ ) );
|
||||
return res;
|
||||
}
|
||||
|
||||
inline static CGresource _RGLGetBaseResource( CGresource resource )
|
||||
{
|
||||
switch ( resource )
|
||||
{
|
||||
case CG_ATTR0: case CG_ATTR1: case CG_ATTR2: case CG_ATTR3:
|
||||
case CG_ATTR4: case CG_ATTR5: case CG_ATTR6: case CG_ATTR7:
|
||||
case CG_ATTR8: case CG_ATTR9: case CG_ATTR10: case CG_ATTR11:
|
||||
case CG_ATTR12: case CG_ATTR13: case CG_ATTR14: case CG_ATTR15:
|
||||
return CG_ATTR0;
|
||||
case CG_HPOS:
|
||||
return CG_HPOS;
|
||||
case CG_COL0: case CG_COL1: case CG_COL2: case CG_COL3:
|
||||
return CG_COL0;
|
||||
case CG_TEXCOORD0: case CG_TEXCOORD1: case CG_TEXCOORD2: case CG_TEXCOORD3:
|
||||
case CG_TEXCOORD4: case CG_TEXCOORD5: case CG_TEXCOORD6: case CG_TEXCOORD7:
|
||||
case CG_TEXCOORD8: case CG_TEXCOORD9:
|
||||
return CG_TEXCOORD0;
|
||||
case CG_TEXUNIT0: case CG_TEXUNIT1: case CG_TEXUNIT2: case CG_TEXUNIT3:
|
||||
case CG_TEXUNIT4: case CG_TEXUNIT5: case CG_TEXUNIT6: case CG_TEXUNIT7:
|
||||
case CG_TEXUNIT8: case CG_TEXUNIT9: case CG_TEXUNIT10: case CG_TEXUNIT11:
|
||||
case CG_TEXUNIT12: case CG_TEXUNIT13: case CG_TEXUNIT14: case CG_TEXUNIT15:
|
||||
return CG_TEXUNIT0;
|
||||
case CG_FOGCOORD:
|
||||
return CG_FOGCOORD;
|
||||
case CG_PSIZ:
|
||||
return CG_PSIZ;
|
||||
case CG_WPOS:
|
||||
return CG_WPOS;
|
||||
case CG_COLOR0: case CG_COLOR1: case CG_COLOR2: case CG_COLOR3:
|
||||
return CG_COLOR0;
|
||||
case CG_DEPTH0:
|
||||
return CG_DEPTH0;
|
||||
case CG_C:
|
||||
return CG_C;
|
||||
case CG_B:
|
||||
return CG_B;
|
||||
case CG_CLP0: case CG_CLP1: case CG_CLP2: case CG_CLP3: case CG_CLP4: case CG_CLP5:
|
||||
return CG_CLP0;
|
||||
case CG_UNDEFINED:
|
||||
return CG_UNDEFINED;
|
||||
default:
|
||||
printf("RGL WARN: resource 0x%d is unknown here.\n", resource );
|
||||
return CG_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
CGprofile _RGLPlatformGetLatestProfile( CGGLenum profile_type );
|
||||
int _RGLPlatformCopyProgram( _CGprogram* source, _CGprogram* destination );
|
||||
|
||||
void _RGLPlatformProgramErase( void* platformProgram );
|
||||
|
||||
int _RGLPlatformGenerateVertexProgram( _CGprogram *program, const CgProgramHeader *programHeader, const void *ucode, const CgParameterTableHeader *parameterHeader, const char *stringTable, const float *defaultValues );
|
||||
|
||||
int _RGLPlatformGenerateFragmentProgram( _CGprogram *program, const CgProgramHeader *programHeader, const void *ucode, const CgParameterTableHeader *parameterHeader, const char *stringTable, const float *defaultValues );
|
||||
CGbool _RGLPlatformSupportsFragmentProgram( CGprofile p );
|
||||
|
||||
|
||||
|
||||
void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * _RGL_RESTRICT v );
|
||||
void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * _RGL_RESTRICT v );
|
||||
void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * _RGL_RESTRICT v );
|
||||
void _RGLPlatformSetFragmentRegisterBlock( unsigned int reg, unsigned int count, const float * _RGL_RESTRICT v );
|
||||
|
||||
unsigned int _cgHashString( const char *str );
|
||||
|
||||
static inline GLenum _RGLCgGetSamplerGLTypeFromCgType( CGtype type )
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case CG_SAMPLER1D:
|
||||
case CG_SAMPLER2D:
|
||||
case CG_SAMPLERRECT:
|
||||
return GL_TEXTURE_2D;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
struct jsNameSpace;
|
||||
|
||||
int _RGLNVGenerateProgram( _CGprogram *program, int profileIndex, const CgProgramHeader *programHeader, const void *ucode,
|
||||
const CgParameterTableHeader *parameterHeader, const CgParameterEntry *parameterEntries,
|
||||
const char *stringTable, const float *defaultValues );
|
||||
|
||||
_cgSetArrayIndexFunction getVectorTypeIndexSetterFunction( unsigned short a, unsigned short b, unsigned short c, unsigned short d );
|
||||
_cgSetArrayIndexFunction getMatrixTypeIndexSetterFunction( unsigned short a, unsigned short b, unsigned short c, unsigned short d, unsigned short e, unsigned short f );
|
||||
|
||||
// -------------------------------------------
|
||||
|
||||
typedef void( * CgcontextHookFunction )( _CGcontext *context );
|
||||
extern CgcontextHookFunction _cgContextCreateHook;
|
||||
extern CgcontextHookFunction _cgContextDestroyHook;
|
||||
|
||||
typedef void( * CgparameterHookFunction )( CgRuntimeParameter *parameter );
|
||||
extern CgparameterHookFunction _cgParameterCreateHook;
|
||||
extern CgparameterHookFunction _cgParameterDestroyHook;
|
||||
|
||||
typedef void( * CgprogramHookFunction )( _CGprogram *program );
|
||||
typedef void( * CgprogramCopyHookFunction )( _CGprogram *newprogram, _CGprogram *oldprogram );
|
||||
extern CgprogramHookFunction _cgProgramCreateHook;
|
||||
extern CgprogramHookFunction _cgProgramDestroyHook;
|
||||
extern CgprogramCopyHookFunction _cgProgramCopyHook;
|
||||
|
||||
typedef int( * cgRTCgcCompileHookFunction )( const char*, const char *, const char*, const char**, char** );
|
||||
typedef void( * cgRTCgcFreeHookFunction )( char* );
|
||||
extern cgRTCgcCompileHookFunction _cgRTCgcCompileProgramHook;
|
||||
extern cgRTCgcFreeHookFunction _cgRTCgcFreeCompiledProgramHook;
|
||||
|
||||
|
||||
static inline const CgParameterResource *_RGLGetParameterResource( const _CGprogram *program, const CgParameterEntry *entry )
|
||||
{
|
||||
return ( CgParameterResource * )( program->parameterResources + entry->typeIndex );
|
||||
}
|
||||
|
||||
static inline CGtype _RGLGetParameterCGtype( const _CGprogram *program, const CgParameterEntry *entry )
|
||||
{
|
||||
if ( entry->flags & CGP_RTCREATED )
|
||||
{
|
||||
return ( CGtype )entry->typeIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
const CgParameterResource *parameterResource = _RGLGetParameterResource( program, entry );
|
||||
if ( parameterResource )
|
||||
{
|
||||
return ( CGtype )parameterResource->type;
|
||||
}
|
||||
}
|
||||
return CG_UNKNOWN_TYPE;
|
||||
}
|
||||
|
||||
static inline const CgParameterArray *_RGLGetParameterArray( const _CGprogram *program, const CgParameterEntry *entry )
|
||||
{
|
||||
return ( CgParameterArray* )( program->parameterResources + entry->typeIndex );
|
||||
}
|
||||
|
||||
static inline const CgParameterStructure *_RGLGetParameterStructure( const _CGprogram *program, const CgParameterEntry *entry )
|
||||
{
|
||||
return ( CgParameterStructure* )( program->parameterResources + entry->typeIndex );
|
||||
}
|
||||
|
||||
inline int _RGLGetProgramProfileIndex( CGprofile profile )
|
||||
{
|
||||
if ( profile == CG_PROFILE_SCE_FP_TYPEB || profile == CG_PROFILE_SCE_FP_TYPEC || profile == CG_PROFILE_SCE_FP_RSX )
|
||||
return FRAGMENT_PROFILE_INDEX;
|
||||
else if ( profile == CG_PROFILE_SCE_VP_TYPEB || profile == CG_PROFILE_SCE_VP_TYPEC || profile == CG_PROFILE_SCE_VP_RSX )
|
||||
return VERTEX_PROFILE_INDEX;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
368
console/rgl/ps3/cgbio.cpp
Normal file
368
console/rgl/ps3/cgbio.cpp
Normal file
@ -0,0 +1,368 @@
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
|
||||
#include <Cg/cgc.h>
|
||||
#include <Cg/cgGL.h>
|
||||
#include <Cg/cgBinary.h>
|
||||
|
||||
#include "cgbio.hpp"
|
||||
|
||||
using std::fill_n;
|
||||
|
||||
namespace cgc {
|
||||
namespace bio {
|
||||
|
||||
bin_io* bin_io::instance_ = 0;
|
||||
|
||||
bin_io::bin_io()
|
||||
{
|
||||
}
|
||||
|
||||
bin_io::bin_io( const bin_io& )
|
||||
{
|
||||
}
|
||||
|
||||
const bin_io* bin_io::instance()
|
||||
{
|
||||
if ( 0 == instance_ )
|
||||
{
|
||||
instance_ = new bin_io;
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
void bin_io::delete_instance()
|
||||
{
|
||||
if ( 0 != instance_ )
|
||||
{
|
||||
delete instance_;
|
||||
instance_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CGBIO_ERROR bin_io::new_elf_reader( elf_reader** obj ) const
|
||||
{
|
||||
CGBIO_ERROR ret = CGBIO_ERROR_NO_ERROR;
|
||||
*obj = new elf_reader_impl;
|
||||
|
||||
if ( 0 == *obj )
|
||||
ret = CGBIO_ERROR_MEMORY;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char*
|
||||
bin_io::error_string( CGBIO_ERROR error ) const
|
||||
{
|
||||
switch ( error )
|
||||
{
|
||||
case CGBIO_ERROR_NO_ERROR:
|
||||
return "No error";
|
||||
case CGBIO_ERROR_LOADED:
|
||||
return "Binary file has been loaded earlier";
|
||||
case CGBIO_ERROR_FILEIO:
|
||||
return "File input output error";
|
||||
case CGBIO_ERROR_FORMAT:
|
||||
return "File format error";
|
||||
case CGBIO_ERROR_INDEX:
|
||||
return "Index is out of range";
|
||||
case CGBIO_ERROR_MEMORY:
|
||||
return "Can't allocate memory";
|
||||
case CGBIO_ERROR_RELOC:
|
||||
return "Relocation error";
|
||||
case CGBIO_ERROR_SYMBOL:
|
||||
return "Symbol error";
|
||||
case CGBIO_ERROR_UNKNOWN_TYPE:
|
||||
return "Uknown type";
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
CGBIO_ERROR
|
||||
bin_io::new_nvb_reader( nvb_reader** obj ) const
|
||||
{
|
||||
CGBIO_ERROR ret = CGBIO_ERROR_NO_ERROR;
|
||||
*obj = new nvb_reader_impl;
|
||||
|
||||
if ( *obj == 0 )
|
||||
ret = CGBIO_ERROR_MEMORY;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
nvb_reader_impl::nvb_reader_impl()
|
||||
{
|
||||
ref_count_ = 1;
|
||||
offset_ = 0;
|
||||
image_ = 0;
|
||||
owner_ = false;
|
||||
loaded_ = false;
|
||||
endianness_ = host_endianness();
|
||||
std::fill_n( reinterpret_cast<char*>( &header_ ), sizeof( header_ ), '\0' );
|
||||
}
|
||||
|
||||
nvb_reader_impl::~nvb_reader_impl()
|
||||
{
|
||||
if ( image_ != 0 )
|
||||
delete [] image_;
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
nvb_reader_impl::reference() const
|
||||
{
|
||||
return ++ref_count_;
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
nvb_reader_impl::release() const
|
||||
{
|
||||
ptrdiff_t ret = --ref_count_;
|
||||
|
||||
if ( ref_count_ == 0 )
|
||||
delete this;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CGBIO_ERROR
|
||||
nvb_reader_impl::loadFromString( const char* source, size_t length)
|
||||
{
|
||||
if ( loaded_ )
|
||||
{
|
||||
return CGBIO_ERROR_LOADED;
|
||||
}
|
||||
CGBIO_ERROR ret = CGBIO_ERROR_NO_ERROR;
|
||||
while (1)
|
||||
{
|
||||
if (length < sizeof( header_ ))
|
||||
{
|
||||
ret = CGBIO_ERROR_FORMAT;
|
||||
break;
|
||||
}
|
||||
memcpy(&header_ ,source,sizeof( header_ ));
|
||||
if ( CG_BINARY_FORMAT_REVISION != header_.binaryFormatRevision )
|
||||
{
|
||||
endianness_ = ( CGBIODATALSB == endianness_ ) ? CGBIODATAMSB : CGBIODATALSB;
|
||||
int binaryRevision = convert_endianness( header_.binaryFormatRevision, endianness_ );
|
||||
if ( CG_BINARY_FORMAT_REVISION != binaryRevision )
|
||||
{
|
||||
ret = CGBIO_ERROR_FORMAT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
size_t sz = length;
|
||||
image_ = new char[sz];
|
||||
memcpy(image_,source,sz);
|
||||
loaded_ = true;
|
||||
ret = CGBIO_ERROR_NO_ERROR;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
nvb_reader_impl::is_loaded() const
|
||||
{
|
||||
return loaded_;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
nvb_reader_impl::endianness() const
|
||||
{
|
||||
return endianness_;
|
||||
}
|
||||
|
||||
CGprofile
|
||||
nvb_reader_impl::profile() const
|
||||
{
|
||||
return (CGprofile) convert_endianness( (unsigned int) header_.profile, endianness() );
|
||||
}
|
||||
|
||||
unsigned int
|
||||
nvb_reader_impl::revision() const
|
||||
{
|
||||
return convert_endianness( header_.binaryFormatRevision, endianness() );
|
||||
}
|
||||
|
||||
unsigned int nvb_reader_impl::size() const
|
||||
{
|
||||
return convert_endianness( header_.totalSize, endianness() );
|
||||
}
|
||||
|
||||
unsigned int nvb_reader_impl::number_of_params() const
|
||||
{
|
||||
return convert_endianness( header_.parameterCount, endianness() );
|
||||
}
|
||||
|
||||
unsigned int nvb_reader_impl::ucode_size() const
|
||||
{
|
||||
return convert_endianness( header_.ucodeSize, endianness() );
|
||||
}
|
||||
|
||||
const char* nvb_reader_impl::ucode() const
|
||||
{
|
||||
if ( 0 == image_ || 0 == ucode_size() )
|
||||
return 0;
|
||||
|
||||
return ( image_ + convert_endianness( header_.ucode, endianness() ) );
|
||||
}
|
||||
|
||||
const CgBinaryFragmentProgram*
|
||||
nvb_reader_impl::fragment_program() const
|
||||
{
|
||||
if ( 0 == image_ )
|
||||
return 0;
|
||||
|
||||
return reinterpret_cast<CgBinaryFragmentProgram*>( &image_[convert_endianness( header_.program, endianness_ )] );
|
||||
}
|
||||
|
||||
const CgBinaryVertexProgram* nvb_reader_impl::vertex_program() const
|
||||
{
|
||||
if ( 0 == image_ )
|
||||
return 0;
|
||||
|
||||
return reinterpret_cast<CgBinaryVertexProgram*>( &image_[convert_endianness( header_.program, endianness_ )] );
|
||||
}
|
||||
|
||||
CGBIO_ERROR nvb_reader_impl::get_param_name( unsigned int index, const char **name, bool& is_referenced ) const
|
||||
{
|
||||
if ( index >= number_of_params() )
|
||||
return CGBIO_ERROR_INDEX;
|
||||
|
||||
if ( 0 == image_ )
|
||||
return CGBIO_ERROR_NO_ERROR;
|
||||
|
||||
const CgBinaryParameter* params = reinterpret_cast<CgBinaryParameter*>( &image_[convert_endianness( header_.parameterArray, endianness_ )] );
|
||||
const CgBinaryParameter& pp = params[index];
|
||||
is_referenced = convert_endianness( pp.isReferenced, endianness() ) != 0;
|
||||
CgBinaryStringOffset nm_offset = convert_endianness( pp.name,endianness() );
|
||||
if ( nm_offset != 0 )
|
||||
*name = &image_[nm_offset];
|
||||
else
|
||||
*name = "";
|
||||
return CGBIO_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
CGBIO_ERROR
|
||||
nvb_reader_impl::get_param( unsigned int index,
|
||||
CGtype& type,
|
||||
CGresource& resource,
|
||||
CGenum& variability,
|
||||
int& resource_index,
|
||||
const char ** name,
|
||||
STL_NAMESPACE vector<float>& default_value,
|
||||
STL_NAMESPACE vector<unsigned int>& embedded_constants,
|
||||
const char ** semantic,
|
||||
int& paramno,
|
||||
bool& is_referenced,
|
||||
bool& is_shared ) const
|
||||
{
|
||||
if ( index >= number_of_params() )
|
||||
return CGBIO_ERROR_INDEX;
|
||||
|
||||
if ( 0 == image_ )
|
||||
return CGBIO_ERROR_NO_ERROR;
|
||||
|
||||
const CgBinaryParameter* params = reinterpret_cast<CgBinaryParameter*>( &image_[convert_endianness( header_.parameterArray, endianness_ )] );
|
||||
const CgBinaryParameter& pp = params[index];
|
||||
type = static_cast<CGtype>(convert_endianness( static_cast<unsigned int>( pp.type ), endianness() ) );
|
||||
resource = static_cast<CGresource>(convert_endianness( static_cast<unsigned int>( pp.res ), endianness() ) );
|
||||
variability = static_cast<CGenum>(convert_endianness( static_cast<unsigned int>( pp.var ),endianness() ) );
|
||||
resource_index = convert_endianness( pp.resIndex,endianness() );
|
||||
paramno = convert_endianness( pp.paramno, endianness() );
|
||||
is_referenced = convert_endianness( pp.isReferenced,endianness() ) != 0;
|
||||
is_shared = convert_endianness( pp.isShared,endianness() ) != 0;
|
||||
CgBinaryStringOffset nm_offset = convert_endianness( pp.name,endianness() );
|
||||
CgBinaryFloatOffset dv_offset = convert_endianness( pp.defaultValue,endianness() );
|
||||
CgBinaryEmbeddedConstantOffset ec_offset = convert_endianness( pp.embeddedConst,endianness() );
|
||||
CgBinaryStringOffset sm_offset = convert_endianness( pp.semantic,endianness() );
|
||||
if ( 0 != nm_offset )
|
||||
{
|
||||
*name = &image_[nm_offset];
|
||||
}
|
||||
else
|
||||
*name = "";
|
||||
|
||||
if ( 0 != sm_offset )
|
||||
{
|
||||
*semantic = &image_[sm_offset];
|
||||
}
|
||||
else
|
||||
*semantic = "";
|
||||
if ( 0 != dv_offset )
|
||||
{
|
||||
char *vp = &image_[dv_offset];
|
||||
for (int ii = 0; ii < 4; ++ii)
|
||||
{
|
||||
int tmp;
|
||||
memcpy(&tmp,vp+4*ii,4);
|
||||
tmp = convert_endianness(tmp,endianness());
|
||||
float tmp2;
|
||||
memcpy(&tmp2,&tmp,4);
|
||||
default_value.push_back( tmp2 );
|
||||
}
|
||||
}
|
||||
if ( 0 != ec_offset )
|
||||
{
|
||||
void *vp = &image_[ec_offset];
|
||||
CgBinaryEmbeddedConstant& ec = *(static_cast<CgBinaryEmbeddedConstant*>( vp ));
|
||||
for (unsigned int ii = 0; ii < convert_endianness( ec.ucodeCount, endianness() ); ++ii)
|
||||
{
|
||||
unsigned int offset = convert_endianness( ec.ucodeOffset[ii], endianness() );
|
||||
embedded_constants.push_back( offset );
|
||||
}
|
||||
}
|
||||
return CGBIO_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
elf_reader_impl::elf_reader_impl()
|
||||
{
|
||||
ref_count_ = 1;
|
||||
initialized_ = false;
|
||||
fill_n( reinterpret_cast<char*>( &header_ ), sizeof( header_ ), '\0' );
|
||||
}
|
||||
|
||||
elf_reader_impl::~elf_reader_impl()
|
||||
{
|
||||
}
|
||||
|
||||
CGBIO_ERROR
|
||||
elf_reader_impl::load( const char* filename )
|
||||
{
|
||||
return CGBIO_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
CGBIO_ERROR
|
||||
elf_reader_impl::load( std::istream* stream, int start )
|
||||
{
|
||||
return CGBIO_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
bool
|
||||
elf_reader_impl::is_initialized() const
|
||||
{
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
elf_reader_impl::reference() const
|
||||
{
|
||||
return ++ref_count_;
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
elf_reader_impl::release() const
|
||||
{
|
||||
ptrdiff_t ret = --ref_count_;
|
||||
if ( 0 == ref_count_ )
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
560
console/rgl/ps3/cgbio.hpp
Normal file
560
console/rgl/ps3/cgbio.hpp
Normal file
@ -0,0 +1,560 @@
|
||||
#ifndef CGC_CGBIO_CGBDEFS_HPP
|
||||
#define CGC_CGBIO_CGBDEFS_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifndef STL_NAMESPACE
|
||||
#define STL_NAMESPACE ::std::
|
||||
#endif
|
||||
|
||||
#define CGF_OUTPUTFROMH0 0x01
|
||||
#define CGF_DEPTHREPLACE 0x02
|
||||
#define CGF_PIXELKILL 0x04
|
||||
|
||||
typedef unsigned int Elf32_Addr;
|
||||
typedef unsigned short Elf32_Half;
|
||||
typedef short Elf32_Shalf;
|
||||
typedef unsigned int Elf32_Off;
|
||||
typedef signed int Elf32_Sword;
|
||||
typedef unsigned int Elf32_Word;
|
||||
|
||||
typedef size_t ptrdiff_t;
|
||||
typedef size_t ptrdiff_t;
|
||||
|
||||
typedef struct _Elf32_cgParameter {
|
||||
Elf32_Word cgp_name;
|
||||
Elf32_Word cgp_semantic;
|
||||
Elf32_Half cgp_default;
|
||||
Elf32_Half cgp_reloc;
|
||||
Elf32_Half cgp_resource;
|
||||
Elf32_Half cgp_resource_index;
|
||||
unsigned char cgp_type;
|
||||
Elf32_Half cgp_info;
|
||||
unsigned char unused;
|
||||
} Elf32_cgParameter;
|
||||
|
||||
#define ET_NONE 0
|
||||
#define ET_REL 1
|
||||
#define ET_EXEC 2
|
||||
#define ET_DYN 3
|
||||
#define ET_CORE 4
|
||||
#define ET_LOOS 0xFE00
|
||||
#define ET_HIOS 0xFEFF
|
||||
#define ET_LOPROC 0xFF00
|
||||
#define ET_HIPROC 0xFFFF
|
||||
|
||||
#define EM_NONE 0
|
||||
#define EM_RSX 0x528e
|
||||
|
||||
#define EM_RSX_NONE 0
|
||||
|
||||
#define EI_ABIVERSION_RSX 1
|
||||
|
||||
#define EV_NONE 0
|
||||
#define EV_CURRENT 1
|
||||
|
||||
#define EI_MAG0 0
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_OSABI 7
|
||||
#define EI_ABIVERSION 8
|
||||
#define EI_PAD 9
|
||||
#define EI_NIDENT 16
|
||||
|
||||
#define ELFMAG0 0x7F
|
||||
#define ELFMAG1 'E'
|
||||
#define ELFMAG2 'L'
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
|
||||
#define ELFDATANONE 0
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
|
||||
#define ELFOSABI_NONE 0
|
||||
#define ELFOSABI_HPUX 1
|
||||
#define ELFOSABI_NETBSD 2
|
||||
#define ELFOSABI_LINUX 3
|
||||
#define ELFOSABI_SOLARIS 6
|
||||
#define ELFOSABI_AIX 7
|
||||
#define ELFOSABI_IRIX 8
|
||||
#define ELFOSABI_FREEBSD 9
|
||||
#define ELFOSABI_TRU64 10
|
||||
#define ELFOSABI_MODESTO 11
|
||||
#define ELFOSABI_OPENBSD 12
|
||||
#define ELFOSABI_CGRUNTIME 19
|
||||
|
||||
#define SHN_UNDEF 0
|
||||
#define SHN_LORESERVE 0xFF00
|
||||
#define SHN_LOPROC 0xFF00
|
||||
#define SHN_HIPROC 0xFF1F
|
||||
#define SHN_LOOS 0xFF20
|
||||
#define SHN_HIOS 0xFF3F
|
||||
#define SHN_ABS 0xFFF1
|
||||
#define SHN_COMMON 0xFFF2
|
||||
#define SHN_XINDEX 0xFFFF
|
||||
#define SHN_HIRESERVE 0xFFFF
|
||||
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_STRTAB 3
|
||||
#define SHT_RELA 4
|
||||
#define SHT_HASH 5
|
||||
#define SHT_DYNAMIC 6
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_NOBITS 8
|
||||
#define SHT_REL 9
|
||||
#define SHT_SHLIB 10
|
||||
#define SHT_DYNSYM 11
|
||||
#define SHT_INIT_ARRAY 14
|
||||
#define SHT_FINI_ARRAY 15
|
||||
#define SHT_PREINIT_ARRAY 16
|
||||
#define SHT_GROUP 17
|
||||
#define SHT_SYMTAB_SHNDX 18
|
||||
#define SHT_LOOS 0x60000000
|
||||
#define SHT_HIOS 0x6fffffff
|
||||
#define SHT_LOPROC 0x70000000
|
||||
#define SHT_RSX_PARAM 0x70000000
|
||||
#define SHT_RSX_SHADERTAB 0x70000001
|
||||
#define SHT_RSX_FXTAB 0x70000002
|
||||
#define SHT_RSX_ANNOTATE 0x70000003
|
||||
#define SHT_HIPROC 0x7FFFFFFF
|
||||
#define SHT_LOUSER 0x80000000
|
||||
#define SHT_HIUSER 0xFFFFFFFF
|
||||
|
||||
#define SHF_WRITE 0x1
|
||||
#define SHF_ALLOC 0x2
|
||||
#define SHF_EXECINSTR 0x4
|
||||
#define SHF_MERGE 0x10
|
||||
#define SHF_STRINGS 0x20
|
||||
#define SHF_INFO_LINK 0x40
|
||||
#define SHF_LINK_ORDER 0x80
|
||||
#define SHF_OS_NONCONFORMING 0x100
|
||||
#define SHF_GROUP 0x200
|
||||
#define SHF_TLS 0x400
|
||||
#define SHF_MASKOS 0x0ff00000
|
||||
#define SHF_MASKPROC 0xF0000000
|
||||
|
||||
#define GRP_COMDAT 0x1
|
||||
#define GRP_MASKOS 0x0ff00000
|
||||
#define GRP_MASKPROC 0xf0000000
|
||||
|
||||
#define STB_LOCAL 0
|
||||
#define STB_GLOBAL 1
|
||||
#define STB_WEAK 2
|
||||
#define STB_LOOS 10
|
||||
#define STB_HIOS 12
|
||||
#define STB_LOPROC 13
|
||||
#define STB_HIPROC 15
|
||||
|
||||
#define STT_NOTYPE 0
|
||||
#define STT_OBJECT 1
|
||||
#define STT_FUNC 2
|
||||
#define STT_SECTION 3
|
||||
#define STT_FILE 4
|
||||
#define STT_COMMON 5
|
||||
#define STT_TLS 6
|
||||
#define STT_LOOS 10
|
||||
#define STT_HIOS 12
|
||||
#define STT_LOPROC 13
|
||||
#define STT_HIPROC 15
|
||||
|
||||
#define STV_DEFAULT 0
|
||||
#define STV_INTERNAL 1
|
||||
#define STV_HIDDEN 2
|
||||
#define STV_PROTECTED 3
|
||||
|
||||
#define STO_RSX_SHADER 0
|
||||
#define STO_RSX_EFFECT 1
|
||||
|
||||
#define STN_UNDEF 0
|
||||
|
||||
#define R_RSX_NONE 0
|
||||
#define R_RSX_FLOAT4 1
|
||||
|
||||
struct Elf32_Ehdr {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
Elf32_Half e_type;
|
||||
Elf32_Half e_machine;
|
||||
Elf32_Word e_version;
|
||||
Elf32_Addr e_entry;
|
||||
Elf32_Off e_phoff;
|
||||
Elf32_Off e_shoff;
|
||||
Elf32_Word e_flags;
|
||||
Elf32_Half e_ehsize;
|
||||
Elf32_Half e_phentsize;
|
||||
Elf32_Half e_phnum;
|
||||
Elf32_Half e_shentsize;
|
||||
Elf32_Half e_shnum;
|
||||
Elf32_Half e_shstrndx;
|
||||
};
|
||||
|
||||
struct Elf32_Shdr {
|
||||
Elf32_Word sh_name;
|
||||
Elf32_Word sh_type;
|
||||
Elf32_Word sh_flags;
|
||||
Elf32_Addr sh_addr;
|
||||
Elf32_Off sh_offset;
|
||||
Elf32_Word sh_size;
|
||||
Elf32_Word sh_link;
|
||||
Elf32_Word sh_info;
|
||||
Elf32_Word sh_addralign;
|
||||
Elf32_Word sh_entsize;
|
||||
};
|
||||
|
||||
struct Elf32_Phdr {
|
||||
Elf32_Word p_type;
|
||||
Elf32_Off p_offset;
|
||||
Elf32_Addr p_vaddr;
|
||||
Elf32_Addr p_paddr;
|
||||
Elf32_Word p_filesz;
|
||||
Elf32_Word p_memsz;
|
||||
Elf32_Word p_flags;
|
||||
Elf32_Word p_align;
|
||||
};
|
||||
|
||||
struct Elf32_Sym {
|
||||
Elf32_Word st_name;
|
||||
Elf32_Addr st_value;
|
||||
Elf32_Word st_size;
|
||||
unsigned char st_info;
|
||||
unsigned char st_other;
|
||||
Elf32_Half st_shndx;
|
||||
};
|
||||
|
||||
struct Elf32_Note {
|
||||
Elf32_Word n_namesz; /* Name size */
|
||||
Elf32_Word n_descsz; /* Content size */
|
||||
Elf32_Word n_type; /* Content type */
|
||||
};
|
||||
|
||||
|
||||
struct Elf32_Rel {
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
};
|
||||
|
||||
struct Elf32_Rela {
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
Elf32_Sword r_addend;
|
||||
};
|
||||
|
||||
struct Elf32_Dyn {
|
||||
Elf32_Sword d_tag;
|
||||
union {
|
||||
Elf32_Word d_val;
|
||||
Elf32_Addr d_ptr;
|
||||
} d_un;
|
||||
};
|
||||
|
||||
using std::istream;
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
CGBIODATANONE = ELFDATANONE,
|
||||
CGBIODATALSB = ELFDATA2LSB,
|
||||
CGBIODATAMSB = ELFDATA2MSB
|
||||
} HOST_ENDIANNESS;
|
||||
|
||||
class elf_reader
|
||||
{
|
||||
public:
|
||||
virtual ptrdiff_t reference() const = 0;
|
||||
virtual ptrdiff_t release() const = 0;
|
||||
virtual CGBIO_ERROR load( const char * filename ) = 0;
|
||||
virtual CGBIO_ERROR load( istream* stream, int start ) = 0;
|
||||
virtual bool is_initialized() const = 0;
|
||||
virtual ~elf_reader() {}
|
||||
|
||||
};
|
||||
|
||||
class nvb_reader
|
||||
{
|
||||
public:
|
||||
virtual ~nvb_reader() {}
|
||||
|
||||
virtual ptrdiff_t
|
||||
reference() const = 0;
|
||||
|
||||
virtual ptrdiff_t
|
||||
release() const = 0;
|
||||
|
||||
virtual CGBIO_ERROR
|
||||
loadFromString( const char* source, size_t length ) = 0;
|
||||
|
||||
virtual bool
|
||||
is_loaded() const = 0;
|
||||
|
||||
virtual unsigned char
|
||||
endianness() const = 0;
|
||||
|
||||
virtual CGprofile
|
||||
profile() const = 0;
|
||||
|
||||
virtual unsigned int
|
||||
revision() const = 0;
|
||||
|
||||
virtual unsigned int
|
||||
size() const = 0;
|
||||
|
||||
virtual unsigned int
|
||||
number_of_params() const = 0;
|
||||
|
||||
virtual unsigned int
|
||||
ucode_size() const = 0;
|
||||
|
||||
virtual const char*
|
||||
ucode() const = 0;
|
||||
|
||||
virtual const CgBinaryFragmentProgram*
|
||||
fragment_program() const = 0;
|
||||
|
||||
virtual const CgBinaryVertexProgram*
|
||||
vertex_program() const = 0;
|
||||
|
||||
virtual CGBIO_ERROR
|
||||
get_param( unsigned int index,
|
||||
CGtype& type,
|
||||
CGresource& resource,
|
||||
CGenum& variability,
|
||||
int& resource_index,
|
||||
const char** name,
|
||||
STL_NAMESPACE vector<float>& default_value,
|
||||
STL_NAMESPACE vector<unsigned int>& embedded_constants,
|
||||
const char** semantic,
|
||||
int& paramno,
|
||||
bool& is_referenced,
|
||||
bool& is_shared ) const = 0;
|
||||
|
||||
virtual CGBIO_ERROR get_param_name( unsigned int index, const char** name, bool& is_referenced) const = 0;
|
||||
|
||||
};
|
||||
|
||||
class bin_io
|
||||
{
|
||||
public:
|
||||
static const bin_io* instance();
|
||||
static void delete_instance();
|
||||
|
||||
CGBIO_ERROR new_elf_reader( elf_reader** obj ) const;
|
||||
|
||||
CGBIO_ERROR new_nvb_reader( nvb_reader** obj ) const;
|
||||
|
||||
const char *error_string( CGBIO_ERROR error ) const;
|
||||
|
||||
private:
|
||||
bin_io();
|
||||
bin_io( const bin_io& );
|
||||
|
||||
static bin_io* instance_;
|
||||
};
|
||||
|
||||
|
||||
class isection
|
||||
{
|
||||
public:
|
||||
virtual ~isection() = 0;
|
||||
|
||||
virtual int reference() const = 0;
|
||||
virtual int release() const = 0;
|
||||
|
||||
virtual Elf32_Half index() const = 0;
|
||||
virtual char *name() const = 0;
|
||||
virtual Elf32_Word type() const = 0;
|
||||
virtual Elf32_Word flags() const = 0;
|
||||
virtual Elf32_Addr addr() const = 0;
|
||||
virtual Elf32_Word size() const = 0;
|
||||
virtual Elf32_Word link() const = 0;
|
||||
virtual Elf32_Word info() const = 0;
|
||||
virtual Elf32_Word addralign() const = 0;
|
||||
virtual Elf32_Word entsize() const = 0;
|
||||
virtual const char* data() const = 0;
|
||||
};
|
||||
|
||||
class elf_reader_impl : public elf_reader
|
||||
{
|
||||
public:
|
||||
elf_reader_impl();
|
||||
virtual ~elf_reader_impl();
|
||||
virtual CGBIO_ERROR load( const char* filename );
|
||||
virtual CGBIO_ERROR load( istream* stream, int start );
|
||||
virtual bool is_initialized() const;
|
||||
virtual ptrdiff_t reference() const;
|
||||
virtual ptrdiff_t release() const;
|
||||
private:
|
||||
mutable ptrdiff_t ref_count_;
|
||||
istream* stream_;
|
||||
bool initialized_;
|
||||
Elf32_Ehdr header_;
|
||||
STL_NAMESPACE vector<const isection*> sections_;
|
||||
};
|
||||
|
||||
inline HOST_ENDIANNESS host_endianness()
|
||||
{
|
||||
const int ii = 1;
|
||||
const char* cp = (const char*) ⅈ
|
||||
return ( 1 == cp[0] ) ? CGBIODATALSB : CGBIODATAMSB;
|
||||
}
|
||||
|
||||
template< typename T > inline T
|
||||
convert_endianness( const T value, unsigned char endianness )
|
||||
{
|
||||
if ( host_endianness() == endianness )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
if ( sizeof( T ) == 1 )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
if ( sizeof( T ) == 2 )
|
||||
{
|
||||
return ( ((value & 0x00FF) << 8)
|
||||
| ((value & 0xFF00) >> 8) );
|
||||
}
|
||||
if ( sizeof( T ) == 4 )
|
||||
{
|
||||
return ( ((value & 0x000000FF) << 24)
|
||||
| ((value & 0x0000FF00) << 8)
|
||||
| ((value & 0x00FF0000) >> 8)
|
||||
| ((value & 0xFF000000) >> 24) );
|
||||
}
|
||||
if ( sizeof( T ) == 8 )
|
||||
{
|
||||
T result = value;
|
||||
for ( int ii = 0; ii < 4; ++ii )
|
||||
{
|
||||
char ch = *( (( char* ) &result) + ii );
|
||||
*( (( char* ) &result) + ii ) = *( (( char* ) &result) + (7 - ii) );
|
||||
*( (( char* ) &result) + (7 - ii) ) = ch;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
template< typename T > inline T
|
||||
ELF32_ST_BIND( const T idx )
|
||||
{
|
||||
return ( idx >> 4 );
|
||||
}
|
||||
|
||||
template< typename T > inline T
|
||||
ELF32_ST_TYPE( const T idx )
|
||||
{
|
||||
return ( idx & 0xf );
|
||||
}
|
||||
|
||||
template< typename T > inline T
|
||||
ELF32_ST_INFO( const T b, const T t )
|
||||
{
|
||||
return ( ( b << 4 ) + ( t & 0xf ) );
|
||||
}
|
||||
|
||||
template< typename T > inline T
|
||||
ELF32_ST_VISIBILITY( const T o )
|
||||
{
|
||||
return ( o & 0x3 );
|
||||
}
|
||||
|
||||
class nvb_reader_impl : public nvb_reader
|
||||
{
|
||||
public:
|
||||
nvb_reader_impl();
|
||||
|
||||
virtual
|
||||
~nvb_reader_impl();
|
||||
|
||||
virtual ptrdiff_t
|
||||
reference() const;
|
||||
|
||||
virtual ptrdiff_t
|
||||
release() const;
|
||||
|
||||
virtual CGBIO_ERROR
|
||||
loadFromString( const char* source, size_t length);
|
||||
|
||||
virtual bool
|
||||
is_loaded() const;
|
||||
|
||||
virtual unsigned char
|
||||
endianness() const;
|
||||
|
||||
virtual CGprofile
|
||||
profile() const;
|
||||
|
||||
virtual unsigned int
|
||||
revision() const;
|
||||
|
||||
virtual unsigned int
|
||||
size() const;
|
||||
|
||||
virtual unsigned int
|
||||
number_of_params() const;
|
||||
|
||||
virtual unsigned int
|
||||
ucode_size() const;
|
||||
|
||||
virtual const char*
|
||||
ucode() const;
|
||||
|
||||
virtual const CgBinaryFragmentProgram*
|
||||
fragment_program() const;
|
||||
|
||||
virtual const CgBinaryVertexProgram*
|
||||
vertex_program() const;
|
||||
|
||||
virtual CGBIO_ERROR
|
||||
get_param( unsigned int index,
|
||||
CGtype& type,
|
||||
CGresource& resource,
|
||||
CGenum& variability,
|
||||
int& resource_index,
|
||||
const char ** name,
|
||||
STL_NAMESPACE vector<float>& default_value,
|
||||
STL_NAMESPACE vector<unsigned int>& embedded_constants,
|
||||
const char ** semantic,
|
||||
int& paramno,
|
||||
bool& is_referenced,
|
||||
bool& is_shared ) const;
|
||||
|
||||
virtual CGBIO_ERROR get_param_name( unsigned int index, const char ** name , bool& is_referenced) const;
|
||||
|
||||
private:
|
||||
mutable ptrdiff_t ref_count_;
|
||||
int offset_;
|
||||
bool loaded_;
|
||||
bool owner_;
|
||||
bool strStream_;
|
||||
CgBinaryProgram header_;
|
||||
unsigned char endianness_;
|
||||
char* image_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
1068
console/rgl/ps3/cgnv2rt.cpp
Normal file
1068
console/rgl/ps3/cgnv2rt.cpp
Normal file
File diff suppressed because it is too large
Load Diff
79
console/rgl/ps3/cgnv2rt.h
Normal file
79
console/rgl/ps3/cgnv2rt.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef CGNV2RT_HEADER
|
||||
#define CGNV2RT_HEADER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef STL_NAMESPACE
|
||||
#define STL_NAMESPACE ::std::
|
||||
#endif
|
||||
|
||||
#ifndef CGNV2ELF_VERSION
|
||||
#define CGNV2ELF_VERSION 6365
|
||||
#define CGNV2ELF_PRODUCT_STRING "cgnv2elf"
|
||||
#define CGNV2ELF_VERSION_NOTE_TYPE 0
|
||||
#endif
|
||||
|
||||
#define CNV2END(val) convert_endianness((val), elfEndianness)
|
||||
#define ENDSWAP(val) convert_endianness((val), (host_endianness() == 1) ? 2 : 1)
|
||||
|
||||
static unsigned int stringTableAdd( STL_NAMESPACE vector<char> &stringTable, const char* str )
|
||||
{
|
||||
unsigned int ret = (unsigned int)stringTable.size();
|
||||
|
||||
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);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned int stringTableFind( STL_NAMESPACE vector<char> &stringTable, const char* str )
|
||||
{
|
||||
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;
|
||||
|
||||
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<char> &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;
|
||||
}
|
||||
|
||||
int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTableOffset, void **binaryShader, int *size,
|
||||
STL_NAMESPACE vector<char> &stringTable, STL_NAMESPACE vector<float> &defaultValues);
|
||||
int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize,
|
||||
STL_NAMESPACE vector<char> &stringTable, STL_NAMESPACE vector<float> &defaultValues);
|
||||
|
||||
int convertNvToElfFreeBinaryShader(void *binaryShader);
|
||||
|
||||
#endif
|
1332
console/rgl/ps3/device_ctx.cpp
Normal file
1332
console/rgl/ps3/device_ctx.cpp
Normal file
File diff suppressed because it is too large
Load Diff
161
console/rgl/ps3/elf.h
Normal file
161
console/rgl/ps3/elf.h
Normal file
@ -0,0 +1,161 @@
|
||||
#ifndef ELF_H
|
||||
#define ELF_H 1
|
||||
|
||||
#define RGL_ALIGN_FAST_TRANSFER 128
|
||||
|
||||
typedef unsigned int Elf32_Addr;
|
||||
typedef unsigned int Elf32_Off;
|
||||
typedef unsigned short Elf32_Half;
|
||||
typedef unsigned int Elf32_Word;
|
||||
typedef int Elf32_Sword;
|
||||
|
||||
#define EI_MAG0 0
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_OSABI 7
|
||||
#define EI_ABIVERSION 8
|
||||
#define EI_PAD 9
|
||||
#define EI_NIDENT 16
|
||||
|
||||
#define ELFMAG0 0x7f
|
||||
#define ELFMAG1 'E'
|
||||
#define ELFMAG2 'L'
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
|
||||
#define ELFDATANONE 0
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
|
||||
#define EV_NONE 0
|
||||
#define EV_CURRENT 1
|
||||
|
||||
#define ET_NONE 0
|
||||
#define ET_REL 1
|
||||
#define ET_EXEC 2
|
||||
#define ET_DYN 3
|
||||
#define ET_CORE 4
|
||||
|
||||
#define EM_PPC 20
|
||||
#define EM_PPC64 21
|
||||
|
||||
typedef struct {
|
||||
unsigned char e_ident[EI_NIDENT];
|
||||
Elf32_Half e_type;
|
||||
Elf32_Half e_machine;
|
||||
Elf32_Word e_version;
|
||||
Elf32_Addr e_entry;
|
||||
Elf32_Off e_phoff;
|
||||
Elf32_Off e_shoff;
|
||||
Elf32_Word e_flags;
|
||||
Elf32_Half e_ehsize;
|
||||
Elf32_Half e_phentsize;
|
||||
Elf32_Half e_phnum;
|
||||
Elf32_Half e_shentsize;
|
||||
Elf32_Half e_shnum;
|
||||
Elf32_Half e_shstrndx;
|
||||
} Elf32_Ehdr;
|
||||
|
||||
#define PT_NULL 0
|
||||
#define PT_LOAD 1
|
||||
#define PT_DYNAMIC 2
|
||||
#define PT_INTERP 3
|
||||
#define PT_NOTE 4
|
||||
#define PT_SHLIB 5
|
||||
#define PT_PHDR 6
|
||||
#define PT_LOOS 0x60000000
|
||||
#define PT_HIOS 0x6fffffff
|
||||
#define PT_LOPROC 0x70000000
|
||||
#define PT_HIPROC 0x7fffffff
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word p_type;
|
||||
Elf32_Off p_offset;
|
||||
Elf32_Addr p_vaddr;
|
||||
Elf32_Addr p_paddr;
|
||||
Elf32_Word p_filesz;
|
||||
Elf32_Word p_memsz;
|
||||
Elf32_Word p_flags;
|
||||
Elf32_Word p_align;
|
||||
} Elf32_Phdr;
|
||||
|
||||
#define SHT_NULL 0
|
||||
#define SHT_PROGBITS 1
|
||||
#define SHT_SYMTAB 2
|
||||
#define SHT_STRTAB 3
|
||||
#define SHT_RELA 4
|
||||
#define SHT_HASH 5
|
||||
#define SHT_DYNAMIC 6
|
||||
#define SHT_NOTE 7
|
||||
#define SHT_NOBITS 8
|
||||
#define SHT_REL 9
|
||||
#define SHT_SHLIB 10
|
||||
#define SHT_DYNSYM 11
|
||||
|
||||
#define SHF_WRITE (1 << 0)
|
||||
#define SHF_ALLOC (1 << 1)
|
||||
#define SHF_EXECINSTR (1 << 2)
|
||||
#define SHF_MERGE (1 << 4)
|
||||
#define SHF_STRINGS (1 << 5)
|
||||
#define SHF_INFO_LINK (1 << 6)
|
||||
#define SHF_LINK_ORDER (1 << 7)
|
||||
#define SHF_OS_NONCONFORMING (1 << 8)
|
||||
#define SHF_MASKOS 0x0ff00000
|
||||
#define SHF_MASKPROC 0xf0000000
|
||||
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word sh_name;
|
||||
Elf32_Word sh_type;
|
||||
Elf32_Word sh_flags;
|
||||
Elf32_Addr sh_addr;
|
||||
Elf32_Off sh_offset;
|
||||
Elf32_Word sh_size;
|
||||
Elf32_Word sh_link;
|
||||
Elf32_Word sh_info;
|
||||
Elf32_Word sh_addralign;
|
||||
Elf32_Word sh_entsize;
|
||||
} Elf32_Shdr;
|
||||
|
||||
#define SHN_UNDEF 0
|
||||
#define SHN_LORESERVE 0xff00
|
||||
#define SHN_LOPROC 0xff00
|
||||
#define SHN_HIPROC 0xff1f
|
||||
#define SHN_LOOS 0xff20
|
||||
#define SHN_HIOS 0xff3f
|
||||
#define SHN_ABS 0xfff1
|
||||
#define SHN_COMMON 0xfff2
|
||||
#define SHN_XINDEX 0xffff
|
||||
#define SHN_HIRESERVE 0xffff
|
||||
|
||||
typedef struct {
|
||||
Elf32_Word st_name;
|
||||
Elf32_Word st_value;
|
||||
Elf32_Word st_size;
|
||||
unsigned char st_info;
|
||||
unsigned char st_other;
|
||||
Elf32_Half st_shndx;
|
||||
} Elf32_Sym;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
} Elf32_Rel;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Elf32_Addr r_offset;
|
||||
Elf32_Word r_info;
|
||||
Elf32_Sword r_addend;
|
||||
} Elf32_Rela;
|
||||
|
||||
#endif /* ELF_H */
|
326
console/rgl/ps3/gl.h
Normal file
326
console/rgl/ps3/gl.h
Normal file
@ -0,0 +1,326 @@
|
||||
#ifndef __gl_h_
|
||||
#define __gl_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
** License Applicability. Except to the extent portions of this file are
|
||||
** made subject to an alternative license as permitted in the SGI Free
|
||||
** Software License B, Version 1.0 (the "License"), the contents of this
|
||||
** file are subject only to the provisions of the License. You may not use
|
||||
** this file except in compliance with the License. You may obtain a copy
|
||||
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
|
||||
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
|
||||
**
|
||||
** http://oss.sgi.com/projects/FreeB
|
||||
**
|
||||
** Note that, as provided in the License, the Software is distributed on an
|
||||
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
|
||||
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
|
||||
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
|
||||
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
||||
**
|
||||
** Original Code. The Original Code is: OpenGL Sample Implementation,
|
||||
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
|
||||
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
|
||||
** Copyright in any portions created by third parties is as indicated
|
||||
** elsewhere herein. All Rights Reserved.
|
||||
**
|
||||
** Additional Notice Provisions: The application programming interfaces
|
||||
** established by SGI in conjunction with the Original Code are The
|
||||
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
|
||||
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
|
||||
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
|
||||
** Window System(R) (Version 1.3), released October 19, 1998. This software
|
||||
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
|
||||
** published by SGI, but has not been independently verified as being
|
||||
** compliant with the OpenGL(R) version 1.2.1 Specification.
|
||||
*/
|
||||
|
||||
#ifdef PSGL_EXPORT
|
||||
#define GLAPI PSGL_EXPORT
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SYMBIAN32__)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#ifndef GLAPI
|
||||
#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 )();
|
||||
|
||||
#define GL_OES_VERSION_1_0 1
|
||||
#define GL_OES_read_format 1
|
||||
#define GL_OES_compressed_paletted_texture 1
|
||||
|
||||
#define GL_DEPTH_BUFFER_BIT 0x00000100
|
||||
#define GL_STENCIL_BUFFER_BIT 0x00000400
|
||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||
|
||||
#define GL_FALSE 0
|
||||
#define GL_TRUE 1
|
||||
|
||||
#define GL_POINTS 0x0000
|
||||
#define GL_LINES 0x0001
|
||||
#define GL_LINE_LOOP 0x0002
|
||||
#define GL_LINE_STRIP 0x0003
|
||||
#define GL_TRIANGLES 0x0004
|
||||
#define GL_TRIANGLE_STRIP 0x0005
|
||||
#define GL_TRIANGLE_FAN 0x0006
|
||||
|
||||
#define GL_NEVER 0x0200
|
||||
#define GL_LESS 0x0201
|
||||
#define GL_EQUAL 0x0202
|
||||
#define GL_LEQUAL 0x0203
|
||||
#define GL_GREATER 0x0204
|
||||
#define GL_NOTEQUAL 0x0205
|
||||
#define GL_GEQUAL 0x0206
|
||||
#define GL_ALWAYS 0x0207
|
||||
|
||||
#define GL_ZERO 0
|
||||
#define GL_ONE 1
|
||||
#define GL_SRC_COLOR 0x0300
|
||||
#define GL_ONE_MINUS_SRC_COLOR 0x0301
|
||||
#define GL_SRC_ALPHA 0x0302
|
||||
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
|
||||
#define GL_DST_ALPHA 0x0304
|
||||
#define GL_ONE_MINUS_DST_ALPHA 0x0305
|
||||
|
||||
#define GL_DST_COLOR 0x0306
|
||||
#define GL_ONE_MINUS_DST_COLOR 0x0307
|
||||
#define GL_SRC_ALPHA_SATURATE 0x0308
|
||||
#define GL_FRONT 0x0404
|
||||
#define GL_BACK 0x0405
|
||||
#define GL_FRONT_AND_BACK 0x0408
|
||||
#define GL_TEXTURE_2D 0x0DE1
|
||||
#define GL_BLEND 0x0BE2
|
||||
#define GL_DITHER 0x0BD0
|
||||
#define GL_POINT_SMOOTH 0x0B10
|
||||
#define GL_LINE_SMOOTH 0x0B20
|
||||
#define GL_SCISSOR_TEST 0x0C11
|
||||
#define GL_COLOR_MATERIAL 0x0B57
|
||||
#define GL_NORMALIZE 0x0BA1
|
||||
#define GL_RESCALE_NORMAL 0x803A
|
||||
#define GL_POLYGON_OFFSET_FILL 0x8037
|
||||
#define GL_VERTEX_ARRAY 0x8074
|
||||
#define GL_NORMAL_ARRAY 0x8075
|
||||
#define GL_COLOR_ARRAY 0x8076
|
||||
#define GL_TEXTURE_COORD_ARRAY 0x8078
|
||||
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
|
||||
#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
|
||||
#define GL_SAMPLE_COVERAGE 0x80A0
|
||||
|
||||
#define GL_NO_ERROR 0
|
||||
#define GL_INVALID_ENUM 0x0500
|
||||
#define GL_INVALID_VALUE 0x0501
|
||||
#define GL_INVALID_OPERATION 0x0502
|
||||
#define GL_STACK_OVERFLOW 0x0503
|
||||
#define GL_STACK_UNDERFLOW 0x0504
|
||||
#define GL_OUT_OF_MEMORY 0x0505
|
||||
|
||||
#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
|
||||
#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
|
||||
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
|
||||
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
|
||||
#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
|
||||
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
|
||||
#define GL_MAX_LIGHTS 0x0D31
|
||||
#define GL_MAX_TEXTURE_SIZE 0x0D33
|
||||
#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
|
||||
#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
|
||||
#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
|
||||
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
|
||||
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
|
||||
#define GL_MAX_ELEMENTS_INDICES 0x80E9
|
||||
#define GL_MAX_TEXTURE_UNITS 0x84E2
|
||||
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
|
||||
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
|
||||
#define GL_SUBPIXEL_BITS 0x0D50
|
||||
#define GL_RED_BITS 0x0D52
|
||||
#define GL_GREEN_BITS 0x0D53
|
||||
#define GL_BLUE_BITS 0x0D54
|
||||
#define GL_ALPHA_BITS 0x0D55
|
||||
#define GL_DEPTH_BITS 0x0D56
|
||||
#define GL_STENCIL_BITS 0x0D57
|
||||
|
||||
#define GL_DONT_CARE 0x1100
|
||||
#define GL_FASTEST 0x1101
|
||||
#define GL_NICEST 0x1102
|
||||
|
||||
#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
|
||||
#define GL_POINT_SMOOTH_HINT 0x0C51
|
||||
#define GL_LINE_SMOOTH_HINT 0x0C52
|
||||
#define GL_POLYGON_SMOOTH_HINT 0x0C53
|
||||
#define GL_FOG_HINT 0x0C54
|
||||
|
||||
#define GL_BYTE 0x1400
|
||||
#define GL_UNSIGNED_BYTE 0x1401
|
||||
#define GL_SHORT 0x1402
|
||||
#define GL_UNSIGNED_SHORT 0x1403
|
||||
#define GL_FLOAT 0x1406
|
||||
#define GL_FIXED 0x140C
|
||||
|
||||
#define GL_CLEAR 0x1500
|
||||
#define GL_AND 0x1501
|
||||
#define GL_AND_REVERSE 0x1502
|
||||
#define GL_COPY 0x1503
|
||||
#define GL_AND_INVERTED 0x1504
|
||||
#define GL_NOOP 0x1505
|
||||
#define GL_XOR 0x1506
|
||||
#define GL_OR 0x1507
|
||||
#define GL_NOR 0x1508
|
||||
#define GL_EQUIV 0x1509
|
||||
#define GL_INVERT 0x150A
|
||||
#define GL_OR_REVERSE 0x150B
|
||||
#define GL_COPY_INVERTED 0x150C
|
||||
#define GL_OR_INVERTED 0x150D
|
||||
#define GL_NAND 0x150E
|
||||
#define GL_SET 0x150F
|
||||
|
||||
#define GL_EMISSION 0x1600
|
||||
#define GL_SHININESS 0x1601
|
||||
#define GL_AMBIENT_AND_DIFFUSE 0x1602
|
||||
#define GL_MODELVIEW 0x1700
|
||||
#define GL_PROJECTION 0x1701
|
||||
#define GL_TEXTURE 0x1702
|
||||
|
||||
#define GL_ALPHA 0x1906
|
||||
#define GL_RGB 0x1907
|
||||
#define GL_RGBA 0x1908
|
||||
#define GL_LUMINANCE 0x1909
|
||||
#define GL_LUMINANCE_ALPHA 0x190A
|
||||
|
||||
#define GL_UNPACK_ALIGNMENT 0x0CF5
|
||||
#define GL_PACK_ALIGNMENT 0x0D05
|
||||
|
||||
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
|
||||
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
|
||||
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
|
||||
|
||||
#define GL_FLAT 0x1D00
|
||||
#define GL_SMOOTH 0x1D01
|
||||
|
||||
#define GL_KEEP 0x1E00
|
||||
#define GL_REPLACE 0x1E01
|
||||
#define GL_INCR 0x1E02
|
||||
#define GL_DECR 0x1E03
|
||||
#define GL_VENDOR 0x1F00
|
||||
#define GL_RENDERER 0x1F01
|
||||
#define GL_VERSION 0x1F02
|
||||
#define GL_EXTENSIONS 0x1F03
|
||||
|
||||
#define GL_MODULATE 0x2100
|
||||
#define GL_DECAL 0x2101
|
||||
#define GL_ADD 0x0104
|
||||
#define GL_TEXTURE_ENV_MODE 0x2200
|
||||
#define GL_TEXTURE_ENV_COLOR 0x2201
|
||||
|
||||
#define GL_TEXTURE_ENV 0x2300
|
||||
#define GL_NEAREST 0x2600
|
||||
#define GL_LINEAR 0x2601
|
||||
|
||||
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
|
||||
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
|
||||
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
|
||||
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
|
||||
|
||||
#define GL_TEXTURE_MAG_FILTER 0x2800
|
||||
#define GL_TEXTURE_MIN_FILTER 0x2801
|
||||
#define GL_TEXTURE_WRAP_S 0x2802
|
||||
#define GL_TEXTURE_WRAP_T 0x2803
|
||||
|
||||
#define GL_TEXTURE0 0x84C0
|
||||
#define GL_TEXTURE1 0x84C1
|
||||
#define GL_TEXTURE2 0x84C2
|
||||
#define GL_TEXTURE3 0x84C3
|
||||
#define GL_TEXTURE4 0x84C4
|
||||
#define GL_TEXTURE5 0x84C5
|
||||
#define GL_TEXTURE6 0x84C6
|
||||
#define GL_TEXTURE7 0x84C7
|
||||
#define GL_TEXTURE8 0x84C8
|
||||
#define GL_TEXTURE9 0x84C9
|
||||
#define GL_TEXTURE10 0x84CA
|
||||
#define GL_TEXTURE11 0x84CB
|
||||
#define GL_TEXTURE12 0x84CC
|
||||
#define GL_TEXTURE13 0x84CD
|
||||
#define GL_TEXTURE14 0x84CE
|
||||
#define GL_TEXTURE15 0x84CF
|
||||
#define GL_TEXTURE16 0x84D0
|
||||
#define GL_TEXTURE17 0x84D1
|
||||
#define GL_TEXTURE18 0x84D2
|
||||
#define GL_TEXTURE19 0x84D3
|
||||
#define GL_TEXTURE20 0x84D4
|
||||
#define GL_TEXTURE21 0x84D5
|
||||
#define GL_TEXTURE22 0x84D6
|
||||
#define GL_TEXTURE23 0x84D7
|
||||
#define GL_TEXTURE24 0x84D8
|
||||
#define GL_TEXTURE25 0x84D9
|
||||
#define GL_TEXTURE26 0x84DA
|
||||
#define GL_TEXTURE27 0x84DB
|
||||
#define GL_TEXTURE28 0x84DC
|
||||
#define GL_TEXTURE29 0x84DD
|
||||
#define GL_TEXTURE30 0x84DE
|
||||
#define GL_TEXTURE31 0x84DF
|
||||
|
||||
#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 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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __gl_h_ */
|
274
console/rgl/ps3/glext.h
Normal file
274
console/rgl/ps3/glext.h
Normal file
@ -0,0 +1,274 @@
|
||||
#ifndef __gl_ext_h_
|
||||
#define __gl_ext_h_
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef intptr_t GLintptr;
|
||||
typedef intptr_t GLsizeiptr;
|
||||
typedef unsigned short GLhalfARB;
|
||||
|
||||
#define GL_QUADS 0x0007
|
||||
#define GL_QUAD_STRIP 0x0008
|
||||
|
||||
#define GL_INT 0x1404
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
|
||||
#define GL_UNSIGNED_BYTE_3_3_2 0x8032
|
||||
#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
|
||||
#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
|
||||
#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
|
||||
#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
|
||||
#define GL_UNSIGNED_INT_8_8_8_8 0x8035
|
||||
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
|
||||
#define GL_UNSIGNED_INT_10_10_10_2 0x8036
|
||||
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
|
||||
#define GL_UNSIGNED_INT_24_8_SCE 0x6008
|
||||
#define GL_UNSIGNED_INT_8_24_REV_SCE 0x6009
|
||||
|
||||
#define GL_HALF_FLOAT_ARB 0x140B
|
||||
|
||||
#define GL_ALPHA4 0x803B
|
||||
#define GL_ALPHA8 0x803C
|
||||
#define GL_ALPHA12 0x803D
|
||||
#define GL_ALPHA16 0x803E
|
||||
#define GL_LUMINANCE4 0x803F
|
||||
#define GL_LUMINANCE8 0x8040
|
||||
#define GL_LUMINANCE12 0x8041
|
||||
#define GL_LUMINANCE16 0x8042
|
||||
#define GL_LUMINANCE4_ALPHA4 0x8043
|
||||
#define GL_LUMINANCE6_ALPHA2 0x8044
|
||||
#define GL_LUMINANCE8_ALPHA8 0x8045
|
||||
#define GL_LUMINANCE12_ALPHA4 0x8046
|
||||
#define GL_LUMINANCE12_ALPHA12 0x8047
|
||||
#define GL_LUMINANCE16_ALPHA16 0x8048
|
||||
#define GL_INTENSITY 0x8049
|
||||
#define GL_INTENSITY4 0x804A
|
||||
#define GL_INTENSITY8 0x804B
|
||||
#define GL_INTENSITY12 0x804C
|
||||
#define GL_INTENSITY16 0x804D
|
||||
#define GL_R3_G3_B2 0x2A10
|
||||
#define GL_RGB4 0x804F
|
||||
#define GL_RGB5 0x8050
|
||||
#define GL_RGB8 0x8051
|
||||
#define GL_RGB10 0x8052
|
||||
#define GL_RGB12 0x8053
|
||||
#define GL_RGB16 0x8054
|
||||
#define GL_RGBA2 0x8055
|
||||
#define GL_RGBA4 0x8056
|
||||
#define GL_RGB5_A1 0x8057
|
||||
#define GL_RGB10_A2 0x8059
|
||||
#define GL_RGBA12 0x805A
|
||||
#define GL_RGBA16 0x805B
|
||||
#define GL_BGR 0x80E0
|
||||
#define GL_BGRA 0x80E1
|
||||
#define GL_ABGR 0x8000
|
||||
#define GL_RED 0x1903
|
||||
#define GL_GREEN 0x1904
|
||||
#define GL_BLUE 0x1905
|
||||
#define GL_ARGB_SCE 0x6007
|
||||
|
||||
#define GL_UNSIGNED_SHORT_8_8_SCE 0x600B
|
||||
#define GL_UNSIGNED_SHORT_8_8_REV_SCE 0x600C
|
||||
#define GL_UNSIGNED_INT_16_16_SCE 0x600D
|
||||
#define GL_UNSIGNED_INT_16_16_REV_SCE 0x600E
|
||||
|
||||
#define GL_CONSTANT_COLOR 0x8001
|
||||
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
|
||||
#define GL_CONSTANT_ALPHA 0x8003
|
||||
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
|
||||
#define GL_BLEND_EQUATION 0x8009
|
||||
#define GL_FUNC_ADD 0x8006
|
||||
#define GL_MIN 0x8007
|
||||
#define GL_MAX 0x8008
|
||||
#define GL_FUNC_SUBTRACT 0x800A
|
||||
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
|
||||
|
||||
#define GL_TEXTURE_WRAP_R 0x8072
|
||||
#define GL_MAX_3D_TEXTURE_SIZE 0x8073
|
||||
|
||||
#define GL_POINT 0x1B00
|
||||
#define GL_LINE 0x1B01
|
||||
#define GL_FILL 0x1B02
|
||||
|
||||
#define GL_TEXTURE_FILTER_CONTROL 0x8500
|
||||
#define GL_TEXTURE_LOD_BIAS 0x8501
|
||||
#define GL_TEXTURE_MIN_LOD 0x813A
|
||||
#define GL_TEXTURE_MAX_LOD 0x813B
|
||||
#define GL_TEXTURE_MAX_LEVEL 0x813D
|
||||
#define GL_TEXTURE_BORDER_COLOR 0x1004
|
||||
|
||||
#define GL_NONE 0x0
|
||||
#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
|
||||
#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
|
||||
#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
|
||||
#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
|
||||
|
||||
#define GL_CLAMP 0x2900
|
||||
#define GL_MIRRORED_REPEAT 0x8370
|
||||
#define GL_MIRROR_CLAMP_EXT 0x8742
|
||||
#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
|
||||
#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
|
||||
#define GL_CLAMP_TO_BORDER 0x812D
|
||||
|
||||
/* Fragment Control TXP */
|
||||
#define GL_FRAGMENT_PROGRAM_CONTROL_CONTROLTXP_SCE 0x8453
|
||||
|
||||
/* Gets */
|
||||
#define GL_MODELVIEW_MATRIX 0x0BA6
|
||||
#define GL_TEXTURE_MATRIX 0x0BA8
|
||||
#define GL_PROJECTION_MATRIX 0x0BA7
|
||||
#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
|
||||
#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
|
||||
|
||||
#define GL_RGBA8 0x8058
|
||||
|
||||
#define GL_ARRAY_BUFFER 0x8892
|
||||
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
|
||||
#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
|
||||
#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
|
||||
#define GL_STREAM_DRAW 0x88E0
|
||||
#define GL_STREAM_READ 0x88E1
|
||||
#define GL_STREAM_COPY 0x88E2
|
||||
#define GL_STATIC_DRAW 0x88E4
|
||||
#define GL_STATIC_READ 0x88E5
|
||||
#define GL_STATIC_COPY 0x88E6
|
||||
#define GL_DYNAMIC_DRAW 0x88E8
|
||||
#define GL_DYNAMIC_READ 0x88E9
|
||||
#define GL_DYNAMIC_COPY 0x88EA
|
||||
#define GL_SYSTEM_DRAW_SCE 0x6020
|
||||
|
||||
#define GL_READ_ONLY 0x88B8
|
||||
#define GL_WRITE_ONLY 0x88B9
|
||||
#define GL_READ_WRITE 0x88BA
|
||||
|
||||
#define GL_VSYNC_SCE 0x6006
|
||||
#define GL_SKIP_FIRST_VSYNC_SCE 0x6100
|
||||
|
||||
#define GL_TEXTURE_GAMMA_REMAP_R_SCE 0x6010
|
||||
#define GL_TEXTURE_GAMMA_REMAP_G_SCE 0x6011
|
||||
#define GL_TEXTURE_GAMMA_REMAP_B_SCE 0x6012
|
||||
#define GL_TEXTURE_GAMMA_REMAP_A_SCE 0x6013
|
||||
|
||||
#define GL_SHADER_SRGB_REMAP_SCE 0x6014
|
||||
|
||||
#define GL_TEXTURE_FROM_VERTEX_PROGRAM_SCE 0x6017
|
||||
|
||||
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
|
||||
#define GL_ALL_COMPLETED_NV 0x84F2
|
||||
#define GL_FENCE_STATUS_NV 0x84F3
|
||||
#define GL_FENCE_CONDITION_NV 0x84F4
|
||||
|
||||
#define GL_MAX_CLIP_PLANES 0x0D32
|
||||
#define GL_CLIP_PLANE0 0x3000
|
||||
#define GL_CLIP_PLANE1 0x3001
|
||||
#define GL_CLIP_PLANE2 0x3002
|
||||
#define GL_CLIP_PLANE3 0x3003
|
||||
#define GL_CLIP_PLANE4 0x3004
|
||||
#define GL_CLIP_PLANE5 0x3005
|
||||
|
||||
#define GL_POINT_SPRITE_OES 0x8861
|
||||
#define GL_COORD_REPLACE_OES 0x8862
|
||||
#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
|
||||
|
||||
#define GL_INVALID_FRAMEBUFFER_OPERATION_OES 0x0506
|
||||
#define GL_MAX_RENDERBUFFER_SIZE_OES 0x84E8
|
||||
#define GL_FRAMEBUFFER_BINDING_OES 0x8CA6
|
||||
#define GL_RENDERBUFFER_BINDING_OES 0x8CA7
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES 0x8CD0
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES 0x8CD1
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES 0x8CD2
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES 0x8CD3
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
|
||||
#define GL_FRAMEBUFFER_COMPLETE_OES 0x8CD5
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES 0x8CD6
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES 0x8CD7
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_OES 0x8CD8
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES 0x8CD9
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_OES 0x8CDA
|
||||
#define GL_FRAMEBUFFER_UNSUPPORTED_OES 0x8CDD
|
||||
#define GL_MAX_COLOR_ATTACHMENTS_OES 0x8CDF
|
||||
#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
|
||||
#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
|
||||
#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
|
||||
#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
|
||||
#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
|
||||
#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
|
||||
#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
|
||||
#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
|
||||
#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
|
||||
#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
|
||||
#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
|
||||
#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
|
||||
#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
|
||||
#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
|
||||
#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
|
||||
#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
|
||||
#define GL_DEPTH_ATTACHMENT_OES 0x8D00
|
||||
#define GL_STENCIL_ATTACHMENT_OES 0x8D20
|
||||
#define GL_FRAMEBUFFER_OES 0x8D40
|
||||
#define GL_RENDERBUFFER_OES 0x8D41
|
||||
#define GL_RENDERBUFFER_WIDTH_OES 0x8D42
|
||||
#define GL_RENDERBUFFER_HEIGHT_OES 0x8D43
|
||||
#define GL_RENDERBUFFER_INTERNAL_FORMAT_OES 0x8D44
|
||||
#define GL_STENCIL_INDEX_OES 0x8D45
|
||||
#define GL_STENCIL_INDEX4_OES 0x8D47
|
||||
#define GL_STENCIL_INDEX8_OES 0x8D48
|
||||
|
||||
#define GL_BLEND_MRT0_SCE GL_COLOR_ATTACHMENT0_EXT
|
||||
#define GL_BLEND_MRT1_SCE GL_COLOR_ATTACHMENT1_EXT
|
||||
#define GL_BLEND_MRT2_SCE GL_COLOR_ATTACHMENT2_EXT
|
||||
#define GL_BLEND_MRT3_SCE GL_COLOR_ATTACHMENT3_EXT
|
||||
|
||||
#define GL_TEXTURE_ALLOCATION_HINT_SCE 0x6018
|
||||
#define GL_TEXTURE_LINEAR_GPU_SCE 0x601A
|
||||
|
||||
#define GL_INCR_WRAP 0x8507
|
||||
#define GL_DECR_WRAP 0x8508
|
||||
|
||||
#define GL_DEPTH_CLAMP_NV 0x864F
|
||||
|
||||
#define GL_FIXED_11_11_10_SCE 0x6020
|
||||
|
||||
#define GL_REDUCE_DST_COLOR_SCE 0x6021
|
||||
|
||||
#define GL_MULTISAMPLING_NONE_SCE 0x6030
|
||||
|
||||
#define GL_TEXTURE_REFERENCE_BUFFER_SCE 0x6040
|
||||
#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 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 glTextureReferenceSCE( GLenum target, GLuint levels, GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
429
console/rgl/ps3/private.h
Normal file
429
console/rgl/ps3/private.h
Normal file
@ -0,0 +1,429 @@
|
||||
#ifndef _RGL_PRIVATE_H
|
||||
#define _RGL_PRIVATE_H
|
||||
|
||||
#include "rgl.h"
|
||||
|
||||
#ifndef OS_VERSION_NUMERIC
|
||||
#define OS_VERSION_NUMERIC 0x160
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define _RGL_EXTERN_C extern "C"
|
||||
#else
|
||||
#define _RGL_EXTERN_C
|
||||
#endif
|
||||
|
||||
extern PSGLcontext *_CurrentContext;
|
||||
extern PSGLdevice *_CurrentDevice;
|
||||
|
||||
#define GL_UNSIGNED_BYTE_4_4 0x4A00
|
||||
#define GL_UNSIGNED_BYTE_4_4_REV 0x4A01
|
||||
#define GL_UNSIGNED_BYTE_6_2 0x4A02
|
||||
#define GL_UNSIGNED_BYTE_2_6_REV 0x4A03
|
||||
#define GL_UNSIGNED_SHORT_12_4 0x4A04
|
||||
#define GL_UNSIGNED_SHORT_4_12_REV 0x4A05
|
||||
#define GL_UNSIGNED_BYTE_2_2_2_2 0x4A06
|
||||
#define GL_UNSIGNED_BYTE_2_2_2_2_REV 0x4A07
|
||||
|
||||
#define GL_FLOAT_RGBA32 0x888B
|
||||
|
||||
#define RGL_SETRENDERTARGET_MAXCOUNT 4
|
||||
|
||||
#define RGL_NOP (0x00000000)
|
||||
#define DEFAULT_FIFO_BLOCK_SIZE (0x10000)
|
||||
|
||||
#define RGL_ATTRIB_COUNT 16
|
||||
|
||||
#define RGL_F0_DOT_0 12582912.0f
|
||||
|
||||
#define RGL_CLAMPF_01(x) ((x) >= 0.0f ? ((x) > 1.0f ? 1.0f : (x)) : 0.0f)
|
||||
|
||||
#define ENDIAN_32(X, F) ((F) ? endianSwapWord(X) : (X))
|
||||
|
||||
#define VERTEX_PROFILE_INDEX 0
|
||||
#define FRAGMENT_PROFILE_INDEX 1
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
unsigned int i;
|
||||
float f;
|
||||
} jsIntAndFloat;
|
||||
|
||||
static const jsIntAndFloat _RGLNan = {i: 0x7fc00000U};
|
||||
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;
|
||||
};
|
||||
|
||||
struct jsPlatformFramebuffer: public jsFramebuffer
|
||||
{
|
||||
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;
|
||||
}
|
||||
RGLDriver;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLuint SET_TEXTURE_CONTROL3;
|
||||
GLuint SET_TEXTURE_OFFSET;
|
||||
GLuint SET_TEXTURE_FORMAT;
|
||||
GLuint SET_TEXTURE_ADDRESS;
|
||||
GLuint SET_TEXTURE_CONTROL0;
|
||||
GLuint SET_TEXTURE_CONTROL1;
|
||||
GLuint SET_TEXTURE_FILTER;
|
||||
GLuint SET_TEXTURE_IMAGE_RECT;
|
||||
}
|
||||
RGLTextureMethods;
|
||||
|
||||
struct RGLTextureAddress
|
||||
{
|
||||
GLuint gamma;
|
||||
};
|
||||
|
||||
struct RGLTextureFilter
|
||||
{
|
||||
GLuint min;
|
||||
GLuint mag;
|
||||
GLint bias;
|
||||
};
|
||||
|
||||
struct RGLTextureMethodParams
|
||||
{
|
||||
RGLTextureAddress address;
|
||||
RGLTextureFilter filter;
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLuint baseWidth;
|
||||
GLuint baseHeight;
|
||||
RGLEnum internalFormat;
|
||||
GLuint pixelBits;
|
||||
GLuint pitch;
|
||||
} RGLTextureLayout;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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;
|
||||
}
|
||||
MODESTRUC;
|
||||
|
||||
enum {
|
||||
_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,
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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;
|
||||
|
||||
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;
|
||||
} RGLShader;
|
||||
|
||||
|
||||
void _RGLFifoFinish( RGLFifo *fifo );
|
||||
|
||||
#define _RGLFifoFlush(fifo) \
|
||||
{ \
|
||||
uint32_t offsetInBytes = 0; \
|
||||
cellGcmAddressToOffset( fifo->current, &offsetInBytes ); \
|
||||
cellGcmFlush( &_RGLState.fifo); \
|
||||
fifo->dmaControl->Put = offsetInBytes; \
|
||||
fifo->lastPutWritten = fifo->current; \
|
||||
fifo->lastSWReferenceFlushed = fifo->lastSWReferenceWritten; \
|
||||
}
|
||||
|
||||
#define RGL_PAGE_SIZE 0x1000
|
||||
#define RGL_LM_MAX_TOTAL_QUERIES 800
|
||||
|
||||
|
||||
|
||||
typedef struct RGLTextureState RGLTextureState;
|
||||
struct RGLTextureState
|
||||
{
|
||||
GLuint hwTexAddress;
|
||||
GLuint hwTexFilter;
|
||||
GLuint hwTexControl0;
|
||||
};
|
||||
|
||||
void _RGLDestroy( void );
|
||||
|
||||
typedef void( * RGLcontextHookFunction )( PSGLcontext *context );
|
||||
extern RGLcontextHookFunction _RGLContextCreateHook;
|
||||
extern RGLcontextHookFunction _RGLContextDestroyHook;
|
||||
|
||||
extern PSGLcontext* _RGLContextCreate (void);
|
||||
extern void _RGLContextFree( PSGLcontext* LContext );
|
||||
extern void _RGLSetError( GLenum error );
|
||||
void _RGLAttachContext( PSGLdevice *device, PSGLcontext* context );
|
||||
|
||||
extern jsTexture *_RGLGetCurrentTexture( const jsTextureImageUnit *unit, GLenum target );
|
||||
|
||||
void _RGLVertexAttribPointerNV( GLuint index, GLint fsize, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer );
|
||||
void _RGLEnableVertexAttribArrayNV( GLuint index );
|
||||
void _RGLDisableVertexAttribArrayNV( GLuint index );
|
||||
|
||||
void _RGLFifoGlSetRenderTarget( RGLRenderTargetEx const * const args );
|
||||
|
||||
extern void _RGLDeviceInit( PSGLinitOptions* options );
|
||||
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;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
static inline GLuint _RGLMapMinTextureFilter( GLenum filter )
|
||||
{
|
||||
switch ( filter )
|
||||
{
|
||||
case GL_NEAREST:
|
||||
return CELL_GCM_TEXTURE_NEAREST;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
return CELL_GCM_TEXTURE_LINEAR;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
return CELL_GCM_TEXTURE_NEAREST_NEAREST;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_LINEAR:
|
||||
return CELL_GCM_TEXTURE_NEAREST_LINEAR;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
return CELL_GCM_TEXTURE_LINEAR_NEAREST;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
return CELL_GCM_TEXTURE_LINEAR_LINEAR;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
static inline GLuint _RGLMapMagTextureFilter( GLenum filter )
|
||||
{
|
||||
switch ( filter )
|
||||
{
|
||||
case GL_NEAREST:
|
||||
return CELL_GCM_TEXTURE_NEAREST;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
return CELL_GCM_TEXTURE_LINEAR;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
static inline void _RGLMapTextureFormat( GLuint internalFormat, uint8_t & gcmFormat, uint32_t & remap )
|
||||
{
|
||||
gcmFormat = 0;
|
||||
|
||||
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 );
|
||||
|
||||
}
|
||||
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 );
|
||||
|
||||
}
|
||||
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 );
|
||||
|
||||
}
|
||||
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:
|
||||
break;
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
72
console/rgl/ps3/readelf.h
Normal file
72
console/rgl/ps3/readelf.h
Normal file
@ -0,0 +1,72 @@
|
||||
#ifndef READELF_H
|
||||
#define READELF_H
|
||||
|
||||
#include "elf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _ELF_section_t
|
||||
{
|
||||
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;
|
||||
} ELF_segment_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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;
|
||||
} ELF_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // READELF_H
|
8808
console/rgl/ps3/rgl.cpp
Normal file
8808
console/rgl/ps3/rgl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1179
console/rgl/ps3/rgl.h
Normal file
1179
console/rgl/ps3/rgl.h
Normal file
File diff suppressed because it is too large
Load Diff
1739
console/rgl/ps3/vector
Normal file
1739
console/rgl/ps3/vector
Normal file
File diff suppressed because it is too large
Load Diff
@ -1201,15 +1201,6 @@ void ps3graphics_set_overscan(bool overscan_enable, float amount, bool recalcula
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* PS3 needs a working graphics stack before RetroArch even starts.
|
||||
|
||||
To deal with this main.c, the top level module owns the instance,
|
||||
and is created beforehand. When RetroArch gets around to init it, it
|
||||
is already allocated.
|
||||
|
||||
When RetroArch wants to free it, it is ignored. */
|
||||
|
||||
void ps3graphics_video_init(bool get_all_resolutions)
|
||||
{
|
||||
video_info_t video_info = {0};
|
||||
|
Loading…
x
Reference in New Issue
Block a user