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,
GLenum mode,
const void *indirect)
{
ANGLE_TRY(mStateManager->setDrawIndirectState(context, GL_NONE));
ANGLE_TRY(mStateManager->setDrawIndirectState(context));
mFunctions->drawArraysIndirect(mode, indirect);
return gl::NoError();
}
......@@ -368,7 +368,7 @@ gl::Error RendererGL::drawElementsIndirect(const gl::Context *context,
GLenum type,
const void *indirect)
{
ANGLE_TRY(mStateManager->setDrawIndirectState(context, type));
ANGLE_TRY(mStateManager->setDrawIndirectState(context));
mFunctions->drawElementsIndirect(mode, type, indirect);
return gl::NoError();
}
......
......@@ -707,8 +707,6 @@ gl::Error StateManagerGL::setDrawArraysState(const gl::Context *context,
ANGLE_TRY(vaoGL->syncDrawArraysState(context, program->getActiveAttribLocationsMask(), first,
count, instanceCount));
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
return setGenericDrawState(context);
}
......@@ -726,32 +724,15 @@ gl::Error StateManagerGL::setDrawElementsState(const gl::Context *context,
const gl::VertexArray *vao = glState.getVertexArray();
const VertexArrayGL *vaoGL = GetImplAs<VertexArrayGL>(vao);
gl::Error error = vaoGL->syncDrawElementsState(context, program->getActiveAttribLocationsMask(),
count, type, indices, instanceCount,
glState.isPrimitiveRestartEnabled(), outIndices);
if (error.isError())
{
return error;
}
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
ANGLE_TRY(vaoGL->syncDrawElementsState(context, program->getActiveAttribLocationsMask(), count,
type, indices, instanceCount,
glState.isPrimitiveRestartEnabled(), outIndices));
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);
}
......@@ -1035,9 +1016,11 @@ void StateManagerGL::updateProgramStorageBufferBindings(const gl::Context *conte
gl::Error StateManagerGL::setGenericDrawState(const gl::Context *context)
{
setGenericShaderState(context);
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();
FramebufferGL *framebufferGL = GetImplAs<FramebufferGL>(framebuffer);
......
......@@ -166,7 +166,7 @@ class StateManagerGL final : angle::NonCopyable
const void *indices,
GLsizei instanceCount,
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);
......
......@@ -131,18 +131,15 @@ gl::Error VertexArrayGL::syncDrawElementsState(const gl::Context *context,
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();
ASSERT(elementArrayBuffer);
if (elementArrayBuffer != mAppliedElementArrayBuffer.get())
if (elementArrayBuffer != nullptr && elementArrayBuffer != mAppliedElementArrayBuffer.get())
{
const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer);
mStateManager->bindBuffer(gl::BufferBinding::ElementArray, bufferGL->getBufferID());
mAppliedElementArrayBuffer.set(context, elementArrayBuffer);
}
return gl::NoError();
}
gl::Error VertexArrayGL::syncDrawState(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
if (elementArrayBuffer != nullptr)
{
if (elementArrayBuffer != mAppliedElementArrayBuffer.get())
{
const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer);
mStateManager->bindBuffer(gl::BufferBinding::ElementArray, bufferGL->getBufferID());
mAppliedElementArrayBuffer.set(context, elementArrayBuffer);
}
ASSERT(elementArrayBuffer == mAppliedElementArrayBuffer.get());
// Only compute the index range if the attributes also need to be streamed
if (attributesNeedStreaming)
{
......@@ -655,7 +646,7 @@ void VertexArrayGL::syncState(const gl::Context *context, const VertexArray::Dir
{
if (dirtyBit == VertexArray::DIRTY_BIT_ELEMENT_ARRAY_BUFFER)
{
// TODO(jmadill): Element array buffer bindings
updateElementArrayBufferBinding(context);
continue;
}
......
......@@ -40,7 +40,6 @@ class VertexArrayGL : public VertexArrayImpl
GLsizei instanceCount,
bool primitiveRestartEnabled,
const void **outIndices) const;
gl::Error syncElementArrayState(const gl::Context *context) const;
GLuint getVertexArrayID() const;
GLuint getAppliedElementArrayBufferID() const;
......@@ -94,6 +93,8 @@ class VertexArrayGL : public VertexArrayImpl
void updateBindingBuffer(const gl::Context *context, size_t bindingIndex);
void updateBindingDivisor(size_t bindingIndex);
void updateElementArrayBufferBinding(const gl::Context *context) const;
void callVertexAttribPointer(GLuint attribIndex,
const gl::VertexAttribute &attrib,
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