(RGL PS3) RGL optimizations - faster video update

This commit is contained in:
twinaphex 2013-03-26 03:14:58 +01:00
parent 0fb415fa82
commit 4938145c10
5 changed files with 233 additions and 331 deletions

View File

@ -37,7 +37,6 @@ extern RGL_EXPORT RGLcontextHookFunction rglContextDestroyHook;
extern RGLcontext* rglContextCreate(); extern RGLcontext* rglContextCreate();
extern void rglContextFree( RGLcontext* LContext ); extern void rglContextFree( RGLcontext* LContext );
extern void rglSetError( GLenum error ); extern void rglSetError( GLenum error );
extern GLuint rglValidateStates( GLuint mask );
void rglAttachContext( RGLdevice *device, RGLcontext* context ); void rglAttachContext( RGLdevice *device, RGLcontext* context );
void rglDetachContext( RGLdevice *device, RGLcontext* context ); void rglDetachContext( RGLdevice *device, RGLcontext* context );
void rglInvalidateAllStates (void *data); void rglInvalidateAllStates (void *data);
@ -193,17 +192,12 @@ extern const GLvoid* rglPlatformGetProcAddress (const char *funcName);
void* rglPlatformRasterInit (void); void* rglPlatformRasterInit (void);
void rglPlatformRasterExit (void* data); void rglPlatformRasterExit (void* data);
void rglPlatformRasterDestroyResources (void); void rglPlatformRasterDestroyResources (void);
void rglPlatformDraw (void *data);
GLboolean rglPlatformNeedsConversion (const rglAttributeState* as, GLuint index); GLboolean rglPlatformNeedsConversion (const rglAttributeState* as, GLuint index);
// [YLIN] Try to avoid LHS inside this function. // [YLIN] Try to avoid LHS inside this function.
// In oringinal implementation, indexType and indexCount will be stored right before this function // In oringinal implementation, indexType and indexCount will be stored right before this function
// and since we will load them right after enter this function, there are LHS. // and since we will load them right after enter this function, there are LHS.
GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint32_t indexCount); GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint32_t indexCount);
void rglPlatformRasterGetIntegerv( GLenum pname, GLint* params ); void rglPlatformRasterGetIntegerv( GLenum pname, GLint* params );
void rglPlatformRasterFlush (void);
void rglPlatformRasterFinish (void);
void rglValidateFragmentProgram (void);
void rglValidateFragmentProgramSharedConstants (void);
void rglValidateClipPlanes (void); void rglValidateClipPlanes (void);
void rglInvalidateAttributes (void); void rglInvalidateAttributes (void);
GLuint rglValidateAttributes (const void* indices, GLboolean *isMain); GLuint rglValidateAttributes (const void* indices, GLboolean *isMain);
@ -224,24 +218,16 @@ extern void rglPlatformCopyTexSubImage3D( GLenum target, GLint level, GLint xoff
GLenum rglPlatformChooseInternalFormat( GLenum internalformat ); GLenum rglPlatformChooseInternalFormat( GLenum internalformat );
void rglPlatformExpandInternalFormat( GLenum internalformat, GLenum *format, GLenum *type ); void rglPlatformExpandInternalFormat( GLenum internalformat, GLenum *format, GLenum *type );
void rglPlatformGetImageData( GLenum target, GLint level, rglTexture *texture, rglImage *image ); void rglPlatformGetImageData( GLenum target, GLint level, rglTexture *texture, rglImage *image );
GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf, GLintptr offset);
//---------------------------------------- //----------------------------------------
// Raster/.../PlatformFBops.c // Raster/.../PlatformFBops.c
//---------------------------------------- //----------------------------------------
extern void rglFBClear( GLbitfield mask );
extern void rglValidateFramebuffer( void ); extern void rglValidateFramebuffer( void );
extern void rglValidateFFXVertexProgram (void); extern void rglValidateFFXVertexProgram (void);
extern void rglValidateFFXFragmentProgram (void); extern void rglValidateFFXFragmentProgram (void);
extern void rglPlatformReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLboolean flip, GLenum format, GLenum type, GLvoid *pixels ); 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 ); extern GLboolean rglPlatformReadPBOPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLboolean flip, GLenum format, GLenum type, GLvoid *pixels );
//----------------------------------------
// Raster/.../PlatformTNL.c
//----------------------------------------
void rglValidateVertexProgram (void);
void rglValidateVertexConstants (void);
//---------------------------------------- //----------------------------------------
// Raster/.../PlatformBuffer.c // Raster/.../PlatformBuffer.c
//---------------------------------------- //----------------------------------------

