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
# (and who have contributed) code to the ANGLE project
# repository.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
TransGaming Inc.
Nicolas Capens
Daniel Koch
Andrew Lewycky
Gavriel State
Shannon Woods
Google Inc.
Brent Austin
John Bauman
Henry Bridge
Nat Duca
Vangelis Kokkevis
Alastair Patrick
Alok Priyadarshi
Kenneth Russell
Ben Vanik
Adrienne Walker
Zhenyao Mo
Mozilla Corp.
Vladimir Vukicevic
Benoit Jacob
Apple Inc.
David Kilzer
Aitor Moreno <aitormoreno at gmail.com>
Jim Hauxwell <james at dattrax.co.uk>
ddefrostt
timeless
# This is the official list of people who can contribute
# (and who have contributed) code to the ANGLE project
# repository.
# The AUTHORS file lists the copyright holders; this file
# lists people. For example, Google employees are listed here
# but not in AUTHORS, because Google holds the copyright.
#
TransGaming Inc.
Nicolas Capens
Daniel Koch
Andrew Lewycky
Gavriel State
Shannon Woods
Google Inc.
Brent Austin
John Bauman
Henry Bridge
Nat Duca
Vangelis Kokkevis
Alastair Patrick
Alok Priyadarshi
Kenneth Russell
Ben Vanik
Adrienne Walker
Zhenyao Mo
Mozilla Corp.
Vladimir Vukicevic
Benoit Jacob
Apple Inc.
David Kilzer
Aitor Moreno <aitormoreno at gmail.com>
Jim Hauxwell <james at dattrax.co.uk>
ddefrostt
timeless
Yore Apex
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 701
#define BUILD_REVISION 702
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -139,9 +139,23 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
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 @@ void ArrayVertexBuffer::addRequiredSpace(UINT 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)
{
}
......
......@@ -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 reserveRequiredSpace() = 0;
void addRequiredSpace(UINT requiredSpace);
void addRequiredSpaceFor(ArrayVertexBuffer *buffer);
protected:
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