Commit 294cad9d by Geoff Lang

When applying vertex array objects, update the currently applied index buffer.

When binding a vertex array object, it was not changing the tracked index buffer binding. This was causing the buffer bindings to sometimes not be updated between index and non-indexed draw calls. Fixes: * Intermittent crashes in chromium startup. * conformance/rendering/many-draw-calls.html * conformance/rendering/framebuffer-switch.html * conformance/attribs/gl-bindAttribLocation-aliasing.html * conformance/attribs/gl-vertex-attrib-render.html * conformance/buffers/index-validation-verifies-too-many-indices.html BUG=angleproject:883 Change-Id: I34ed1ebc65b339329c0f9ab9c28a392f552ed3d8 Reviewed-on: https://chromium-review.googlesource.com/273300Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 90d98afa
...@@ -113,7 +113,7 @@ void StateManagerGL::deleteVertexArray(GLuint vao) ...@@ -113,7 +113,7 @@ void StateManagerGL::deleteVertexArray(GLuint vao)
{ {
if (mVAO == vao) if (mVAO == vao)
{ {
bindVertexArray(0); bindVertexArray(0, 0);
} }
mFunctions->deleteVertexArrays(1, &vao); mFunctions->deleteVertexArrays(1, &vao);
...@@ -194,11 +194,12 @@ void StateManagerGL::useProgram(GLuint program) ...@@ -194,11 +194,12 @@ void StateManagerGL::useProgram(GLuint program)
} }
} }
void StateManagerGL::bindVertexArray(GLuint vao) void StateManagerGL::bindVertexArray(GLuint vao, GLuint elementArrayBuffer)
{ {
if (mVAO != vao) if (mVAO != vao)
{ {
mVAO = vao; mVAO = vao;
mBuffers[GL_ELEMENT_ARRAY_BUFFER] = elementArrayBuffer;
mFunctions->bindVertexArray(vao); mFunctions->bindVertexArray(vao);
} }
} }
...@@ -317,7 +318,7 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Data &data, GLint first, ...@@ -317,7 +318,7 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Data &data, GLint first,
const gl::VertexArray *vao = state.getVertexArray(); const gl::VertexArray *vao = state.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao); const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
vaoGL->syncDrawArraysState(first, count); vaoGL->syncDrawArraysState(first, count);
bindVertexArray(vaoGL->getVertexArrayID()); bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
return setGenericDrawState(data); return setGenericDrawState(data);
} }
...@@ -336,7 +337,7 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Data &data, GLsizei cou ...@@ -336,7 +337,7 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Data &data, GLsizei cou
return error; return error;
} }
bindVertexArray(vaoGL->getVertexArrayID()); bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
return setGenericDrawState(data); return setGenericDrawState(data);
} }
......
...@@ -41,7 +41,7 @@ class StateManagerGL : angle::NonCopyable ...@@ -41,7 +41,7 @@ class StateManagerGL : angle::NonCopyable
void deleteRenderbuffer(GLuint rbo); void deleteRenderbuffer(GLuint rbo);
void useProgram(GLuint program); void useProgram(GLuint program);
void bindVertexArray(GLuint vao); void bindVertexArray(GLuint vao, GLuint elementArrayBuffer);
void bindBuffer(GLenum type, GLuint buffer); void bindBuffer(GLenum type, GLuint buffer);
void activeTexture(size_t unit); void activeTexture(size_t unit);
void bindTexture(GLenum type, GLuint texture); void bindTexture(GLenum type, GLuint texture);
......
...@@ -103,7 +103,7 @@ gl::Error VertexArrayGL::syncDrawElementsState(GLsizei count, GLenum type, const ...@@ -103,7 +103,7 @@ gl::Error VertexArrayGL::syncDrawElementsState(GLsizei count, GLenum type, const
gl::Error VertexArrayGL::syncDrawState(GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const gl::Error VertexArrayGL::syncDrawState(GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const
{ {
mStateManager->bindVertexArray(mVertexArrayID); mStateManager->bindVertexArray(mVertexArrayID, mAppliedElementArrayBuffer);
// Check if any attributes need to be streamed, determines if the index range needs to be computed // Check if any attributes need to be streamed, determines if the index range needs to be computed
bool attributesNeedStreaming = doAttributesNeedStreaming(); bool attributesNeedStreaming = doAttributesNeedStreaming();
...@@ -404,4 +404,9 @@ GLuint VertexArrayGL::getVertexArrayID() const ...@@ -404,4 +404,9 @@ GLuint VertexArrayGL::getVertexArrayID() const
return mVertexArrayID; return mVertexArrayID;
} }
GLuint VertexArrayGL::getAppliedElementArrayBufferID() const
{
return mAppliedElementArrayBuffer;
}
} }
...@@ -32,6 +32,7 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -32,6 +32,7 @@ class VertexArrayGL : public VertexArrayImpl
gl::Error syncDrawElementsState(GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const; gl::Error syncDrawElementsState(GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const;
GLuint getVertexArrayID() const; GLuint getVertexArrayID() const;
GLuint getAppliedElementArrayBufferID() const;
private: private:
gl::Error syncDrawState(GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const; gl::Error syncDrawState(GLint first, GLsizei count, GLenum type, const GLvoid *indices, const GLvoid **outIndices) const;
......
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