Merge branch 'master' into gl-render

This commit is contained in:
Themaister 2013-03-28 12:15:39 +01:00
commit d1b204e63e
6 changed files with 430 additions and 3340 deletions

View File

@ -6,7 +6,6 @@
#include "../export/RGL/rgl.h"
#include "../RGL/private.h"
#include <vector>
#include <string>
#include "Cg/CgInternal.h"
@ -44,20 +43,6 @@ typedef struct CgRuntimeParameter
CGparameter id;
} CgRuntimeParameter;
typedef struct
{
CgRuntimeParameter* child;
CgRuntimeParameter* parent;
CgRuntimeParameter* top;
_cgSetArrayIndexFunction childOnBindSetter;
} CgParameterConnection;
typedef struct
{
CgRuntimeParameter* param;
std::vector<char> semantic;
} CgRuntimeSemantic;
struct _CGprogram
{
struct _CGprogram* next; // link to next in NULL-terminated singly linked list of programs
@ -83,8 +68,6 @@ struct _CGprogram
unsigned int * samplerIndices;
unsigned int * samplerUnits;
unsigned int controlFlowBools;
//binary format additions
//info previously contained in platformProgram ( loadAddress + nvBinary )
CgProgramHeader header;
@ -128,15 +111,6 @@ struct _CGprogram
_CGprogramGroup *programGroup;
int programIndexInGroup;
// supports runtime created parameters
std::vector<CgRuntimeParameter*> runtimeCreatedParameters;
// supports parameter connections
std::vector<CgParameterConnection> connectionTable;
// supports runtime allocation of semantics
std::vector<CgRuntimeSemantic> parameterSemantics;
//runtime compilation / conversion
void *runtimeElf;
};
@ -149,10 +123,6 @@ typedef struct _CGcontext
struct _CGprogram* programList; // head of singly linked list of programs
CGenum compileType; // compile manual, immediate or lazy (unused so far)
CGbool GLmanageTextures;
unsigned int controlFlowBoolsSharedMask;
unsigned int controlFlowBoolsShared;
// default program, fake owner of the context parameters
_CGprogram defaultProgram;
@ -171,16 +141,13 @@ RGL_EXPORT void rglCgRaiseError( CGerror error );
// interface between object types
extern void rglCgProgramDestroyAll( _CGcontext* c );
extern void rglCgDestroyContextParam( CgRuntimeParameter* p );
RGL_EXPORT CgRuntimeParameter*rglCgCreateParameterInternal( _CGprogram *program, const char* name, CGtype type );
RGL_EXPORT void rglCgProgramErase( _CGprogram* prog );
// default setters
void _cgRaiseInvalidParam( void *data, const void*v );
void _cgRaiseNotMatrixParam( void *data, const void*v );
void _cgIgnoreSetParam( void *dat, const void*v );
void _cgRaiseInvalidParamIndex( void *dat, const void*v, const int index );
void _cgRaiseNotMatrixParamIndex( void *dat, const void*v, const int index );
void _cgIgnoreSetParamIndex( void *dat, const void*v, const int index );
void _cgIgnoreParamIndex( void *dat, const void*v, const int index );
// cg helpers
@ -213,7 +180,6 @@ static inline bool isSampler (CGtype type)
unsigned int rglCountFloatsInCgType( CGtype type );
CGbool _cgMatrixDimensions( CGtype type, unsigned int* nrows, unsigned int* ncols );
unsigned int rglGetTypeRowCount( CGtype parameterType );
unsigned int rglGetTypeColCount( CGtype parameterType );
@ -250,51 +216,6 @@ static inline int rglGetSizeofSubArray( const unsigned short *dimensions, unsign
return res;
}
static inline CGresource rglGetBaseResource( CGresource resource )
{
switch ( resource )
{
case CG_ATTR0: case CG_ATTR1: case CG_ATTR2: case CG_ATTR3:
case CG_ATTR4: case CG_ATTR5: case CG_ATTR6: case CG_ATTR7:
case CG_ATTR8: case CG_ATTR9: case CG_ATTR10: case CG_ATTR11:
case CG_ATTR12: case CG_ATTR13: case CG_ATTR14: case CG_ATTR15:
return CG_ATTR0;
case CG_HPOS:
return CG_HPOS;
case CG_COL0: case CG_COL1: case CG_COL2: case CG_COL3:
return CG_COL0;
case CG_TEXCOORD0: case CG_TEXCOORD1: case CG_TEXCOORD2: case CG_TEXCOORD3:
case CG_TEXCOORD4: case CG_TEXCOORD5: case CG_TEXCOORD6: case CG_TEXCOORD7:
case CG_TEXCOORD8: case CG_TEXCOORD9:
return CG_TEXCOORD0;
case CG_TEXUNIT0: case CG_TEXUNIT1: case CG_TEXUNIT2: case CG_TEXUNIT3:
case CG_TEXUNIT4: case CG_TEXUNIT5: case CG_TEXUNIT6: case CG_TEXUNIT7:
case CG_TEXUNIT8: case CG_TEXUNIT9: case CG_TEXUNIT10: case CG_TEXUNIT11:
case CG_TEXUNIT12: case CG_TEXUNIT13: case CG_TEXUNIT14: case CG_TEXUNIT15:
return CG_TEXUNIT0;
case CG_FOGCOORD:
return CG_FOGCOORD;
case CG_PSIZ:
return CG_PSIZ;
case CG_WPOS:
return CG_WPOS;
case CG_COLOR0: case CG_COLOR1: case CG_COLOR2: case CG_COLOR3:
return CG_COLOR0;
case CG_DEPTH0:
return CG_DEPTH0;
case CG_C:
return CG_C;
case CG_B:
return CG_B;
case CG_CLP0: case CG_CLP1: case CG_CLP2: case CG_CLP3: case CG_CLP4: case CG_CLP5:
return CG_CLP0;
case CG_UNDEFINED:
return CG_UNDEFINED;
default:
return CG_UNDEFINED;
}
}
// platform API
CGprofile rglPlatformGetLatestProfile( CGGLenum profile_type );
int rglPlatformCopyProgram( _CGprogram* source, _CGprogram* destination );
@ -315,113 +236,6 @@ void rglPlatformSetFragmentRegisterBlock (unsigned int reg, unsigned int count,
void rglPlatformSetBoolVertexRegisters (unsigned int values );
// names API
RGL_EXPORT unsigned int _cgHashString (const char *str);
inline static void _pullConnectedParameterValues (void *data)
{
_CGprogram *ptr = (_CGprogram*)data;
// we now use a pull method to get the data into the children parameters
// when their program is bound they pull the data from their parents
std::vector<CgParameterConnection>::iterator connectionIter = ptr->connectionTable.begin();
while ( connectionIter != ptr->connectionTable.end() )
{
// pull data into connectionIter->child from connectionIter->top
connectionIter->childOnBindSetter( connectionIter->child, connectionIter->top->pushBufferPointer, 0 );
connectionIter++;
}
}
static inline void _cgGLBindVertexProgram (void *data)
{
_CGprogram *program = (_CGprogram*)data;
// the program is a vertex program, just update the GL state
_CurrentContext->BoundVertexProgram = program;
// and inform the GL state to re-upload the vertex program
_CurrentContext->needValidate |= PSGL_VALIDATE_VERTEX_PROGRAM;
// This must happen before the sampler setters so texture parameters have the correct value in their push buffers for that routine
_pullConnectedParameterValues( program );
CGbool is_managed = program->parentContext->GLmanageTextures;
// enable texture parameters if the managed flag is set.
if ( is_managed )
{
for ( GLuint index = 0; index < program->samplerCount; ++index )
{
// walk the array of sampler parameters
CgRuntimeParameter *rtParameter = program->runtimeParameters + program->samplerIndices[index];
rtParameter->samplerSetter( rtParameter, NULL, 0 );
}
}
}
static inline void _cgGLBindFragmentProgram (void *data)
{
_CGprogram *program = (_CGprogram*)data;
_CurrentContext->BoundFragmentProgram = program;
// need to revalidate the textures in order to update which targets to fetch from
_CurrentContext->needValidate |= PSGL_VALIDATE_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_FRAGMENT_SHARED_CONSTANTS;
// This must happen before the sampler setters so texture parameters have the correct value in their push buffers for that routine
_pullConnectedParameterValues( program );
// TODO: push texture state
// Needs to be done per profile. Can't use glPushAttrib.
CGbool is_managed = program->parentContext->GLmanageTextures;
// deal with the texture parameters now.
for ( GLuint index = 0; index < program->samplerCount; ++index )
{
// walk the array of sampler parameters
CgRuntimeParameter *rtParameter = program->runtimeParameters + program->samplerIndices[index];
CgParameterResource *parameter = ( CgParameterResource * )( program->parameterResources + rtParameter->parameterEntry->typeIndex );
// find out which texture unit this parameter has been assigned to
unsigned int unit = parameter->resource - CG_TEXUNIT0;
_CurrentContext->TextureImageUnits[unit].fragmentTarget = rtParameter->glType;
// enable texture parameters if the managed flag is set.
if ( is_managed )
{
//tmp
rtParameter->samplerSetter( rtParameter, NULL, 0 );
}
else
{
rglUpdateCurrentTextureCache( &_CurrentContext->TextureImageUnits[unit] );
}
}
}
static inline void _cgGLUnbindVertexProgram (void)
{
_CurrentContext->BoundVertexProgram = NULL;
_CurrentContext->needValidate |= PSGL_VALIDATE_VERTEX_PROGRAM;
}
static inline void rglLeaveFFXFP (void *data)
{
RGLcontext *LContext = (RGLcontext*)data;
LContext->FragmentProgram = GL_TRUE;
struct _CGprogram* current = LContext->BoundFragmentProgram;
if ( current )
{
for ( GLuint i = 0; i < current->samplerCount; ++i )
{
int unit = current->samplerUnits[i];
rglUpdateCurrentTextureCache( &_CurrentContext->TextureImageUnits[unit] );
}
}
LContext->needValidate |= PSGL_VALIDATE_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED | PSGL_VALIDATE_FRAGMENT_SHARED_CONSTANTS;
}
static inline void _cgGLUnbindFragmentProgram (void)
{
_CurrentContext->BoundFragmentProgram = NULL;
}
static inline GLenum rglCgGetSamplerGLTypeFromCgType( CGtype type )
{
@ -440,25 +254,11 @@ static inline GLenum rglCgGetSamplerGLTypeFromCgType( CGtype type )
}
}
static inline int is_created_param( CgRuntimeParameter* ptr )
{
if ( ptr->parameterEntry->flags & CGP_RTCREATED )
return 1;
return 0;
}
struct rglNameSpace;
#define VERTEX_PROFILE_INDEX 0
#define FRAGMENT_PROFILE_INDEX 1
// these functions return the statically allocated table of function pointers originally
// written for NV unshared vertex parameter setters, but now also used by runtime
// created parameters cause these setters just do straight copies into the pushbuffer memory
//
_cgSetArrayIndexFunction getVectorTypeIndexSetterFunction( unsigned short a, unsigned short b, unsigned short c, unsigned short d );
_cgSetArrayIndexFunction getMatrixTypeIndexSetterFunction( unsigned short a, unsigned short b, unsigned short c, unsigned short d, unsigned short e, unsigned short f );
// -------------------------------------------
typedef void( * CgcontextHookFunction )( _CGcontext *context );
@ -483,12 +283,6 @@ extern RGL_EXPORT cgRTCgcFreeHookFunction _cgRTCgcFreeCompiledProgramHook;
//-----------------------------------------------
//inlined helper functions
static inline int rglGetParameterType (const void *data, const CgParameterEntry *entry)
{
const CGprogram *program = (const CGprogram*)data;
return (entry->flags & CGP_TYPE_MASK);
}
static inline const CgParameterResource *rglGetParameterResource (const void *data, const CgParameterEntry *entry )
{
const _CGprogram *program = (const _CGprogram*)data;

View File

@ -86,7 +86,7 @@ static inline void rglTextureTouchFBOs (void *data)
rglFramebuffer* framebuffer = texture->framebuffers[i];
framebuffer->needValidate = GL_TRUE;
if (RGL_UNLIKELY( framebuffer == contextFramebuffer))
LContext->needValidate |= PSGL_VALIDATE_SCISSOR_BOX | PSGL_VALIDATE_FRAMEBUFFER;
LContext->needValidate |= PSGL_VALIDATE_FRAMEBUFFER;
}
}
}
@ -199,7 +199,6 @@ void rglPlatformGetImageData( GLenum target, GLint level, rglTexture *texture, r
//----------------------------------------
// Raster/.../PlatformFBops.c
//----------------------------------------
extern void rglValidateFramebuffer( void );
extern void rglPlatformReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLboolean flip, GLenum format, GLenum type, GLvoid *pixels );
extern GLboolean rglPlatformReadPBOPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLboolean flip, GLenum format, GLenum type, GLvoid *pixels );

