diff --git a/ps3/rgl/include/RGL/private.h b/ps3/rgl/include/RGL/private.h index 6f4cdc3a27..04492c5047 100644 --- a/ps3/rgl/include/RGL/private.h +++ b/ps3/rgl/include/RGL/private.h @@ -37,7 +37,6 @@ extern RGL_EXPORT RGLcontextHookFunction rglContextDestroyHook; extern RGLcontext* rglContextCreate(); extern void rglContextFree( RGLcontext* LContext ); extern void rglSetError( GLenum error ); -extern GLuint rglValidateStates( GLuint mask ); void rglAttachContext( RGLdevice *device, RGLcontext* context ); void rglDetachContext( RGLdevice *device, RGLcontext* context ); void rglInvalidateAllStates (void *data); @@ -193,17 +192,12 @@ extern const GLvoid* rglPlatformGetProcAddress (const char *funcName); void* rglPlatformRasterInit (void); void rglPlatformRasterExit (void* data); void rglPlatformRasterDestroyResources (void); -void rglPlatformDraw (void *data); GLboolean rglPlatformNeedsConversion (const rglAttributeState* as, GLuint index); // [YLIN] Try to avoid LHS inside 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. GLboolean rglPlatformRequiresSlowPath (void *data, const GLenum indexType, uint32_t indexCount); void rglPlatformRasterGetIntegerv( GLenum pname, GLint* params ); -void rglPlatformRasterFlush (void); -void rglPlatformRasterFinish (void); -void rglValidateFragmentProgram (void); -void rglValidateFragmentProgramSharedConstants (void); void rglValidateClipPlanes (void); void rglInvalidateAttributes (void); GLuint rglValidateAttributes (const void* indices, GLboolean *isMain); @@ -224,24 +218,16 @@ extern void rglPlatformCopyTexSubImage3D( GLenum target, GLint level, GLint xoff GLenum rglPlatformChooseInternalFormat( GLenum internalformat ); void rglPlatformExpandInternalFormat( GLenum internalformat, GLenum *format, GLenum *type ); void rglPlatformGetImageData( GLenum target, GLint level, rglTexture *texture, rglImage *image ); -GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf, GLintptr offset); //---------------------------------------- // Raster/.../PlatformFBops.c //---------------------------------------- -extern void rglFBClear( GLbitfield mask ); extern void rglValidateFramebuffer( void ); extern void rglValidateFFXVertexProgram (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 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 //---------------------------------------- diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index 570ab93069..da4a953d8a 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -3248,11 +3248,11 @@ void rglPlatformDestroyDevice (void *data) rglDuringDestroyDevice = GL_FALSE; } -void rglPlatformSwapBuffers (void *data) +GLAPI void RGL_EXPORT psglSwap (void) { gmmUpdateFreeList(CELL_GCM_LOCATION_LOCAL); - RGLdevice *device = (RGLdevice*)data; + RGLdevice *device = (RGLdevice*)_CurrentDevice; rglGcmDevice *gcmDevice = (rglGcmDevice *)device->platformDevice; 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) { 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" diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index b5035f2d1d..997522ba74 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -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; + + if ( LContext->needValidate & RGL_VALIDATE_FRAMEBUFFER ) + rglValidateFramebuffer(); + rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; if (!driver->rtValid) @@ -1487,10 +1491,6 @@ void rglFBClear( GLbitfield mask ) rglGcmFifoGlFlush(); } -/*============================================================ - PLATFORM FRAMEBUFFER - ============================================================ */ - rglFramebuffer* rglCreateFramebuffer (void) { rglFramebuffer* framebuffer = new rglPlatformFramebuffer(); @@ -1789,13 +1789,160 @@ void rglPlatformRasterExit (void *data) 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 /* 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: // glDrawElements, glDrawRangeElements, glDrawArrays // Slow rendering calls this function also, though it must also perform various // 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; if (RGL_UNLIKELY(!driver->rtValid)) @@ -1835,20 +1982,6 @@ void rglPlatformDraw (void *data) 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 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 } -void rglPlatformRasterFlush (void) +GLAPI void APIENTRY glFlush(void) { + RGLcontext * LContext = _CurrentContext; + + if (RGL_UNLIKELY(LContext->needValidate)) + rglValidateStates( RGL_VALIDATE_ALL ); + rglGcmFifoGlFlush(); } @@ -2851,7 +2989,7 @@ GLenum rglPlatformTranslateTextureFormat( GLenum internalFormat ) // Implementation of texture reference // 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; rglTexture *texture = (rglTexture*)data; @@ -2864,21 +3002,6 @@ GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf, GLboolean isRenderTarget = 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->vertexEnable = vertexEnable; @@ -2900,6 +3023,72 @@ GLboolean rglPlatformTextureReference (void *data, GLuint pitch, void *data_buf, 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 // 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 ); } -/*============================================================ - 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 ============================================================ */ diff --git a/ps3/rgl/src/rgl.cpp b/ps3/rgl/src/rgl.cpp index 99212e0798..2132cf7551 100644 --- a/ps3/rgl/src/rgl.cpp +++ b/ps3/rgl/src/rgl.cpp @@ -30,7 +30,7 @@ static rglBufferObject *rglCreateBufferObject (void) if(!buffer ) return NULL; - memset( buffer, 0, size ); + memset(buffer, 0, size); buffer->refCount = 1; new( &buffer->textureReferences ) RGL::Vector(); @@ -111,27 +111,11 @@ GLAPI GLvoid* APIENTRY glMapBuffer( GLenum target, GLenum access ) rglSetError( GL_INVALID_ENUM ); return NULL; } + 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; - void *result = rglPlatformBufferObjectMap( bufferObject, access ); - return result; + return rglPlatformBufferObjectMap( bufferObject, access ); } GLAPI GLboolean APIENTRY glUnmapBuffer( GLenum target ) @@ -280,15 +264,6 @@ GLAPI void APIENTRY glBufferSubData( GLenum target, GLintptr offset, GLsizeiptr 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 ) { } @@ -759,44 +734,6 @@ void rglImageFreeCPUStorage(void *data) 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 ) { 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) { 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 ) { 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; -#endif rglUpdateCurrentTextureCache( unit ); LContext->needValidate |= RGL_VALIDATE_TEXTURES_USED; @@ -1752,39 +1602,10 @@ GLAPI void APIENTRY glActiveTexture( GLenum texture ) 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 ============================================================ */ -#include /* 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 ) { 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] ); } -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 ============================================================ */ @@ -2049,11 +1844,3 @@ RGLdevice *psglGetCurrentDevice (void) { return _CurrentDevice; } - -GLAPI void RGL_EXPORT psglSwap (void) -{ -#ifndef HAVE_RGL_2D - if ( _CurrentDevice != NULL) -#endif - rglPlatformSwapBuffers( _CurrentDevice ); -} diff --git a/ps3/rgl/src/rglp.h b/ps3/rgl/src/rglp.h index e2f172565b..1a41a05dd1 100644 --- a/ps3/rgl/src/rglp.h +++ b/ps3/rgl/src/rglp.h @@ -22,10 +22,6 @@ #include "ps3/include/rgl-constants.h" #endif -extern void rglpValidateViewport(void); -extern void rglpValidateBlending(void); -extern void rglpValidateShaderSRGBRemap(void); - extern int rglpBufferObjectSize(void); extern GLboolean rglpCreateBufferObject (void *data);