Fix an overflow issue when a static buffer is invalidated.
Issue=104,139,179
TRAC #15143
Signed-off-by: Daniel Koch
Author: Nicolas Capens
Original-patch-by: Yore Apex
git-svn-id: https://angleproject.googlecode.com/svn/trunk@702 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/VertexDataManager.cpp b/src/libGLESv2/VertexDataManager.cpp
index 8a7d9f0..e339b10 100644
--- a/src/libGLESv2/VertexDataManager.cpp
+++ b/src/libGLESv2/VertexDataManager.cpp
@@ -139,9 +139,23 @@
else if (staticBuffer->lookupAttribute(attribs[i]) == -1)
{
// This static buffer doesn't have matching attributes, so fall back to using the streaming buffer
- mStreamingBuffer->addRequiredSpaceFor(staticBuffer);
buffer->invalidateStaticData();
+ // Add the space of all previous attributes belonging to the invalidated static buffer to the streaming buffer
+ for (int previous = 0; previous < i; previous++)
+ {
+ if (translated[previous].active && attribs[previous].mArrayEnabled)
+ {
+ Buffer *previousBuffer = attribs[previous].mBoundBuffer.get();
+ StaticVertexBuffer *previousStaticBuffer = previousBuffer ? previousBuffer->getStaticVertexBuffer() : NULL;
+
+ if (staticBuffer == previousStaticBuffer)
+ {
+ mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[previous], count));
+ }
+ }
+ }
+
mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count));
}
}
@@ -583,11 +597,6 @@
mRequiredSpace += requiredSpace;
}
-void ArrayVertexBuffer::addRequiredSpaceFor(ArrayVertexBuffer *buffer)
-{
- mRequiredSpace += buffer->mRequiredSpace;
-}
-
StreamingVertexBuffer::StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize) : ArrayVertexBuffer(device, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY)
{
}