mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
(RGL PS3) Make functions static and make macros out of small inline
functions
This commit is contained in:
parent
2dc77c570b
commit
22cd6a0511
@ -30,7 +30,6 @@ _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 );
|
||||
|
@ -154,10 +154,6 @@ void gmmSetTileAttrib(
|
||||
|
||||
void *gmmGetTileData (const uint32_t id);
|
||||
|
||||
void gmmPinAllocations (void);
|
||||
|
||||
void gmmUnpinAllocations (void);
|
||||
|
||||
static inline uint8_t gmmIdIsMain (const uint32_t id)
|
||||
{
|
||||
return false;
|
||||
|
@ -18,10 +18,8 @@ void rglSetDefaultValuesFP (void *data);
|
||||
void rglSetDefaultValuesVP (void *data);
|
||||
void rglGcmSend( unsigned int dstId, unsigned dstOffset, unsigned int pitch, const char *src, unsigned int size );
|
||||
void rglGcmMemcpy( const GLuint dstId, unsigned dstOffset, unsigned int pitch, const GLuint srcId, GLuint srcOffset, unsigned int size );
|
||||
void rglSetNativeCgFragmentProgram(const void *data);
|
||||
void rglGcmFreeTiledSurface (GLuint bufferId);
|
||||
|
||||
void rglGcmCopySurface(const void *data, GLuint srcX, GLuint srcY,
|
||||
const void *data_dst, GLuint dstX, GLuint dstY,
|
||||
GLuint width, GLuint height, GLboolean writeSync);
|
||||
void rglSetNativeCgVertexProgram (const void *data);
|
||||
|
@ -56,15 +56,8 @@ static uint32_t cachedLockValue = 0;
|
||||
static uint8_t pinAllocations = 0;
|
||||
static GmmFixedAllocData *pGmmFixedAllocData = NULL;
|
||||
|
||||
static inline uint32_t pad(uint32_t x, uint32_t pad)
|
||||
{
|
||||
return ( x + pad - 1 ) / pad * pad;
|
||||
}
|
||||
|
||||
static inline uint32_t gmmAddressToOffset(uint32_t address)
|
||||
{
|
||||
return address - pGmmLocalAllocator->memoryBase;
|
||||
}
|
||||
#define PAD(x, pad) ((x + pad - 1) / pad * pad)
|
||||
#define GMM_ADDRESS_TO_OFFSET(address) (address - pGmmLocalAllocator->memoryBase)
|
||||
|
||||
static uint32_t gmmInitFixedAllocator(void)
|
||||
{
|
||||
@ -216,10 +209,7 @@ static void gmmDestroyFixedAllocator (void)
|
||||
}
|
||||
}
|
||||
|
||||
static GmmBlock *gmmAllocFixedBlock (void)
|
||||
{
|
||||
return (GmmBlock *)gmmAllocFixed(0);
|
||||
}
|
||||
#define GMM_ALLOC_FIXED_BLOCK() ((GmmBlock*)gmmAllocFixed(0))
|
||||
|
||||
static void gmmFreeFixedBlock (void *data)
|
||||
{
|
||||
@ -238,16 +228,6 @@ static void gmmFreeFixedTileBlock (void *data)
|
||||
gmmFreeFixed(1, pTileBlock);
|
||||
}
|
||||
|
||||
void gmmPinAllocations (void)
|
||||
{
|
||||
pinAllocations = 1;
|
||||
}
|
||||
|
||||
void gmmUnpinAllocations (void)
|
||||
{
|
||||
pinAllocations = 0;
|
||||
}
|
||||
|
||||
uint32_t gmmInit(
|
||||
const void *localMemoryBase,
|
||||
const void *localStartAddress,
|
||||
@ -375,7 +355,7 @@ uint32_t gmmIdToOffset(const uint32_t id)
|
||||
pBlock->isPinned = pinAllocations;
|
||||
}
|
||||
|
||||
offset = gmmAddressToOffset(pBaseBlock->address);
|
||||
offset = GMM_ADDRESS_TO_OFFSET(pBaseBlock->address);
|
||||
|
||||
return offset;
|
||||
}
|
||||
@ -427,7 +407,7 @@ static GmmBlock *gmmAllocBlock(
|
||||
if (UINT_MAX - address >= size &&
|
||||
address + size <= pAllocator->startAddress + pAllocator->size)
|
||||
{
|
||||
pNewBlock = gmmAllocFixedBlock();
|
||||
pNewBlock = GMM_ALLOC_FIXED_BLOCK();
|
||||
if (pNewBlock == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@ -608,7 +588,7 @@ uint32_t gmmAllocExtendedTileBlock(
|
||||
pAllocator = pGmmLocalAllocator;
|
||||
|
||||
|
||||
newSize = pad(size, GMM_TILE_ALIGNMENT);
|
||||
newSize = PAD(size, GMM_TILE_ALIGNMENT);
|
||||
|
||||
GmmTileBlock *pBlock = pAllocator->pTileTail;
|
||||
|
||||
@ -1044,8 +1024,8 @@ static uint8_t gmmInternalSweep(void *data, const uint8_t location)
|
||||
pBlock->pNext->base.address > pBlock->base.address + pBlock->base.size ||
|
||||
pBlock->pNext->isPinned))
|
||||
{
|
||||
dstOffset = gmmAddressToOffset(dstAddress);
|
||||
srcOffset = gmmAddressToOffset(srcAddress);
|
||||
dstOffset = GMM_ADDRESS_TO_OFFSET(dstAddress);
|
||||
srcOffset = GMM_ADDRESS_TO_OFFSET(srcAddress);
|
||||
|
||||
totalMoveSize += moveSize;
|
||||
|
||||
@ -1095,8 +1075,8 @@ static uint8_t gmmInternalSweep(void *data, const uint8_t location)
|
||||
pBlock->pPrev->base.address + pBlock->pPrev->base.size;
|
||||
uint32_t pinSrcAddress = pTempBlock->base.address;
|
||||
|
||||
dstOffset = gmmAddressToOffset(pinDstAddress);
|
||||
srcOffset = gmmAddressToOffset(pinSrcAddress);
|
||||
dstOffset = GMM_ADDRESS_TO_OFFSET(pinDstAddress);
|
||||
srcOffset = GMM_ADDRESS_TO_OFFSET(pinSrcAddress);
|
||||
|
||||
totalMoveSize += pTempBlock->base.size;
|
||||
|
||||
@ -1111,13 +1091,9 @@ static uint8_t gmmInternalSweep(void *data, const uint8_t location)
|
||||
if (pTempBlock == pAllocator->pTail)
|
||||
{
|
||||
if (pTempBlock->pNext)
|
||||
{
|
||||
pAllocator->pTail = pTempBlock->pNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
pAllocator->pTail = pTempBlock->pPrev;
|
||||
}
|
||||
}
|
||||
|
||||
if (pTempBlock->pNext)
|
||||
@ -1144,7 +1120,7 @@ static uint8_t gmmInternalSweep(void *data, const uint8_t location)
|
||||
|
||||
if (availableSize > 0)
|
||||
{
|
||||
GmmBlock *pNewBlock = gmmAllocFixedBlock();
|
||||
GmmBlock *pNewBlock = GMM_ALLOC_FIXED_BLOCK();
|
||||
|
||||
if (pNewBlock)
|
||||
{
|
||||
@ -1340,7 +1316,7 @@ static uint32_t gmmFindFreeBlock(
|
||||
{
|
||||
if (pBlock->base.size != size)
|
||||
{
|
||||
GmmBlock *pNewBlock = gmmAllocFixedBlock();
|
||||
GmmBlock *pNewBlock = GMM_ALLOC_FIXED_BLOCK();
|
||||
if (pNewBlock == NULL)
|
||||
return GMM_ERROR;
|
||||
|
||||
@ -1381,13 +1357,13 @@ uint32_t gmmAlloc(void *data, const uint8_t location,
|
||||
|
||||
if (!isTile)
|
||||
{
|
||||
newSize = pad(size, GMM_ALIGNMENT);
|
||||
newSize = PAD(size, GMM_ALIGNMENT);
|
||||
|
||||
retId = gmmFindFreeBlock(pAllocator, newSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = pad(size, GMM_TILE_ALIGNMENT);
|
||||
newSize = PAD(size, GMM_TILE_ALIGNMENT);
|
||||
retId = GMM_ERROR;
|
||||
}
|
||||
|
||||
@ -1414,90 +1390,6 @@ uint32_t gmmAlloc(void *data, const uint8_t location,
|
||||
return retId;
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
FRAGMENT SHADER
|
||||
============================================================ */
|
||||
|
||||
void rglSetNativeCgFragmentProgram(const void *data)
|
||||
{
|
||||
const _CGprogram *program = (const _CGprogram *)data;
|
||||
|
||||
CellCgbFragmentProgramConfiguration conf;
|
||||
|
||||
conf.offset = gmmIdToOffset(program->loadProgramId) + program->loadProgramOffset;
|
||||
|
||||
rglGcmInterpolantState *s = &rglGcmState_i.state.interpolant;
|
||||
s->fragmentProgramAttribMask |= program->header.attributeInputMask | CELL_GCM_ATTRIB_OUTPUT_MASK_POINTSIZE;
|
||||
|
||||
conf.attributeInputMask = ( s->vertexProgramAttribMask) &
|
||||
s->fragmentProgramAttribMask;
|
||||
|
||||
conf.texCoordsInputMask = program->header.fragmentProgram.texcoordInputMask;
|
||||
conf.texCoords2D = program->header.fragmentProgram.texcoord2d;
|
||||
conf.texCoordsCentroid = program->header.fragmentProgram.texcoordCentroid;
|
||||
|
||||
int fragmentControl = ( 1 << 15 ) | ( 1 << 10 );
|
||||
fragmentControl |= program->header.fragmentProgram.flags & CGF_DEPTHREPLACE ? 0xE : 0x0;
|
||||
fragmentControl |= program->header.fragmentProgram.flags & CGF_OUTPUTFROMH0 ? 0x00 : 0x40;
|
||||
fragmentControl |= program->header.fragmentProgram.flags & CGF_PIXELKILL ? 0x80 : 0x00;
|
||||
|
||||
conf.fragmentControl = fragmentControl;
|
||||
conf.registerCount = program->header.fragmentProgram.registerCount < 2 ? 2 : program->header.fragmentProgram.registerCount;
|
||||
|
||||
uint32_t controlTxp = _CurrentContext->AllowTXPDemotion;
|
||||
conf.fragmentControl &= ~CELL_GCM_MASK_SET_SHADER_CONTROL_CONTROL_TXP;
|
||||
conf.fragmentControl |= controlTxp << CELL_GCM_SHIFT_SET_SHADER_CONTROL_CONTROL_TXP;
|
||||
|
||||
GCM_FUNC( cellGcmSetFragmentProgramLoad, &conf );
|
||||
|
||||
GCM_FUNC( cellGcmSetZMinMaxControl, ( program->header.fragmentProgram.flags & CGF_DEPTHREPLACE ) ? RGLGCM_FALSE : RGLGCM_TRUE, RGLGCM_FALSE, RGLGCM_FALSE );
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
VERTEX SHADER
|
||||
============================================================ */
|
||||
|
||||
void rglSetNativeCgVertexProgram(const void *data)
|
||||
{
|
||||
const _CGprogram *program = (const _CGprogram*)data;
|
||||
|
||||
__dcbt(program->ucode);
|
||||
__dcbt(((uint8_t*)program->ucode)+128);
|
||||
__dcbt(((uint8_t*)program->ucode)+256);
|
||||
__dcbt(((uint8_t*)program->ucode)+384);
|
||||
|
||||
CellCgbVertexProgramConfiguration conf;
|
||||
conf.instructionSlot = program->header.vertexProgram.instructionSlot;
|
||||
conf.instructionCount = program->header.instructionCount;
|
||||
conf.registerCount = program->header.vertexProgram.registerCount;
|
||||
conf.attributeInputMask = program->header.attributeInputMask;
|
||||
|
||||
rglGcmFifoWaitForFreeSpace( &rglGcmState_i.fifo, 7 + 5 * conf.instructionCount );
|
||||
|
||||
GCM_FUNC( cellGcmSetVertexProgramLoad, &conf, program->ucode );
|
||||
|
||||
GCM_FUNC( cellGcmSetUserClipPlaneControl, 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
rglGcmInterpolantState *s = &rglGcmState_i.state.interpolant;
|
||||
s->vertexProgramAttribMask = program->header.vertexProgram.attributeOutputMask;
|
||||
|
||||
GCM_FUNC( cellGcmSetVertexAttribOutputMask, (( s->vertexProgramAttribMask) &
|
||||
s->fragmentProgramAttribMask) );
|
||||
|
||||
program = (_CGprogram*)data;
|
||||
int count = program->defaultValuesIndexCount;
|
||||
for ( int i = 0;i < count;i++ )
|
||||
{
|
||||
const CgParameterEntry *parameterEntry = program->parametersEntries + program->defaultValuesIndices[i].entryIndex;
|
||||
if (( parameterEntry->flags & CGPF_REFERENCED ) && ( parameterEntry->flags & CGPV_MASK ) == CGPV_CONSTANT )
|
||||
{
|
||||
const float *itemDefaultValues = program->defaultValues +
|
||||
program->defaultValuesIndices[i].defaultValueIndex;
|
||||
rglFifoGlProgramParameterfvVP( program, parameterEntry, itemDefaultValues );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*============================================================
|
||||
SURFACE COPYING
|
||||
============================================================ */
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "../rgl_cg.h"
|
||||
|
||||
CGbool rglpSupportsVertexProgram( CGprofile p )
|
||||
static CGbool rglpSupportsVertexProgram( CGprofile p )
|
||||
{
|
||||
if ( p == CG_PROFILE_SCE_VP_TYPEB )
|
||||
return CG_TRUE;
|
||||
@ -28,7 +28,7 @@ CGbool rglpSupportsVertexProgram( CGprofile p )
|
||||
return CG_FALSE;
|
||||
}
|
||||
|
||||
CGbool rglpSupportsFragmentProgram( CGprofile p )
|
||||
static CGbool rglpSupportsFragmentProgram( CGprofile p )
|
||||
{
|
||||
if ( p == CG_PROFILE_SCE_FP_TYPEB )
|
||||
return CG_TRUE;
|
||||
@ -37,7 +37,7 @@ CGbool rglpSupportsFragmentProgram( CGprofile p )
|
||||
return CG_FALSE;
|
||||
}
|
||||
|
||||
CGprofile rglpGetLatestProfile( CGGLenum profile_type )
|
||||
static CGprofile rglpGetLatestProfile( CGGLenum profile_type )
|
||||
{
|
||||
switch ( profile_type )
|
||||
{
|
||||
@ -51,39 +51,7 @@ CGprofile rglpGetLatestProfile( CGGLenum profile_type )
|
||||
return CG_PROFILE_UNKNOWN;
|
||||
}
|
||||
|
||||
// uploads the given fp shader to gpu memory. Allocates if needed.
|
||||
// This also builds the shared constants push buffer if needed, since it depends on the load address
|
||||
static int rglpsLoadFPShader (void *data)
|
||||
{
|
||||
_CGprogram *program = (_CGprogram*)data;
|
||||
unsigned int ucodeSize = program->header.instructionCount * 16;
|
||||
|
||||
if ( program->loadProgramId == GMM_ERROR )
|
||||
{
|
||||
program->loadProgramId = gmmAlloc((CellGcmContextData*)&rglGcmState_i.fifo,
|
||||
CELL_GCM_LOCATION_LOCAL, 0, ucodeSize);
|
||||
program->loadProgramOffset = 0;
|
||||
}
|
||||
|
||||
rglGcmSend( program->loadProgramId, program->loadProgramOffset, 0, ( char* )program->ucode, ucodeSize );
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void rglpsUnloadFPShader (void *data)
|
||||
{
|
||||
_CGprogram *program = (_CGprogram*)data;
|
||||
|
||||
if ( program->loadProgramId != GMM_ERROR )
|
||||
{
|
||||
gmmFree( program->loadProgramId );
|
||||
program->loadProgramId = GMM_ERROR;
|
||||
program->loadProgramOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//new binary addition
|
||||
|
||||
int rglGcmGenerateProgram (void *data, int profileIndex, const CgProgramHeader *programHeader, const void *ucode, const CgParameterTableHeader *parameterHeader,
|
||||
static int rglGcmGenerateProgram (void *data, int profileIndex, const CgProgramHeader *programHeader, const void *ucode, const CgParameterTableHeader *parameterHeader,
|
||||
const CgParameterEntry *parameterEntries, const char *stringTable, const float *defaultValues )
|
||||
{
|
||||
_CGprogram *program = (_CGprogram*)data;
|
||||
@ -184,13 +152,18 @@ int rglGcmGenerateProgram (void *data, int profileIndex, const CgProgramHeader *
|
||||
if ( profileIndex == FRAGMENT_PROFILE_INDEX )
|
||||
{
|
||||
// always load fragment shaders.
|
||||
int loaded = rglpsLoadFPShader( program );
|
||||
if ( ! loaded )
|
||||
// uploads the given fp shader to gpu memory. Allocates if needed.
|
||||
// This also builds the shared constants push buffer if needed, since it depends on the load address
|
||||
unsigned int ucodeSize = program->header.instructionCount * 16;
|
||||
|
||||
if ( program->loadProgramId == GMM_ERROR )
|
||||
{
|
||||
//TODO: what do we need to delete here ?
|
||||
rglCgRaiseError( CG_MEMORY_ALLOC_ERROR );
|
||||
return 0;
|
||||
program->loadProgramId = gmmAlloc((CellGcmContextData*)&rglGcmState_i.fifo,
|
||||
CELL_GCM_LOCATION_LOCAL, 0, ucodeSize);
|
||||
program->loadProgramOffset = 0;
|
||||
}
|
||||
|
||||
rglGcmSend( program->loadProgramId, program->loadProgramOffset, 0, ( char* )program->ucode, ucodeSize );
|
||||
}
|
||||
|
||||
program->programGroup = NULL;
|
||||
@ -231,41 +204,7 @@ CGprogram rglpCgUpdateProgramAtIndex( CGprogramGroup group, int index, int refco
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//add the group to the context:
|
||||
static void rglCgAddGroup( CGcontext ctx, CGprogramGroup group )
|
||||
{
|
||||
_CGcontext *context = _cgGetContextPtr(ctx);
|
||||
if ( !context->groupList )
|
||||
context->groupList = group;
|
||||
else
|
||||
{
|
||||
_CGprogramGroup *current = context->groupList;
|
||||
while ( current->next )
|
||||
current = current->next;
|
||||
current->next = group;
|
||||
}
|
||||
}
|
||||
|
||||
static void rglCgRemoveGroup( CGcontext ctx, CGprogramGroup group )
|
||||
{
|
||||
_CGcontext *context = _cgGetContextPtr( ctx );
|
||||
_CGprogramGroup *current = context->groupList;
|
||||
_CGprogramGroup *previous = NULL;
|
||||
while ( current && current != group )
|
||||
{
|
||||
previous = current;
|
||||
current = current->next;
|
||||
}
|
||||
if ( current )
|
||||
{
|
||||
if ( !previous )
|
||||
context->groupList = current->next;
|
||||
else
|
||||
previous->next = current->next;
|
||||
}
|
||||
}
|
||||
|
||||
CGprogramGroup rglCgCreateProgramGroupFromFile( CGcontext ctx, const char *group_file )
|
||||
static CGprogramGroup rglCgCreateProgramGroupFromFile( CGcontext ctx, const char *group_file )
|
||||
{
|
||||
// check that file exists
|
||||
FILE* fp = fopen( group_file, "rb" );
|
||||
@ -362,7 +301,16 @@ CGprogramGroup rglCgCreateProgramGroup( CGcontext ctx, const char *name, void *
|
||||
memcpy(( char* )group + nvStringTableOffset, elfBinary.strtab, elfStringTableSize );
|
||||
|
||||
//add the group to the context:
|
||||
rglCgAddGroup( ctx, group );
|
||||
_CGcontext *context = _cgGetContextPtr(ctx);
|
||||
if ( !context->groupList )
|
||||
context->groupList = group;
|
||||
else
|
||||
{
|
||||
_CGprogramGroup *current = context->groupList;
|
||||
while ( current->next )
|
||||
current = current->next;
|
||||
current->next = group;
|
||||
}
|
||||
|
||||
//create all the shaders contained in the package and add them to the group
|
||||
for ( i = 0;i < ( int )group->programCount;i++ )
|
||||
@ -414,7 +362,21 @@ void rglCgDestroyProgramGroup( CGprogramGroup group )
|
||||
free( _group->name );
|
||||
|
||||
//remove the group from the group list
|
||||
rglCgRemoveGroup( group->ctx, group );
|
||||
_CGcontext *context = _cgGetContextPtr( group->ctx );
|
||||
_CGprogramGroup *current = context->groupList;
|
||||
_CGprogramGroup *previous = NULL;
|
||||
while ( current && current != group )
|
||||
{
|
||||
previous = current;
|
||||
current = current->next;
|
||||
}
|
||||
if ( current )
|
||||
{
|
||||
if ( !previous )
|
||||
context->groupList = current->next;
|
||||
else
|
||||
previous->next = current->next;
|
||||
}
|
||||
free( _group );
|
||||
}
|
||||
|
||||
@ -441,7 +403,11 @@ void rglpProgramErase (void *data)
|
||||
_CGprogram* program = (_CGprogram*)platformProgram;
|
||||
|
||||
if ( program->loadProgramId != GMM_ERROR )
|
||||
rglpsUnloadFPShader( program );
|
||||
{
|
||||
gmmFree( program->loadProgramId );
|
||||
program->loadProgramId = GMM_ERROR;
|
||||
program->loadProgramOffset = 0;
|
||||
}
|
||||
|
||||
//free the runtime parameters
|
||||
if ( program->runtimeParameters )
|
||||
@ -8701,23 +8667,6 @@ static int getSizeofSubArray(_CGNVCONTAINERS &containers, int dimensionIndex, in
|
||||
return res;
|
||||
}
|
||||
|
||||
/*static unsigned int constTableAddUnique( float *value )//128 bytes
|
||||
{
|
||||
unsigned int constTableSize = (int)_constTable.size();
|
||||
unsigned int i;
|
||||
for (i=0;i<constTableSize;i++)
|
||||
{
|
||||
if (!memcmp(value,(char*)(&_constTable[0])+i,sizeof(_float4)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
//not found add it:
|
||||
_constTable.push_back(*(_float4*)value);
|
||||
|
||||
return constTableSize;
|
||||
}*/
|
||||
|
||||
template<class Type> static void array_push(char* ¶meterOffset, std::vector<Type> &array)
|
||||
{
|
||||
size_t dataSize = array.size()*sizeof(array[0]);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <Cg/CgCommon.h>
|
||||
#include <Cg/cgBinary.h>
|
||||
|
||||
#include <ppu_intrinsics.h>
|
||||
|
||||
#include <RGL/platform.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -1918,7 +1920,40 @@ static GLuint rglValidateStates (GLuint mask)
|
||||
|
||||
if (RGL_UNLIKELY(needValidate & RGL_VALIDATE_VERTEX_PROGRAM))
|
||||
{
|
||||
rglSetNativeCgVertexProgram(LContext->BoundVertexProgram);
|
||||
const _CGprogram *program = (const _CGprogram*)LContext->BoundVertexProgram;
|
||||
__dcbt(program->ucode);
|
||||
__dcbt(((uint8_t*)program->ucode)+128);
|
||||
__dcbt(((uint8_t*)program->ucode)+256);
|
||||
__dcbt(((uint8_t*)program->ucode)+384);
|
||||
|
||||
CellCgbVertexProgramConfiguration conf;
|
||||
conf.instructionSlot = program->header.vertexProgram.instructionSlot;
|
||||
conf.instructionCount = program->header.instructionCount;
|
||||
conf.registerCount = program->header.vertexProgram.registerCount;
|
||||
conf.attributeInputMask = program->header.attributeInputMask;
|
||||
|
||||
rglGcmFifoWaitForFreeSpace( &rglGcmState_i.fifo, 7 + 5 * conf.instructionCount );
|
||||
|
||||
GCM_FUNC( cellGcmSetVertexProgramLoad, &conf, program->ucode );
|
||||
GCM_FUNC( cellGcmSetUserClipPlaneControl, 0, 0, 0, 0, 0, 0 );
|
||||
|
||||
rglGcmInterpolantState *s = &rglGcmState_i.state.interpolant;
|
||||
s->vertexProgramAttribMask = program->header.vertexProgram.attributeOutputMask;
|
||||
|
||||
GCM_FUNC( cellGcmSetVertexAttribOutputMask, (( s->vertexProgramAttribMask) &
|
||||
s->fragmentProgramAttribMask) );
|
||||
|
||||
int count = program->defaultValuesIndexCount;
|
||||
for ( int i = 0;i < count;i++ )
|
||||
{
|
||||
const CgParameterEntry *parameterEntry = program->parametersEntries + program->defaultValuesIndices[i].entryIndex;
|
||||
if (( parameterEntry->flags & CGPF_REFERENCED ) && ( parameterEntry->flags & CGPV_MASK ) == CGPV_CONSTANT )
|
||||
{
|
||||
const float *itemDefaultValues = program->defaultValues +
|
||||
program->defaultValuesIndices[i].defaultValueIndex;
|
||||
rglFifoGlProgramParameterfvVP( program, parameterEntry, itemDefaultValues );
|
||||
}
|
||||
}
|
||||
|
||||
// Set all uniforms.
|
||||
if(!(LContext->needValidate & RGL_VALIDATE_VERTEX_CONSTANTS) && LContext->BoundVertexProgram->parentContext)
|
||||
@ -1952,7 +1987,36 @@ static GLuint rglValidateStates (GLuint mask)
|
||||
_CGprogram *program = LContext->BoundFragmentProgram;
|
||||
|
||||
// params are set directly in the GPU memory, so there is nothing to be done here.
|
||||
rglSetNativeCgFragmentProgram( program );
|
||||
CellCgbFragmentProgramConfiguration conf;
|
||||
|
||||
conf.offset = gmmIdToOffset(program->loadProgramId) + program->loadProgramOffset;
|
||||
|
||||
rglGcmInterpolantState *s = &rglGcmState_i.state.interpolant;
|
||||
s->fragmentProgramAttribMask |= program->header.attributeInputMask | CELL_GCM_ATTRIB_OUTPUT_MASK_POINTSIZE;
|
||||
|
||||
conf.attributeInputMask = ( s->vertexProgramAttribMask) &
|
||||
s->fragmentProgramAttribMask;
|
||||
|
||||
conf.texCoordsInputMask = program->header.fragmentProgram.texcoordInputMask;
|
||||
conf.texCoords2D = program->header.fragmentProgram.texcoord2d;
|
||||
conf.texCoordsCentroid = program->header.fragmentProgram.texcoordCentroid;
|
||||
|
||||
int fragmentControl = ( 1 << 15 ) | ( 1 << 10 );
|
||||
fragmentControl |= program->header.fragmentProgram.flags & CGF_DEPTHREPLACE ? 0xE : 0x0;
|
||||
fragmentControl |= program->header.fragmentProgram.flags & CGF_OUTPUTFROMH0 ? 0x00 : 0x40;
|
||||
fragmentControl |= program->header.fragmentProgram.flags & CGF_PIXELKILL ? 0x80 : 0x00;
|
||||
|
||||
conf.fragmentControl = fragmentControl;
|
||||
conf.registerCount = program->header.fragmentProgram.registerCount < 2 ? 2 : program->header.fragmentProgram.registerCount;
|
||||
|
||||
uint32_t controlTxp = _CurrentContext->AllowTXPDemotion;
|
||||
conf.fragmentControl &= ~CELL_GCM_MASK_SET_SHADER_CONTROL_CONTROL_TXP;
|
||||
conf.fragmentControl |= controlTxp << CELL_GCM_SHIFT_SET_SHADER_CONTROL_CONTROL_TXP;
|
||||
|
||||
GCM_FUNC( cellGcmSetFragmentProgramLoad, &conf );
|
||||
|
||||
GCM_FUNC( cellGcmSetZMinMaxControl, ( program->header.fragmentProgram.flags & CGF_DEPTHREPLACE ) ? RGLGCM_FALSE : RGLGCM_TRUE, RGLGCM_FALSE, RGLGCM_FALSE );
|
||||
|
||||
driver->fpLoadProgramId = program->loadProgramId;
|
||||
driver->fpLoadProgramOffset = program->loadProgramOffset;
|
||||
}
|
||||
@ -2006,7 +2070,6 @@ static GLuint rglValidateStates (GLuint mask)
|
||||
return dirty;
|
||||
}
|
||||
|
||||
#include <ppu_intrinsics.h> /* TODO: move to platform-specific code */
|
||||
|
||||
const uint32_t c_rounded_size_ofrglDrawParams = (sizeof(rglDrawParams)+0x7f)&~0x7f;
|
||||
static uint8_t s_dparams_buff[ c_rounded_size_ofrglDrawParams ] __attribute__((aligned(128)));
|
||||
|
@ -78,9 +78,6 @@ typedef struct
|
||||
int index;
|
||||
} CGELFProgram;
|
||||
|
||||
extern CGbool rglpSupportsVertexProgram( CGprofile p );
|
||||
extern CGbool rglpSupportsFragmentProgram( CGprofile p );
|
||||
extern CGprofile rglpGetLatestProfile( CGGLenum profile_type );
|
||||
extern int rglpCopyProgram (void *src_data, void *dst_data);
|
||||
extern int rglpGenerateFragmentProgram (void *data,
|
||||
const CgProgramHeader *programHeader, const void *ucode,
|
||||
|
Loading…
x
Reference in New Issue
Block a user