(RGL PS3) Slim down headers
This commit is contained in:
parent
7b9b87c284
commit
ab0d1a2e65
|
@ -1,17 +1,6 @@
|
||||||
#ifndef _CGC_CGBIO_CGBDEFS_HPP
|
#ifndef _CGC_CGBIO_CGBDEFS_HPP
|
||||||
#define _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
|
// ELF Header Constants
|
||||||
|
|
||||||
|
@ -248,21 +237,24 @@ typedef short Elf64_Shalf;
|
||||||
#define R_RSX_FLOAT4 1
|
#define R_RSX_FLOAT4 1
|
||||||
|
|
||||||
/* Note header in a PT_NOTE section */
|
/* Note header in a PT_NOTE section */
|
||||||
struct Elf32_Note {
|
struct Elf32_Note
|
||||||
Elf32_Word n_namesz; /* Name size */
|
{
|
||||||
Elf32_Word n_descsz; /* Content size */
|
unsigned int n_namesz; /* Name size */
|
||||||
Elf32_Word n_type; /* Content type */
|
unsigned int n_descsz; /* Content size */
|
||||||
|
unsigned int n_type; /* Content type */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Relocation entries
|
// Relocation entries
|
||||||
|
|
||||||
// Dynamic structure
|
// Dynamic structure
|
||||||
struct Elf32_Dyn {
|
struct Elf32_Dyn
|
||||||
Elf32_Sword d_tag;
|
{
|
||||||
union {
|
signed int d_tag;
|
||||||
Elf32_Word d_val;
|
union
|
||||||
Elf32_Addr d_ptr;
|
{
|
||||||
|
unsigned int d_val;
|
||||||
|
unsigned int d_ptr;
|
||||||
} d_un;
|
} d_un;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -5,18 +5,19 @@
|
||||||
* format.
|
* format.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(CGC_CGBIO_CGBIO_HPP)
|
#ifndef CGC_CGBIO_CGBIO_HPP
|
||||||
#define CGC_CGBIO_CGBIO_HPP 1
|
#define CGC_CGBIO_CGBIO_HPP
|
||||||
|
|
||||||
#include "cgbdefs.hpp"
|
#include "cgbdefs.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace cgc
|
||||||
namespace cgc {
|
{
|
||||||
namespace bio {
|
namespace bio
|
||||||
|
{
|
||||||
enum CGBIO_ERROR {
|
enum CGBIO_ERROR
|
||||||
|
{
|
||||||
CGBIO_ERROR_NO_ERROR,
|
CGBIO_ERROR_NO_ERROR,
|
||||||
CGBIO_ERROR_LOADED,
|
CGBIO_ERROR_LOADED,
|
||||||
CGBIO_ERROR_FILEIO,
|
CGBIO_ERROR_FILEIO,
|
||||||
|
@ -26,16 +27,17 @@ enum CGBIO_ERROR {
|
||||||
CGBIO_ERROR_RELOC,
|
CGBIO_ERROR_RELOC,
|
||||||
CGBIO_ERROR_SYMBOL,
|
CGBIO_ERROR_SYMBOL,
|
||||||
CGBIO_ERROR_UNKNOWN_TYPE
|
CGBIO_ERROR_UNKNOWN_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
} // bio namespace
|
} // bio namespace
|
||||||
} // cgc namespace
|
} // cgc namespace
|
||||||
|
|
||||||
#include "nvbi.hpp"
|
#include "nvbi.hpp"
|
||||||
|
|
||||||
namespace cgc {
|
namespace cgc
|
||||||
namespace bio {
|
{
|
||||||
|
namespace bio
|
||||||
|
{
|
||||||
class bin_io
|
class bin_io
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -51,9 +53,9 @@ namespace bio {
|
||||||
bin_io( const bin_io& );
|
bin_io( const bin_io& );
|
||||||
|
|
||||||
static bin_io* instance_;
|
static bin_io* instance_;
|
||||||
}; // bin_io
|
}; // bin_io
|
||||||
|
|
||||||
} // bio namespace
|
} // bio namespace
|
||||||
} // cgc namespace
|
} // cgc namespace
|
||||||
|
|
||||||
#endif // CGC_CGBIO_CGBIO_HPP
|
#endif // CGC_CGBIO_CGBIO_HPP
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
#define CGBTYPES_HEADER
|
#define CGBTYPES_HEADER
|
||||||
|
|
||||||
// parameter structure
|
// parameter structure
|
||||||
typedef struct _Elf32_cgParameter {
|
typedef struct _Elf32_cgParameter
|
||||||
|
{
|
||||||
uint32_t cgp_name; // index of name in strtab
|
uint32_t cgp_name; // index of name in strtab
|
||||||
uint32_t cgp_semantic; // index of semantic string 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_default; // index of default data in const //Reduced to half
|
||||||
|
|
|
@ -1,48 +1,46 @@
|
||||||
#if !defined(CGC_CGBIO_CGBUTILS_HPP)
|
#ifndef CGC_CGBIO_CGBUTILS_HPP
|
||||||
#define CGC_CGBIO_CGBUTILS_HPP 1
|
#define CGC_CGBIO_CGBUTILS_HPP
|
||||||
|
|
||||||
#include "cgbdefs.hpp"
|
#include "cgbdefs.hpp"
|
||||||
|
|
||||||
namespace cgc {
|
#define ELF32_ST_BIND(idx) ( idx >> 4 )
|
||||||
namespace bio {
|
#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 {
|
namespace cgc
|
||||||
|
{
|
||||||
|
namespace bio
|
||||||
|
{
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
CGBIODATANONE = ELFDATANONE,
|
CGBIODATANONE = ELFDATANONE,
|
||||||
CGBIODATALSB = ELFDATA2LSB,
|
CGBIODATALSB = ELFDATA2LSB,
|
||||||
CGBIODATAMSB = ELFDATA2MSB
|
CGBIODATAMSB = ELFDATA2MSB
|
||||||
} HOST_ENDIANNESS; // endianness
|
} HOST_ENDIANNESS; // endianness
|
||||||
|
|
||||||
inline HOST_ENDIANNESS
|
inline HOST_ENDIANNESS host_endianness(void)
|
||||||
host_endianness()
|
{
|
||||||
{
|
|
||||||
const int ii = 1;
|
const int ii = 1;
|
||||||
const char* cp = (const char*) ⅈ
|
const char* cp = (const char*) ⅈ
|
||||||
return ( 1 == cp[0] ) ? CGBIODATALSB : CGBIODATAMSB;
|
return ( cp[0] == 1 ) ? CGBIODATALSB : CGBIODATAMSB;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T > inline T
|
template< typename T > inline T convert_endianness( const T value, unsigned char endianness )
|
||||||
convert_endianness( const T value, unsigned char endianness )
|
{
|
||||||
{
|
|
||||||
if ( host_endianness() == endianness )
|
if ( host_endianness() == endianness )
|
||||||
{
|
|
||||||
return value;
|
return value;
|
||||||
}
|
|
||||||
if ( sizeof( T ) == 1 )
|
if ( sizeof( T ) == 1 )
|
||||||
{
|
|
||||||
return value;
|
return value;
|
||||||
}
|
|
||||||
if ( sizeof( T ) == 2 )
|
if ( sizeof( T ) == 2 )
|
||||||
{
|
return ( ((value & 0x00FF) << 8) | ((value & 0xFF00) >> 8) );
|
||||||
return ( ((value & 0x00FF) << 8)
|
|
||||||
| ((value & 0xFF00) >> 8) );
|
|
||||||
}
|
|
||||||
if ( sizeof( T ) == 4 )
|
if ( sizeof( T ) == 4 )
|
||||||
{
|
return ( ((value & 0x000000FF) << 24) | ((value & 0x0000FF00) << 8)
|
||||||
return ( ((value & 0x000000FF) << 24)
|
| ((value & 0x00FF0000) >> 8) | ((value & 0xFF000000) >> 24) );
|
||||||
| ((value & 0x0000FF00) << 8)
|
|
||||||
| ((value & 0x00FF0000) >> 8)
|
|
||||||
| ((value & 0xFF000000) >> 24) );
|
|
||||||
}
|
|
||||||
if ( sizeof( T ) == 8 )
|
if ( sizeof( T ) == 8 )
|
||||||
{
|
{
|
||||||
T result = value;
|
T result = value;
|
||||||
|
@ -54,49 +52,11 @@ convert_endianness( const T value, unsigned char endianness )
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// exception
|
// exception
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
} // bio namespace
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
|
|
||||||
#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
|
|
||||||
} // cgc namespace
|
} // cgc namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
#ifndef CGNV2ELF_VERSION
|
|
||||||
#define CGNV2ELF_VERSION 6365
|
|
||||||
#define CGNV2ELF_PRODUCT_STRING "SCE cgnv2elf"
|
|
||||||
#define CGNV2ELF_VERSION_NOTE_TYPE 0
|
|
||||||
#endif
|
|
|
@ -7,8 +7,6 @@
|
||||||
#define CNV2END(val) convert_endianness((val), elfEndianness)
|
#define CNV2END(val) convert_endianness((val), elfEndianness)
|
||||||
#define ENDSWAP(val) convert_endianness((val), (host_endianness() == 1) ? 2 : 1)
|
#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<char> &stringTable, std::vector<float> &defaultValues);
|
|
||||||
int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize,
|
int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize,
|
||||||
std::vector<char> &stringTable, std::vector<float> &defaultValues);
|
std::vector<char> &stringTable, std::vector<float> &defaultValues);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#if !defined(CGC_CGBIO_NVBI_HPP)
|
#ifndef CGC_CGBIO_NVBI_HPP
|
||||||
#define CGC_CGBIO_NVBI_HPP 1
|
#define CGC_CGBIO_NVBI_HPP
|
||||||
|
|
||||||
#include "cgbdefs.hpp"
|
#include "cgbdefs.hpp"
|
||||||
|
|
||||||
|
@ -11,11 +11,12 @@
|
||||||
#include <Cg/cg.h>
|
#include <Cg/cg.h>
|
||||||
#include <Cg/cgBinary.h>
|
#include <Cg/cgBinary.h>
|
||||||
|
|
||||||
|
namespace cgc
|
||||||
namespace cgc {
|
{
|
||||||
namespace bio {
|
namespace bio
|
||||||
|
{
|
||||||
class nvb_reader {
|
class nvb_reader
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~nvb_reader() {}
|
virtual ~nvb_reader() {}
|
||||||
|
|
||||||
|
@ -25,14 +26,6 @@ class nvb_reader {
|
||||||
virtual ptrdiff_t
|
virtual ptrdiff_t
|
||||||
release() const = 0;
|
release() const = 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 CGBIO_ERROR
|
virtual CGBIO_ERROR
|
||||||
loadFromString( const char* source, size_t length ) = 0;
|
loadFromString( const char* source, size_t length ) = 0;
|
||||||
|
|
||||||
|
@ -83,10 +76,8 @@ class nvb_reader {
|
||||||
|
|
||||||
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
|
}; // nvb_reader
|
||||||
|
} // bio namespace
|
||||||
|
|
||||||
} // bio namespace
|
|
||||||
} // cgc namespace
|
} // cgc namespace
|
||||||
|
|
||||||
#endif // CGC_CGBIO_NVBI_HPP
|
#endif // CGC_CGBIO_NVBI_HPP
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#if !defined(CGC_CGBIO_NVBIIMPL_HPP)
|
#ifndef CGC_CGBIO_NVBIIMPL_HPP
|
||||||
#define CGC_CGBIO_NVBIIMPL_HPP 1
|
#define CGC_CGBIO_NVBIIMPL_HPP
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
@ -11,11 +10,12 @@
|
||||||
|
|
||||||
#include "cgbio.hpp"
|
#include "cgbio.hpp"
|
||||||
|
|
||||||
namespace cgc {
|
namespace cgc
|
||||||
namespace bio {
|
|
||||||
|
|
||||||
class nvb_reader_impl : public nvb_reader
|
|
||||||
{
|
{
|
||||||
|
namespace bio
|
||||||
|
{
|
||||||
|
class nvb_reader_impl : public nvb_reader
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
nvb_reader_impl();
|
nvb_reader_impl();
|
||||||
|
|
||||||
|
@ -28,14 +28,6 @@ class nvb_reader_impl : public nvb_reader
|
||||||
virtual ptrdiff_t
|
virtual ptrdiff_t
|
||||||
release() const;
|
release() const;
|
||||||
|
|
||||||
#ifndef __CELLOS_LV2__
|
|
||||||
virtual CGBIO_ERROR
|
|
||||||
load( std::istream* stream, int start ,bool owner = false);
|
|
||||||
|
|
||||||
virtual CGBIO_ERROR
|
|
||||||
load( const char* filename );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual CGBIO_ERROR
|
virtual CGBIO_ERROR
|
||||||
loadFromString( const char* source, size_t length);
|
loadFromString( const char* source, size_t length);
|
||||||
|
|
||||||
|
@ -95,9 +87,9 @@ class nvb_reader_impl : public nvb_reader
|
||||||
CgBinaryProgram header_;
|
CgBinaryProgram header_;
|
||||||
unsigned char endianness_;
|
unsigned char endianness_;
|
||||||
char* image_;
|
char* image_;
|
||||||
}; // nvb_reader_impl
|
}; // nvb_reader_impl
|
||||||
|
|
||||||
} // bio namespace
|
} // bio namespace
|
||||||
} // cgc namespace
|
} // cgc namespace
|
||||||
|
|
||||||
#endif // CGC_CGBIO_NVBIIMPL_HPP
|
#endif // CGC_CGBIO_NVBIIMPL_HPP
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
#ifndef ELF_H
|
#ifndef ELF_H
|
||||||
#define ELF_H
|
#define ELF_H
|
||||||
|
|
||||||
/*
|
|
||||||
* Data Representation
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ELF header
|
* ELF header
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
|
|
||||||
#include "cg/cgbtypes.h"
|
#include "cg/cgbtypes.h"
|
||||||
#include "cg/cgnv2rt.h"
|
#include "cg/cgnv2rt.h"
|
||||||
#include "cg/cgnv2elfversion.h"
|
|
||||||
|
|
||||||
#include "cg/cgbio.hpp"
|
#include "cg/cgbio.hpp"
|
||||||
#include "cg/nvbiimpl.hpp"
|
#include "cg/nvbiimpl.hpp"
|
||||||
|
|
Loading…
Reference in New Issue