(RGL) Cleanups

This commit is contained in:
Twinaphex 2012-07-30 04:01:54 +02:00
parent d324683306
commit b03fa0c37b
10 changed files with 364 additions and 497 deletions

View File

@ -9,10 +9,6 @@
#include "rgl.h"
#include "private.h"
#ifndef STL_NAMESPACE
#define STL_NAMESPACE std::
#endif
#include <string.h>
#define RGL_BOOLEAN_REGISTERS_COUNT 32
@ -66,23 +62,23 @@ typedef struct CgBinaryProgram CgBinaryProgram;
typedef struct _CGnamedProgram
{
const char *name;
CGprogram program;
int refCount;
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;
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;
@ -99,90 +95,77 @@ 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;
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;
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[];
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;
unsigned short memberCount;
unsigned short reserved;
} CgParameterStructure;
typedef struct _CgParameterResource
{
unsigned short type;
unsigned short resource;
}
CgParameterResource;
unsigned short type;
unsigned short resource;
} CgParameterResource;
typedef struct _CgParameterSemantic
{
unsigned short entryIndex;
unsigned short reserved;
unsigned int semanticOffset;
}
CgParameterSemantic;
unsigned short entryIndex;
unsigned short reserved;
unsigned int semanticOffset;
} CgParameterSemantic;
typedef struct _CgParameterDefaultValue
{
unsigned short entryIndex;
unsigned short defaultValueIndex;
}
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;
};
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;
@ -192,79 +175,78 @@ typedef void( *_cgSetArrayIndexFunction )( struct CgRuntimeParameter* __restrict
typedef struct _CgUniform
{
void *pushBufferPtr;
void *pushBufferPtr;
} _CgUniform;
typedef struct _CGprogram _CGprogram;
typedef struct CgRuntimeParameter
{
_cgSetArrayIndexFunction samplerSetter;
_cgSetArrayIndexFunction samplerSetter;
_cgSetArrayIndexFunction setterIndex;
_cgSetArrayIndexFunction settercIndex;
_cgSetArrayIndexFunction setterrIndex;
_cgSetArrayIndexFunction setterIndex;
_cgSetArrayIndexFunction settercIndex;
_cgSetArrayIndexFunction setterrIndex;
void *pushBufferPointer;
const CgParameterEntry *parameterEntry;
_CGprogram *program;
int glType;
CGparameter id;
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;
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];
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;
@ -286,26 +268,20 @@ void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index
#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_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;
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 );
@ -314,33 +290,25 @@ unsigned int _RGLGetTypeColCount( CGtype parameterType );
inline static CgRuntimeParameter* _cgGetParamPtr( CGparameter p )
{
return ( CgRuntimeParameter* )_RGLGetNamedValue( &_CurrentContext->cgParameterNameSpace, ( jsName )((( unsigned int )p )&CG_PARAMETERMASK ) );
return ( CgRuntimeParameter* )_RGLGetNamedValue( &_CurrentContext->cgParameterNameSpace, ( jsName )((( unsigned int )p )&CG_PARAMETERMASK ) );
}
inline static _CGprogram* _cgGetProgPtr( CGprogram p )
{
return ( _CGprogram* )_RGLGetNamedValue( &_CurrentContext->cgProgramNameSpace, ( jsName )p );
return ( _CGprogram* )_RGLGetNamedValue( &_CurrentContext->cgProgramNameSpace, ( jsName )p );
}
inline static _CGcontext* _cgGetContextPtr( CGcontext c )
{
return ( _CGcontext* )_RGLGetNamedValue( &_CurrentContext->cgContextNameSpace, ( jsName )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;
int res = 1;
for ( int i = 0;i < count;i++ )
res *= ( int )( *( dimensions++ ) );
return res;
}
inline static CGresource _RGLGetBaseResource( CGresource resource )
@ -396,8 +364,6 @@ void _RGLPlatformProgramErase( void* platformProgram );
CGbool _RGLPlatformSupportsFragmentProgram( CGprofile p );
void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * __restrict v );
void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v );
void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * __restrict v );
@ -407,22 +373,21 @@ 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;
}
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 );
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 );
@ -451,44 +416,41 @@ extern cgRTCgcFreeHookFunction _cgRTCgcFreeCompiledProgramHook;
static inline const CgParameterResource *_RGLGetParameterResource( const _CGprogram *program, const CgParameterEntry *entry )
{
return ( CgParameterResource * )( program->parameterResources + entry->typeIndex );
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;
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 );
return ( CgParameterArray* )( program->parameterResources + entry->typeIndex );
}
static inline const CgParameterStructure *_RGLGetParameterStructure( const _CGprogram *program, const CgParameterEntry *entry )
{
return ( CgParameterStructure* )( program->parameterResources + entry->typeIndex );
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;
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

View File

@ -252,8 +252,8 @@ nvb_reader_impl::get_param( unsigned int index,
CGenum& variability,
int& resource_index,
const char ** name,
STL_NAMESPACE vector<float>& default_value,
STL_NAMESPACE vector<unsigned int>& embedded_constants,
std::vector<float>& default_value,
std::vector<unsigned int>& embedded_constants,
const char ** semantic,
int& paramno,
bool& is_referenced,

View File

@ -3,10 +3,6 @@
#include <vector>
#ifndef STL_NAMESPACE
#define STL_NAMESPACE ::std::
#endif
#define CGF_OUTPUTFROMH0 0x01
#define CGF_DEPTHREPLACE 0x02
#define CGF_PIXELKILL 0x04
@ -338,8 +334,8 @@ class nvb_reader
CGenum& variability,
int& resource_index,
const char** name,
STL_NAMESPACE vector<float>& default_value,
STL_NAMESPACE vector<unsigned int>& embedded_constants,
std::vector<float>& default_value,
std::vector<unsigned int>& embedded_constants,
const char** semantic,
int& paramno,
bool& is_referenced,
@ -405,7 +401,7 @@ class elf_reader_impl : public elf_reader
istream* stream_;
bool initialized_;
Elf32_Ehdr header_;
STL_NAMESPACE vector<const isection*> sections_;
std::vector<const isection*> sections_;
};
inline HOST_ENDIANNESS host_endianness()
@ -530,8 +526,8 @@ class nvb_reader_impl : public nvb_reader
CGenum& variability,
int& resource_index,
const char ** name,
STL_NAMESPACE vector<float>& default_value,
STL_NAMESPACE vector<unsigned int>& embedded_constants,
std::vector<float>& default_value,
std::vector<unsigned int>& embedded_constants,
const char ** semantic,
int& paramno,
bool& is_referenced,

View File

@ -65,7 +65,7 @@ public:
}
}
STL_NAMESPACE vector<CgStructuralElement> _elements;
std::vector<CgStructuralElement> _elements;
bool _insideArray;
bool _root;
};
@ -92,11 +92,11 @@ typedef float _float4[4];
typedef struct
{
STL_NAMESPACE vector<short> _resources;
STL_NAMESPACE vector<unsigned short> _defaultValuesIndices;
STL_NAMESPACE vector<unsigned short> _elfDefaultsIndices;
STL_NAMESPACE vector<short> _dimensions;
STL_NAMESPACE vector<CgParameterSemantic> _semanticIndices;
std::vector<short> _resources;
std::vector<unsigned short> _defaultValuesIndices;
std::vector<unsigned short> _elfDefaultsIndices;
std::vector<short> _dimensions;
std::vector<CgParameterSemantic> _semanticIndices;
} _CGNVCONTAINERS;
static bool bIsVertexProgram = true;
@ -104,23 +104,23 @@ static bool bIsVertexProgram = true;
static int getStride(CgBaseType *type);
static int getSizeofSubArray(_CGNVCONTAINERS &containers, int dimensionIndex, int dimensionCount, int endianness);
static unsigned int stringTableFind( STL_NAMESPACE vector<char> &stringTable, const char* str);
static unsigned int stringTableAdd( STL_NAMESPACE vector<char> &stringTable, const char* str );
static unsigned int stringTableAddUnique( STL_NAMESPACE vector<char> &stringTable, const char* str );
template<class Type> static size_t array_size(STL_NAMESPACE vector<Type> &array);
template<class Type> static void array_push(char* &parameterOffset, STL_NAMESPACE vector<Type> &array);
static unsigned int stringTableFind( std::vector<char> &stringTable, const char* str);
static unsigned int stringTableAdd( std::vector<char> &stringTable, const char* str );
static unsigned int stringTableAddUnique( std::vector<char> &stringTable, const char* str );
template<class Type> static size_t array_size(std::vector<Type> &array);
template<class Type> static void array_push(char* &parameterOffset, std::vector<Type> &array);
inline static unsigned int swap16(const unsigned int v);
static unsigned short getFlags(CGenum var, CGenum dir, int no, bool is_referenced, bool is_shared, int paramIndex);
static void fillStructureItems(_CGNVCONTAINERS &containers, CgStructureType *structure,
int endianness,
STL_NAMESPACE vector<CgParameterEntry> &parameterEntries,
STL_NAMESPACE vector<char> &parameterResources, STL_NAMESPACE vector<char> &stringTable, unsigned short *arrayResourceIndex = NULL,
std::vector<CgParameterEntry> &parameterEntries,
std::vector<char> &parameterResources, std::vector<char> &stringTable, unsigned short *arrayResourceIndex = NULL,
unsigned short *arrayDefaultValueIndex = NULL);
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)
std::vector<char> &stringTable, std::vector<float> &defaultValues)
{
_CGNVCONTAINERS containers;
@ -260,8 +260,8 @@ int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness
CGenum var;
int rin;
const char *name;
STL_NAMESPACE vector<float> dv;
STL_NAMESPACE vector<unsigned int> ec;
std::vector<float> dv;
std::vector<unsigned int> ec;
const char *sem;
CGenum dir;
int no;
@ -664,8 +664,8 @@ int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness
nvbr->release();
bin_io::delete_instance();
STL_NAMESPACE vector<CgParameterEntry> parameterEntries;
STL_NAMESPACE vector<char> parameterResources;
std::vector<CgParameterEntry> parameterEntries;
std::vector<char> parameterResources;
fillStructureItems(containers,&root,endianness,parameterEntries,parameterResources,stringTable);
CgParameterTableHeader header;
@ -728,7 +728,7 @@ int convertNvToElfFreeBinaryShader(void *binaryShader)
return 0;
}
static void pushbackUnsignedShort(STL_NAMESPACE vector<char> &parameterResources, unsigned short value)
static void pushbackUnsignedShort(std::vector<char> &parameterResources, unsigned short value)
{
size_t size = parameterResources.size();
parameterResources.resize(size + 2);
@ -736,8 +736,8 @@ static void pushbackUnsignedShort(STL_NAMESPACE vector<char> &parameterResources
}
static void fillStructureItems(_CGNVCONTAINERS &containers, CgStructureType *structure, int endianness,
STL_NAMESPACE vector<CgParameterEntry> &parameterEntries,STL_NAMESPACE vector<char> &parameterResources,
STL_NAMESPACE vector<char> &stringTable, unsigned short *arrayResourceIndex, unsigned short *arrayDefaultValueIndex)
std::vector<CgParameterEntry> &parameterEntries,std::vector<char> &parameterResources,
std::vector<char> &stringTable, unsigned short *arrayResourceIndex, unsigned short *arrayDefaultValueIndex)
{
unsigned char elfEndianness = endianness;
@ -1021,12 +1021,12 @@ static int getSizeofSubArray(_CGNVCONTAINERS &containers, int dimensionIndex, in
return res;
}
template<class Type> static size_t array_size(STL_NAMESPACE vector<Type> &array)
template<class Type> static size_t array_size(std::vector<Type> &array)
{
return (unsigned int)array.size()*sizeof(array[0]);
}
template<class Type> static void array_push(char* &parameterOffset, STL_NAMESPACE vector<Type> &array)
template<class Type> static void array_push(char* &parameterOffset, std::vector<Type> &array)
{
size_t dataSize = array.size()*sizeof(array[0]);
memcpy(parameterOffset,&array[0],dataSize);

View File

@ -5,10 +5,6 @@
#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"
@ -18,7 +14,7 @@
#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 )
static unsigned int stringTableAdd( std::vector<char> &stringTable, const char* str )
{
unsigned int ret = (unsigned int)stringTable.size();
@ -35,7 +31,7 @@ static unsigned int stringTableAdd( STL_NAMESPACE vector<char> &stringTable, con
return ret;
}
static unsigned int stringTableFind( STL_NAMESPACE vector<char> &stringTable, const char* str )
static unsigned int stringTableFind( std::vector<char> &stringTable, const char* str )
{
const char* data = &stringTable[0];
size_t size = stringTable.size();
@ -60,7 +56,7 @@ static unsigned int stringTableFind( STL_NAMESPACE vector<char> &stringTable, co
return 0;
}
static unsigned int stringTableAddUnique( STL_NAMESPACE vector<char> &stringTable, const char* str )
static unsigned int stringTableAddUnique( std::vector<char> &stringTable, const char* str )
{
if ( stringTable.size() == 0 )
stringTable.push_back('\0');
@ -73,8 +69,8 @@ static unsigned int stringTableAddUnique( STL_NAMESPACE vector<char> &stringTabl
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 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, std::vector<char> &stringTable, std::vector<float> &defaultValues);
int convertNvToElfFreeBinaryShader(void *binaryShader);

View File

@ -282,7 +282,6 @@ static GLboolean _RGLInitFromRM( RGLResource *rmResource )
cellGcmSetPointSpriteControlInline( &_RGLState.fifo, CELL_GCM_FALSE, 1, 0);
cellGcmSetFrequencyDividerOperationInline( &_RGLState.fifo, 0);
cellGcmSetDitherEnableInline( &_RGLState.fifo, CELL_GCM_TRUE);
cellGcmSetRestartIndexInline( &_RGLState.fifo, 0);
cellGcmSetShadeModeInline( &_RGLState.fifo, CELL_GCM_SMOOTH);
@ -892,6 +891,7 @@ static int _RGLPlatformCreateDevice( PSGLdevice* device )
cellGcmSetClearColorInline( &_RGLState.fifo, hwColor);
gcmDevice->rt.colorFormat = RGL_ARGB8;
for ( int i = 0; i < params->bufferingMode; ++i )
{
gcmDevice->rt.colorId[0] = gcmDevice->color[i].dataId;
@ -991,7 +991,8 @@ static int _RGLPlatformCreateDevice( PSGLdevice* device )
PSGLdevice* psglCreateDeviceExtended(const PSGLdeviceParameters *parameters )
{
PSGLdevice *device = ( PSGLdevice * )malloc( sizeof( PSGLdevice ) + sizeof(RGLDevice) );
PSGLdevice *device = (PSGLdevice *)malloc(sizeof(PSGLdevice) + sizeof(RGLDevice));
if ( !device )
{
_RGLSetError( GL_OUT_OF_MEMORY );
@ -1000,6 +1001,7 @@ PSGLdevice* psglCreateDeviceExtended(const PSGLdeviceParameters *parameters )
memset( device, 0, sizeof( PSGLdevice ) + sizeof(RGLDevice) );
PSGLdeviceParameters defaultParameters;
defaultParameters.enable = 0;
defaultParameters.colorFormat = GL_ARGB_SCE;
defaultParameters.depthFormat = GL_NONE;
@ -1092,12 +1094,6 @@ void psglGetDeviceDimensions(const PSGLdevice * device, GLuint *width, GLuint *h
*height = device->deviceParameters.height;
}
void psglGetRenderBufferDimensions(const PSGLdevice * device, GLuint *width, GLuint *height)
{
*width = device->deviceParameters.renderWidth;
*height = device->deviceParameters.renderHeight;
}
void psglDestroyDevice(PSGLdevice *device)
{
if ( _CurrentDevice == device ) psglMakeCurrent( NULL, NULL );
@ -1146,7 +1142,7 @@ void psglDestroyDevice(PSGLdevice *device)
static void *_RGLPlatformRasterInit (void)
{
RGLDriver *driver = (RGLDriver *)malloc( sizeof( RGLDriver ) );
RGLDriver *driver = (RGLDriver*)malloc(sizeof(RGLDriver));
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
_RGLFifoFinish( &_RGLState.fifo );
@ -1242,7 +1238,6 @@ GLAPI void psglSwap(void)
cellGcmSetLineStippleEnableInline( &_RGLState.fifo, CELL_GCM_FALSE );
cellGcmSetPolygonStippleEnableInline( &_RGLState.fifo, CELL_GCM_FALSE);
cellGcmSetDepthBoundsTestEnable( &_RGLState.fifo, CELL_GCM_FALSE);
cellGcmSetDitherEnableInline( &_RGLState.fifo, CELL_GCM_FALSE);
LContext->needValidate = PSGL_VALIDATE_ALL;

View File

@ -1,8 +1,6 @@
#ifndef ELF_H
#define ELF_H 1
#define RGL_ALIGN_FAST_TRANSFER 128
#define EI_MAG0 0
#define EI_MAG1 1
#define EI_MAG2 2

View File

@ -23,8 +23,6 @@
#include "../../../compat/strl.h"
#include "../../../general.h"
#define RGL_ALIGN_FAST_TRANSFER 128
#define ENDIAN_32(X, F) ((F) ? endianSwapWord(X) : (X))
#define SWAP_IF_BIG_ENDIAN(arg) endianSwapWordByHalf(arg)
@ -136,21 +134,15 @@ static inline float _RGLFloatFrom_GL_FLOAT(type_GL_FLOAT v)
typedef GLhalfARB type_GL_HALF_FLOAT_ARB;
static const char *_getStringTable(const Elf32_Ehdr *ehdr)
{
const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff;
const Elf32_Shdr *shstrtabHeader = (const Elf32_Shdr*)sectionHeaderStart + ehdr->e_shstrndx;
return (const char*)ehdr + shstrtabHeader->sh_offset;
}
const char *findSectionInPlace(const char* memory,unsigned int /*size*/,const char *name, size_t *sectionSize)
{
const Elf32_Ehdr *ehdr = (const Elf32_Ehdr*)memory;
const char *shstrtab = _getStringTable(ehdr);
const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff;
const Elf32_Shdr *shstrtabHeader = (const Elf32_Shdr*)sectionHeaderStart + ehdr->e_shstrndx;
const char *shstrtab = (const char*)ehdr + shstrtabHeader->sh_offset;
size_t sectionCount = ehdr->e_shnum;
const char *sectionHeaderStart = (const char*)ehdr + ehdr->e_shoff;
for(size_t i=0; i < sectionCount; i++)
{
@ -188,7 +180,6 @@ const char *findSymbolSectionInPlace(const char *memory, unsigned int /*size*/,
return NULL;
}
int lookupSymbolValueInPlace(const char* symbolSection, size_t symbolSize, size_t symbolCount, const char *symbolstrtab, const char *name)
{
for (size_t i = 0; i < symbolCount; i++)
@ -270,7 +261,6 @@ static inline void _RGLFifoGlVertexAttribPointer
GLboolean normalized,
GLsizei stride,
GLushort frequency,
GLboolean isMain,
GLuint offset
)
{
@ -322,12 +312,7 @@ static inline void _RGLFifoGlVertexAttribPointer
break;
}
uint8_t location = CELL_GCM_LOCATION_LOCAL;
if ( isMain )
location = CELL_GCM_LOCATION_MAIN;
cellGcmSetVertexDataArrayInline( &_RGLState.fifo, index, frequency, stride, size, gcmType, location, offset );
cellGcmSetVertexDataArrayInline( &_RGLState.fifo, index, frequency, stride, size, gcmType, CELL_GCM_LOCATION_LOCAL, offset );
}
static void _RGLResetAttributeState( jsAttributeState* as )
@ -392,14 +377,9 @@ static void _RGLDestroyAttribSet( jsAttribSet* attribSet )
free( attribSet );
}
static inline jsBufferObject *_RGLGetBufferObject( PSGLcontext *LContext, GLuint name )
{
return ( jsBufferObject * )LContext->bufferObjectNameSpace.data[name];
}
static void _RGLAttribSetDeleteBuffer( PSGLcontext *LContext, GLuint buffName )
{
jsBufferObject *bufferObject = _RGLGetBufferObject( LContext, buffName );
jsBufferObject *bufferObject = ( jsBufferObject * )LContext->bufferObjectNameSpace.data[buffName];
GLuint attrSetCount = bufferObject->attribSets.getCount();
if ( attrSetCount == 0 ) return;
for ( unsigned int i = 0;i < attrSetCount;++i )
@ -416,20 +396,6 @@ static void _RGLAttribSetDeleteBuffer( PSGLcontext *LContext, GLuint buffName )
bufferObject->attribSets.clear();
}
static inline jsAttribSet* _RGLGetAttribSet( GLuint name )
{
PSGLcontext* LContext = _CurrentContext;
return ( jsAttribSet* ) LContext->attribSetNameSpace.data[name];
}
static void _RGLAttribSetMarkDirty (void)
{
PSGLcontext* LContext = _CurrentContext;
jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName );
attribSet->dirty = GL_TRUE;
LContext->attribSetDirty = GL_TRUE;
}
static jsBufferObject *_RGLCreateBufferObject (void)
{
GLuint size = sizeof( jsBufferObject ) + sizeof( RGLBufferObject);
@ -438,7 +404,7 @@ static jsBufferObject *_RGLCreateBufferObject (void)
if( !buffer )
return NULL;
memset( buffer, 0, size );
memset(buffer, 0, size);
buffer->refCount = 1;
new( &buffer->textureReferences ) RGL::Vector<jsTexture *>();
@ -526,10 +492,10 @@ GLAPI void APIENTRY glDeleteBuffers(GLsizei n, const GLuint *buffers)
PSGLcontext *LContext = _CurrentContext;
for(int i = 0; i < n; ++i)
{
if ( !_RGLTexNameSpaceIsName( &LContext->bufferObjectNameSpace, buffers[i] ) )
if(!_RGLTexNameSpaceIsName( &LContext->bufferObjectNameSpace, buffers[i] ) )
continue;
if ( buffers[i] )
if(buffers[i] )
_RGLUnbindBufferObject( LContext, buffers[i] );
}
_RGLTexNameSpaceDeleteNames( &LContext->bufferObjectNameSpace, n, buffers );
@ -748,13 +714,14 @@ GLAPI void APIENTRY glBufferData( GLenum target, GLsizeiptr size, const GLvoid *
return;
}
jsBufferObject* bufferObject = _RGLGetBufferObject( LContext, name );
jsBufferObject* bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[name];
if(bufferObject->refCount > 1)
{
_RGLTexNameSpaceDeleteNames( &LContext->bufferObjectNameSpace, 1, &name );
_RGLTexNameSpaceCreateNameLazy( &LContext->bufferObjectNameSpace, name );
bufferObject = _RGLGetBufferObject( LContext, name );
bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[name];
}
if (bufferObject->size > 0)
@ -838,7 +805,8 @@ GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr
return;
}
jsBufferObject* bufferObject = _RGLGetBufferObject( LContext, name );
jsBufferObject* bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[name];
if ( bufferObject->refCount > 1 )
@ -848,7 +816,7 @@ GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr
_RGLTexNameSpaceDeleteNames( &LContext->bufferObjectNameSpace, 1, &name );
_RGLTexNameSpaceCreateNameLazy( &LContext->bufferObjectNameSpace, name );
bufferObject = _RGLGetBufferObject( LContext, name );
bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[name];
bufferObject->size = oldBufferObject->size;
bufferObject->usage = oldBufferObject->usage;
@ -863,37 +831,22 @@ GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr
_RGLPlatformBufferObjectSetData( bufferObject, offset, size, data, GL_FALSE );
}
static inline jsTexture* _RGLGetTexture( PSGLcontext *LContext, GLuint name )
{
return ( jsTexture* )LContext->textureNameSpace.data[name];
}
static inline jsTexture* _RGLGetTextureSafe( PSGLcontext *LContext, GLuint name )
{
return _RGLTexNameSpaceIsName( &LContext->textureNameSpace, name ) ? ( jsTexture* )LContext->textureNameSpace.data[name] : NULL;
}
static void _RGLFramebufferGetAttachmentTexture(
const jsFramebufferAttachment* attachment,
jsTexture** texture,
GLuint* face )
jsTexture** texture)
{
PSGLcontext* LContext = _CurrentContext;
switch ( attachment->type )
{
case _RGL_FRAMEBUFFER_ATTACHMENT_NONE:
*texture = NULL;
*face = 0;
break;
case _RGL_FRAMEBUFFER_ATTACHMENT_RENDERBUFFER:
break;
case _RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE:
*texture = _RGLGetTextureSafe( LContext, attachment->name );
*face = 0;
*texture = _RGLTexNameSpaceIsName( &LContext->textureNameSpace, attachment->name ) ? ( jsTexture* )LContext->textureNameSpace.data[attachment->name] : NULL;
break;
default:
*face = 0;
*texture = NULL;
break;
}
@ -941,8 +894,7 @@ static GLenum _RGLPlatformFramebufferCheckStatus( jsFramebuffer* framebuffer )
for ( int i = 0; i < _RGL_MAX_COLOR_ATTACHMENTS; ++i )
{
jsTexture* colorTexture = NULL;
GLuint colorFace = 0;
_RGLFramebufferGetAttachmentTexture(&framebuffer->color[i], &colorTexture, &colorFace );
_RGLFramebufferGetAttachmentTexture(&framebuffer->color[i], &colorTexture);
if ( colorTexture != NULL )
{
@ -1298,7 +1250,7 @@ int _RGLGetPixelSize( GLenum format, GLenum type )
{
int componentSize;
switch ( type )
switch(type)
{
#define DECLARE_PACKED_TYPE(REALTYPE,TYPE,N,S1,S2,S3,S4,REV) \
@ -1474,7 +1426,8 @@ static void _RGLPlatformValidateTextureResources( jsTexture *texture )
}
texture->isComplete = GL_TRUE;
if ( texture->revalidate & _RGL_TEXTURE_REVALIDATE_IMAGES || texture->revalidate & _RGL_TEXTURE_REVALIDATE_LAYOUT )
if ( texture->revalidate & _RGL_TEXTURE_REVALIDATE_IMAGES ||
texture->revalidate & _RGL_TEXTURE_REVALIDATE_LAYOUT )
{
_RGLPlatformReallocateGcmTexture( texture );
RGLTexture *gcmTexture = ( RGLTexture * )texture->platformTexture;
@ -1559,10 +1512,10 @@ source: _RGL_SURFACE_SOURCE_TEXTURE,
GLuint gamma = 0;
GLuint remap = texture->gammaRemap;
gamma |= ( remap & RGL_GAMMA_REMAP_RED_BIT ) ? CELL_GCM_TEXTURE_GAMMA_R : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_GREEN_BIT ) ? CELL_GCM_TEXTURE_GAMMA_G : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_BLUE_BIT ) ? CELL_GCM_TEXTURE_GAMMA_B : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_ALPHA_BIT ) ? CELL_GCM_TEXTURE_GAMMA_A : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_RED_BIT ) ? CELL_GCM_TEXTURE_GAMMA_R : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_GREEN_BIT ) ? CELL_GCM_TEXTURE_GAMMA_G : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_BLUE_BIT ) ? CELL_GCM_TEXTURE_GAMMA_B : 0;
gamma |= ( remap & RGL_GAMMA_REMAP_ALPHA_BIT ) ? CELL_GCM_TEXTURE_GAMMA_A : 0;
platformTexture->gcmMethods.address.gamma = gamma;
@ -1609,8 +1562,7 @@ static void jsPlatformFramebuffer_validate( jsPlatformFramebuffer * fb, PSGLcont
for ( int i = 0; i < RGL_SETRENDERTARGET_MAXCOUNT; ++i )
{
jsTexture* colorTexture = NULL;
GLuint face = 0;
_RGLFramebufferGetAttachmentTexture(&fb->color[i], &colorTexture, &face );
_RGLFramebufferGetAttachmentTexture(&fb->color[i], &colorTexture);
if(colorTexture == NULL)
continue;
@ -1703,17 +1655,19 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
return;
GLbitfield newmask = 0;
if (driver->rt.colorBufferCount ) newmask |= RGL_COLOR_BUFFER_BIT;
if ( !newmask )
if(driver->rt.colorBufferCount)
newmask |= RGL_COLOR_BUFFER_BIT;
if(!newmask)
return;
GLbitfield clearMask = newmask;
if ( driver->rt.colorBufferCount > 1 )
clearMask &= ~RGL_COLOR_BUFFER_BIT;
if(driver->rt.colorBufferCount > 1)
clearMask &= ~RGL_COLOR_BUFFER_BIT;
if ( clearMask )
if (clearMask)
{
GLuint hwColor;
RGL_CALC_COLOR_LE_ARGB8( &hwColor, RGL_CLAMPF_01(LContext->ClearColor.R), RGL_CLAMPF_01(LContext->ClearColor.G), RGL_CLAMPF_01(LContext->ClearColor.B), RGL_CLAMPF_01(LContext->ClearColor.A) );
@ -1729,7 +1683,7 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
cellGcmSetDepthTestEnableInline( &_RGLState.fifo, CELL_GCM_FALSE);
cellGcmSetStencilTestEnableInline( &_RGLState.fifo, CELL_GCM_FALSE);
static float _RGLClearVertexBuffer[12] __attribute__(( aligned( RGL_ALIGN_FAST_TRANSFER ) ) ) =
static float _RGLClearVertexBuffer[12] __attribute__((aligned(128))) =
{
-1.f, -1.f, 0.f,
-1.f, 1.f, 0.f,
@ -1744,12 +1698,12 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
GLuint bufferId = gmmAlloc(0, sizeof(_RGLClearVertexBuffer));
memcpy( gmmIdToAddress(bufferId), _RGLClearVertexBuffer, sizeof( _RGLClearVertexBuffer ) );
_RGLFifoGlVertexAttribPointer( 0, 3, RGL_FLOAT, CELL_GCM_FALSE, 3*sizeof( GLfloat ), 1, 0, gmmIdToOffset(bufferId) );
_RGLFifoGlVertexAttribPointer( 0, 3, RGL_FLOAT, CELL_GCM_FALSE, 3*sizeof( GLfloat ), 1, gmmIdToOffset(bufferId) );
RGLBIT_TRUE( LContext->attribs->DirtyMask, 0 );
for(int i = 1; i < _RGL_MAX_VERTEX_ATTRIBS; ++i)
{
_RGLFifoGlVertexAttribPointer( i, 0, RGL_FLOAT, 0, 0, 0, 0, 0 );
_RGLFifoGlVertexAttribPointer( i, 0, RGL_FLOAT, 0, 0, 0, 0 );
RGLBIT_TRUE( LContext->attribs->DirtyMask, i );
}
cellGcmSetVertexData4fInline( &_RGLState.fifo, _RGL_ATTRIB_PRIMARY_COLOR_INDEX, (GLfloat*)&LContext->ClearColor);
@ -1879,8 +1833,7 @@ GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum target, GLenum attachment,
return;
jsTexture *textureObject = NULL;
GLuint face;
_RGLFramebufferGetAttachmentTexture(attach, &textureObject, &face );
_RGLFramebufferGetAttachmentTexture(attach, &textureObject);
if ( textureObject )
textureObject->framebuffers.removeElement( framebuffer );
@ -1888,7 +1841,7 @@ GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum target, GLenum attachment,
if ( texture )
{
attach->type = _RGL_FRAMEBUFFER_ATTACHMENT_TEXTURE;
textureObject = _RGLGetTexture( LContext, texture );
textureObject = ( jsTexture* )LContext->textureNameSpace.data[texture];
textureObject->framebuffers.pushBack( framebuffer );
}
else
@ -3304,24 +3257,6 @@ static void _RGLUnloadFPShader( _CGprogram *program )
}
}
typedef struct RGLparamUIDRec
{
char * string;
GLboolean global;
} RGLparamUID;
typedef struct RGLparamUIDTableRec
{
int count;
RGLparamUID* uids;
} RGLparamUIDTable;
RGLparamUID getParamUIDByIndex( const RGLparamUIDTable* st, int index )
{
return st->uids[index];
}
void _RGLPlatformSetVertexRegister4fv( unsigned int reg, const float * __restrict v ) {}
void _RGLPlatformSetVertexRegisterBlock( unsigned int reg, unsigned int count, const float * __restrict v ) {}
void _RGLPlatformSetFragmentRegister4fv( unsigned int reg, const float * __restrict v ) {}
@ -4644,9 +4579,11 @@ static GLenum _RGLPlatformChooseInternalStorage( jsImage* image, GLenum internal
return GL_NO_ERROR;
}
static inline GLuint _RGLGetBufferObjectOrigin( GLuint buffer )
static inline GLuint _RGLGetBufferObjectOrigin(GLuint buffer)
{
jsBufferObject *bufferObject = _RGLGetBufferObject( _CurrentContext, buffer );
PSGLcontext* LContext = _CurrentContext;
jsBufferObject *bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[buffer];
RGLBufferObject *gcmBuffer = ( RGLBufferObject * ) & bufferObject->platformBufferObject;
return gcmBuffer->bufferId;
}
@ -4764,13 +4701,13 @@ static GLboolean _RGLPlatformTexturePBOImage(
formatOK = GL_FALSE;
}
if ( !formatOK )
if (!formatOK )
{
RARCH_WARN("PBO format/type requires conversion to texture internal format, using slow path.\n");
return GL_FALSE;
}
if ( !_RGLTextureIsValid( texture ) )
if (!_RGLTextureIsValid(texture))
{
RARCH_WARN("PBO transfering to incomplete texture, using slow path.\n");
return GL_FALSE;
@ -4779,7 +4716,7 @@ static GLboolean _RGLPlatformTexturePBOImage(
RGLTextureLayout newLayout;
_RGLPlatformChooseGPUFormatAndLayout( texture, GL_TRUE, pboPitch, &newLayout );
jsBufferObject* bufferObject = _RGLGetBufferObject( LContext, LContext->PixelUnpackBuffer );
jsBufferObject* bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[LContext->PixelUnpackBuffer];
if ( newLayout.pitch != 0 && !bufferObject->mapped )
{
gcmTexture->gpuLayout = newLayout;
@ -4918,22 +4855,11 @@ static inline void _RGLSetColorDepthBuffers( RGLRenderTarget *rt, RGLRenderTarge
if (( grt->height != oldHeight ) | ( rt->yInverted != oldyInverted ) )
{
RGLViewportState *v = &_RGLState.state.viewport;
_RGLFifoGlViewport( v->x, v->y, v->w, v->h );
RGLViewportState *v = &_RGLState.state.viewport;
_RGLFifoGlViewport( v->x, v->y, v->w, v->h );
}
}
static inline void _RGLSetColorDepthFormats( RGLRenderTarget *rt, RGLRenderTargetEx const * const args )
{
CellGcmSurface * grt = &rt->gcmRenderTarget;
grt->colorFormat = CELL_GCM_SURFACE_A8R8G8B8;
grt->depthFormat = CELL_GCM_SURFACE_Z24S8;
grt->depthLocation = CELL_GCM_LOCATION_LOCAL;
grt->depthOffset = 0;
grt->depthPitch = 64;
}
static inline void _RGLSetTarget( RGLRenderTarget *rt, RGLRenderTargetEx const * const args )
{
CellGcmSurface * grt = &rt->gcmRenderTarget;
@ -4962,21 +4888,27 @@ static inline void _RGLSetTarget( RGLRenderTarget *rt, RGLRenderTargetEx const *
void _RGLFifoGlSetRenderTarget( RGLRenderTargetEx const * const args )
{
RGLRenderTarget *rt = &_RGLState.renderTarget;
CellGcmSurface * grt = &_RGLState.renderTarget.gcmRenderTarget;
RGLRenderTarget *rt = &_RGLState.renderTarget;
CellGcmSurface * grt = &_RGLState.renderTarget.gcmRenderTarget;
_RGLSetColorDepthBuffers( rt, args );
_RGLSetColorDepthFormats( rt, args );
_RGLSetColorDepthBuffers( rt, args );
grt->antialias = CELL_GCM_SURFACE_CENTER_1;
//set color depth formats
grt->colorFormat = CELL_GCM_SURFACE_A8R8G8B8;
grt->depthFormat = CELL_GCM_SURFACE_Z24S8;
grt->depthLocation = CELL_GCM_LOCATION_LOCAL;
grt->depthOffset = 0;
grt->depthPitch = 64;
cellGcmSetAntiAliasingControlInline( &_RGLState.fifo, CELL_GCM_FALSE, CELL_GCM_FALSE, CELL_GCM_FALSE, 0xFFFF);
grt->antialias = CELL_GCM_SURFACE_CENTER_1;
grt->type = CELL_GCM_SURFACE_PITCH;
_RGLSetTarget( rt, args );
cellGcmSetAntiAliasingControlInline( &_RGLState.fifo, CELL_GCM_FALSE, CELL_GCM_FALSE, CELL_GCM_FALSE, 0xFFFF);
cellGcmSetSurfaceInline( &_RGLState.fifo, grt);
cellGcmSetDepthTestEnableInline( &_RGLState.fifo, CELL_GCM_FALSE);
grt->type = CELL_GCM_SURFACE_PITCH;
_RGLSetTarget( rt, args );
cellGcmSetSurfaceInline( &_RGLState.fifo, grt);
cellGcmSetDepthTestEnableInline( &_RGLState.fifo, CELL_GCM_FALSE);
}
void _RGLSetError( GLenum error ) {}
@ -5004,12 +4936,14 @@ static uint32_t * _RGLFifoWaitForFreeSpace( RGLFifo *fifo, GLuint spaceInWords )
static inline void _RGLPushProgramPushBuffer( _CGprogram * cgprog )
{
_RGLFifoWaitForFreeSpace( &_RGLState.fifo, cgprog->constantPushBufferWordSize + 4 + 32);
uint32_t padding_in_word = ( ( 0x10-(((uint32_t)_RGLState.fifo.current)&0xf))&0xf )>>2;
uint32_t padded_size = ( ((cgprog->constantPushBufferWordSize)<<2) + 0xf )&~0xf;
cellGcmSetNopCommandUnsafeInline( &_RGLState.fifo, padding_in_word);
memcpy16(_RGLState.fifo.current, cgprog->constantPushBuffer, padded_size);
_RGLState.fifo.current+=cgprog->constantPushBufferWordSize;
_RGLFifoWaitForFreeSpace( &_RGLState.fifo, cgprog->constantPushBufferWordSize + 4 + 32);
uint32_t padding_in_word = ( ( 0x10-(((uint32_t)_RGLState.fifo.current)&0xf))&0xf )>>2;
uint32_t padded_size = ( ((cgprog->constantPushBufferWordSize)<<2) + 0xf )&~0xf;
cellGcmSetNopCommandUnsafeInline( &_RGLState.fifo, padding_in_word);
memcpy(_RGLState.fifo.current, cgprog->constantPushBuffer, padded_size);
_RGLState.fifo.current+=cgprog->constantPushBufferWordSize;
}
static GLuint _RGLValidateStates( void )
@ -5335,8 +5269,6 @@ static void _RGLResetContext( PSGLcontext *LContext )
LContext->BlendFactorSrcAlpha = GL_ONE;
LContext->BlendFactorDestAlpha = GL_ZERO;
LContext->Dithering = GL_TRUE;
for ( int i = 0;i < _RGL_MAX_TEXTURE_COORDS;++i )
{
jsTextureCoordsUnit *tu = LContext->TextureCoordsUnits + i;
@ -5427,25 +5359,26 @@ static jsTexture *_RGLAllocateTexture (void)
static void _RGLFreeTexture( jsTexture *texture )
{
_RGLTextureTouchFBOs( texture );
texture->framebuffers.~Vector<jsFramebuffer *>();
if ( texture->image )
{
for ( GLuint i = 0;i < texture->imageCount;++i )
{
jsImage *image = texture->image + i;
_RGLImageFreeCPUStorage( image );
}
if(texture->image != NULL)
free( texture->image );
}
if ( texture->referenceBuffer )
{
texture->referenceBuffer->textureReferences.removeElement( texture );
}
_RGLPlatformDestroyTexture( texture );
if(texture != NULL)
free( texture );
_RGLTextureTouchFBOs( texture );
texture->framebuffers.~Vector<jsFramebuffer *>();
if ( texture->image )
{
for ( GLuint i = 0;i < texture->imageCount;++i )
{
jsImage *image = texture->image + i;
_RGLImageFreeCPUStorage( image );
}
if(texture->image != NULL)
free( texture->image );
}
if ( texture->referenceBuffer )
texture->referenceBuffer->textureReferences.removeElement( texture );
_RGLPlatformDestroyTexture( texture );
if(texture != NULL)
free( texture );
}
PSGLcontext* psglCreateContext (void)
@ -5528,7 +5461,8 @@ void psglResetCurrentContext (void)
static void _RGLMatrixStackClear( jsMatrixStack* LMatrixStack )
{
if ( LMatrixStack->MatrixStackf ) free( LMatrixStack->MatrixStackf );
if(LMatrixStack->MatrixStackf)
free( LMatrixStack->MatrixStackf );
LMatrixStack->MatrixStackf = NULL;
LMatrixStack->MatrixStackPtr = 0;
LMatrixStack->dirty = GL_FALSE;
@ -5610,11 +5544,9 @@ GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params )
case GL_MODELVIEW_MATRIX:
jsContextGetMatrixf( LContext, GL_MODELVIEW, LMatrixStack, LMatrix );
break;
case GL_PROJECTION_MATRIX:
jsContextGetMatrixf( LContext, GL_PROJECTION, LMatrixStack, LMatrix );
break;
case GL_TEXTURE_MATRIX:
jsContextGetMatrixf( LContext, GL_TEXTURE, LMatrixStack, LMatrix );
break;
@ -5663,7 +5595,6 @@ GLAPI void APIENTRY glEnable( GLenum cap )
case GL_POINT_SMOOTH:
break;
case GL_DITHER:
LContext->Dithering = GL_TRUE;
break;
case GL_POINT_SPRITE_OES:
case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
@ -5722,7 +5653,6 @@ GLAPI void APIENTRY glDisable( GLenum cap )
case GL_LINE_SMOOTH:
break;
case GL_DITHER:
LContext->Dithering = GL_FALSE;
break;
case GL_POINT_SPRITE_OES:
case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
@ -5791,22 +5721,22 @@ GLAPI void APIENTRY glDisableClientState( GLenum array )
GLAPI void APIENTRY glFlush()
{
PSGLcontext *LContext = _CurrentContext;
RGLFifo *fifo = &_RGLState.fifo;
PSGLcontext *LContext = _CurrentContext;
RGLFifo *fifo = &_RGLState.fifo;
if ( RGL_UNLIKELY( LContext->needValidate ) )
_RGLValidateStates();
if ( RGL_UNLIKELY( LContext->needValidate ) )
_RGLValidateStates();
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
_RGLFifoFlush( fifo );
_RGLFifoFlush( fifo );
}
GLAPI void APIENTRY glFinish (void)
{
glFlush();
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
_RGLFifoFinish( &_RGLState.fifo );
glFlush();
cellGcmSetInvalidateVertexCacheInline( &_RGLState.fifo);
_RGLFifoFinish( &_RGLState.fifo );
}
GLAPI const GLubyte* APIENTRY glGetString( GLenum name )
@ -5946,9 +5876,6 @@ GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLflo
LContext->InverseModelViewValid = GL_FALSE;
}
int _psglCheckDrawElementsVBOBounds = 0;
GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer )
{
_RGLVertexAttribPointerNV( _RGL_ATTRIB_POSITION_INDEX, size, type, GL_FALSE, stride, pointer );
@ -6063,50 +5990,64 @@ void _RGLVertexAttribPointerNV(
if ( LContext->attribSetName )
{
jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName );
jsAttribSet* attribSet = (jsAttribSet*)LContext->attribSetNameSpace.data[LContext->attribSetName];
if ( oldArrayBuffer )
{
int refcount = 0;
for ( unsigned int i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i )
for(unsigned int i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i )
{
if ( attribSet->attribs.attrib[i].arrayBuffer == oldArrayBuffer ) ++refcount;
}
if ( refcount == 1 ) _RGLGetBufferObject( LContext, oldArrayBuffer )->attribSets.removeElement( attribSet );
if(refcount == 1)
{
jsBufferObject *buffer = (jsBufferObject *)LContext->bufferObjectNameSpace.data[oldArrayBuffer];
buffer->attribSets.removeElement(attribSet);
}
}
if ( attrib->arrayBuffer )
{
_RGLGetBufferObject( LContext, attrib->arrayBuffer )->attribSets.appendUnique( attribSet );
jsBufferObject *buffer = (jsBufferObject *)LContext->bufferObjectNameSpace.data[attrib->arrayBuffer];
buffer->attribSets.appendUnique(attribSet);
}
_RGLAttribSetMarkDirty();
attribSet->dirty = GL_TRUE;
LContext->attribSetDirty = GL_TRUE;
}
}
void _RGLEnableVertexAttribArrayNV( GLuint index )
{
PSGLcontext *LContext = _CurrentContext;
PSGLcontext *LContext = _CurrentContext;
jsAttribSet* attribSet = (jsAttribSet*)LContext->attribSetNameSpace.data[LContext->attribSetName];
RGLBIT_TRUE( LContext->attribs->EnabledMask, index );
RGLBIT_TRUE( LContext->attribs->DirtyMask, index );
if ( LContext->attribSetName )
_RGLAttribSetMarkDirty();
{
attribSet->dirty = GL_TRUE;
LContext->attribSetDirty = GL_TRUE;
}
}
void _RGLDisableVertexAttribArrayNV( GLuint index )
{
PSGLcontext *LContext = _CurrentContext;
jsAttribSet* attribSet = (jsAttribSet*)LContext->attribSetNameSpace.data[LContext->attribSetName];
RGLBIT_FALSE( LContext->attribs->EnabledMask, index );
RGLBIT_TRUE( LContext->attribs->DirtyMask, index );
if ( LContext->attribSetName )
_RGLAttribSetMarkDirty();
{
attribSet->dirty = GL_TRUE;
LContext->attribSetDirty = GL_TRUE;
}
}
static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams, GLboolean *isMain )
static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams)
{
PSGLcontext* LContext = _CurrentContext;
RGLDriver *driver= (RGLDriver *)_CurrentDevice->rasterDriver;
@ -6149,30 +6090,27 @@ static GLuint _RGLValidateAttributesSlow( jsDrawParams *dparams, GLboolean *isMa
else
offset = ( dparams->firstVertex / freq ) * stride;
char * b = ( char * )xferBuffer + dparams->attribXferOffset[i];
char *b = (char *)xferBuffer + dparams->attribXferOffset[i];
memcpy( b + offset,
( char * )attrib->clientData + offset,
dparams->attribXferSize[i] - offset );
*isMain = gmmIdIsMain(xferId);
gpuOffset = gmmIdToOffset(xferId) + (b - ( char * )xferBuffer);
}
else
{
VBOId = _RGLGetBufferObjectOrigin( attrib->arrayBuffer );
*isMain = gmmIdIsMain(VBOId);
gpuOffset = gmmIdToOffset(VBOId)
+ (( const GLubyte* )attrib->clientData - ( const GLubyte* )NULL );
gpuOffset = gmmIdToOffset(VBOId) + (( const GLubyte* )attrib->clientData - ( const GLubyte* )NULL );
}
_RGLFifoGlVertexAttribPointer( i, attrib->clientSize,
( RGLEnum )attrib->clientType, attrib->normalized,
stride, freq, *isMain, gpuOffset );
stride, freq, gpuOffset );
}
else
{
_RGLFifoGlVertexAttribPointer( i, 0, RGL_FLOAT, 0, 0, 0, 0, 0 );
_RGLFifoGlVertexAttribPointer( i, 0, RGL_FLOAT, 0, 0, 0, 0 );
cellGcmSetVertexData4fInline( &_RGLState.fifo, i,attrib->value);
}
}
@ -6246,17 +6184,12 @@ GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count )
if ( driver->flushBufferCount != 0 )
driver->invalidateVertexCache = GL_TRUE;
GLboolean isMain = 0;
if ( LContext->attribSetDirty && LContext->attribSetName )
jsAttribSet* attribSet = _RGLGetAttribSet( LContext->attribSetName );
uint32_t totalXfer = 0;
for (GLuint i = 0; i < _RGL_MAX_VERTEX_ATTRIBS; ++i)
totalXfer += dparams->attribXferSize[i];
GLuint gpuOffset = _RGLValidateAttributesSlow( dparams, &isMain );
GLuint gpuOffset = _RGLValidateAttributesSlow( dparams);
(void)gpuOffset;
if(driver->invalidateVertexCache)
@ -6279,7 +6212,7 @@ GLAPI void APIENTRY glGenTextures( GLsizei n, GLuint *textures )
static void _RGLTextureUnbind( PSGLcontext* context, GLuint name )
{
int unit;
for ( unit = 0;unit < _RGL_MAX_TEXTURE_IMAGE_UNITS;++unit )
for (unit = 0; unit < _RGL_MAX_TEXTURE_IMAGE_UNITS; ++unit)
{
jsTextureImageUnit *tu = context->TextureImageUnits + unit;
GLboolean dirty = GL_FALSE;
@ -6294,7 +6227,7 @@ static void _RGLTextureUnbind( PSGLcontext* context, GLuint name )
context->needValidate |= PSGL_VALIDATE_TEXTURES_USED;
}
}
if ( _RGLTexNameSpaceIsName( &context->textureNameSpace, name ) )
if(_RGLTexNameSpaceIsName( &context->textureNameSpace, name))
{
jsTexture*texture = ( jsTexture * )context->textureNameSpace.data[name];
for ( unit = 0;unit < _RGL_MAX_VERTEX_TEXTURE_IMAGE_UNITS; ++unit )
@ -6440,7 +6373,7 @@ GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const G
jsBufferObject* bufferObject = NULL;
if ( LContext->PixelUnpackBuffer != 0 )
{
bufferObject = _RGLGetBufferObject( LContext, LContext->PixelUnpackBuffer );
bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[LContext->PixelUnpackBuffer];
pixels = _RGLPlatformBufferObjectMap( bufferObject, GL_READ_ONLY ) +
(( const GLubyte* )pixels - ( const GLubyte* )NULL );
}
@ -6521,7 +6454,7 @@ GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, GLuint
PSGLcontext* LContext = _CurrentContext;
jsTexture *texture = _RGLGetCurrentTexture( LContext->CurrentImageUnit, GL_TEXTURE_2D);
jsBufferObject *bufferObject = _RGLGetBufferObject( LContext, LContext->TextureBuffer );
jsBufferObject *bufferObject = (jsBufferObject *)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer];
_RGLReallocateImages( texture, MAX( baseWidth, MAX( baseHeight, baseDepth ) ) );
GLuint width = baseWidth;
@ -6744,7 +6677,7 @@ static bool cgOpenElf( const void *ptr, size_t size, CGELFBinary *elfBinary )
static bool cgGetElfProgramByIndex( CGELFBinary *elfBinary, int index, CGELFProgram *elfProgram )
{
while ( true )
while(1)
{
char sectionName[64];
snprintf( sectionName, sizeof(sectionName), ".text%04i", index );
@ -6771,15 +6704,15 @@ static bool cgGetElfProgramByIndex( CGELFBinary *elfBinary, int index, CGELFProg
static bool cgGetElfProgramByName( CGELFBinary *elfBinary, const char *name, CGELFProgram *elfProgram )
{
//if no name try to return the first program
int res;
int ret;
if ( name == NULL || name[0] == '\0' )
res = 0;
ret = 0;
else
res = lookupSymbolValueInPlace( elfBinary->symtab, elfBinary->symbolSize, elfBinary->symbolCount, elfBinary->symbolstrtab, name );
ret = lookupSymbolValueInPlace( elfBinary->symtab, elfBinary->symbolSize, elfBinary->symbolCount, elfBinary->symbolstrtab, name );
if ( res != -1 )
return cgGetElfProgramByIndex( elfBinary, res, elfProgram );
if (ret != -1)
return cgGetElfProgramByIndex( elfBinary, ret, elfProgram );
else
return false;
}
@ -6931,8 +6864,8 @@ CG_API CGprogram cgCreateProgram( CGcontext ctx,
//convert from NV format to the runtime format
int compiled_program_size = 0;
STL_NAMESPACE vector<char> stringTableArray;
STL_NAMESPACE vector<float> defaultValuesArray;
std::vector<char> stringTableArray;
std::vector<float> defaultValuesArray;
CgBinaryProgram* nvProgram = ( CgBinaryProgram* )binaryBuffer;
char *runtimeElfShader = NULL;
@ -7101,9 +7034,9 @@ CG_API CGprogram cgCreateProgramFromFile( CGcontext ctx,
unsigned int filetag = 0;
int res = fread( &filetag, sizeof( filetag ), 1, fp );
if ( !res )
if (!res)
{
fclose( fp );
fclose(fp);
_RGLCgRaiseError( CG_FILE_READ_ERROR );
return ( CGprogram )NULL;
}
@ -7382,9 +7315,9 @@ static void _RGLCgRemoveGroup( CGcontext ctx, CGprogramGroup group )
CGprogramGroup _RGLCgCreateProgramGroupFromFile( CGcontext ctx, const char *group_file )
{
FILE* fp = fopen( group_file, "rb" );
FILE *fp = fopen(group_file, "rb");
if ( fp == NULL )
if(fp == NULL)
{
_RGLCgRaiseError( CG_FILE_READ_ERROR );
return ( CGprogramGroup )NULL;
@ -7395,8 +7328,8 @@ CGprogramGroup _RGLCgCreateProgramGroupFromFile( CGcontext ctx, const char *grou
file_size = ftell( fp );
rewind( fp );
char* ptr = ( char* )malloc( file_size + 1 );
if ( ptr == NULL )
char *ptr = ( char* )malloc(file_size + 1);
if(ptr == NULL)
{
_RGLCgRaiseError( CG_MEMORY_ALLOC_ERROR );
return ( CGprogramGroup )NULL;
@ -8002,7 +7935,7 @@ CGGL_API void cgGLUnbindProgram( CGprofile profile )
CGGL_API void cgGLSetParameter1f( CGparameter param, float x )
{
CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param );
CgRuntimeParameter *ptr = _cgGetParamPtr( param );
float v[4] = {x, x, x, x};
ptr->setterIndex( ptr, v, CG_GETINDEX( param ) );
@ -8010,7 +7943,7 @@ CGGL_API void cgGLSetParameter1f( CGparameter param, float x )
CGGL_API void cgGLSetParameter2f( CGparameter param, float x, float y )
{
CgRuntimeParameter *ptr = _RGLCgGLTestParameter( param );
CgRuntimeParameter *ptr = _cgGetParamPtr( param );
float v[4] = {x, y, y, y};
ptr->setterIndex( ptr, v, CG_GETINDEX( param ) );
@ -8024,7 +7957,7 @@ CGGL_API void cgGLSetParameterPointer
const GLvoid *pointer )
{
CgRuntimeParameter *_ptr = _RGLCgGLTestParameter( param );
CgRuntimeParameter *_ptr = _cgGetParamPtr( param );
const CgParameterResource *parameterResource = _RGLGetParameterResource( _ptr->program, _ptr->parameterEntry );
GLuint index = ( GLuint )( parameterResource->resource - CG_ATTR0 );
@ -8040,7 +7973,7 @@ CGGL_API void cgGLSetParameterPointer
CGGL_API void cgGLEnableClientState( CGparameter param )
{
CgRuntimeParameter *_ptr = _RGLCgGLTestParameter( param );
CgRuntimeParameter *_ptr = _cgGetParamPtr( param );
const CgParameterResource *parameterResource = _RGLGetParameterResource( _ptr->program, _ptr->parameterEntry );
@ -8050,7 +7983,7 @@ CGGL_API void cgGLEnableClientState( CGparameter param )
CGGL_API void cgGLDisableClientState( CGparameter param )
{
CgRuntimeParameter *_ptr = _RGLCgGLTestParameter( param );
CgRuntimeParameter *_ptr = _cgGetParamPtr( param );
const CgParameterResource *parameterResource = _RGLGetParameterResource( _ptr->program, _ptr->parameterEntry );
@ -8094,7 +8027,7 @@ CGGL_API void cgGLSetStateMatrixParameter( CGparameter param,
return;
}
CgRuntimeParameter* ptr = _RGLCgGLTestParameter( param );
CgRuntimeParameter* ptr = _cgGetParamPtr( param );
CGtype parameterType = _RGLGetParameterCGtype( ptr->program, ptr->parameterEntry );
if ( RGL_LIKELY( parameterType == CG_FLOAT4x4 ) )
@ -8115,14 +8048,14 @@ CGGL_API void cgGLSetStateMatrixParameter( CGparameter param,
CGGL_API void cgGLSetTextureParameter( CGparameter param, GLuint texobj )
{
CgRuntimeParameter* ptr = _cgGLTestTextureParameter( param );
CgRuntimeParameter* ptr = _cgGetParamPtr(param);
ptr->samplerSetter( ptr, &texobj, 0 );
}
CGGL_API void cgGLEnableTextureParameter( CGparameter param )
{
CgRuntimeParameter* ptr = _cgGLTestTextureParameter( param );
CgRuntimeParameter* ptr = _cgGetParamPtr(param);
ptr->samplerSetter( ptr, NULL, 0 );
}
@ -8166,7 +8099,11 @@ CG_API CGcontext cgCreateContext(void)
_RGLCgContextZero( ptr );
CGcontext result = ( CGcontext )_RGLCreateName( &_CurrentContext->cgContextNameSpace, ptr );
if ( !result ) { free( ptr ); return NULL; }
if ( !result )
{
free( ptr );
return NULL;
}
ptr->id = result;
ptr->defaultProgram.parentContext = ptr;
@ -8214,13 +8151,9 @@ CG_API void cgDestroyContext(CGcontext c)
destroy_context( head );
if ( second )
{
_CurrentContext->RGLcgContextHead = second->id;
}
else
{
_CurrentContext->RGLcgContextHead = 0;
}
}
}
@ -8479,13 +8412,6 @@ void _cgRaiseNotMatrixParamIndex( CgRuntimeParameter*p, const void*v, const int
void _cgIgnoreSetParam( CgRuntimeParameter*p, const void*v ) {}
void _cgIgnoreSetParamIndex( CgRuntimeParameter*p, const void*v, const int index ) {}
CgRuntimeParameter* _cgGLTestTextureParameter( CGparameter param )
{
CgRuntimeParameter* ptr = _RGLCgGLTestParameter( param );
return ptr;
}
#define CG_DATATYPE_MACRO(name, compiler_name, enum_name, base_enum, nrows, ncols,classname) \
nrows ,
static int _typesRowCount[] =

View File

@ -18,10 +18,8 @@ typedef struct _CGcontext *CGcontext;
#include <cell/resc.h>
#endif
#define RGL_ALIGN_FAST_TRANSFER 128
#define _RGL_MAX_COLOR_ATTACHMENTS 4
#define RGL_SUBPIXEL_ADJUST (0.5/(1<<12))
#define RGL_VIEWPORT_EPSILON (0.0f)
#define gmmIdIsMain(id) (((GmmBaseBlock *)id)->isMain)
@ -532,7 +530,6 @@ struct PSGLcontext
GLenum BlendFactorSrcAlpha;
GLenum BlendFactorDestAlpha;
jsColorRGBAf BlendColor;
GLboolean Dithering;
jsTexNameSpace textureNameSpace;
GLuint ActiveTexture;
GLuint CS_ActiveTexture;
@ -1035,7 +1032,7 @@ void static inline _RGLFifoGlViewport( GLint x, GLint y, GLsizei width, GLsizei
if ( rt->yInverted )
{
vp->yScale *= -0.5f;
vp->yCenter = ( GLfloat )( rt->gcmRenderTarget.height - RGL_VIEWPORT_EPSILON - y + vp->yScale + RGL_SUBPIXEL_ADJUST );
vp->yCenter = ( GLfloat )( rt->gcmRenderTarget.height - y + vp->yScale + RGL_SUBPIXEL_ADJUST );
}
else
{
@ -1106,7 +1103,6 @@ PSGLdevice* psglCreateDeviceAuto( GLenum colorFormat, GLenum depthFormat, GLenum
PSGLdevice* psglCreateDeviceExtended( const PSGLdeviceParameters *parameters );
GLfloat psglGetDeviceAspectRatio( const PSGLdevice * device );
void psglGetDeviceDimensions( const PSGLdevice * device, GLuint *width, GLuint *height );
void psglGetRenderBufferDimensions( const PSGLdevice * device, GLuint *width, GLuint *height );
void psglDestroyDevice( PSGLdevice* device );
void psglMakeCurrent( PSGLcontext* context, PSGLdevice* device );
@ -1115,7 +1111,7 @@ void psglDestroyContext( PSGLcontext* LContext );
void psglResetCurrentContext();
PSGLcontext* psglGetCurrentContext();
PSGLdevice* psglGetCurrentDevice();
void psglSwap( void );
void psglSwap(void);
#ifdef __cplusplus
}

View File

@ -4,8 +4,6 @@
#include <memory>
#include <stdexcept>
#define STL_NAMESPACE ::RGL::
namespace RGL
{