View File

@ -196,224 +196,6 @@ static inline GLuint rglGcmMapWrapMode( GLuint mode )
return 0;
}
static inline void rglGcmMapTextureFormat( GLuint internalFormat, uint8_t *gcmFormat, uint32_t *remap )
{
*gcmFormat = 0;
switch (internalFormat)
{
case RGLGCM_ALPHA8: // in_rgba = xxAx, out_rgba = 000A
{
*gcmFormat = CELL_GCM_TEXTURE_B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO );
}
break;
case RGLGCM_ALPHA16: // in_rgba = xAAx, out_rgba = 000A
{
*gcmFormat = CELL_GCM_TEXTURE_X16;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO );
}
break;
case RGLGCM_HILO8: // in_rgba = HLxx, out_rgba = HL11
{
*gcmFormat = CELL_GCM_TEXTURE_COMPRESSED_HILO8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ONE );
}
break;
case RGLGCM_HILO16: // in_rgba = HLxx, out_rgba = HL11
{
*gcmFormat = CELL_GCM_TEXTURE_Y16_X16;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ONE );
}
break;
case RGLGCM_ARGB8: // in_rgba = RGBA, out_rgba = RGBA
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_BGRA8: // in_rgba = GRAB, out_rgba = RGBA ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_RGBA8: // in_rgba = GBAR, out_rgba = RGBA ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_ABGR8: // in_rgba = BGRA, out_rgba = RGBA ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_RGBX8: // in_rgba = BGRA, out_rgba = RGB1 ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_XBGR8: // in_rgba = BGRA, out_rgba = RGB1 ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_FLOAT_R32: // in_rgba = Rxxx, out_rgba = R001
{
*gcmFormat = CELL_GCM_TEXTURE_X32_FLOAT;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO );
}
break;
case RGLGCM_RGB5_A1_SCE: // in_rgba = RGBA, out_rgba = RGBA
{
*gcmFormat = CELL_GCM_TEXTURE_A1R5G5B5;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XXXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_RGB565_SCE: // in_rgba = RGBA, out_rgba = RGBA
{
*gcmFormat = CELL_GCM_TEXTURE_R5G6B5;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XXXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
default:
break;
}
}
// Fast conversion for values between 0.0 and 65535.0
static inline GLuint RGLGCM_QUICK_FLOAT2UINT (const GLfloat f)
{
@ -461,99 +243,6 @@ static inline void rglGcmUtilWaitForIdle (void)
rglGcmState_i.labelValue++;
}
// Sets the source and destination factor used for blending.
static inline void rglGcmFifoGlBlendFunc( rglGcmEnum sf, rglGcmEnum df, rglGcmEnum sfAlpha, rglGcmEnum dfAlpha )
{
// syntax check
switch ( sf )
{
case RGLGCM_ZERO:
case RGLGCM_ONE:
case RGLGCM_SRC_COLOR:
case RGLGCM_ONE_MINUS_SRC_COLOR:
case RGLGCM_SRC_ALPHA:
case RGLGCM_ONE_MINUS_SRC_ALPHA:
case RGLGCM_DST_ALPHA:
case RGLGCM_ONE_MINUS_DST_ALPHA:
case RGLGCM_DST_COLOR:
case RGLGCM_ONE_MINUS_DST_COLOR:
case RGLGCM_SRC_ALPHA_SATURATE:
case RGLGCM_CONSTANT_COLOR:
case RGLGCM_ONE_MINUS_CONSTANT_COLOR:
case RGLGCM_CONSTANT_ALPHA:
case RGLGCM_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
break;
}
switch ( sfAlpha )
{
case RGLGCM_ZERO:
case RGLGCM_ONE:
case RGLGCM_SRC_COLOR:
case RGLGCM_ONE_MINUS_SRC_COLOR:
case RGLGCM_SRC_ALPHA:
case RGLGCM_ONE_MINUS_SRC_ALPHA:
case RGLGCM_DST_ALPHA:
case RGLGCM_ONE_MINUS_DST_ALPHA:
case RGLGCM_DST_COLOR:
case RGLGCM_ONE_MINUS_DST_COLOR:
case RGLGCM_SRC_ALPHA_SATURATE:
case RGLGCM_CONSTANT_COLOR:
case RGLGCM_ONE_MINUS_CONSTANT_COLOR:
case RGLGCM_CONSTANT_ALPHA:
case RGLGCM_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
break;
}
switch ( df )
{
case RGLGCM_ZERO:
case RGLGCM_ONE:
case RGLGCM_SRC_COLOR:
case RGLGCM_ONE_MINUS_SRC_COLOR:
case RGLGCM_SRC_ALPHA:
case RGLGCM_ONE_MINUS_SRC_ALPHA:
case RGLGCM_DST_ALPHA:
case RGLGCM_ONE_MINUS_DST_ALPHA:
case RGLGCM_DST_COLOR:
case RGLGCM_ONE_MINUS_DST_COLOR:
case RGLGCM_SRC_ALPHA_SATURATE:
case RGLGCM_CONSTANT_COLOR:
case RGLGCM_ONE_MINUS_CONSTANT_COLOR:
case RGLGCM_CONSTANT_ALPHA:
case RGLGCM_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
break;
}
switch ( dfAlpha )
{
case RGLGCM_ZERO:
case RGLGCM_ONE:
case RGLGCM_SRC_COLOR:
case RGLGCM_ONE_MINUS_SRC_COLOR:
case RGLGCM_SRC_ALPHA:
case RGLGCM_ONE_MINUS_SRC_ALPHA:
case RGLGCM_DST_ALPHA:
case RGLGCM_ONE_MINUS_DST_ALPHA:
case RGLGCM_DST_COLOR:
case RGLGCM_ONE_MINUS_DST_COLOR:
case RGLGCM_SRC_ALPHA_SATURATE:
case RGLGCM_CONSTANT_COLOR:
case RGLGCM_ONE_MINUS_CONSTANT_COLOR:
case RGLGCM_CONSTANT_ALPHA:
case RGLGCM_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
break;
}
GCM_FUNC( cellGcmSetBlendFunc, sf, df, sfAlpha, dfAlpha );
}
// Prints out an int in hexedecimal and binary, broken into bytes.
// Can be used for printing out macro and constant values.
// example: rglPrintIt( RGLGCM_3DCONST(SET_SURFACE_FORMAT, COLOR, LE_A8R8G8B8) );
@ -599,71 +288,6 @@ static inline void rglGcmFifoGlIncFenceRef (GLuint *ref)
*ref = rglGcmFifoPutReference( fifo );
}
// Flush the current FIFO.
static inline void rglGcmFifoGlFlush (void)
{
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFlush( &rglGcmState_i.fifo );
}
// Set blending constant, used for certain blending modes.
static inline void rglGcmFifoGlBlendColor( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
{
rglGcmBlendState *blend = &rglGcmState_i.state.blend;
GLuint hwColor;
// syntax check
blend->r = r;
blend->g = g;
blend->b = b;
blend->a = a;
// program hw
switch ( rglGcmState_i.renderTarget.colorFormat )
{
case RGLGCM_ARGB8:
RGLGCM_CALC_COLOR_LE_ARGB8( &hwColor, r, g, b, a );
GCM_FUNC( cellGcmSetBlendColor, hwColor, hwColor );
break;
case RGLGCM_NONE:
case RGLGCM_FLOAT_R32:
// no native support support
break;
default:
break;
}
}
// Set the current blend equation.
static inline void rglGcmFifoGlBlendEquation( rglGcmEnum mode, rglGcmEnum modeAlpha )
{
// syntax check
switch ( mode )
{
case RGLGCM_FUNC_ADD:
case RGLGCM_MIN:
case RGLGCM_MAX:
case RGLGCM_FUNC_SUBTRACT:
case RGLGCM_FUNC_REVERSE_SUBTRACT:
break;
default:
break;
}
switch ( modeAlpha )
{
case RGLGCM_FUNC_ADD:
case RGLGCM_MIN:
case RGLGCM_MAX:
case RGLGCM_FUNC_SUBTRACT:
case RGLGCM_FUNC_REVERSE_SUBTRACT:
break;
default:
break;
}
GCM_FUNC( cellGcmSetBlendEquation, mode, modeAlpha );
}
static inline void rglGcmFifoGlVertexAttribPointer
(
GLuint index,
@ -729,44 +353,6 @@ static inline void rglGcmFifoGlVertexAttribPointer
GCM_FUNC( cellGcmSetVertexDataArray, index, frequency, stride, size, gcmType, CELL_GCM_LOCATION_LOCAL, offset );
}
static inline void rglGcmFifoGlEnable( rglGcmEnum cap )
{
switch (cap)
{
case RGLGCM_BLEND:
GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_TRUE );
GCM_FUNC( cellGcmSetBlendEnableMrt, RGLGCM_TRUE, RGLGCM_TRUE, RGLGCM_TRUE );
break;
case RGLGCM_DITHER:
GCM_FUNC( cellGcmSetDitherEnable, RGLGCM_TRUE );
break;
case RGLGCM_PSHADER_SRGB_REMAPPING:
GCM_FUNC( cellGcmSetFragmentProgramGammaEnable, RGLGCM_TRUE );
break;
default:
break;
}
}
static inline void rglGcmFifoGlDisable( rglGcmEnum cap )
{
switch (cap)
{
case RGLGCM_BLEND:
GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_FALSE );
GCM_FUNC( cellGcmSetBlendEnableMrt, RGLGCM_FALSE, RGLGCM_FALSE, RGLGCM_FALSE );
break;
case RGLGCM_DITHER:
GCM_FUNC( cellGcmSetDitherEnable, RGLGCM_FALSE );
break;
case RGLGCM_PSHADER_SRGB_REMAPPING:
GCM_FUNC( cellGcmSetFragmentProgramGammaEnable, RGLGCM_FALSE );
break;
default:
break;
}
}
// Look up the memory location of a buffer object (VBO, PBO)
static inline GLuint rglGcmGetBufferObjectOrigin (GLuint buffer)
{

View File

@ -1570,19 +1570,20 @@ void rglGcmSetOpenGLState (void *data)
GLuint i;
// initialize the default OpenGL state
rglGcmFifoGlBlendColor( 0.0f, 0.0f, 0.0f, 0.0f );
rglGcmFifoGlBlendEquation( RGLGCM_FUNC_ADD, RGLGCM_FUNC_ADD );
rglGcmFifoGlBlendFunc( RGLGCM_ONE, RGLGCM_ZERO, RGLGCM_ONE, RGLGCM_ZERO );
GCM_FUNC( cellGcmSetBlendColor, 0, 0);
GCM_FUNC( cellGcmSetBlendEquation, RGLGCM_FUNC_ADD, RGLGCM_FUNC_ADD );
GCM_FUNC( cellGcmSetBlendFunc, RGLGCM_ONE, RGLGCM_ZERO, RGLGCM_ONE, RGLGCM_ZERO );
GCM_FUNC( cellGcmSetClearColor, 0 );
rglGcmFifoGlDisable( RGLGCM_BLEND );
rglGcmFifoGlDisable( RGLGCM_PSHADER_SRGB_REMAPPING );
GCM_FUNC( cellGcmSetBlendEnable, RGLGCM_FALSE );
GCM_FUNC( cellGcmSetBlendEnableMrt, RGLGCM_FALSE, RGLGCM_FALSE, RGLGCM_FALSE );
GCM_FUNC( cellGcmSetFragmentProgramGammaEnable, RGLGCM_FALSE );
for ( i = 0; i < RGLGCM_ATTRIB_COUNT; i++ )
{
GCM_FUNC( cellGcmSetVertexDataArray, i, 0, 0, 0, CELL_GCM_VERTEX_F, CELL_GCM_LOCATION_LOCAL, 0);
}
rglGcmFifoGlEnable( RGLGCM_DITHER );
GCM_FUNC( cellGcmSetDitherEnable, RGLGCM_TRUE );
for ( i = 0; i < RGLGCM_MAX_TEXIMAGE_COUNT; i++ )
{
@ -1895,7 +1896,8 @@ void rglPsglPlatformExit(void)
if ( LContext )
{
rglGcmFifoGlFlush();
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFlush( &rglGcmState_i.fifo );
psglMakeCurrent( NULL, NULL );
rglDeviceExit();
@ -3145,17 +3147,19 @@ GLAPI void RGL_EXPORT psglSwap (void)
const char * __restrict v = driver->sharedVPConstants;
GCM_FUNC( cellGcmSetVertexProgramParameterBlock, 0, 8, ( float* )v ); // GCM_PORT_UNTESTED [KHOFF]
rglGcmFifoGlEnable( RGLGCM_DITHER );
GCM_FUNC( cellGcmSetDitherEnable, RGLGCM_TRUE );
RGLcontext *context = (RGLcontext*)_CurrentContext;
context->needValidate = RGL_VALIDATE_ALL;
context->attribs->DirtyMask = ( 1 << RGL_MAX_VERTEX_ATTRIBS ) - 1;
rglGcmFifoGlFlush();
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFlush( &rglGcmState_i.fifo );
while (sys_semaphore_wait(FlipSem,1000) != CELL_OK);
rglGcmFifoGlFlush();
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFlush( &rglGcmState_i.fifo );
if ( device->deviceParameters.bufferingMode == RGL_BUFFERING_MODE_DOUBLE )
{
@ -3476,7 +3480,7 @@ GLAPI void APIENTRY glBindFramebufferOES( GLenum target, GLuint framebuffer )
rglTexNameSpaceCreateNameLazy( &LContext->framebufferNameSpace, framebuffer );
LContext->framebuffer = framebuffer;
LContext->needValidate |= RGL_VALIDATE_SCISSOR_BOX | RGL_VALIDATE_FRAMEBUFFER;
LContext->needValidate |= RGL_VALIDATE_FRAMEBUFFER;
}
GLAPI void APIENTRY glDeleteFramebuffersOES( GLsizei n, const GLuint *framebuffers )
@ -3541,7 +3545,7 @@ GLAPI void APIENTRY glFramebufferTexture2DOES( GLenum target, GLenum attachment,
attach->textureTarget = textarget;
framebuffer->needValidate = GL_TRUE;
LContext->needValidate |= RGL_VALIDATE_SCISSOR_BOX | RGL_VALIDATE_FRAMEBUFFER;
LContext->needValidate |= RGL_VALIDATE_FRAMEBUFFER;
}
@ -4530,10 +4534,6 @@ GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param )
texture->vertexEnable = GL_FALSE;
texture->revalidate |= RGL_TEXTURE_REVALIDATE_LAYOUT;
break;
case GL_TEXTURE_ALLOCATION_HINT_SCE:
texture->usage = param;
texture->revalidate |= RGL_TEXTURE_REVALIDATE_LAYOUT;
break;
case GL_TEXTURE_COMPARE_MODE_ARB:
texture->compareMode = param;
break;
@ -4776,7 +4776,7 @@ void RGL_EXPORT psglMakeCurrent (RGLcontext *context, RGLdevice *device)
{
context->ViewPort.XSize = device->deviceParameters.width;
context->ViewPort.YSize = device->deviceParameters.height;
context->needValidate |= RGL_VALIDATE_VIEWPORT | RGL_VALIDATE_SCISSOR_BOX;
context->needValidate |= RGL_VALIDATE_VIEWPORT;
context->everAttached = GL_TRUE;
}

File diff suppressed because it is too large Load Diff

View File

@ -131,7 +131,6 @@ template<int SIZE> static void setVectorTypeSharedfpIndex (void *data, const voi
values[3] = ( 3 < SIZE ) ? SWAP_IF_BIG_ENDIAN( vi[3] ) : 0;
GCM_FUNC( cellGcmInlineTransfer, dstVidOffset, values, 4, 0 );
LContext->needValidate |= RGL_VALIDATE_FRAGMENT_SHARED_CONSTANTS;
// XXX we don't care about 32bit wrapping, do we ?
++LContext->LastFPConstantModification;
}
@ -164,7 +163,6 @@ template<int SIZE> static void setVectorTypeSharedfpIndexArray (void *data, cons
values[3] = ( 3 < SIZE ) ? SWAP_IF_BIG_ENDIAN( vi[3] ) : 0;
GCM_FUNC( cellGcmInlineTransfer, dstVidOffset, values, 4, 0 );
LContext->needValidate |= RGL_VALIDATE_FRAGMENT_SHARED_CONSTANTS;
// XXX we don't care about 32bit wrapping, do we ?
++LContext->LastFPConstantModification;
}
@ -359,7 +357,6 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndex (voi
}
RGLcontext * LContext = _CurrentContext;
LContext->needValidate |= RGL_VALIDATE_FRAGMENT_SHARED_CONSTANTS;
++LContext->LastFPConstantModification;
}
@ -408,7 +405,6 @@ template <int ROWS, int COLS, int ORDER> static void setMatrixSharedfpIndexArray
}
RGLcontext * LContext = _CurrentContext;
LContext->needValidate |= RGL_VALIDATE_FRAGMENT_SHARED_CONSTANTS;
++LContext->LastFPConstantModification;
}
@ -563,16 +559,6 @@ static _cgSetArrayIndexFunction setMatrixTypeIndex[2][2][2][4][4][2] =
}
};
_cgSetArrayIndexFunction getVectorTypeIndexSetterFunction( unsigned short a, unsigned short b, unsigned short c, unsigned short d )
{
return setVectorTypeIndex[a][b][c][d];
}
_cgSetArrayIndexFunction getMatrixTypeIndexSetterFunction( unsigned short a, unsigned short b, unsigned short c, unsigned short d, unsigned short e, unsigned short f )
{
return setMatrixTypeIndex[a][b][c][d][e][f];
}
static void setSamplerfp (void *data, const void*v, int /* index */)
{
CgRuntimeParameter *ptr = (CgRuntimeParameter*)data;
@ -774,15 +760,12 @@ void rglCreatePushBuffer(void *data)
if ( containerEntry == NULL )
containerEntry = parameterEntry;
//rtParameter->setter = _cgRaiseInvalidParam;
//rtParameter->setterr = _cgRaiseNotMatrixParam;
//rtParameter->setterc = _cgRaiseNotMatrixParam;
rtParameter->samplerSetter = _cgRaiseInvalidParamIndex;
rtParameter->samplerSetter = _cgIgnoreParamIndex;
//tentative
rtParameter->setterIndex = _cgRaiseInvalidParamIndex;
rtParameter->setterrIndex = _cgRaiseNotMatrixParamIndex;
rtParameter->settercIndex = _cgRaiseNotMatrixParamIndex;
rtParameter->setterIndex = _cgIgnoreParamIndex;
rtParameter->setterrIndex = _cgIgnoreParamIndex;
rtParameter->settercIndex = _cgIgnoreParamIndex;
CGparameter id = ( CGparameter )rglCreateName( &_CurrentContext->cgParameterNameSpace, ( void* )rtParameter );
if ( !id )
@ -837,7 +820,7 @@ void rglCreatePushBuffer(void *data)
// the parameters should have a "validate" function instead
if ( profileIndex == VERTEX_PROFILE_INDEX )
{
rtParameter->setterIndex = _cgIgnoreSetParamIndex;
rtParameter->setterIndex = _cgIgnoreParamIndex;
rtParameter->samplerSetter = setSamplervp;
}
else
@ -1005,17 +988,17 @@ void rglCreatePushBuffer(void *data)
{
case CG_FLOAT:
case CG_FLOAT1: case CG_FLOAT2: case CG_FLOAT3: case CG_FLOAT4:
rtParameter->setterIndex = _cgIgnoreSetParamIndex;
rtParameter->setterIndex = _cgIgnoreParamIndex;
break;
case CG_FLOAT1x1: case CG_FLOAT1x2: case CG_FLOAT1x3: case CG_FLOAT1x4:
case CG_FLOAT2x1: case CG_FLOAT2x2: case CG_FLOAT2x3: case CG_FLOAT2x4:
case CG_FLOAT3x1: case CG_FLOAT3x2: case CG_FLOAT3x3: case CG_FLOAT3x4:
case CG_FLOAT4x1: case CG_FLOAT4x2: case CG_FLOAT4x3: case CG_FLOAT4x4:
rtParameter->setterrIndex = _cgIgnoreSetParamIndex;
rtParameter->settercIndex = _cgIgnoreSetParamIndex;
rtParameter->setterrIndex = _cgIgnoreParamIndex;
rtParameter->settercIndex = _cgIgnoreParamIndex;
break;
case CG_SAMPLER1D: case CG_SAMPLER2D: case CG_SAMPLER3D: case CG_SAMPLERRECT: case CG_SAMPLERCUBE:
rtParameter->samplerSetter = _cgIgnoreSetParamIndex;
rtParameter->samplerSetter = _cgIgnoreParamIndex;
break;
case CGP_SCF_BOOL:
break;
@ -1027,7 +1010,7 @@ void rglCreatePushBuffer(void *data)
case CG_BOOL1: case CG_BOOL2: case CG_BOOL3: case CG_BOOL4:
case CG_FIXED:
case CG_FIXED1: case CG_FIXED2: case CG_FIXED3: case CG_FIXED4:
rtParameter->setterIndex = _cgIgnoreSetParamIndex;
rtParameter->setterIndex = _cgIgnoreParamIndex;
break;
case CG_HALF1x1: case CG_HALF1x2: case CG_HALF1x3: case CG_HALF1x4:
case CG_HALF2x1: case CG_HALF2x2: case CG_HALF2x3: case CG_HALF2x4:
@ -1045,8 +1028,8 @@ void rglCreatePushBuffer(void *data)
case CG_FIXED2x1: case CG_FIXED2x2: case CG_FIXED2x3: case CG_FIXED2x4:
case CG_FIXED3x1: case CG_FIXED3x2: case CG_FIXED3x3: case CG_FIXED3x4:
case CG_FIXED4x1: case CG_FIXED4x2: case CG_FIXED4x3: case CG_FIXED4x4:
rtParameter->setterrIndex = _cgIgnoreSetParamIndex;
rtParameter->settercIndex = _cgIgnoreSetParamIndex;
rtParameter->setterrIndex = _cgIgnoreParamIndex;
rtParameter->settercIndex = _cgIgnoreParamIndex;
break;
// addition to be compatible with cgc 2.0
case CG_STRING:
@ -1322,6 +1305,41 @@ GLboolean rglPlatformBufferObjectUnmap (void *data)
PLATFORM FRAMEBUFFER
============================================================ */
// set render targets
static void rglValidateFramebuffer (void)
{
RGLdevice *LDevice = _CurrentDevice;
rglGcmDevice *gcmDevice = ( rglGcmDevice * )LDevice->platformDevice;
RGLcontext* LContext = _CurrentContext;
rglGcmDriver *gcmDriver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
// reset buffer data
gcmDriver->rtValid = GL_FALSE;
// get buffer parameters
// This may come from a framebuffer_object or the default framebuffer.
//
gcmDriver->rt = gcmDevice->rt;
if (LContext->framebuffer)
{
rglPlatformFramebuffer* framebuffer = (rglPlatformFramebuffer *)rglGetFramebuffer(LContext, LContext->framebuffer);
if (framebuffer->needValidate)
framebuffer->validate( LContext );
gcmDriver->rt = framebuffer->rt;
}
gcmDriver->rtValid = GL_TRUE;
// update GPU configuration
rglGcmFifoGlSetRenderTarget( &gcmDriver->rt );
LContext->needValidate &= ~RGL_VALIDATE_FRAMEBUFFER;
LContext->needValidate |= RGL_VALIDATE_VIEWPORT;
}
GLAPI void APIENTRY glClear( GLbitfield mask )
{
RGLcontext* LContext = _CurrentContext;
@ -1404,12 +1422,13 @@ GLAPI void APIENTRY glClear( GLbitfield mask )
int clearcolor = 0;
GCM_FUNC( cellGcmSetVertexData4f, RGL_ATTRIB_PRIMARY_COLOR_INDEX, ( GLfloat* )&clearcolor );
LContext->needValidate |= RGL_VALIDATE_WRITE_MASK | RGL_VALIDATE_FRAGMENT_PROGRAM;
LContext->needValidate |= RGL_VALIDATE_FRAGMENT_PROGRAM;
gmmFree( bufferId );
}
rglGcmFifoGlFlush();
GCM_FUNC_NO_ARGS( cellGcmSetInvalidateVertexCache );
rglGcmFifoFlush( &rglGcmState_i.fifo );
}
rglFramebuffer* rglCreateFramebuffer (void)
@ -1570,41 +1589,6 @@ void rglPlatformFramebuffer::validate (void *data)
needValidate = GL_FALSE;
}
// set render targets
void rglValidateFramebuffer (void)
{
RGLdevice *LDevice = _CurrentDevice;
rglGcmDevice *gcmDevice = ( rglGcmDevice * )LDevice->platformDevice;
RGLcontext* LContext = _CurrentContext;
rglGcmDriver *gcmDriver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
// reset buffer data
gcmDriver->rtValid = GL_FALSE;
// get buffer parameters
// This may come from a framebuffer_object or the default framebuffer.
if (LContext->framebuffer)
{
rglPlatformFramebuffer* framebuffer = (rglPlatformFramebuffer *)rglGetFramebuffer(LContext, LContext->framebuffer);
if (framebuffer->needValidate)
framebuffer->validate( LContext );
gcmDriver->rt = framebuffer->rt;
}
else // use default framebuffer
gcmDriver->rt = gcmDevice->rt;
gcmDriver->rtValid = GL_TRUE;
// update GPU configuration
rglGcmFifoGlSetRenderTarget( &gcmDriver->rt );
LContext->needValidate &= ~RGL_VALIDATE_FRAMEBUFFER;
LContext->needValidate |= RGL_VALIDATE_VIEWPORT | RGL_VALIDATE_SCISSOR_BOX
| RGL_VALIDATE_WRITE_MASK;
}
/*============================================================
PLATFORM RASTER
@ -1997,15 +1981,23 @@ static inline void rglValidateStates (GLuint mask)
{
GCM_FUNC( cellGcmSetBlendEnable, LContext->Blending );
rglGcmFifoGlBlendColor(
LContext->BlendColor.R,
LContext->BlendColor.G,
LContext->BlendColor.B,
LContext->BlendColor.A);
rglGcmFifoGlBlendEquation(
(rglGcmEnum)LContext->BlendEquationRGB,
(rglGcmEnum)LContext->BlendEquationAlpha);
rglGcmFifoGlBlendFunc((rglGcmEnum)LContext->BlendFactorSrcRGB,(rglGcmEnum)LContext->BlendFactorDestRGB,(rglGcmEnum)LContext->BlendFactorSrcAlpha,(rglGcmEnum)LContext->BlendFactorDestAlpha);
rglGcmBlendState *blend = &rglGcmState_i.state.blend;
GLuint hwColor;
blend->r = LContext->BlendColor.R;
blend->g = LContext->BlendColor.G;
blend->b = LContext->BlendColor.B;
blend->a = LContext->BlendColor.A;
if (rglGcmState_i.renderTarget.colorFormat == RGLGCM_ARGB8)
{
RGLGCM_CALC_COLOR_LE_ARGB8( &hwColor, blend->r, blend->g, blend->b, blend->a );
GCM_FUNC( cellGcmSetBlendColor, hwColor, hwColor );
}
GCM_FUNC( cellGcmSetBlendEquation, (rglGcmEnum)LContext->BlendEquationRGB,
(rglGcmEnum)LContext->BlendEquationAlpha );
GCM_FUNC( cellGcmSetBlendFunc, (rglGcmEnum)LContext->BlendFactorSrcRGB,(rglGcmEnum)LContext->BlendFactorDestRGB,(rglGcmEnum)LContext->BlendFactorSrcAlpha,(rglGcmEnum)LContext->BlendFactorDestAlpha);
}
}
@ -2301,240 +2293,6 @@ void rglPlatformDropTexture (void *data)
rglTextureTouchFBOs( texture );
}
// Drop unbound textures from the GPU memory
// This is kind of slow, but we hit a slow path anyway.
// If the pool argument is not RGLGCM_SURFACE_POOL_NONE, then only textures
// in the specified pool will be dropped.
void rglPlatformDropUnboundTextures (GLenum pool)
{
RGLcontext* LContext = _CurrentContext;
GLuint i, j;
for (i = 0; i < LContext->textureNameSpace.capacity; ++i)
{
GLboolean bound = GL_FALSE;
rglTexture *texture = ( rglTexture * )LContext->textureNameSpace.data[i];
if (!texture || (texture->referenceBuffer != 0))
continue;
// check if bound
for ( j = 0;j < RGL_MAX_TEXTURE_IMAGE_UNITS;++j )
{
rglTextureImageUnit *tu = LContext->TextureImageUnits + j;
if ( tu->bound2D == i)
{
bound = GL_TRUE;
break;
}
}
if ( bound )
continue;
rglGcmTexture *gcmTexture = ( rglGcmTexture * )texture->platformTexture;
// check pool
if ( pool != RGLGCM_SURFACE_POOL_NONE &&
pool != gcmTexture->pool )
continue;
rglPlatformDropTexture( texture );
}
}
// Drop filitering mode for FP32 texture
static inline GLenum unFilter( GLenum filter )
{
GLenum newFilter;
switch ( filter )
{
case GL_NEAREST:
case GL_LINEAR:
newFilter = GL_NEAREST;
break;
case GL_NEAREST_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_NEAREST:
case GL_LINEAR_MIPMAP_LINEAR:
newFilter = GL_NEAREST_MIPMAP_NEAREST;
break;
default:
newFilter = GL_NEAREST;
}
return newFilter;
}
// texture strategy actions
// A texture strategy is a sequence of actions represented by these tokens.
// RGL_TEXTURE_STRATEGY_END must be the last token in any strategy.
enum rglTextureStrategy {
RGL_TEXTURE_STRATEGY_END, // allocation failed, give up
RGL_TEXTURE_STRATEGY_FORCE_LINEAR,
RGL_TEXTURE_STRATEGY_TILED_ALLOC,
RGL_TEXTURE_STRATEGY_TILED_CLEAR,
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC,
RGL_TEXTURE_STRATEGY_UNTILED_CLEAR,
RGL_TEXTURE_STRATEGY_SYSTEM_ALLOC,
RGL_TEXTURE_STRATEGY_SYSTEM_CLEAR, // XXX probably not useful
};
static enum rglTextureStrategy tiledGPUStrategy[] =
{
RGL_TEXTURE_STRATEGY_TILED_ALLOC, // try tiled alloction
RGL_TEXTURE_STRATEGY_FORCE_LINEAR,
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC, // if failure, try linear allocation
RGL_TEXTURE_STRATEGY_UNTILED_CLEAR, // if failure, drop linear textures
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC, // try linear again
RGL_TEXTURE_STRATEGY_END, // give up
};
static enum rglTextureStrategy linearGPUStrategy[] =
{
RGL_TEXTURE_STRATEGY_FORCE_LINEAR,
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC,
RGL_TEXTURE_STRATEGY_UNTILED_CLEAR,
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC,
RGL_TEXTURE_STRATEGY_END,
};
static enum rglTextureStrategy swizzledGPUStrategy[] =
{
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC,
RGL_TEXTURE_STRATEGY_UNTILED_CLEAR,
RGL_TEXTURE_STRATEGY_UNTILED_ALLOC,
RGL_TEXTURE_STRATEGY_END,
};
static enum rglTextureStrategy linearSystemStrategy[] =
{
RGL_TEXTURE_STRATEGY_FORCE_LINEAR,
RGL_TEXTURE_STRATEGY_SYSTEM_ALLOC,
RGL_TEXTURE_STRATEGY_END,
};
static enum rglTextureStrategy swizzledSystemStrategy[] =
{
RGL_TEXTURE_STRATEGY_SYSTEM_ALLOC,
RGL_TEXTURE_STRATEGY_END,
};
// Reallocate texture based on usage, pool system, and strategy
void rglPlatformReallocateGcmTexture (void *data)
{
rglTexture *texture = (rglTexture*)data;
rglGcmTexture *gcmTexture = ( rglGcmTexture * )texture->platformTexture;
// select the allocation strategy
enum rglTextureStrategy *step = NULL;
switch ( texture->usage )
{
case GL_TEXTURE_TILED_GPU_SCE:
step = tiledGPUStrategy;
break;
case GL_TEXTURE_LINEAR_GPU_SCE:
step = linearGPUStrategy;
break;
case GL_TEXTURE_SWIZZLED_GPU_SCE:
step = swizzledGPUStrategy;
break;
case GL_TEXTURE_LINEAR_SYSTEM_SCE:
step = linearSystemStrategy;
break;
case GL_TEXTURE_SWIZZLED_SYSTEM_SCE:
step = swizzledSystemStrategy;
break;
default:
step = swizzledGPUStrategy;
break;
}
GLuint size = 0;
GLuint id = GMM_ERROR;
// allow swizzled format unless explicitly disallowed
// PBO textures cannot be swizzled.
GLboolean forceLinear = GL_FALSE;
const rglGcmTextureLayout currentLayout = gcmTexture->gpuLayout;
const GLuint currentSize = gcmTexture->gpuSize;
// process strategy
GLboolean done = GL_FALSE;
while ( !done )
{
rglGcmTextureLayout newLayout;
switch ( *step++ )
{
case RGL_TEXTURE_STRATEGY_FORCE_LINEAR:
forceLinear = GL_TRUE;
break;
case RGL_TEXTURE_STRATEGY_UNTILED_ALLOC:
{
// get layout and size compatible with this pool
rglImage *image = texture->image + texture->baseLevel;
newLayout.levels = 1;
newLayout.faces = 1;
newLayout.baseWidth = image->width;
newLayout.baseHeight = image->height;
newLayout.baseDepth = image->depth;
newLayout.internalFormat = ( rglGcmEnum )image->internalFormat;
newLayout.pixelBits = rglPlatformGetBitsPerPixel( newLayout.internalFormat );
newLayout.pitch = GET_TEXTURE_PITCH(texture);
size = rglGetGcmTextureSize( &newLayout );
// determine if current allocation already works
// If the current allocation has the right size and pool, we
// don't have to do anything. If not, we only drop from the
// target pool because we may reuse the allocation from a
// different pool in a later step.
if ( gcmTexture->pool == RGLGCM_SURFACE_POOL_LINEAR )
{
if ( currentSize >= size && newLayout.pitch == currentLayout.pitch )
{
gcmTexture->gpuLayout = newLayout;
done = GL_TRUE;
}
else
rglPlatformDropTexture( texture );
}
if ( !done )
{
// allocate in the specified pool
id = gmmAlloc((CellGcmContextData*)&rglGcmState_i.fifo,
0, size);
if ( id != GMM_ERROR )
{
// drop old allocation
if ( gcmTexture->pool != RGLGCM_SURFACE_POOL_NONE )
rglPlatformDropTexture( texture );
// set new
gcmTexture->pool = RGLGCM_SURFACE_POOL_LINEAR;
gcmTexture->gpuAddressId = id;
gcmTexture->gpuAddressIdOffset = 0;
gcmTexture->gpuSize = size;
gcmTexture->gpuLayout = newLayout;
done = GL_TRUE;
}
}
}
break;
case RGL_TEXTURE_STRATEGY_UNTILED_CLEAR:
rglPlatformDropUnboundTextures( RGLGCM_SURFACE_POOL_LINEAR );
break;
case RGL_TEXTURE_STRATEGY_END:
rglSetError( GL_OUT_OF_MEMORY );
done = GL_TRUE;
break;
default:
break;
}
} // while loop for allocation strategy steps
rglTextureTouchFBOs( texture );
}
// Free memory pooled by a GCM texture
void rglPlatformFreeGcmTexture (void *data)
{
@ -2577,11 +2335,61 @@ static void rglPlatformValidateTextureResources (void *data)
if ( texture->revalidate & RGL_TEXTURE_REVALIDATE_IMAGES || texture->revalidate & RGL_TEXTURE_REVALIDATE_LAYOUT )
{
// upload images
rglPlatformReallocateGcmTexture( texture );
// Upload texure from host memory to GPU memory
//
// Reallocate texture based on usage, pool system, and strategy
rglGcmTexture *gcmTexture = ( rglGcmTexture * )texture->platformTexture;
// select the allocation strategy
GLboolean done = GL_FALSE;
GLuint size = 0;
GLuint id = GMM_ERROR;
if (texture->usage == GL_TEXTURE_LINEAR_SYSTEM_SCE ||
texture->usage == GL_TEXTURE_SWIZZLED_SYSTEM_SCE)
done = GL_TRUE;
const rglGcmTextureLayout currentLayout = gcmTexture->gpuLayout;
const GLuint currentSize = gcmTexture->gpuSize;
if (!done)
{
rglGcmTextureLayout newLayout;
// get layout and size compatible with this pool
rglImage *image = texture->image + texture->baseLevel;
newLayout.levels = 1;
newLayout.faces = 1;
newLayout.baseWidth = image->width;
newLayout.baseHeight = image->height;
newLayout.baseDepth = image->depth;
newLayout.internalFormat = ( rglGcmEnum )image->internalFormat;
newLayout.pixelBits = rglPlatformGetBitsPerPixel( newLayout.internalFormat );
newLayout.pitch = GET_TEXTURE_PITCH(texture);
size = rglGetGcmTextureSize( &newLayout );
if ( currentSize >= size && newLayout.pitch == currentLayout.pitch )
gcmTexture->gpuLayout = newLayout;
else
{
rglPlatformDropTexture( texture );
// allocate in the specified pool
id = gmmAlloc((CellGcmContextData*)&rglGcmState_i.fifo,
0, size);
// set new
gcmTexture->pool = RGLGCM_SURFACE_POOL_LINEAR;
gcmTexture->gpuAddressId = id;
gcmTexture->gpuAddressIdOffset = 0;
gcmTexture->gpuSize = size;
gcmTexture->gpuLayout = newLayout;
}
}
rglTextureTouchFBOs( texture );
// Upload texture from host memory to GPU memory
rglGcmTextureLayout *layout = &gcmTexture->gpuLayout;
const GLuint pixelBytes = layout->pixelBits / 8;
@ -2703,6 +2511,7 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE,
platformTexture->gcmMethods.address.wrapR = rglGcmMapWrapMode( texture->wrapR );
platformTexture->gcmMethods.address.unsignedRemap = CELL_GCM_TEXTURE_UNSIGNED_REMAP_NORMAL;
#if 0
// now for gamma remap
GLuint gamma = 0;
GLuint remap = texture->gammaRemap;
@ -2712,6 +2521,9 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE,
gamma |= ( remap & RGLGCM_GAMMA_REMAP_ALPHA_BIT ) ? CELL_GCM_TEXTURE_GAMMA_A : 0;
platformTexture->gcmMethods.address.gamma = gamma;
#else
platformTexture->gcmMethods.address.gamma = 0;
#endif
// set border colors
RGLGCM_CALC_COLOR_LE_ARGB8(&(platformTexture->gcmMethods.borderColor),
@ -2729,8 +2541,225 @@ source: RGLGCM_SURFACE_SOURCE_TEXTURE,
GLuint internalFormat = layout->internalFormat;
// set the format and remap( control 1)
rglGcmMapTextureFormat( internalFormat,
&platformTexture->gcmTexture.format, &platformTexture->gcmTexture.remap );
uint8_t *gcmFormat = &platformTexture->gcmTexture.format;
uint32_t *remap = &platformTexture->gcmTexture.remap;
*gcmFormat = 0;
switch (internalFormat)
{
case RGLGCM_ALPHA8: // in_rgba = xxAx, out_rgba = 000A
{
*gcmFormat = CELL_GCM_TEXTURE_B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO );
}
break;
case RGLGCM_ALPHA16: // in_rgba = xAAx, out_rgba = 000A
{
*gcmFormat = CELL_GCM_TEXTURE_X16;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO );
}
break;
#if 0
case RGLGCM_HILO8: // in_rgba = HLxx, out_rgba = HL11
{
*gcmFormat = CELL_GCM_TEXTURE_COMPRESSED_HILO8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ONE );
}
break;
case RGLGCM_HILO16: // in_rgba = HLxx, out_rgba = HL11
{
*gcmFormat = CELL_GCM_TEXTURE_Y16_X16;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ONE );
}
break;
#endif
case RGLGCM_ARGB8: // in_rgba = RGBA, out_rgba = RGBA
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
#if 0
case RGLGCM_BGRA8: // in_rgba = GRAB, out_rgba = RGBA ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_RGBA8: // in_rgba = GBAR, out_rgba = RGBA ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_ABGR8: // in_rgba = BGRA, out_rgba = RGBA ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_RGBX8: // in_rgba = BGRA, out_rgba = RGB1 ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_XBGR8: // in_rgba = BGRA, out_rgba = RGB1 ** NEEDS TO BE TESTED
{
*gcmFormat = CELL_GCM_TEXTURE_A8R8G8B8;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
case RGLGCM_FLOAT_R32: // in_rgba = Rxxx, out_rgba = R001
{
*gcmFormat = CELL_GCM_TEXTURE_X32_FLOAT;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XYXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_ZERO,
CELL_GCM_TEXTURE_REMAP_ZERO );
}
break;
case RGLGCM_RGB5_A1_SCE: // in_rgba = RGBA, out_rgba = RGBA
{
*gcmFormat = CELL_GCM_TEXTURE_A1R5G5B5;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XXXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
#endif
case RGLGCM_RGB565_SCE: // in_rgba = RGBA, out_rgba = RGBA
{
*gcmFormat = CELL_GCM_TEXTURE_R5G6B5;
*remap = CELL_GCM_REMAP_MODE(
CELL_GCM_TEXTURE_REMAP_ORDER_XXXY,
CELL_GCM_TEXTURE_REMAP_FROM_A,
CELL_GCM_TEXTURE_REMAP_FROM_R,
CELL_GCM_TEXTURE_REMAP_FROM_G,
CELL_GCM_TEXTURE_REMAP_FROM_B,
CELL_GCM_TEXTURE_REMAP_ONE,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP,
CELL_GCM_TEXTURE_REMAP_REMAP );
}
break;
}
// This is just to cover the conversion from swizzled to linear
if(layout->pitch)
@ -2989,8 +3018,15 @@ void static inline rglGcmSetColorDepthBuffers(void *data, const void *data_args)
{
// ARGB8 and FP16 interpret some registers differently
rglGcmBlendState *blend = &rglGcmState_i.state.blend;
GLuint hwColor;
rt->colorFormat = args->colorFormat;
rglGcmFifoGlBlendColor( blend->r, blend->g, blend->b, blend->a );
if (rglGcmState_i.renderTarget.colorFormat == RGLGCM_ARGB8)
{
RGLGCM_CALC_COLOR_LE_ARGB8( &hwColor, blend->r, blend->g, blend->b, blend->a );
GCM_FUNC( cellGcmSetBlendColor, hwColor, hwColor );
}
}
GLuint i = 0;