Browse Source

GBufferGroup colors to std::vector

Adam Johnson 10 years ago
parent
commit
e7a0f4a4d1
  1. 28
      Sources/Plasma/PubUtilLib/plPipeline/plGBufferGroup.cpp
  2. 14
      Sources/Plasma/PubUtilLib/plPipeline/plGBufferGroup.h

28
Sources/Plasma/PubUtilLib/plPipeline/plGBufferGroup.cpp

@ -114,7 +114,7 @@ plGBufferGroup::plGBufferGroup( uint8_t format, bool vertsVolatile, bool idxVola
{ {
fVertBuffStorage.Reset(); fVertBuffStorage.Reset();
fIdxBuffStorage.Reset(); fIdxBuffStorage.Reset();
fColorBuffStorage.Reset(); fColorBuffStorage.clear();
fVertexBufferRefs.Reset(); fVertexBufferRefs.Reset();
fIndexBufferRefs.Reset(); fIndexBufferRefs.Reset();
fCells.clear(); fCells.clear();
@ -216,7 +216,7 @@ void plGBufferGroup::CleanUp( void )
plProfile_DelMem(MemBufGrpIndex, fIdxBuffCounts[i] * sizeof(uint16_t)); plProfile_DelMem(MemBufGrpIndex, fIdxBuffCounts[i] * sizeof(uint16_t));
delete [] fIdxBuffStorage[ i ]; delete [] fIdxBuffStorage[ i ];
} }
for( i = 0; i < fColorBuffStorage.GetCount(); i++ ) for (size_t i = 0; i < fColorBuffStorage.size(); ++i)
{ {
plProfile_DelMem(MemBufGrpVertex, fColorBuffCounts[i] * sizeof(plGBufferColor)); plProfile_DelMem(MemBufGrpVertex, fColorBuffCounts[i] * sizeof(plGBufferColor));
delete [] fColorBuffStorage[ i ]; delete [] fColorBuffStorage[ i ];
@ -233,8 +233,8 @@ void plGBufferGroup::CleanUp( void )
fIdxBuffCounts.Reset(); fIdxBuffCounts.Reset();
fIdxBuffStarts.Reset(); fIdxBuffStarts.Reset();
fIdxBuffEnds.Reset(); fIdxBuffEnds.Reset();
fColorBuffStorage.Reset(); fColorBuffStorage.clear();
fColorBuffCounts.Reset(); fColorBuffCounts.clear();
fCells.clear(); fCells.clear();
} }
@ -374,7 +374,7 @@ void plGBufferGroup::Read( hsStream *s )
fVertBuffSizes.Reset(); fVertBuffSizes.Reset();
fVertBuffStarts.Reset(); fVertBuffStarts.Reset();
fVertBuffEnds.Reset(); fVertBuffEnds.Reset();
fColorBuffCounts.Reset(); fColorBuffCounts.clear();
fIdxBuffCounts.Reset(); fIdxBuffCounts.Reset();
fIdxBuffStarts.Reset(); fIdxBuffStarts.Reset();
fIdxBuffEnds.Reset(); fIdxBuffEnds.Reset();
@ -401,8 +401,8 @@ void plGBufferGroup::Read( hsStream *s )
coder.Read(s, vData, fFormat, fStride, numVerts); coder.Read(s, vData, fFormat, fStride, numVerts);
fColorBuffCounts.Append(0); fColorBuffCounts.push_back(0);
fColorBuffStorage.Append(nil); fColorBuffStorage.push_back(nullptr);
} }
else else
@ -420,7 +420,7 @@ void plGBufferGroup::Read( hsStream *s )
plProfile_NewMem(MemBufGrpVertex, temp); plProfile_NewMem(MemBufGrpVertex, temp);
temp = s->ReadLE32(); temp = s->ReadLE32();
fColorBuffCounts.Append( temp ); fColorBuffCounts.push_back( temp );
if( temp > 0 ) if( temp > 0 )
{ {
@ -431,7 +431,7 @@ void plGBufferGroup::Read( hsStream *s )
else else
cData = nil; cData = nil;
fColorBuffStorage.Append( cData ); fColorBuffStorage.push_back( cData );
} }
} }
@ -753,8 +753,8 @@ bool plGBufferGroup::ReserveVertStorage( uint32_t numVerts, uint32_t *vbIndex
fVertBuffStarts.Append(0); fVertBuffStarts.Append(0);
fVertBuffEnds.Append(-1); fVertBuffEnds.Append(-1);
fColorBuffStorage.Append( nil ); fColorBuffStorage.push_back(nullptr);
fColorBuffCounts.Append( 0 ); fColorBuffCounts.push_back(0);
fCells.push_back( new std::vector<plGBufferCell> ); fCells.push_back( new std::vector<plGBufferCell> );
} }
@ -795,15 +795,15 @@ bool plGBufferGroup::ReserveVertStorage( uint32_t numVerts, uint32_t *vbIndex
} }
/// Switch over /// Switch over
if( storagePtr != nil ) if (storagePtr)
{ {
if( fVertBuffStorage[ i ] != nil ) if( fVertBuffStorage[ i ] != nil )
delete [] fVertBuffStorage[ i ]; delete [] fVertBuffStorage[ i ];
fVertBuffStorage[ i ] = storagePtr; fVertBuffStorage[ i ] = storagePtr;
} }
if( cStoragePtr != nil ) if (cStoragePtr)
{ {
if( fColorBuffStorage[ i ] != nil ) if (fColorBuffStorage[ i ])
delete [] fColorBuffStorage[ i ]; delete [] fColorBuffStorage[ i ];
fColorBuffStorage[ i ] = cStoragePtr; fColorBuffStorage[ i ] = cStoragePtr;
fColorBuffCounts[ i ] += numVerts; fColorBuffCounts[ i ] += numVerts;

14
Sources/Plasma/PubUtilLib/plPipeline/plGBufferGroup.h

@ -125,18 +125,18 @@ class plGBufferGroup
hsTArray<hsGDeviceRef *> fVertexBufferRefs; hsTArray<hsGDeviceRef *> fVertexBufferRefs;
hsTArray<hsGDeviceRef *> fIndexBufferRefs; hsTArray<hsGDeviceRef *> fIndexBufferRefs;
hsTArray<uint32_t> fVertBuffSizes; hsTArray<uint32_t> fVertBuffSizes;
hsTArray<uint32_t> fIdxBuffCounts; hsTArray<uint32_t> fIdxBuffCounts;
hsTArray<uint32_t> fColorBuffCounts; std::vector<uint32_t> fColorBuffCounts;
hsTArray<uint8_t *> fVertBuffStorage; hsTArray<uint8_t *> fVertBuffStorage;
hsTArray<uint16_t *> fIdxBuffStorage; hsTArray<uint16_t *> fIdxBuffStorage;
hsTArray<uint32_t> fVertBuffStarts; hsTArray<uint32_t> fVertBuffStarts;
hsTArray<int32_t> fVertBuffEnds; hsTArray<int32_t> fVertBuffEnds;
hsTArray<uint32_t> fIdxBuffStarts; hsTArray<uint32_t> fIdxBuffStarts;
hsTArray<int32_t> fIdxBuffEnds; hsTArray<int32_t> fIdxBuffEnds;
hsTArray<plGBufferColor *> fColorBuffStorage; std::vector<plGBufferColor*> fColorBuffStorage;
std::vector<std::vector<plGBufferCell>*> fCells; std::vector<std::vector<plGBufferCell>*> fCells;
@ -236,7 +236,7 @@ class plGBufferGroup
uint8_t *GetVertBufferData( uint32_t idx ) { return fVertBuffStorage[ idx ]; } uint8_t *GetVertBufferData( uint32_t idx ) { return fVertBuffStorage[ idx ]; }
uint16_t *GetIndexBufferData( uint32_t idx ) { return fIdxBuffStorage[ idx ]; } uint16_t *GetIndexBufferData( uint32_t idx ) { return fIdxBuffStorage[ idx ]; }
plGBufferColor *GetColorBufferData( uint32_t idx ) { return fColorBuffStorage[ idx ]; } plGBufferColor *GetColorBufferData( size_t idx ) { return fColorBuffStorage[ idx ]; }
hsGDeviceRef *GetVertexBufferRef( uint32_t i ); hsGDeviceRef *GetVertexBufferRef( uint32_t i );
hsGDeviceRef *GetIndexBufferRef( uint32_t i ); hsGDeviceRef *GetIndexBufferRef( uint32_t i );

Loading…
Cancel
Save