(RGL PS3) Cleanups #3

This commit is contained in:
twinaphex 2014-02-18 00:53:42 +01:00
parent ab8221a258
commit dc98252d82
4 changed files with 18 additions and 25 deletions

View File

@ -9,10 +9,10 @@ namespace RGL
template<class T> 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<T*>( realloc( static_cast<void *>( 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]; }
};
}

View File

@ -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;

View File

@ -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 );

View File

@ -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;