Commit 5f3047c5 by Geoff Lang Committed by Commit Bot

StateManagerGL: Use dirty bits for VAO bindings.

Delay binding the VAO in VertexArrayGL::syncDrawState until we actually need to make glVertexAttrib calls. BUG=angleproject:2188 Change-Id: Ib7d22d641c9f19c639ba8c596bff6bc7de952e7f Reviewed-on: https://chromium-review.googlesource.com/919503Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 3f4b87b4
...@@ -1037,14 +1037,11 @@ void StateManagerGL::updateProgramStorageBufferBindings(const gl::Context *conte ...@@ -1037,14 +1037,11 @@ void StateManagerGL::updateProgramStorageBufferBindings(const gl::Context *conte
gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context) gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
{ {
const gl::State &glState = context->getGLState();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(glState.getVertexArray());
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
setGenericShaderState(context); setGenericShaderState(context);
if (context->getExtensions().webglCompatibility) if (context->getExtensions().webglCompatibility)
{ {
const gl::State &glState = context->getGLState();
FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(glState.getDrawFramebuffer()); FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(glState.getDrawFramebuffer());
auto activeOutputs = glState.getProgram()->getState().getActiveOutputVariables(); auto activeOutputs = glState.getProgram()->getState().getActiveOutputVariables();
framebufferGL->maskOutInactiveOutputDrawBuffers(GL_DRAW_FRAMEBUFFER, activeOutputs); framebufferGL->maskOutInactiveOutputDrawBuffers(GL_DRAW_FRAMEBUFFER, activeOutputs);
...@@ -1053,6 +1050,8 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context) ...@@ -1053,6 +1050,8 @@ gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
ASSERT( ASSERT(
mFramebuffers[angle::FramebufferBindingDraw] == mFramebuffers[angle::FramebufferBindingDraw] ==
GetImplAs<FramebufferGL>(context->getGLState().getDrawFramebuffer())->getFramebufferID()); GetImplAs<FramebufferGL>(context->getGLState().getDrawFramebuffer())->getFramebufferID());
ASSERT(mVAO ==
GetImplAs<VertexArrayGL>(context->getGLState().getVertexArray())->getVertexArrayID());
return gl::NoError(); return gl::NoError();
} }
...@@ -1952,10 +1951,14 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -1952,10 +1951,14 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt
// TODO(jmadill): implement this // TODO(jmadill): implement this
break; break;
case gl::State::DIRTY_BIT_VERTEX_ARRAY_BINDING: case gl::State::DIRTY_BIT_VERTEX_ARRAY_BINDING:
// TODO(jmadill): implement this {
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(state.getVertexArray());
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
propagateNumViewsToVAO(state.getProgram(), propagateNumViewsToVAO(state.getProgram(),
GetImplAs<VertexArrayGL>(state.getVertexArray())); GetImplAs<VertexArrayGL>(state.getVertexArray()));
break; break;
}
case gl::State::DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING: case gl::State::DIRTY_BIT_DRAW_INDIRECT_BUFFER_BINDING:
updateDrawIndirectBufferBinding(context); updateDrawIndirectBufferBinding(context);
break; break;
......
...@@ -152,8 +152,6 @@ gl::Error VertexArrayGL::syncDrawState(const gl::Context *context, ...@@ -152,8 +152,6 @@ gl::Error VertexArrayGL::syncDrawState(const gl::Context *context,
bool primitiveRestartEnabled, bool primitiveRestartEnabled,
const void **outIndices) const const void **outIndices) const
{ {
mStateManager->bindVertexArray(mVertexArrayID, getAppliedElementArrayBufferID());
// Check if any attributes need to be streamed, determines if the index range needs to be // Check if any attributes need to be streamed, determines if the index range needs to be
// computed // computed
bool attributesNeedStreaming = mAttributesNeedStreaming.any(); bool attributesNeedStreaming = mAttributesNeedStreaming.any();
...@@ -233,6 +231,8 @@ gl::Error VertexArrayGL::syncIndexData(const gl::Context *context, ...@@ -233,6 +231,8 @@ gl::Error VertexArrayGL::syncIndexData(const gl::Context *context,
mStreamingElementArrayBufferSize = 0; mStreamingElementArrayBufferSize = 0;
} }
mStateManager->bindVertexArray(mVertexArrayID, getAppliedElementArrayBufferID());
mStateManager->bindBuffer(gl::BufferBinding::ElementArray, mStreamingElementArrayBuffer); mStateManager->bindBuffer(gl::BufferBinding::ElementArray, mStreamingElementArrayBuffer);
mAppliedElementArrayBuffer.set(context, nullptr); mAppliedElementArrayBuffer.set(context, nullptr);
...@@ -329,6 +329,8 @@ gl::Error VertexArrayGL::streamAttributes(const gl::AttributesMask &activeAttrib ...@@ -329,6 +329,8 @@ gl::Error VertexArrayGL::streamAttributes(const gl::AttributesMask &activeAttrib
mStreamingArrayBufferSize = requiredBufferSize; mStreamingArrayBufferSize = requiredBufferSize;
} }
mStateManager->bindVertexArray(mVertexArrayID, getAppliedElementArrayBufferID());
// Unmapping a buffer can return GL_FALSE to indicate that the system has corrupted the data // Unmapping a buffer can return GL_FALSE to indicate that the system has corrupted the data
// somehow (such as by a screen change), retry writing the data a few times and return // somehow (such as by a screen change), retry writing the data a few times and return
// OUT_OF_MEMORY if that fails. // OUT_OF_MEMORY if that fails.
......
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