From 346557c7d6d4cbfc417ded0ddf854e12b412cf1c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 18 Feb 2014 01:36:49 +0100 Subject: [PATCH] (RGL PS3) Get rid of pushBack in RGLVector --- ps3/rgl/include/RGL/Base.h | 4 +--- ps3/rgl/src/rgl_ps3_raster.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ps3/rgl/include/RGL/Base.h b/ps3/rgl/include/RGL/Base.h index 10a77b1f3d..4fe78de686 100644 --- a/ps3/rgl/include/RGL/Base.h +++ b/ps3/rgl/include/RGL/Base.h @@ -25,10 +25,8 @@ namespace RGL for ( unsigned int i = 0;i < count;++i ) ( array + i )->~T(); count = 0; - } - - if (array) free(array); + } array = 0; } diff --git a/ps3/rgl/src/rgl_ps3_raster.cpp b/ps3/rgl/src/rgl_ps3_raster.cpp index b2c05d731c..08c17f5bde 100644 --- a/ps3/rgl/src/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/rgl_ps3_raster.cpp @@ -2515,6 +2515,26 @@ GLenum rglPlatformChooseInternalStorage (void *data, GLenum internalFormat ) return GL_NO_ERROR; } +static inline void textureReferences_pushBack(rglTexture *element) +{ + RGLcontext* LContext = (RGLcontext*)_CurrentContext; + rglTexture *texture = (rglTexture*)rglGetCurrentTexture( LContext->CurrentImageUnit, GL_TEXTURE_2D ); + rglBufferObject *bufferObject = (rglBufferObject*)LContext->bufferObjectNameSpace.data[LContext->TextureBuffer]; + + uint32_t newCapacity = bufferObject->textureReferences.count + 1; + + if (newCapacity > bufferObject->textureReferences.capacity) + { + if ( newCapacity > bufferObject->textureReferences.capacity ) + newCapacity = ( newCapacity > bufferObject->textureReferences.capacity + bufferObject->textureReferences.increment ) ? newCapacity : ( bufferObject->textureReferences.capacity + bufferObject->textureReferences.increment ); + + bufferObject->textureReferences.array = (rglTexture**)realloc((void *)(bufferObject->textureReferences.array), sizeof(rglTexture) * newCapacity); + bufferObject->textureReferences.capacity = newCapacity; + } + new((void *)(bufferObject->textureReferences.array + bufferObject->textureReferences.count))rglTexture((const rglTexture&)element); + ++bufferObject->textureReferences.count; +} + GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, GLuint baseWidth, GLuint baseHeight, GLuint baseDepth, GLenum internalFormat, GLuint pitch, GLintptr offset ) { @@ -2594,7 +2614,8 @@ GLAPI void APIENTRY glTextureReferenceSCE( GLenum target, GLuint levels, texture->revalidate |= RGL_TEXTURE_REVALIDATE_PARAMETERS; rglTextureTouchFBOs( texture ); - bufferObject->textureReferences.pushBack( texture ); + textureReferences_pushBack(texture); + texture->referenceBuffer = bufferObject; texture->offset = offset; rglTextureTouchFBOs( texture );