View File

@ -3248,11 +3248,11 @@ void rglPlatformDestroyDevice (void *data)
rglDuringDestroyDevice = GL_FALSE; rglDuringDestroyDevice = GL_FALSE;
} }
void rglPlatformSwapBuffers (void *data) GLAPI void RGL_EXPORT psglSwap (void)
{ {
gmmUpdateFreeList(CELL_GCM_LOCATION_LOCAL); gmmUpdateFreeList(CELL_GCM_LOCATION_LOCAL);
RGLdevice *device = (RGLdevice*)data; RGLdevice *device = (RGLdevice*)_CurrentDevice;
rglGcmDevice *gcmDevice = (rglGcmDevice *)device->platformDevice; rglGcmDevice *gcmDevice = (rglGcmDevice *)device->platformDevice;
const GLuint drawBuffer = gcmDevice->drawBuffer; const GLuint drawBuffer = gcmDevice->drawBuffer;
@ -3332,19 +3332,6 @@ void rglPlatformSwapBuffers (void *data)
} }
} }
void rglpValidateViewport (void)
{
RGLcontext* LContext = _CurrentContext;
rglGcmViewportState *v = &rglGcmState_i.state.viewport;
v->x = LContext->ViewPort.X;
v->y = LContext->ViewPort.Y;
v->w = LContext->ViewPort.XSize;
v->h = LContext->ViewPort.YSize;
rglGcmFifoGlViewport(v, LContext->DepthNear, LContext->DepthFar);
}
void rglpValidateBlending(void) void rglpValidateBlending(void)
{ {
RGLcontext* LContext = _CurrentContext; RGLcontext* LContext = _CurrentContext;
@ -3365,11 +3352,4 @@ void rglpValidateBlending(void)
} }
} }
void rglpValidateShaderSRGBRemap(void)
{
RGLcontext* LContext = _CurrentContext;
GCM_FUNC( cellGcmSetFragmentProgramGammaEnable, LContext->ShaderSRGBRemap ? CELL_GCM_TRUE : CELL_GCM_FALSE);
LContext->needValidate &= ~RGL_VALIDATE_SHADER_SRGB_REMAP;
}
#include "rgl_ps3_cg.cpp" #include "rgl_ps3_cg.cpp"

View File

