Extract validation from VertexDataManager.cpp to the API.
We can check for buffer overflow at draw validation time, before
processing any vertex data.
BUG=angle:571
Change-Id: I4f49629b98c17ca28e25baed74cad4ae5341b20f
Reviewed-on: https://chromium-review.googlesource.com/210647
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/renderer/d3d/VertexDataManager.cpp b/src/libGLESv2/renderer/d3d/VertexDataManager.cpp
index 9d92f7b..2e0d1da 100644
--- a/src/libGLESv2/renderer/d3d/VertexDataManager.cpp
+++ b/src/libGLESv2/renderer/d3d/VertexDataManager.cpp
@@ -144,13 +144,7 @@
else
{
int totalCount = StreamingBufferElementCount(attribs[i], count, instances);
-
- // [OpenGL ES 3.0.2] section 2.9.4 page 40:
- // We can return INVALID_OPERATION if our vertex attribute does not have enough backing data.
- if (bufferImpl && ElementsInBuffer(attribs[i], bufferImpl->getSize()) < totalCount)
- {
- return GL_INVALID_OPERATION;
- }
+ ASSERT(!bufferImpl || ElementsInBuffer(attribs[i], bufferImpl->getSize()) >= totalCount);
if (!mStreamingBuffer->reserveVertexSpace(attribs[i], totalCount, instances))
{
@@ -217,13 +211,7 @@
GLsizei instances)
{
gl::Buffer *buffer = attrib.buffer.get();
-
- if (!buffer && attrib.pointer == NULL)
- {
- // This is an application error that would normally result in a crash, but we catch it and return an error
- ERR("An enabled vertex array has no buffer and no pointer.");
- return GL_INVALID_OPERATION;
- }
+ ASSERT(buffer || attrib.pointer);
BufferD3D *storage = buffer ? BufferD3D::makeBufferD3D(buffer->getImplementation()) : NULL;
StaticVertexBufferInterface *staticBuffer = storage ? storage->getStaticVertexBuffer() : NULL;