Support BufferData with size zero.

TRAC #12027 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Andrew Lewycky git-svn-id: https://angleproject.googlecode.com/svn/trunk@191 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent c46c9c07
...@@ -37,7 +37,14 @@ GLenum Buffer::bufferData(const void* data, GLsizeiptr size, GLenum usage) ...@@ -37,7 +37,14 @@ GLenum Buffer::bufferData(const void* data, GLsizeiptr size, GLenum usage)
const GLubyte* newdata = static_cast<const GLubyte*>(data); const GLubyte* newdata = static_cast<const GLubyte*>(data);
if (size != mContents.size()) if (size == 0)
{
mContents.clear();
delete mIdentityTranslation;
mIdentityTranslation = NULL;
}
else if (size != mContents.size())
{ {
// vector::resize only provides the basic exception guarantee, so use temporaries & swap to get the strong exception guarantee. // vector::resize only provides the basic exception guarantee, so use temporaries & swap to get the strong exception guarantee.
// We don't want to risk having mContents and mIdentityTranslation that have different contents or even different sizes. // We don't want to risk having mContents and mIdentityTranslation that have different contents or even different sizes.
...@@ -87,11 +94,14 @@ GLenum Buffer::copyToIdentityBuffer(GLintptr offset, GLsizeiptr length) ...@@ -87,11 +94,14 @@ GLenum Buffer::copyToIdentityBuffer(GLintptr offset, GLsizeiptr length)
{ {
ASSERT(offset >= 0 && length >= 0); ASSERT(offset >= 0 && length >= 0);
// This is a stalling map. Not great for performance. if (length > 0) // If length == 0 mIdentityTranslation might be NULL.
GLubyte *p = static_cast<GLubyte*>(mIdentityTranslation->map()); {
// This is a stalling map. Not great for performance.
GLubyte *p = static_cast<GLubyte*>(mIdentityTranslation->map());
memcpy(p + offset, &mContents[0] + offset, length); memcpy(p + offset, &mContents[0] + offset, length);
mIdentityTranslation->unmap(); mIdentityTranslation->unmap();
}
return GL_NO_ERROR; return GL_NO_ERROR;
} }
......
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