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
parent a2a85dc1
...@@ -37,3 +37,4 @@ Aitor Moreno <aitormoreno at gmail.com> ...@@ -37,3 +37,4 @@ Aitor Moreno <aitormoreno at gmail.com>
Jim Hauxwell <james at dattrax.co.uk> Jim Hauxwell <james at dattrax.co.uk>
ddefrostt ddefrostt
timeless timeless
Yore Apex
#define MAJOR_VERSION 0 #define MAJOR_VERSION 0
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 701 #define BUILD_REVISION 702
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -139,9 +139,23 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat ...@@ -139,9 +139,23 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
else if (staticBuffer->lookupAttribute(attribs[i]) == -1) else if (staticBuffer->lookupAttribute(attribs[i]) == -1)
{ {
// This static buffer doesn't have matching attributes, so fall back to using the streaming buffer // This static buffer doesn't have matching attributes, so fall back to using the streaming buffer
mStreamingBuffer->addRequiredSpaceFor(staticBuffer);
buffer->invalidateStaticData(); 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)); mStreamingBuffer->addRequiredSpace(spaceRequired(attribs[i], count));
} }
} }
...@@ -583,11 +597,6 @@ void ArrayVertexBuffer::addRequiredSpace(UINT requiredSpace) ...@@ -583,11 +597,6 @@ void ArrayVertexBuffer::addRequiredSpace(UINT requiredSpace)
mRequiredSpace += requiredSpace; 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) StreamingVertexBuffer::StreamingVertexBuffer(IDirect3DDevice9 *device, std::size_t initialSize) : ArrayVertexBuffer(device, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY)
{ {
} }
......
...@@ -67,7 +67,6 @@ class ArrayVertexBuffer : public VertexBuffer ...@@ -67,7 +67,6 @@ class ArrayVertexBuffer : public VertexBuffer
virtual void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset) = 0; virtual void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset) = 0;
virtual void reserveRequiredSpace() = 0; virtual void reserveRequiredSpace() = 0;
void addRequiredSpace(UINT requiredSpace); void addRequiredSpace(UINT requiredSpace);
void addRequiredSpaceFor(ArrayVertexBuffer *buffer);
protected: protected:
std::size_t mBufferSize; std::size_t mBufferSize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment