Check that IDirect3DVertexBuffer9 and IDirect3DIndexBuffer9::Lock succeed.
I've been seeing crashes like this on Windows XP:
0x013319aa [libglesv2.dll - memcpy.asm:188] memcpy
0x0130989a [libglesv2.dll - vertexdatamanager.cpp:164] gl::VertexDataManager::preRenderValidate(int,int,gl::TranslatedAttribute *)
0x01304f66 [libglesv2.dll - context.cpp:1996] gl::Context::applyVertexBuffer(unsigned int,int,int,bool *,gl::TranslatedIndexData *)
0x013061a7 [libglesv2.dll - context.cpp:2648] gl::Context::drawArrays(unsigned int,int,int)
0x012f7721 [libglesv2.dll - libglesv2.cpp:1741] glDrawArrays
0x01c54f1e [chrome.dll - gles2_cmd_decoder.cc:3179] gpu::gles2::GLES2DecoderImpl::DoDrawArrays(unsigned int,int,int)
0x01c59122 [chrome.dll - gles2_cmd_decoder_autogen.h:640] gpu::gles2::GLES2DecoderImpl::HandleDrawArrays(unsigned int,gpu::gles2::DrawArrays const &)
Review URL: http://codereview.appspot.com/3043042
git-svn-id: https://angleproject.googlecode.com/svn/trunk@480 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/geometry/VertexDataManager.cpp b/src/libGLESv2/geometry/VertexDataManager.cpp
index db6df30..ea05dd9 100644
--- a/src/libGLESv2/geometry/VertexDataManager.cpp
+++ b/src/libGLESv2/geometry/VertexDataManager.cpp
@@ -65,6 +65,7 @@
GLenum VertexDataManager::preRenderValidate(GLint start, GLsizei count,
TranslatedAttribute *translated)
{
+ GLenum error = GL_NO_ERROR;
const AttributeState *attribs = mContext->getVertexAttribBlock();
const std::bitset<MAX_VERTEX_ATTRIBS> activeAttribs = getActiveAttribs();
@@ -126,6 +127,11 @@
size_t elementSize = typeSize(attribs[i].mType) * attribs[i].mSize;
void *output = mStreamBuffer->map(spaceRequired(attribs[i], count), &translated[i].offset);
+ if (output == NULL)
+ {
+ ERR(" failed to map vertex buffer.");
+ return GL_OUT_OF_MEMORY;
+ }
const void *input;
if (attribs[i].mBoundBuffer.get())
@@ -174,10 +180,10 @@
if (usesCurrentValues)
{
- processNonArrayAttributes(attribs, activeAttribs, translated, count);
+ error = processNonArrayAttributes(attribs, activeAttribs, translated, count);
}
- return GL_NO_ERROR;
+ return error;
}
std::size_t VertexDataManager::typeSize(GLenum type) const
@@ -223,7 +229,7 @@
return roundUp(size, 4 * sizeof(GLfloat));
}
-void VertexDataManager::processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count)
+GLenum VertexDataManager::processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count)
{
if (mDirtyCurrentValues)
{
@@ -232,6 +238,11 @@
mCurrentValueBuffer->reserveSpace(totalSize);
float* currentValues = static_cast<float*>(mCurrentValueBuffer->map(totalSize, &mCurrentValueOffset));
+ if (currentValues == NULL)
+ {
+ ERR(" failed to map vertex buffer.");
+ return GL_OUT_OF_MEMORY;
+ }
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
@@ -260,6 +271,8 @@
translated[i].offset = mCurrentValueOffset + 4 * sizeof(float) * i;
}
}
+
+ return GL_NO_ERROR;
}
}