Commit 4747414e by Jiajia Qin Committed by Commit Bot

Use dirty bit for element array buffer

BUG=angleproject:2188 Change-Id: I2b2aced542032c7c263f911ef1516af1d42190cc Reviewed-on: https://chromium-review.googlesource.com/846346 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent ceffd20c
...@@ -358,7 +358,7 @@ gl::Error RendererGL::drawArraysIndirect(const gl::Context *context, ...@@ -358,7 +358,7 @@ gl::Error RendererGL::drawArraysIndirect(const gl::Context *context,
GLenum mode, GLenum mode,
const void *indirect) const void *indirect)
{ {
ANGLE_TRY(mStateManager->setDrawIndirectState(context, GL_NONE)); ANGLE_TRY(mStateManager->setDrawIndirectState(context));
mFunctions->drawArraysIndirect(mode, indirect); mFunctions->drawArraysIndirect(mode, indirect);
return gl::NoError(); return gl::NoError();
} }
...@@ -368,7 +368,7 @@ gl::Error RendererGL::drawElementsIndirect(const gl::Context *context, ...@@ -368,7 +368,7 @@ gl::Error RendererGL::drawElementsIndirect(const gl::Context *context,
GLenum type, GLenum type,
const void *indirect) const void *indirect)
{ {
ANGLE_TRY(mStateManager->setDrawIndirectState(context, type)); ANGLE_TRY(mStateManager->setDrawIndirectState(context));
mFunctions->drawElementsIndirect(mode, type, indirect); mFunctions->drawElementsIndirect(mode, type, indirect);
return gl::NoError(); return gl::NoError();
} }
......
...@@ -707,8 +707,6 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Context *context, ...@@ -707,8 +707,6 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Context *context,
ANGLE_TRY(vaoGL->syncDrawArraysState(context, program->getActiveAttribLocationsMask(), first, ANGLE_TRY(vaoGL->syncDrawArraysState(context, program->getActiveAttribLocationsMask(), first,
count, instanceCount)); count, instanceCount));
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
return setGenericDrawState(context); return setGenericDrawState(context);
} }
...@@ -726,32 +724,15 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Context *context, ...@@ -726,32 +724,15 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Context *context,
const gl::VertexArray *vao = glState.getVertexArray(); const gl::VertexArray *vao = glState.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao); const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
gl::Error error = vaoGL->syncDrawElementsState(context, program->getActiveAttribLocationsMask(), ANGLE_TRY(vaoGL->syncDrawElementsState(context, program->getActiveAttribLocationsMask(), count,
count, type, indices, instanceCount, type, indices, instanceCount,
glState.isPrimitiveRestartEnabled(), outIndices); glState.isPrimitiveRestartEnabled(), outIndices));
if (error.isError())
{
return error;
}
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
return setGenericDrawState(context); return setGenericDrawState(context);
} }
gl::Error StateManagerGL::setDrawIndirectState(const gl::Context *context, GLenum type) gl::Error StateManagerGL::setDrawIndirectState(const gl::Context *context)
{ {
const gl::State &glState = context->getGLState();
const gl::VertexArray *vao = glState.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
if (type != GL_NONE)
{
ANGLE_TRY(vaoGL->syncElementArrayState(context));
}
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
return setGenericDrawState(context); return setGenericDrawState(context);
} }
...@@ -1035,9 +1016,11 @@ void StateManagerGL::updateProgramStorageBufferBindings(const gl::Context *conte ...@@ -1035,9 +1016,11 @@ void StateManagerGL::updateProgramStorageBufferBindings(const gl::Context *conte
gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context) gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
{ {
setGenericShaderState(context);
const gl::State &glState = context->getGLState(); const gl::State &glState = context->getGLState();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(glState.getVertexArray());
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
setGenericShaderState(context);
gl::Framebuffer *framebuffer = glState.getDrawFramebuffer(); gl::Framebuffer *framebuffer = glState.getDrawFramebuffer();
FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer); FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer);
......
...@@ -166,7 +166,7 @@ class StateManagerGL final : angle::NonCopyable ...@@ -166,7 +166,7 @@ class StateManagerGL final : angle::NonCopyable
const void *indices, const void *indices,
GLsizei instanceCount, GLsizei instanceCount,
const void **outIndices); const void **outIndices);
gl::Error setDrawIndirectState(const gl::Context *context, GLenum type); gl::Error setDrawIndirectState(const gl::Context *context);
gl::Error setDispatchComputeState(const gl::Context *context); gl::Error setDispatchComputeState(const gl::Context *context);
......
...@@ -131,18 +131,15 @@ gl::Error VertexArrayGL::syncDrawElementsState(const gl::Context *context, ...@@ -131,18 +131,15 @@ gl::Error VertexArrayGL::syncDrawElementsState(const gl::Context *context,
primitiveRestartEnabled, outIndices); primitiveRestartEnabled, outIndices);
} }
gl::Error VertexArrayGL::syncElementArrayState(const gl::Context *context) const void VertexArrayGL::updateElementArrayBufferBinding(const gl::Context *context) const
{ {
gl::Buffer *elementArrayBuffer = mState.getElementArrayBuffer().get(); gl::Buffer *elementArrayBuffer = mState.getElementArrayBuffer().get();
ASSERT(elementArrayBuffer); if (elementArrayBuffer != nullptr && elementArrayBuffer != mAppliedElementArrayBuffer.get())
if (elementArrayBuffer != mAppliedElementArrayBuffer.get())
{ {
const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer); const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer);
mStateManager->bindBuffer(gl::BufferBinding::ElementArray, bufferGL->getBufferID()); mStateManager->bindBuffer(gl::BufferBinding::ElementArray, bufferGL->getBufferID());
mAppliedElementArrayBuffer.set(context, elementArrayBuffer); mAppliedElementArrayBuffer.set(context, elementArrayBuffer);
} }
return gl::NoError();
} }
gl::Error VertexArrayGL::syncDrawState(const gl::Context *context, gl::Error VertexArrayGL::syncDrawState(const gl::Context *context,
...@@ -200,13 +197,7 @@ gl::Error VertexArrayGL::syncIndexData(const gl::Context *context, ...@@ -200,13 +197,7 @@ gl::Error VertexArrayGL::syncIndexData(const gl::Context *context,
// Need to check the range of indices if attributes need to be streamed // Need to check the range of indices if attributes need to be streamed
if (elementArrayBuffer != nullptr) if (elementArrayBuffer != nullptr)
{ {
if (elementArrayBuffer != mAppliedElementArrayBuffer.get()) ASSERT(elementArrayBuffer == mAppliedElementArrayBuffer.get());
{
const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer);
mStateManager->bindBuffer(gl::BufferBinding::ElementArray, bufferGL->getBufferID());
mAppliedElementArrayBuffer.set(context, elementArrayBuffer);
}
// Only compute the index range if the attributes also need to be streamed // Only compute the index range if the attributes also need to be streamed
if (attributesNeedStreaming) if (attributesNeedStreaming)
{ {
...@@ -655,7 +646,7 @@ void VertexArrayGL::syncState(const gl::Context *context, const VertexArray::Dir ...@@ -655,7 +646,7 @@ void VertexArrayGL::syncState(const gl::Context *context, const VertexArray::Dir
{ {
if (dirtyBit == VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER) if (dirtyBit == VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER)
{ {
// TODO(jmadill): Element array buffer bindings updateElementArrayBufferBinding(context);
continue; continue;
} }
......
...@@ -40,7 +40,6 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -40,7 +40,6 @@ class VertexArrayGL : public VertexArrayImpl
GLsizei instanceCount, GLsizei instanceCount,
bool primitiveRestartEnabled, bool primitiveRestartEnabled,
const void **outIndices) const; const void **outIndices) const;
gl::Error syncElementArrayState(const gl::Context *context) const;
GLuint getVertexArrayID() const; GLuint getVertexArrayID() const;
GLuint getAppliedElementArrayBufferID() const; GLuint getAppliedElementArrayBufferID() const;
...@@ -94,6 +93,8 @@ class VertexArrayGL : public VertexArrayImpl ...@@ -94,6 +93,8 @@ class VertexArrayGL : public VertexArrayImpl
void updateBindingBuffer(const gl::Context *context, size_t bindingIndex); void updateBindingBuffer(const gl::Context *context, size_t bindingIndex);
void updateBindingDivisor(size_t bindingIndex); void updateBindingDivisor(size_t bindingIndex);
void updateElementArrayBufferBinding(const gl::Context *context) const;
void callVertexAttribPointer(GLuint attribIndex, void callVertexAttribPointer(GLuint attribIndex,
const gl::VertexAttribute &attrib, const gl::VertexAttribute &attrib,
GLsizei stride, GLsizei stride,
......
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