mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-14 22:38:34 +00:00
(RGL PS3) Remove cgGLSet/GetManageTextureParameters - take away more state
code associated to it (and speed up cgGLBindProgram in the process)
This commit is contained in:
parent
b8178a60eb
commit
949e2c3cae
@ -149,7 +149,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;
|
||||
@ -331,98 +330,6 @@ inline static void _pullConnectedParameterValues (void *data)
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
switch ( type )
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -3476,7 +3476,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 +3541,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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -6437,7 +6437,19 @@ CGGL_API void cgGLEnableProfile( CGprofile profile )
|
||||
|
||||
case CG_PROFILE_SCE_FP_TYPEB:
|
||||
case CG_PROFILE_SCE_FP_RSX:
|
||||
rglLeaveFFXFP( LContext );
|
||||
{
|
||||
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;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rglCgRaiseError( CG_INVALID_PROFILE_ERROR );
|
||||
@ -6521,14 +6533,42 @@ CGGL_API void cgGLBindProgram( CGprogram program )
|
||||
//hack to counter removal of TypeC during beta
|
||||
case 7005:
|
||||
case CG_PROFILE_SCE_VP_RSX:
|
||||
_cgGLBindVertexProgram( ptr );
|
||||
// the program is a vertex program, just update the GL state
|
||||
_CurrentContext->BoundVertexProgram = ptr;
|
||||
|
||||
// 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( ptr );
|
||||
break;
|
||||
|
||||
case CG_PROFILE_SCE_FP_TYPEB:
|
||||
//hack to counter removal of TypeC during beta
|
||||
case 7006:
|
||||
case CG_PROFILE_SCE_FP_RSX:
|
||||
_cgGLBindFragmentProgram( ptr );
|
||||
_CurrentContext->BoundFragmentProgram = ptr;
|
||||
|
||||
// need to revalidate the textures in order to update which targets to fetch from
|
||||
_CurrentContext->needValidate |= PSGL_VALIDATE_FRAGMENT_PROGRAM | PSGL_VALIDATE_TEXTURES_USED;
|
||||
|
||||
// This must happen before the sampler setters so texture parameters have the correct value in their push buffers for that routine
|
||||
_pullConnectedParameterValues( ptr );
|
||||
|
||||
// TODO: push texture state
|
||||
// Needs to be done per profile. Can't use glPushAttrib.
|
||||
|
||||
// deal with the texture parameters now.
|
||||
for ( GLuint index = 0; index < ptr->samplerCount; ++index )
|
||||
{
|
||||
// walk the array of sampler parameters
|
||||
CgRuntimeParameter *rtParameter = ptr->runtimeParameters + ptr->samplerIndices[index];
|
||||
CgParameterResource *parameter = ( CgParameterResource * )( ptr->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;
|
||||
rglUpdateCurrentTextureCache( &_CurrentContext->TextureImageUnits[unit] );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -6547,7 +6587,8 @@ CGGL_API void cgGLUnbindProgram( CGprofile profile )
|
||||
case CG_PROFILE_SCE_VP_RSX:
|
||||
//hack to counter removal of TypeC during beta
|
||||
case 7005:
|
||||
_cgGLUnbindVertexProgram();
|
||||
_CurrentContext->BoundVertexProgram = NULL;
|
||||
_CurrentContext->needValidate |= PSGL_VALIDATE_VERTEX_PROGRAM;
|
||||
// no need to invalidate textures because they are only available on programmable pipe.
|
||||
break;
|
||||
case CG_PROFILE_SCE_FP_TYPEB:
|
||||
@ -6555,8 +6596,7 @@ CGGL_API void cgGLUnbindProgram( CGprofile profile )
|
||||
case CG_PROFILE_SCE_FP_RSX:
|
||||
//hack to counter removal of TypeC during beta
|
||||
case 7006:
|
||||
_cgGLUnbindFragmentProgram();
|
||||
|
||||
_CurrentContext->BoundFragmentProgram = NULL;
|
||||
break;
|
||||
default:
|
||||
rglCgRaiseError( CG_INVALID_PROFILE_ERROR );
|
||||
@ -7368,17 +7408,6 @@ CGGL_API GLenum cgGLGetTextureEnum( CGparameter param )
|
||||
return GL_TEXTURE0 + parameterResource->resource - CG_TEXUNIT0;
|
||||
}
|
||||
|
||||
CGGL_API void cgGLSetManageTextureParameters( CGcontext ctx, CGbool flag )
|
||||
{
|
||||
_cgGetContextPtr( ctx )->GLmanageTextures = flag;
|
||||
}
|
||||
|
||||
CGGL_API CGbool cgGLGetManageTextureParameters( CGcontext ctx )
|
||||
{
|
||||
return _cgGetContextPtr( ctx )->GLmanageTextures;
|
||||
}
|
||||
|
||||
|
||||
void cgGLSetParameter1b( CGparameter param, CGbool v )
|
||||
{
|
||||
CgRuntimeParameter* ptr = rglCgGLTestParameter( param );
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
@ -1322,6 +1318,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,7 +1435,7 @@ 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 );
|
||||
}
|
||||
@ -1570,41 +1601,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
|
||||
|
Loading…
Reference in New Issue
Block a user