Fixed the GLBufferObject size computation so that it takes into account padding.
This commit is contained in:
@@ -152,6 +152,14 @@ class BufferObjectProfile
|
|||||||
class GLBufferObjectSet;
|
class GLBufferObjectSet;
|
||||||
class GLBufferObjectManager;
|
class GLBufferObjectManager;
|
||||||
|
|
||||||
|
inline unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment)
|
||||||
|
{
|
||||||
|
if (bufferAlignment<2) return pos;
|
||||||
|
if ((pos%bufferAlignment)==0) return pos;
|
||||||
|
return ((pos/bufferAlignment)+1)*bufferAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class OSG_EXPORT GLBufferObject : public GraphicsObject
|
class OSG_EXPORT GLBufferObject : public GraphicsObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -235,9 +243,7 @@ class OSG_EXPORT GLBufferObject : public GraphicsObject
|
|||||||
|
|
||||||
unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment) const
|
unsigned int computeBufferAlignment(unsigned int pos, unsigned int bufferAlignment) const
|
||||||
{
|
{
|
||||||
if (bufferAlignment<2) return pos;
|
return osg::computeBufferAlignment(pos, bufferAlignment);
|
||||||
if ((pos%bufferAlignment)==0) return pos;
|
|
||||||
return ((pos/bufferAlignment)+1)*bufferAlignment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int _contextID;
|
unsigned int _contextID;
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ void GLBufferObject::compileBuffer()
|
|||||||
entry.dataSource != bd ||
|
entry.dataSource != bd ||
|
||||||
entry.dataSize != bd->getTotalDataSize())
|
entry.dataSize != bd->getTotalDataSize())
|
||||||
{
|
{
|
||||||
unsigned int previousEndOfBufferDataMarker = computeBufferAlignment(entry.offset + entry.dataSize, bufferAlignment);
|
unsigned int previousEndOfBufferDataMarker = osg::computeBufferAlignment(entry.offset + entry.dataSize, bufferAlignment);
|
||||||
|
|
||||||
// OSG_NOTICE<<"GLBufferObject::compileBuffer(..) updating BufferEntry"<<std::endl;
|
// OSG_NOTICE<<"GLBufferObject::compileBuffer(..) updating BufferEntry"<<std::endl;
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ void GLBufferObject::compileBuffer()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newTotalSize = computeBufferAlignment(newTotalSize + entry.dataSize, bufferAlignment);
|
newTotalSize = osg::computeBufferAlignment(newTotalSize + entry.dataSize, bufferAlignment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1188,13 +1188,14 @@ void BufferObject::removeBufferData(BufferData* bd)
|
|||||||
|
|
||||||
unsigned int BufferObject::computeRequiredBufferSize() const
|
unsigned int BufferObject::computeRequiredBufferSize() const
|
||||||
{
|
{
|
||||||
|
unsigned int bufferAlignment = 4;
|
||||||
unsigned int newTotalSize = 0;
|
unsigned int newTotalSize = 0;
|
||||||
for(BufferDataList::const_iterator itr = _bufferDataList.begin();
|
for(BufferDataList::const_iterator itr = _bufferDataList.begin();
|
||||||
itr != _bufferDataList.end();
|
itr != _bufferDataList.end();
|
||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
BufferData* bd = *itr;
|
BufferData* bd = *itr;
|
||||||
if (bd) newTotalSize += bd->getTotalDataSize();
|
if (bd) newTotalSize = osg::computeBufferAlignment(newTotalSize + bd->getTotalDataSize(), bufferAlignment);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OSG_NOTICE<<"BufferObject::"<<this<<":"<<className()<<"::BufferObject::computeRequiredBufferSize() error, BufferData is 0x0"<<std::endl;
|
OSG_NOTICE<<"BufferObject::"<<this<<":"<<className()<<"::BufferObject::computeRequiredBufferSize() error, BufferData is 0x0"<<std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user