From febbfc44b77c7754796800ab1d7d69fc2c5a5521 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 26 Mar 2013 17:10:42 +0100 Subject: [PATCH] (RGL) Cleanups - cut down on feature set --- ps3/rgl/include/RGL/private.h | 20 --- ps3/rgl/include/export/GLES/gl.h | 6 +- ps3/rgl/include/export/GLES/glext.h | 2 - ps3/rgl/src/ps3/rgl_ps3.cpp | 220 +++++++--------------------- 4 files changed, 50 insertions(+), 198 deletions(-) diff --git a/ps3/rgl/include/RGL/private.h b/ps3/rgl/include/RGL/private.h index 4da6f46bb2..6694cf8f37 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 ); -void rglAttachContext( RGLdevice *device, RGLcontext* context ); void rglDetachContext( RGLdevice *device, RGLcontext* context ); void rglSetFlipHandler(void (*handler)(const GLuint head), RGLdevice *device); void rglSetVBlankHandler(void (*handler)(const GLuint head), RGLdevice *device); @@ -47,7 +46,6 @@ void rglSetVBlankHandler(void (*handler)(const GLuint head), RGLdevice *device); //---------------------------------------- rglTexture *rglAllocateTexture (void); void rglFreeTexture (void *data); -void rglTextureUnbind (void *data, GLuint name ); extern int rglTextureInit( RGLcontext* context, GLuint name ); extern void rglTextureDelete( RGLcontext* context, GLuint name ); extern GLboolean rglTextureHasValidLevels( const rglTexture *texture, int levels, int width, int height, int depth, GLenum format, GLenum type, GLenum internalFormat ); @@ -113,9 +111,6 @@ static inline int rglGetStorageSize( GLenum format, GLenum type, GLsizei width, extern int rglGetTypeSize( GLenum type ); extern int rglGetMaxBitSize( GLenum type ); extern int rglGetStorageSize( GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth ); -extern void rglImageToRaster( const rglImage* image, rglRaster* raster, GLuint x, GLuint y, GLuint z ); -extern void rglRasterToImage( const rglRaster* raster, rglImage* image, GLuint x, GLuint y, GLuint z ); -extern void rglRawRasterToImage (const void *in_data, void *out_data, GLuint x, GLuint y, GLuint z); //---------------------------------------- // FramebufferObject.c @@ -136,27 +131,14 @@ static inline rglFramebuffer *rglGetFramebufferSafe( RGLcontext *LContext, GLuin void rglFramebufferGetAttachmentTexture( RGLcontext* LContext, const rglFramebufferAttachment* attachment, rglTexture** texture, GLuint* face ); GLenum rglPlatformFramebufferCheckStatus (void *data); void rglPlatformFramebufferGetParameteriv( GLenum pname, GLint* params ); -void rglGetFramebufferSize( GLuint* width, GLuint* height ); //---------------------------------------- // VertexArray.c //---------------------------------------- -void rglVertexAttrib1fNV( GLuint index, GLfloat x ); -void rglVertexAttrib1fvNV( GLuint index, const GLfloat* v ); -void rglVertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y ); -void rglVertexAttrib2fvNV( GLuint index, const GLfloat* v ); -void rglVertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z ); -void rglVertexAttrib3fvNV( GLuint index, const GLfloat* v ); void rglVertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -void rglVertexAttrib4fvNV( GLuint index, const GLfloat* v ); void rglVertexAttribPointerNV( GLuint index, GLint fsize, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer ); -void rglVertexAttribElementFunc( GLuint index, GLenum func, GLuint frequency ); void rglEnableVertexAttribArrayNV( GLuint index ); void rglDisableVertexAttribArrayNV( GLuint index ); -GLint rglConvertStream( rglAttributeState* asDst, const rglAttributeState* asSrc, GLuint index, - GLint skip, GLint first, GLint count, - const void* indices, GLenum indexType ); -void rglComputeMinMaxIndices( RGLcontext* LContext, GLuint* min, GLuint* max, const void* indices, GLenum indexType, GLsizei count ); //---------------------------------------- // Platform/Init.c @@ -220,8 +202,6 @@ void rglPlatformGetImageData( GLenum target, GLint level, rglTexture *texture, r // Raster/.../PlatformFBops.c //---------------------------------------- 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 ); diff --git a/ps3/rgl/include/export/GLES/gl.h b/ps3/rgl/include/export/GLES/gl.h index 505b2c854c..0494d68df1 100644 --- a/ps3/rgl/include/export/GLES/gl.h +++ b/ps3/rgl/include/export/GLES/gl.h @@ -476,7 +476,6 @@ extern "C" GLAPI void APIENTRY glClearDepthx( GLclampx depth ); GLAPI void APIENTRY glClearStencil( GLint s ); GLAPI void APIENTRY glClientActiveTexture( GLenum texture ); - GLAPI void APIENTRY glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); GLAPI void APIENTRY glColor4x( GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha ); GLAPI void APIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); GLAPI void APIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); @@ -514,7 +513,6 @@ extern "C" GLAPI void APIENTRY glMultiTexCoord4x( GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q ); GLAPI void APIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); GLAPI void APIENTRY glNormal3x( GLfixed nx, GLfixed ny, GLfixed nz ); - GLAPI void APIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer ); GLAPI void APIENTRY glOrthof( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar ); GLAPI void APIENTRY glOrthox( GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar ); GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ); @@ -539,9 +537,7 @@ extern "C" GLAPI void APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); GLAPI void APIENTRY glTexParameterx( GLenum target, GLenum pname, GLfixed param ); GLAPI void APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); - GLAPI void APIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); - GLAPI void APIENTRY glTranslatex( GLfixed x, GLfixed y, GLfixed z ); - 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 ); GLAPI void APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); #ifdef __cplusplus diff --git a/ps3/rgl/include/export/GLES/glext.h b/ps3/rgl/include/export/GLES/glext.h index 8c4ad92822..990739b5f0 100644 --- a/ps3/rgl/include/export/GLES/glext.h +++ b/ps3/rgl/include/export/GLES/glext.h @@ -365,8 +365,6 @@ extern "C" GLAPI void APIENTRY glBlendFuncSeparate( GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha ); GLAPI void APIENTRY glBlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); GLAPI void APIENTRY glNormal3fv( const GLfloat* v ); - GLAPI void APIENTRY glColor4fv( const GLfloat* v ); - GLAPI void APIENTRY glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); GLAPI void APIENTRY glGetBooleanv( GLenum pname, GLboolean* params ); GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat* params ); GLAPI void APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GLfloat* params ); diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index cfabf52dd6..992ffd90f4 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -3261,25 +3261,6 @@ static void rglFreeBufferObject (void *data) } } -static void rglUnbindBufferObject (void *data, GLuint name) -{ - RGLcontext *LContext = (RGLcontext*)data; - - if (LContext->ArrayBuffer == name) - LContext->ArrayBuffer = 0; - if (LContext->PixelUnpackBuffer == name) - LContext->PixelUnpackBuffer = 0; - - for ( int i = 0;i < RGL_MAX_VERTEX_ATTRIBS;++i ) - { - if ( LContext->attribs->attrib[i].arrayBuffer == name ) - { - LContext->attribs->attrib[i].arrayBuffer = 0; - LContext->attribs->HasVBOMask &= ~( 1 << i ); - } - } -} - GLAPI void APIENTRY glBindBuffer( GLenum target, GLuint name ) { RGLcontext *LContext = _CurrentContext; @@ -3364,7 +3345,23 @@ GLAPI void APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers ) if(!rglTexNameSpaceIsName(&LContext->bufferObjectNameSpace, buffers[i])) continue; if (buffers[i]) - rglUnbindBufferObject( LContext, buffers[i] ); + { + GLuint name = buffers[i]; + + if (LContext->ArrayBuffer == name) + LContext->ArrayBuffer = 0; + if (LContext->PixelUnpackBuffer == name) + LContext->PixelUnpackBuffer = 0; + + for ( int i = 0;i < RGL_MAX_VERTEX_ATTRIBS;++i ) + { + if ( LContext->attribs->attrib[i].arrayBuffer == name ) + { + LContext->attribs->attrib[i].arrayBuffer = 0; + LContext->attribs->HasVBOMask &= ~( 1 << i ); + } + } + } } rglTexNameSpaceDeleteNames( &LContext->bufferObjectNameSpace, n, buffers ); } @@ -3512,41 +3509,6 @@ rglFramebufferAttachment* rglFramebufferGetAttachment(void *data, GLenum attachm } } -void rglGetFramebufferSize( GLuint* width, GLuint* height ) -{ - RGLcontext* LContext = _CurrentContext; - - *width = *height = 0; - - if ( LContext->framebuffer ) - { - rglFramebuffer* framebuffer = rglGetFramebuffer( LContext, LContext->framebuffer ); - - if (rglPlatformFramebufferCheckStatus(framebuffer) != GL_FRAMEBUFFER_COMPLETE_OES) - return; - - for ( int i = 0; i < RGL_MAX_COLOR_ATTACHMENTS; ++i ) - { - rglTexture* colorTexture = NULL; - GLuint face = 0; - rglFramebufferGetAttachmentTexture( LContext, &framebuffer->color[i], &colorTexture, &face ); - if (colorTexture == NULL) - continue; - - unsigned texture_width = colorTexture->image->width; - unsigned texture_height = colorTexture->image->height; - *width = MIN( *width, texture_width); - *height = MIN( *height, texture_height); - } - } - else - { - RGLdevice *LDevice = _CurrentDevice; - *width = LDevice->deviceParameters.width; - *height = LDevice->deviceParameters.height; - } -} - GLAPI GLboolean APIENTRY glIsFramebufferOES( GLuint framebuffer ) { RGLcontext* LContext = _CurrentContext; @@ -4207,20 +4169,6 @@ void RGL_EXPORT psglDestroyContext (void *data) free( LContext ); } -void rglAttachContext (RGLdevice *device, RGLcontext* context) -{ - if (!context->everAttached) - { - context->ViewPort.XSize = device->deviceParameters.width; - context->ViewPort.YSize = device->deviceParameters.height; - context->needValidate |= RGL_VALIDATE_VIEWPORT | RGL_VALIDATE_SCISSOR_BOX; - context->everAttached = GL_TRUE; - } - - context->needValidate = RGL_VALIDATE_ALL; - context->attribs->DirtyMask = ( 1 << RGL_MAX_VERTEX_ATTRIBS ) - 1; -} - GLAPI void APIENTRY glEnable( GLenum cap ) { RGLcontext* LContext = _CurrentContext; @@ -4423,28 +4371,6 @@ void rglFreeTexture (void *data) free( texture ); } -void rglTextureUnbind (void *data, GLuint name ) -{ - RGLcontext *context = (RGLcontext*)data; - int unit; - - for ( unit = 0; unit < RGL_MAX_TEXTURE_IMAGE_UNITS; ++unit) - { - rglTextureImageUnit *tu = context->TextureImageUnits + unit; - GLboolean dirty = GL_FALSE; - if ( tu->bound2D == name ) - { - tu->bound2D = 0; - dirty = GL_TRUE; - } - if ( dirty ) - { - rglUpdateCurrentTextureCache( tu ); - context->needValidate |= RGL_VALIDATE_TEXTURES_USED; - } - } -} - GLboolean rglTextureIsValid (const void *data) { const rglTexture *texture = (const rglTexture*)data; @@ -4601,7 +4527,26 @@ GLAPI void APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures ) for ( int i = 0;i < n;++i ) { if (textures[i]) - rglTextureUnbind( LContext, textures[i] ); + { + GLuint name = textures[i]; + int unit; + + for ( unit = 0; unit < RGL_MAX_TEXTURE_IMAGE_UNITS; ++unit) + { + rglTextureImageUnit *tu = LContext->TextureImageUnits + unit; + GLboolean dirty = GL_FALSE; + if ( tu->bound2D == name ) + { + tu->bound2D = 0; + dirty = GL_TRUE; + } + if ( dirty ) + { + rglUpdateCurrentTextureCache( tu ); + LContext->needValidate |= RGL_VALIDATE_TEXTURES_USED; + } + } + } } rglTexNameSpaceDeleteNames( &LContext->textureNameSpace, n, textures ); @@ -4739,27 +4684,6 @@ GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, co rglVertexAttribPointerNV( RGL_ATTRIB_POSITION_INDEX, size, type, GL_FALSE, stride, pointer ); } -GLAPI void APIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid* pointer ) -{ - rglVertexAttribPointerNV( RGL_ATTRIB_NORMAL_INDEX, 3, type, GL_TRUE, stride, pointer ); -} - -GLAPI void APIENTRY glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) -{ - rglVertexAttrib4fNV( RGL_ATTRIB_PRIMARY_COLOR_INDEX, red, green, blue, alpha ); -} - -GLAPI void APIENTRY glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) -{ - const float f = 1.f / 255.f; - rglVertexAttrib4fNV( RGL_ATTRIB_PRIMARY_COLOR_INDEX, f*red, f*green, f*blue, f*alpha ); -} - -GLAPI void APIENTRY glColor4fv( const GLfloat *v ) -{ - rglVertexAttrib4fvNV( RGL_ATTRIB_PRIMARY_COLOR_INDEX, v ); -} - void rglVertexAttribPointerNV( GLuint index, GLint fsize, @@ -4818,43 +4742,6 @@ void rglDisableVertexAttribArrayNV (GLuint index) RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); } -void rglVertexAttrib1fNV (GLuint index, GLfloat x) -{ - RGLcontext* LContext = _CurrentContext; - - rglAttribute* attrib = LContext->attribs->attrib + index; - attrib->value[0] = x; - attrib->value[1] = 0.0f; - attrib->value[2] = 0.0f; - attrib->value[3] = 1.0f; - RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); -} - -void rglVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y) -{ - RGLcontext* LContext = _CurrentContext; - - rglAttribute* attrib = LContext->attribs->attrib + index; - attrib->value[0] = x; - attrib->value[1] = y; - attrib->value[2] = 0.0f; - attrib->value[3] = 1.0f; - RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); -} - -void rglVertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z ) -{ - RGLcontext* LContext = _CurrentContext; - - rglAttribute* attrib = LContext->attribs->attrib + index; - attrib->value[0] = x; - attrib->value[1] = y; - attrib->value[2] = z; - attrib->value[3] = 1.0f; - RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); - -} - void rglVertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { RGLcontext* LContext = _CurrentContext; @@ -4867,26 +4754,6 @@ void rglVertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat RGLBIT_TRUE( LContext->attribs->DirtyMask, index ); } -void rglVertexAttrib1fvNV( GLuint index, const GLfloat* v ) -{ - rglVertexAttrib1fNV( index, v[0] ); -} - -void rglVertexAttrib2fvNV( GLuint index, const GLfloat* v ) -{ - rglVertexAttrib2fNV( index, v[0], v[1] ); -} - -void rglVertexAttrib3fvNV( GLuint index, const GLfloat* v ) -{ - rglVertexAttrib3fNV( index, v[0], v[1], v[2] ); -} - -void rglVertexAttrib4fvNV( GLuint index, const GLfloat* v ) -{ - rglVertexAttrib4fNV( index, v[0], v[1], v[2], v[3] ); -} - /*============================================================ DEVICE CONTEXT CREATION ============================================================ */ @@ -4958,7 +4825,18 @@ void RGL_EXPORT psglMakeCurrent (RGLcontext *context, RGLdevice *device) { device->rasterDriver = rglPlatformRasterInit(); } - rglAttachContext( device, context ); + + //attach context + if (!context->everAttached) + { + context->ViewPort.XSize = device->deviceParameters.width; + context->ViewPort.YSize = device->deviceParameters.height; + context->needValidate |= RGL_VALIDATE_VIEWPORT | RGL_VALIDATE_SCISSOR_BOX; + context->everAttached = GL_TRUE; + } + + context->needValidate = RGL_VALIDATE_ALL; + context->attribs->DirtyMask = ( 1 << RGL_MAX_VERTEX_ATTRIBS ) - 1; } else {