diff --git a/ps3/rgl/include/RGL/Base.h b/ps3/rgl/include/RGL/Base.h index 8419400c16..10a77b1f3d 100644 --- a/ps3/rgl/include/RGL/Base.h +++ b/ps3/rgl/include/RGL/Base.h @@ -9,10 +9,10 @@ namespace RGL template class Vector { + public: T* array; unsigned int capacity; unsigned int increment; - public: unsigned int count; void * operator new( size_t size ) { return malloc( size ); } void * operator new( size_t /*size*/, void *p ) { return p; } @@ -27,28 +27,24 @@ namespace RGL count = 0; } - reallocArray( 0 ); - } - - inline void reallocArray( unsigned int newCapacity ) - { - if ( newCapacity == capacity ) - return; - if ( newCapacity > capacity ) - newCapacity = ( newCapacity > capacity + increment ) ? newCapacity : ( capacity + increment ); - if ( newCapacity == 0 ) - { - free( array ); - array = 0; - } - else array = static_cast( realloc( static_cast( array ), sizeof( T ) * newCapacity ) ); - capacity = newCapacity; + if (array) + free(array); + array = 0; } inline unsigned int pushBack( const T &element ) { - if ( count + 1 > capacity ) reallocArray( count + 1 ); - new(( void * )( array + count ) ) T( element ); + uint32_t newCapacity = count + 1; + + if (newCapacity > capacity) + { + if ( newCapacity > capacity ) + newCapacity = ( newCapacity > capacity + increment ) ? newCapacity : ( capacity + increment ); + + array = (T*)realloc((void *)(array), sizeof(T) * newCapacity); + capacity = newCapacity; + } + new((void *)(array + count))T( element ); return ++count; } @@ -66,9 +62,6 @@ namespace RGL } } } - - inline T *getArray() const { return array; } - inline T& operator []( int i ) const { return array[i]; } }; } diff --git a/ps3/rgl/include/RGL/private.h b/ps3/rgl/include/RGL/private.h index eb829b889f..e8dfcae0cc 100644 --- a/ps3/rgl/include/RGL/private.h +++ b/ps3/rgl/include/RGL/private.h @@ -72,7 +72,7 @@ static inline void rglTextureTouchFBOs (void *data) rglFramebuffer *contextFramebuffer = LContext->framebuffer ? rglGetFramebuffer( LContext, LContext->framebuffer ) : NULL; for ( GLuint i = 0;i < fbCount;++i ) { - rglFramebuffer* framebuffer = texture->framebuffers[i]; + rglFramebuffer* framebuffer = texture->framebuffers.array[i]; framebuffer->needValidate = GL_TRUE; if (RGL_UNLIKELY( framebuffer == contextFramebuffer)) LContext->needValidate |= PSGL_VALIDATE_FRAMEBUFFER; diff --git a/ps3/rgl/src/rgl_ps3.cpp b/ps3/rgl/src/rgl_ps3.cpp index b0378defa9..5f4bff75be 100644 --- a/ps3/rgl/src/rgl_ps3.cpp +++ b/ps3/rgl/src/rgl_ps3.cpp @@ -3814,7 +3814,7 @@ static void rglFreeTexture (void *data) rglImageFreeCPUStorage( image ); free( texture->image ); } - if ( texture->referenceBuffer ) + if (texture->referenceBuffer) texture->referenceBuffer->textureReferences.removeElement( texture ); rglPlatformDestroyTexture( texture ); free( texture ); diff --git a/ps3/rgl/src/rgl_ps3_raster.cpp b/ps3/rgl/src/rgl_ps3_raster.cpp index 6a300f203a..b2c05d731c 100644 --- a/ps3/rgl/src/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/rgl_ps3_raster.cpp @@ -769,7 +769,7 @@ static void rglpsAllocateBuffer (void *data) { for ( GLuint i = 0;i < referenceCount;++i ) { - rglTexture *texture = bufferObject->textureReferences[i]; + rglTexture *texture = (rglTexture*)bufferObject->textureReferences.array[i]; rglGcmTexture *gcmTexture = ( rglGcmTexture * )texture->platformTexture; gcmTexture->gpuAddressId = rglBuffer->bufferId; gcmTexture->gpuAddressIdOffset = texture->offset;