diff --git a/ps3/rgl/src/cg/cgbdefs.hpp b/ps3/rgl/src/cg/cgbdefs.hpp index 04f52045d0..7fb27a4021 100644 --- a/ps3/rgl/src/cg/cgbdefs.hpp +++ b/ps3/rgl/src/cg/cgbdefs.hpp @@ -1,17 +1,6 @@ #ifndef _CGC_CGBIO_CGBDEFS_HPP #define _CGC_CGBIO_CGBDEFS_HPP -// Platform depended definitions: -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 unsigned short Elf64_Half; -typedef short Elf64_Shalf; - /////////////////////// // ELF Header Constants @@ -248,21 +237,24 @@ typedef short Elf64_Shalf; #define R_RSX_FLOAT4 1 /* Note header in a PT_NOTE section */ -struct Elf32_Note { - Elf32_Word n_namesz; /* Name size */ - Elf32_Word n_descsz; /* Content size */ - Elf32_Word n_type; /* Content type */ +struct Elf32_Note +{ + unsigned int n_namesz; /* Name size */ + unsigned int n_descsz; /* Content size */ + unsigned int n_type; /* Content type */ }; // Relocation entries // Dynamic structure -struct Elf32_Dyn { - Elf32_Sword d_tag; - union { - Elf32_Word d_val; - Elf32_Addr d_ptr; +struct Elf32_Dyn +{ + signed int d_tag; + union + { + unsigned int d_val; + unsigned int d_ptr; } d_un; }; diff --git a/ps3/rgl/src/cg/cgbio.def b/ps3/rgl/src/cg/cgbio.def deleted file mode 100644 index 36ebe48c1f..0000000000 --- a/ps3/rgl/src/cg/cgbio.def +++ /dev/null @@ -1,9 +0,0 @@ -LIBRARY cgbu -EXPORTS -;?CreateCGBI@CGBIO@@QBE?AW4CGBIO_Err@@PAPAVCGBI@@@Z -;?instance@CGBIO@@SAPBV1@XZ -;?get_revision@CGBIImpl@@UBEHXZ -get_revision -instance -CreateCGBI - diff --git a/ps3/rgl/src/cg/cgbio.hpp b/ps3/rgl/src/cg/cgbio.hpp index 957c7998bb..701b9c981e 100644 --- a/ps3/rgl/src/cg/cgbio.hpp +++ b/ps3/rgl/src/cg/cgbio.hpp @@ -5,55 +5,57 @@ * format. */ -#if !defined(CGC_CGBIO_CGBIO_HPP) -#define CGC_CGBIO_CGBIO_HPP 1 +#ifndef CGC_CGBIO_CGBIO_HPP +#define CGC_CGBIO_CGBIO_HPP #include "cgbdefs.hpp" #include +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 + }; -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 -}; - -} // bio namespace + } // bio namespace } // cgc namespace #include "nvbi.hpp" -namespace cgc { -namespace bio { +namespace cgc +{ + namespace bio + { + class bin_io + { + public: + static const bin_io* instance(); + static void delete_instance(); - class bin_io - { - public: - static const bin_io* instance(); - static void delete_instance(); + CGBIO_ERROR new_nvb_reader( nvb_reader** obj ) const; - CGBIO_ERROR new_nvb_reader( nvb_reader** obj ) const; + const char *error_string( CGBIO_ERROR error ) const; - const char *error_string( CGBIO_ERROR error ) const; + private: + bin_io(); + bin_io( const bin_io& ); - private: - bin_io(); - bin_io( const bin_io& ); + static bin_io* instance_; + }; // bin_io - static bin_io* instance_; -}; // bin_io - -} // bio namespace + } // bio namespace } // cgc namespace #endif // CGC_CGBIO_CGBIO_HPP diff --git a/ps3/rgl/src/cg/cgbtypes.h b/ps3/rgl/src/cg/cgbtypes.h index aa483a3c0a..2394447bae 100644 --- a/ps3/rgl/src/cg/cgbtypes.h +++ b/ps3/rgl/src/cg/cgbtypes.h @@ -2,20 +2,21 @@ #define CGBTYPES_HEADER // parameter structure -typedef struct _Elf32_cgParameter { - uint32_t cgp_name; // index of name in strtab - uint32_t cgp_semantic; // index of semantic string in strtab - uint16_t cgp_default; // index of default data in const //Reduced to half - uint16_t cgp_reloc; // index of reloc indices in rel - uint16_t cgp_resource; // index of hardware resource assigned - uint16_t cgp_resource_index; // index of hardware resource assigned - unsigned char cgp_type; - uint16_t cgp_info; - unsigned char unused; +typedef struct _Elf32_cgParameter +{ + uint32_t cgp_name; // index of name in strtab + uint32_t cgp_semantic; // index of semantic string in strtab + uint16_t cgp_default; // index of default data in const //Reduced to half + uint16_t cgp_reloc; // index of reloc indices in rel + uint16_t cgp_resource; // index of hardware resource assigned + uint16_t cgp_resource_index; // index of hardware resource assigned + unsigned char cgp_type; + uint16_t cgp_info; + unsigned char unused; } Elf32_cgParameter; //20 bytes #define CGF_OUTPUTFROMH0 0x01 #define CGF_DEPTHREPLACE 0x02 -#define CGF_PIXELKILL 0x04 +#define CGF_PIXELKILL 0x04 #endif diff --git a/ps3/rgl/src/cg/cgbutils.hpp b/ps3/rgl/src/cg/cgbutils.hpp index 03c507ccb6..f7b2c71023 100644 --- a/ps3/rgl/src/cg/cgbutils.hpp +++ b/ps3/rgl/src/cg/cgbutils.hpp @@ -1,102 +1,62 @@ -#if !defined(CGC_CGBIO_CGBUTILS_HPP) -#define CGC_CGBIO_CGBUTILS_HPP 1 +#ifndef CGC_CGBIO_CGBUTILS_HPP +#define CGC_CGBIO_CGBUTILS_HPP #include "cgbdefs.hpp" -namespace cgc { -namespace bio { +#define ELF32_ST_BIND(idx) ( idx >> 4 ) +#define ELF32_ST_TYPE(idx) ( idx & 0xf ) +#define ELF32_ST_INFO(b, t) (( b << 4 ) + ( t & 0xf )) +#define ELF32_ST_VISIBILITY(o) ( o & 0x3 ) -typedef enum { - CGBIODATANONE = ELFDATANONE, - CGBIODATALSB = ELFDATA2LSB, - CGBIODATAMSB = ELFDATA2MSB -} HOST_ENDIANNESS; // endianness - -inline HOST_ENDIANNESS -host_endianness() +namespace cgc { - const int ii = 1; - const char* cp = (const char*) ⅈ - return ( 1 == cp[0] ) ? CGBIODATALSB : CGBIODATAMSB; -} + namespace bio + { + typedef enum + { + CGBIODATANONE = ELFDATANONE, + CGBIODATALSB = ELFDATA2LSB, + CGBIODATAMSB = ELFDATA2MSB + } HOST_ENDIANNESS; // endianness -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; - } - // exception - return value; -} + inline HOST_ENDIANNESS host_endianness(void) + { + const int ii = 1; + const char* cp = (const char*) ⅈ + return ( cp[0] == 1 ) ? CGBIODATALSB : CGBIODATAMSB; + } -template< typename T > inline T -ELF32_ST_BIND( const T idx ) -{ - return ( idx >> 4 ); -} + template< typename T > inline T convert_endianness( const T value, unsigned char endianness ) + { + if ( host_endianness() == endianness ) + return value; -template< typename T > inline T -ELF32_ST_TYPE( const T idx ) -{ - return ( idx & 0xf ); -} + if ( sizeof( T ) == 1 ) + return value; -template< typename T > inline T -ELF32_ST_INFO( const T b, const T t ) -{ - return ( ( b << 4 ) + ( t & 0xf ) ); -} + if ( sizeof( T ) == 2 ) + return ( ((value & 0x00FF) << 8) | ((value & 0xFF00) >> 8) ); -template< typename T > inline T -ELF32_ST_VISIBILITY( const T o ) -{ - return ( o & 0x3 ); -} + if ( sizeof( T ) == 4 ) + return ( ((value & 0x000000FF) << 24) | ((value & 0x0000FF00) << 8) + | ((value & 0x00FF0000) >> 8) | ((value & 0xFF000000) >> 24) ); -// these are not used in our relocations, will be replaced by the ones -// we design, will be defined as templates. -#ifndef ELF32_R_SYM -#define ELF32_R_SYM(i) ((i)>>8) -#endif + 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; + } -#ifndef ELF32_R_TYPE -#define ELF32_R_TYPE(i) ((unsigned char)(i)) -#endif - -#ifndef ELF32_R_INFO -#define ELF32_R_INFO(s,t) (((s)<<8 )+(unsigned char)(t)) -#endif - -} // bio namespace + // exception + return value; + } + } // bio namespace } // cgc namespace diff --git a/ps3/rgl/src/cg/cgnv2elfversion.h b/ps3/rgl/src/cg/cgnv2elfversion.h deleted file mode 100644 index 47d162b4a2..0000000000 --- a/ps3/rgl/src/cg/cgnv2elfversion.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef CGNV2ELF_VERSION -#define CGNV2ELF_VERSION 6365 -#define CGNV2ELF_PRODUCT_STRING "SCE cgnv2elf" -#define CGNV2ELF_VERSION_NOTE_TYPE 0 -#endif diff --git a/ps3/rgl/src/cg/cgnv2rt.h b/ps3/rgl/src/cg/cgnv2rt.h index 683d7ef3c4..0b513926c8 100644 --- a/ps3/rgl/src/cg/cgnv2rt.h +++ b/ps3/rgl/src/cg/cgnv2rt.h @@ -7,8 +7,6 @@ #define CNV2END(val) convert_endianness((val), elfEndianness) #define ENDSWAP(val) convert_endianness((val), (host_endianness() == 1) ? 2 : 1) -int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTableOffset, void **binaryShader, int *size, - std::vector &stringTable, std::vector &defaultValues); int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize, std::vector &stringTable, std::vector &defaultValues); diff --git a/ps3/rgl/src/cg/nvbi.hpp b/ps3/rgl/src/cg/nvbi.hpp index 8fe4fd769d..26a3cd2d64 100644 --- a/ps3/rgl/src/cg/nvbi.hpp +++ b/ps3/rgl/src/cg/nvbi.hpp @@ -1,5 +1,5 @@ -#if !defined(CGC_CGBIO_NVBI_HPP) -#define CGC_CGBIO_NVBI_HPP 1 +#ifndef CGC_CGBIO_NVBI_HPP +#define CGC_CGBIO_NVBI_HPP #include "cgbdefs.hpp" @@ -11,82 +11,73 @@ #include #include +namespace cgc +{ + namespace bio + { + class nvb_reader + { + public: + virtual ~nvb_reader() {} -namespace cgc { -namespace bio { + virtual ptrdiff_t + reference() const = 0; -class nvb_reader { - public: - virtual ~nvb_reader() {} - - virtual ptrdiff_t - reference() const = 0; + virtual ptrdiff_t + release() const = 0; - virtual ptrdiff_t - release() const = 0; + virtual CGBIO_ERROR + loadFromString( const char* source, size_t length ) = 0; -#ifndef __CELLOS_LV2__ - virtual CGBIO_ERROR - load( std::istream* stream, int start, bool owner = false ) = 0; - - virtual CGBIO_ERROR - load( const char *filename ) = 0; -#endif + virtual bool + is_loaded() const = 0; - virtual CGBIO_ERROR - loadFromString( const char* source, size_t length ) = 0; + virtual unsigned char + endianness() const = 0; - virtual bool - is_loaded() const = 0; + virtual CGprofile + profile() const = 0; - virtual unsigned char - endianness() const = 0; + virtual unsigned int + revision() const = 0; - virtual CGprofile - profile() const = 0; + virtual unsigned int + size() const = 0; - virtual unsigned int - revision() const = 0; + virtual unsigned int + number_of_params() const = 0; - virtual unsigned int - size() const = 0; - - virtual unsigned int - number_of_params() const = 0; + virtual unsigned int + ucode_size() const = 0; - virtual unsigned int - ucode_size() const = 0; + virtual const char* + ucode() const = 0; - virtual const char* - ucode() const = 0; + virtual const CgBinaryFragmentProgram* + fragment_program() const = 0; - virtual const CgBinaryFragmentProgram* - fragment_program() const = 0; + virtual const CgBinaryVertexProgram* + vertex_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, + std::vector& default_value, + std::vector& embedded_constants, + const char** semantic, + CGenum& direction, + int& paramno, + bool& is_referenced, + bool& is_shared ) const = 0; - virtual CGBIO_ERROR - get_param( unsigned int index, - CGtype& type, - CGresource& resource, - CGenum& variability, - int& resource_index, - const char** name, - std::vector& default_value, - std::vector& embedded_constants, - const char** semantic, - CGenum& direction, - 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; - virtual CGBIO_ERROR get_param_name( unsigned int index, const char** name, bool& is_referenced) const = 0; - -}; // nvb_reader - - -} // bio namespace + }; // nvb_reader + } // bio namespace } // cgc namespace #endif // CGC_CGBIO_NVBI_HPP diff --git a/ps3/rgl/src/cg/nvbiimpl.hpp b/ps3/rgl/src/cg/nvbiimpl.hpp index e04d248734..9704e44efa 100644 --- a/ps3/rgl/src/cg/nvbiimpl.hpp +++ b/ps3/rgl/src/cg/nvbiimpl.hpp @@ -1,7 +1,6 @@ -#if !defined(CGC_CGBIO_NVBIIMPL_HPP) -#define CGC_CGBIO_NVBIIMPL_HPP 1 +#ifndef CGC_CGBIO_NVBIIMPL_HPP +#define CGC_CGBIO_NVBIIMPL_HPP -#include #include #include #include @@ -11,93 +10,86 @@ #include "cgbio.hpp" -namespace cgc { -namespace bio { - -class nvb_reader_impl : public nvb_reader +namespace cgc { - public: - nvb_reader_impl(); + namespace bio + { + class nvb_reader_impl : public nvb_reader + { + public: + nvb_reader_impl(); - virtual - ~nvb_reader_impl(); + virtual + ~nvb_reader_impl(); - virtual ptrdiff_t - reference() const; + virtual ptrdiff_t + reference() const; - virtual ptrdiff_t - release() const; + virtual ptrdiff_t + release() const; -#ifndef __CELLOS_LV2__ - virtual CGBIO_ERROR - load( std::istream* stream, int start ,bool owner = false); + virtual CGBIO_ERROR + loadFromString( const char* source, size_t length); - virtual CGBIO_ERROR - load( const char* filename ); -#endif - - virtual CGBIO_ERROR - loadFromString( const char* source, size_t length); - - virtual bool - is_loaded() const; + virtual bool + is_loaded() const; - virtual unsigned char - endianness() const; + virtual unsigned char + endianness() const; - virtual CGprofile - profile() const; + virtual CGprofile + profile() const; - virtual unsigned int - revision() const; + virtual unsigned int + revision() const; - virtual unsigned int - size() const; - - virtual unsigned int - number_of_params() const; + virtual unsigned int + size() const; - virtual unsigned int - ucode_size() const; + virtual unsigned int + number_of_params() const; - virtual const char* - ucode() const; + virtual unsigned int + ucode_size() const; - virtual const CgBinaryFragmentProgram* - fragment_program() const; + virtual const char* + ucode() const; - virtual const CgBinaryVertexProgram* - vertex_program() const; + virtual const CgBinaryFragmentProgram* + fragment_program() const; - virtual CGBIO_ERROR - get_param( unsigned int index, - CGtype& type, - CGresource& resource, - CGenum& variability, - int& resource_index, - const char ** name, - std::vector& default_value, - std::vector& embedded_constants, - const char ** semantic, - CGenum& direction, - int& paramno, - bool& is_referenced, - bool& is_shared ) const; + virtual const CgBinaryVertexProgram* + vertex_program() const; - virtual CGBIO_ERROR get_param_name( unsigned int index, const char ** name , bool& is_referenced) const; + virtual CGBIO_ERROR + get_param( unsigned int index, + CGtype& type, + CGresource& resource, + CGenum& variability, + int& resource_index, + const char ** name, + std::vector& default_value, + std::vector& embedded_constants, + const char ** semantic, + CGenum& direction, + int& paramno, + bool& is_referenced, + bool& is_shared ) const; - private: - mutable ptrdiff_t ref_count_; - int offset_; - bool loaded_; - bool owner_; - bool strStream_; - CgBinaryProgram header_; - unsigned char endianness_; - char* image_; -}; // nvb_reader_impl + virtual CGBIO_ERROR get_param_name( unsigned int index, const char ** name , bool& is_referenced) const; -} // bio namespace + private: + mutable ptrdiff_t ref_count_; + int offset_; + bool loaded_; + bool owner_; + bool strStream_; + CgBinaryProgram header_; + unsigned char endianness_; + char* image_; + }; // nvb_reader_impl + + } // bio namespace } // cgc namespace #endif // CGC_CGBIO_NVBIIMPL_HPP diff --git a/ps3/rgl/src/libelf/elf.h b/ps3/rgl/src/libelf/elf.h index 4a8af2e8ba..ffc93b1885 100644 --- a/ps3/rgl/src/libelf/elf.h +++ b/ps3/rgl/src/libelf/elf.h @@ -1,10 +1,6 @@ #ifndef ELF_H #define ELF_H -/* - * Data Representation - */ - /* * ELF header */ diff --git a/ps3/rgl/src/rgl_cg.h b/ps3/rgl/src/rgl_cg.h index 699a3dac3b..ab7140fb52 100644 --- a/ps3/rgl/src/rgl_cg.h +++ b/ps3/rgl/src/rgl_cg.h @@ -41,7 +41,6 @@ #include "cg/cgbtypes.h" #include "cg/cgnv2rt.h" -#include "cg/cgnv2elfversion.h" #include "cg/cgbio.hpp" #include "cg/nvbiimpl.hpp"