@ -1404,12 +1404,16 @@ GLboolean rglPlatformBufferObjectUnmap (void *data)
} }
/*============================================================ /*============================================================
PLATFORM FRAME BUFFER OPERATIONS PLATFORM FRAMEBUFFER
============================================================ */ ============================================================ */
void rglFBClear( GLbitfield mask ) GLAPI void APIENTRY glClear( GLbitfield mask )
{ {
RGLcontext* LContext = _CurrentContext; RGLcontext* LContext = _CurrentContext;
if ( LContext->needValidate & RGL_VALIDATE_FRAMEBUFFER )
rglValidateFramebuffer();
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
if (!driver->rtValid) if (!driver->rtValid)
@ -1487,10 +1491,6 @@ void rglFBClear( GLbitfield mask )
rglGcmFifoGlFlush(); rglGcmFifoGlFlush();
} }
/*============================================================
PLATFORM FRAMEBUFFER
============================================================ */
rglFramebuffer* rglCreateFramebuffer (void) rglFramebuffer* rglCreateFramebuffer (void)
{ {
rglFramebuffer* framebuffer = new rglPlatformFramebuffer(); rglFramebuffer* framebuffer = new rglPlatformFramebuffer();
@ -1789,13 +1789,160 @@ void rglPlatformRasterExit (void *data)
void rglDumpFifo (char *name); void rglDumpFifo (char *name);
static GLuint rglValidateStates (GLuint mask)
{
RGLcontext* LContext = _CurrentContext;
GLuint dirty = LContext->needValidate & ~mask;
LContext->needValidate &= mask;
GLuint needValidate = LContext->needValidate;
if (RGL_UNLIKELY( needValidate & RGL_VALIDATE_FRAMEBUFFER))
{
rglValidateFramebuffer();
needValidate = LContext->needValidate;
}
if (RGL_UNLIKELY( needValidate & RGL_VALIDATE_TEXTURES_USED))
{
long unitInUseCount = LContext->BoundFragmentProgram->samplerCount;
const GLuint* unitsInUse = LContext->BoundFragmentProgram->samplerUnits;
for ( long i = 0; i < unitInUseCount; ++i )
{
long unit = unitsInUse[i];
rglTexture* texture = LContext->TextureImageUnits[unit].currentTexture;
if (texture)
rglPlatformValidateTextureStage( unit, texture );
}
}
bool validate_vertex_consts = false;
if (RGL_UNLIKELY(needValidate & RGL_VALIDATE_VERTEX_PROGRAM))
{
rglSetNativeCgVertexProgram(LContext->BoundVertexProgram);
// Set all uniforms.
if(!(LContext->needValidate & RGL_VALIDATE_VERTEX_CONSTANTS) && LContext->BoundVertexProgram->parentContext)
validate_vertex_consts = true;
}
if (RGL_LIKELY(needValidate & RGL_VALIDATE_VERTEX_CONSTANTS) || validate_vertex_consts)
{
_CGprogram *cgprog = LContext->BoundVertexProgram;
// Push a CG program onto the current command buffer
// make sure there is space for the pushbuffer + any nops we need to add for alignment
rglGcmFifoWaitForFreeSpace( &rglGcmState_i.fifo, cgprog->constantPushBufferWordSize + 4 + 32);
// first add nops to get us the next alligned position in the fifo
// [YLIN] Use VMX register to copy
uint32_t padding_in_word = ( ( 0x10-(((uint32_t)rglGcmState_i.fifo.current)&0xf))&0xf )>>2;
uint32_t padded_size = ( ((cgprog->constantPushBufferWordSize)<<2) + 0xf )&~0xf;
GCM_FUNC( cellGcmSetNopCommandUnsafe, padding_in_word );
memcpy16(rglGcmState_i.fifo.current, cgprog->constantPushBuffer, padded_size);
rglGcmState_i.fifo.current+=cgprog->constantPushBufferWordSize;
}
if (RGL_UNLIKELY(needValidate & RGL_VALIDATE_FRAGMENT_PROGRAM))
{
// Set up the current fragment program on hardware
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
_CGprogram *program = LContext->BoundFragmentProgram;
// params are set directly in the GPU memory, so there is nothing to be done here.
rglSetNativeCgFragmentProgram( program );
driver->fpLoadProgramId = program->loadProgramId;
driver->fpLoadProgramOffset = program->loadProgramOffset;
}
if ( RGL_LIKELY(( needValidate & ~( RGL_VALIDATE_TEXTURES_USED |
RGL_VALIDATE_VERTEX_PROGRAM |
RGL_VALIDATE_VERTEX_CONSTANTS |
RGL_VALIDATE_FRAGMENT_PROGRAM ) ) == 0 ) )
{
LContext->needValidate = 0;
return dirty;
}
if ( RGL_UNLIKELY( needValidate & RGL_VALIDATE_VIEWPORT ) )
{
rglGcmViewportState *v = &rglGcmState_i.state.viewport;
v->x = LContext->ViewPort.X;
v->y = LContext->ViewPort.Y;
v->w = LContext->ViewPort.XSize;
v->h = LContext->ViewPort.YSize;
rglGcmFifoGlViewport(v, LContext->DepthNear, LContext->DepthFar);
}
if (RGL_UNLIKELY(needValidate & RGL_VALIDATE_BLENDING ))
{
if ((LContext->Blending))
{
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);
}
}
if ( RGL_UNLIKELY( needValidate & RGL_VALIDATE_SHADER_SRGB_REMAP ) )
{
GCM_FUNC( cellGcmSetFragmentProgramGammaEnable, LContext->ShaderSRGBRemap ? CELL_GCM_TRUE : CELL_GCM_FALSE);
LContext->needValidate &= ~RGL_VALIDATE_SHADER_SRGB_REMAP;
}
LContext->needValidate = 0;
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)));
// Fast rendering path called by several glDraw calls: // Fast rendering path called by several glDraw calls:
// glDrawElements, glDrawRangeElements, glDrawArrays // glDrawElements, glDrawRangeElements, glDrawArrays
// Slow rendering calls this function also, though it must also perform various // Slow rendering calls this function also, though it must also perform various
// memory setup operations first // memory setup operations first
void rglPlatformDraw (void *data) GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
{ {
rglDrawParams *dparams = (rglDrawParams*)data; RGLcontext* LContext = _CurrentContext;
if (RGL_UNLIKELY(!RGLBIT_GET(LContext->attribs->EnabledMask, RGL_ATTRIB_POSITION_INDEX)))
return;
uint32_t _tmp_clear_loop = c_rounded_size_ofrglDrawParams>>7;
do{
--_tmp_clear_loop;
__dcbz(s_dparams_buff+(_tmp_clear_loop<<7));
}while(_tmp_clear_loop);
rglDrawParams *dparams = (rglDrawParams *)s_dparams_buff;
dparams->mode = mode;
dparams->firstVertex = first;
dparams->vertexCount = count;
if ( LContext->needValidate )
rglValidateStates( RGL_VALIDATE_ALL );
GLboolean slowPath = rglPlatformRequiresSlowPath( dparams, 0, 0);
(void)slowPath;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
if (RGL_UNLIKELY(!driver->rtValid)) if (RGL_UNLIKELY(!driver->rtValid))
@ -1835,20 +1982,6 @@ void rglPlatformDraw (void *data)
rglGcmFifoGlDrawArrays(( rglGcmEnum )dparams->mode, dparams->firstVertex, dparams->vertexCount ); rglGcmFifoGlDrawArrays(( rglGcmEnum )dparams->mode, dparams->firstVertex, dparams->vertexCount );
} }
// Set up the current fragment program on hardware
void rglValidateFragmentProgram (void)
{
RGLcontext* LContext = _CurrentContext;
rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver;
_CGprogram *program = LContext->BoundFragmentProgram;
// params are set directly in the GPU memory, so there is nothing to be done here.
rglSetNativeCgFragmentProgram( program );
driver->fpLoadProgramId = program->loadProgramId;
driver->fpLoadProgramOffset = program->loadProgramOffset;
}
// must always call this before rglPlatformDraw() to setup rglDrawParams // must always call this before rglPlatformDraw() to setup rglDrawParams
GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint32_t indexCount) GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint32_t indexCount)
{ {
@ -1888,8 +2021,13 @@ GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint3
return GL_FALSE; // we are finally qualified for the fast path return GL_FALSE; // we are finally qualified for the fast path
} }
void rglPlatformRasterFlush (void) GLAPI void APIENTRY glFlush(void)
{ {
RGLcontext * LContext = _CurrentContext;
if (RGL_UNLIKELY(LContext->needValidate))
rglValidateStates( RGL_VALIDATE_ALL );
rglGcmFifoGlFlush(); rglGcmFifoGlFlush();
} }
@ -2851,7 +2989,7 @@ GLenum rglPlatformTranslateTextureFormat( GLenum internalFormat )
// Implementation of texture reference // Implementation of texture reference
// Associate bufferObject to texture by assigning buffer's gpu address to the gcm texture // Associate bufferObject to texture by assigning buffer's gpu address to the gcm texture
GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf, GLintptr offset ) static inline GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf, GLintptr offset )
{ {
rglBufferObject *bufferObject = (rglBufferObject*)data_buf; rglBufferObject *bufferObject = (rglBufferObject*)data_buf;
rglTexture *texture = (rglTexture*)data; rglTexture *texture = (rglTexture*)data;
@ -2864,21 +3002,6 @@ GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf,
GLboolean isRenderTarget = GL_FALSE; GLboolean isRenderTarget = GL_FALSE;
GLboolean vertexEnable = GL_FALSE; GLboolean vertexEnable = GL_FALSE;
#ifndef HAVE_RGL_2D
// can usually be a render target, except for restrictions below
if (rglIsDrawableColorFormat( newLayout.internalFormat))
isRenderTarget = GL_TRUE;
switch (newLayout.internalFormat)
{
case GL_FLOAT_RGBA32:
case GL_RGBA32F_ARB:
vertexEnable = GL_TRUE;
break;
default:
break;
}
#endif
texture->isRenderTarget = isRenderTarget; texture->isRenderTarget = isRenderTarget;
texture->vertexEnable = vertexEnable; texture->vertexEnable = vertexEnable;
@ -2900,6 +3023,72 @@ GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf,
return GL_TRUE; return GL_TRUE;
} }
static inline void rglSetImageTexRef(void *data, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei alignment)
{
rglImage *image = (rglImage*)data;
image->width = width;
image->height = height;
image->depth = depth;
image->alignment = alignment;
image->xblk = 0;
image->yblk = 0;
image->xstride = 0;
image->ystride = 0;
image->zstride = 0;
image->format = 0;
image->type = 0;
image->internalFormat = 0;
const GLenum status = rglPlatformChooseInternalStorage( image, internalFormat );
(( void )status );
image->data = NULL;
image->mallocData = NULL;
image->mallocStorageSize = 0;
image->isSet = GL_TRUE;
if ( image->xstride == 0 )
image->xstride = rglGetPixelSize( image->format, image->type );
if ( image->ystride == 0 )
image->ystride = image->width * image->xstride;
if ( image->zstride == 0 )
image->zstride = image->height * image->ystride;
image->dataState = RGL_IMAGE_DATASTATE_UNSET;
}
GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels,
GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset )
{
RGLcontext* LContext = _CurrentContext;
rglTexture *texture = rglGetCurrentTexture( LContext->CurrentImageUnit, target );
rglBufferObject *bufferObject =
(rglBufferObject*)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer];
rglReallocateImages( texture, 0, MAX( baseWidth, MAX( baseHeight, baseDepth ) ) );
rglSetImageTexRef(texture->image, internalFormat, baseWidth, baseHeight,
baseDepth, LContext->unpackAlignment);
texture->maxLevel = 0;
texture->usage = GL_TEXTURE_LINEAR_GPU_SCE;
GLboolean r = rglPlatformTextureReference( texture, pitch, bufferObject, offset );
if ( !r )
return;
bufferObject->textureReferences.pushBack( texture );
texture->referenceBuffer = bufferObject;
texture->offset = offset;
rglTextureTouchFBOs( texture );
LContext->needValidate |= RGL_VALIDATE_TEXTURES_USED;
}
// GlSetRenderTarget implementation starts here // GlSetRenderTarget implementation starts here
// Render target rt's color and depth buffer parameters are updated with args // Render target rt's color and depth buffer parameters are updated with args
@ -3060,42 +3249,6 @@ void rglGcmFifoGlSetRenderTarget (const void *data)
GCM_FUNC( cellGcmSetSurface, grt ); GCM_FUNC( cellGcmSetSurface, grt );
} }
/*============================================================
PLATFORM TNL
============================================================ */
void rglValidateVertexProgram (void)
{
// if validation is required, it means the program has to be downloaded.
RGLcontext* LContext = _CurrentContext;
rglSetNativeCgVertexProgram(LContext->BoundVertexProgram);
// Set all uniforms.
if(!(LContext->needValidate & RGL_VALIDATE_VERTEX_CONSTANTS) && LContext->BoundVertexProgram->parentContext)
rglValidateVertexConstants();
}
void rglValidateVertexConstants (void)
{
RGLcontext* LContext = _CurrentContext;
_CGprogram *cgprog = LContext->BoundVertexProgram;
// Push a CG program onto the current command buffer
// make sure there is space for the pushbuffer + any nops we need to add for alignment
rglGcmFifoWaitForFreeSpace( &rglGcmState_i.fifo, cgprog->constantPushBufferWordSize + 4 + 32);
// first add nops to get us the next alligned position in the fifo
// [YLIN] Use VMX register to copy
uint32_t padding_in_word = ( ( 0x10-(((uint32_t)rglGcmState_i.fifo.current)&0xf))&0xf )>>2;
uint32_t padded_size = ( ((cgprog->constantPushBufferWordSize)<<2) + 0xf )&~0xf;
GCM_FUNC( cellGcmSetNopCommandUnsafe, padding_in_word );
memcpy16(rglGcmState_i.fifo.current, cgprog->constantPushBuffer, padded_size);
rglGcmState_i.fifo.current+=cgprog->constantPushBufferWordSize;
}
/*============================================================ /*============================================================
UTILS UTILS
============================================================ */ ============================================================ */

