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
# This is the official list of people who can contribute # This is the official list of people who can contribute
# (and who have contributed) code to the ANGLE project # (and who have contributed) code to the ANGLE project
# repository. # repository.
# The AUTHORS file lists the copyright holders; this file # The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here # lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright. # but not in AUTHORS, because Google holds the copyright.
# #
TransGaming Inc. TransGaming Inc.
Nicolas Capens Nicolas Capens
Daniel Koch Daniel Koch
Andrew Lewycky Andrew Lewycky
Gavriel State Gavriel State
Shannon Woods Shannon Woods
Google Inc. Google Inc.
Brent Austin Brent Austin
John Bauman John Bauman
Henry Bridge Henry Bridge
Nat Duca Nat Duca
Vangelis Kokkevis Vangelis Kokkevis
Alastair Patrick Alastair Patrick
Alok Priyadarshi Alok Priyadarshi
Kenneth Russell Kenneth Russell
Ben Vanik Ben Vanik
Adrienne Walker Adrienne Walker
Zhenyao Mo Zhenyao Mo
Mozilla Corp. Mozilla Corp.
Vladimir Vukicevic Vladimir Vukicevic
Benoit Jacob Benoit Jacob
Apple Inc. Apple Inc.
David Kilzer David Kilzer
Aitor Moreno <aitormoreno at gmail.com> 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