View File

@ -30,7 +30,7 @@ static rglBufferObject *rglCreateBufferObject (void)
if(!buffer ) if(!buffer )
return NULL; return NULL;
memset( buffer, 0, size ); memset(buffer, 0, size);
buffer->refCount = 1; buffer->refCount = 1;
new( &buffer->textureReferences ) RGL::Vector<rglTexture *>(); new( &buffer->textureReferences ) RGL::Vector<rglTexture *>();
@ -111,27 +111,11 @@ GLAPI GLvoid* APIENTRY glMapBuffer( GLenum target, GLenum access )
rglSetError( GL_INVALID_ENUM ); rglSetError( GL_INVALID_ENUM );
return NULL; return NULL;
} }
rglBufferObject* bufferObject = (rglBufferObject*)LContext->bufferObjectNameSpace.data[name]; rglBufferObject* bufferObject = (rglBufferObject*)LContext->bufferObjectNameSpace.data[name];
#ifndef HAVE_RGL_2D
switch ( access )
{
case GL_READ_ONLY:
case GL_WRITE_ONLY:
case GL_READ_WRITE:
break;
default:
rglSetError( GL_INVALID_ENUM );
return NULL;
}
#else
(void)0;
#endif
bufferObject->mapped = GL_TRUE; bufferObject->mapped = GL_TRUE;
void *result = rglPlatformBufferObjectMap( bufferObject, access );
return result; return rglPlatformBufferObjectMap( bufferObject, access );
} }
GLAPI GLboolean APIENTRY glUnmapBuffer( GLenum target ) GLAPI GLboolean APIENTRY glUnmapBuffer( GLenum target )
@ -280,15 +264,6 @@ GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr
FRAMEBUFFER FRAMEBUFFER
============================================================ */ ============================================================ */
GLAPI void APIENTRY glClear( GLbitfield mask )
{
RGLcontext* LContext = _CurrentContext;
if ( LContext->needValidate & RGL_VALIDATE_FRAMEBUFFER )
rglValidateFramebuffer();
rglFBClear( mask );
}
GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
{ {
} }
@ -759,44 +734,6 @@ void rglImageFreeCPUStorage(void *data)
image->dataState &= ~RGL_IMAGE_DATASTATE_HOST; image->dataState &= ~RGL_IMAGE_DATASTATE_HOST;
} }
static inline void rglSetImageTexRef(void *data, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei alignment)
{
rglImage *image = (rglImage*)data;
image->width = width;
image->height = height;
image->depth = depth;
image->alignment = alignment;
image->xblk = 0;
image->yblk = 0;
image->xstride = 0;
image->ystride = 0;
image->zstride = 0;
image->format = 0;
image->type = 0;
image->internalFormat = 0;
const GLenum status = rglPlatformChooseInternalStorage( image, internalFormat );
(( void )status );
image->data = NULL;
image->mallocData = NULL;
image->mallocStorageSize = 0;
image->isSet = GL_TRUE;
if ( image->xstride == 0 )
image->xstride = rglGetPixelSize( image->format, image->type );
if ( image->ystride == 0 )
image->ystride = image->width * image->xstride;
if ( image->zstride == 0 )
image->zstride = image->height * image->ystride;
image->dataState = RGL_IMAGE_DATASTATE_UNSET;
}
void rglSetImage(void *data, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei alignment, GLenum format, GLenum type, const void *pixels ) void rglSetImage(void *data, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei alignment, GLenum format, GLenum type, const void *pixels )
{ {
rglImage *image = (rglImage*)data; rglImage *image = (rglImage*)data;
@ -919,72 +856,6 @@ GLAPI void APIENTRY glGetIntegerv(GLenum pname, GLint* params)
} }
} }
GLuint rglValidateStates (GLuint mask)
{
RGLcontext* LContext = _CurrentContext;
GLuint dirty = LContext->needValidate & ~mask;
LContext->needValidate &= mask;
GLuint needValidate = LContext->needValidate;
if (RGL_UNLIKELY( needValidate & RGL_VALIDATE_FRAMEBUFFER))
{
rglValidateFramebuffer();
needValidate = LContext->needValidate;
}
if (RGL_UNLIKELY( needValidate & RGL_VALIDATE_TEXTURES_USED))
{
long unitInUseCount = LContext->BoundFragmentProgram->samplerCount;
const GLuint* unitsInUse = LContext->BoundFragmentProgram->samplerUnits;
for ( long i = 0; i < unitInUseCount; ++i )
{
long unit = unitsInUse[i];
rglTexture* texture = LContext->TextureImageUnits[unit].currentTexture;
if (texture)
rglPlatformValidateTextureStage( unit, texture );
}
}
if (RGL_UNLIKELY(needValidate & RGL_VALIDATE_VERTEX_PROGRAM))
{
rglValidateVertexProgram();
}
if (RGL_LIKELY(needValidate & RGL_VALIDATE_VERTEX_CONSTANTS))
{
rglValidateVertexConstants();
}
if (RGL_UNLIKELY(needValidate & RGL_VALIDATE_FRAGMENT_PROGRAM))
{
rglValidateFragmentProgram();
}
if ( RGL_LIKELY(( needValidate & ~( RGL_VALIDATE_TEXTURES_USED |
RGL_VALIDATE_VERTEX_PROGRAM |
RGL_VALIDATE_VERTEX_CONSTANTS |
RGL_VALIDATE_FRAGMENT_PROGRAM ) ) == 0 ) )
{
LContext->needValidate = 0;
return dirty;
}
if ( RGL_UNLIKELY( needValidate & RGL_VALIDATE_VIEWPORT ) )
rglpValidateViewport();
if ( RGL_UNLIKELY( needValidate & RGL_VALIDATE_BLENDING ) )
rglpValidateBlending();
if ( RGL_UNLIKELY( needValidate & RGL_VALIDATE_SHADER_SRGB_REMAP ) )
rglpValidateShaderSRGBRemap();
LContext->needValidate = 0;
return dirty;
}
void rglResetAttributeState(void *data) void rglResetAttributeState(void *data)
{ {
rglAttributeState *as = (rglAttributeState*)data; rglAttributeState *as = (rglAttributeState*)data;
@ -1322,16 +1193,6 @@ GLAPI void APIENTRY glDisableClientState( GLenum array )
} }
} }
GLAPI void APIENTRY glFlush(void)
{
RGLcontext * LContext = _CurrentContext;
if (RGL_UNLIKELY(LContext->needValidate))
rglValidateStates( RGL_VALIDATE_ALL );
rglPlatformRasterFlush();
}
GLAPI const GLubyte* APIENTRY glGetString( GLenum name ) GLAPI const GLubyte* APIENTRY glGetString( GLenum name )
{ {
switch ( name ) switch ( name )
@ -1589,18 +1450,7 @@ void rglBindTextureInternal (void *data, GLuint name, GLenum target )
} }
} }
#ifndef HAVE_RGL_2D
switch ( target )
{
case GL_TEXTURE_2D:
unit->bound2D = name;
break;
default:
break;
}
#else
unit->bound2D = name; unit->bound2D = name;
#endif
rglUpdateCurrentTextureCache( unit ); rglUpdateCurrentTextureCache( unit );
LContext->needValidate |= RGL_VALIDATE_TEXTURES_USED; LContext->needValidate |= RGL_VALIDATE_TEXTURES_USED;
@ -1752,39 +1602,10 @@ GLAPI void APIENTRY glActiveTexture( GLenum texture )
LContext->CurrentImageUnit = NULL; LContext->CurrentImageUnit = NULL;
} }
GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels,
GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset )
{
RGLcontext* LContext = _CurrentContext;
rglTexture *texture = rglGetCurrentTexture( LContext->CurrentImageUnit, target );
rglBufferObject *bufferObject =
(rglBufferObject*)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer];
rglReallocateImages( texture, 0, MAX( baseWidth, MAX( baseHeight, baseDepth ) ) );
rglSetImageTexRef(texture->image, internalFormat, baseWidth, baseHeight,
baseDepth, LContext->unpackAlignment);
texture->maxLevel = 0;
texture->usage = GL_TEXTURE_LINEAR_GPU_SCE;
GLboolean r = rglPlatformTextureReference( texture, pitch, bufferObject, offset );
if ( !r ) return;
bufferObject->textureReferences.pushBack( texture );
texture->referenceBuffer = bufferObject;
texture->offset = offset;
rglTextureTouchFBOs( texture );
LContext->needValidate |= RGL_VALIDATE_TEXTURES_USED;
}
/*============================================================ /*============================================================
VERTEX ARRAYS VERTEX ARRAYS
============================================================ */ ============================================================ */
#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)));
GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer ) GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid* pointer )
{ {
rglVertexAttribPointerNV( RGL_ATTRIB_POSITION_INDEX, size, type, GL_FALSE, stride, pointer ); rglVertexAttribPointerNV( RGL_ATTRIB_POSITION_INDEX, size, type, GL_FALSE, stride, pointer );
@ -1938,32 +1759,6 @@ void rglVertexAttrib4fvNV( GLuint index, const GLfloat* v )
rglVertexAttrib4fNV( index, v[0], v[1], v[2], v[3] ); rglVertexAttrib4fNV( index, v[0], v[1], v[2], v[3] );
} }
GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
{
RGLcontext* LContext = _CurrentContext;
if (RGL_UNLIKELY(!RGLBIT_GET(LContext->attribs->EnabledMask, RGL_ATTRIB_POSITION_INDEX)))
return;
uint32_t _tmp_clear_loop = c_rounded_size_ofrglDrawParams>>7;
do{
--_tmp_clear_loop;
__dcbz(s_dparams_buff+(_tmp_clear_loop<<7));
}while(_tmp_clear_loop);
rglDrawParams *dparams = (rglDrawParams *)s_dparams_buff;
dparams->mode = mode;
dparams->firstVertex = first;
dparams->vertexCount = count;
if ( LContext->needValidate ) rglValidateStates( RGL_VALIDATE_ALL );
GLboolean slowPath = rglPlatformRequiresSlowPath( dparams, 0, 0);
(void)slowPath;
rglPlatformDraw( dparams );
}
/*============================================================ /*============================================================
DEVICE CONTEXT CREATION DEVICE CONTEXT CREATION
============================================================ */ ============================================================ */
@ -2049,11 +1844,3 @@ RGLdevice *psglGetCurrentDevice (void)
{ {
return _CurrentDevice; return _CurrentDevice;
} }
GLAPI void RGL_EXPORT psglSwap (void)
{
#ifndef HAVE_RGL_2D
if ( _CurrentDevice != NULL)
#endif
rglPlatformSwapBuffers( _CurrentDevice );
}

View File

@ -22,10 +22,6 @@
#include "ps3/include/rgl-constants.h" #include "ps3/include/rgl-constants.h"
#endif #endif
extern void rglpValidateViewport(void);
extern void rglpValidateBlending(void);
extern void rglpValidateShaderSRGBRemap(void);
extern int rglpBufferObjectSize(void); extern int rglpBufferObjectSize(void);
extern GLboolean rglpCreateBufferObject (void *data); extern GLboolean rglpCreateBufferObject (void *data);