Commit 5b6b9c63 by Jiajia Qin Committed by Commit Bot

Use dirty bit for draw indirect buffer

Bug: angleproject:1595 Change-Id: I031beab818daca8a20726d7bff564649feefc1f3 Reviewed-on: https://chromium-review.googlesource.com/844214 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent ea78d2bb
...@@ -729,14 +729,14 @@ gl::Error RendererGL::dispatchCompute(const gl::Context *context, ...@@ -729,14 +729,14 @@ gl::Error RendererGL::dispatchCompute(const gl::Context *context,
GLuint numGroupsY, GLuint numGroupsY,
GLuint numGroupsZ) GLuint numGroupsZ)
{ {
ANGLE_TRY(mStateManager->setDispatchComputeState(context, false)); ANGLE_TRY(mStateManager->setDispatchComputeState(context));
mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ); mFunctions->dispatchCompute(numGroupsX, numGroupsY, numGroupsZ);
return gl::NoError(); return gl::NoError();
} }
gl::Error RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect) gl::Error RendererGL::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
{ {
ANGLE_TRY(mStateManager->setDispatchComputeState(context, true)); ANGLE_TRY(mStateManager->setDispatchComputeState(context));
mFunctions->dispatchComputeIndirect(indirect); mFunctions->dispatchComputeIndirect(indirect);
return gl::NoError(); return gl::NoError();
} }
......
...@@ -168,8 +168,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions, ...@@ -168,8 +168,7 @@ StateManagerGL::StateManagerGL(const FunctionsGL *functions,
mLocalDirtyBits(), mLocalDirtyBits(),
mMultiviewDirtyBits(), mMultiviewDirtyBits(),
mProgramTexturesAndSamplersDirty(true), mProgramTexturesAndSamplersDirty(true),
mProgramStorageBuffersDirty(true), mProgramStorageBuffersDirty(true)
mProgramDispatchIndirectBufferDirty(false)
{ {
ASSERT(mFunctions); ASSERT(mFunctions);
ASSERT(extensions.maxViews >= 1u); ASSERT(extensions.maxViews >= 1u);
...@@ -753,33 +752,34 @@ gl::Error StateManagerGL::setDrawIndirectState(const gl::Context *context, GLenu ...@@ -753,33 +752,34 @@ gl::Error StateManagerGL::setDrawIndirectState(const gl::Context *context, GLenu
} }
bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID()); bindVertexArray(vaoGL->getVertexArrayID(), vaoGL->getAppliedElementArrayBufferID());
gl::Buffer *drawIndirectBuffer = glState.getTargetBuffer(gl::BufferBinding::DrawIndirect);
ASSERT(drawIndirectBuffer);
const BufferGL *bufferGL = GetImplAs<BufferGL>(drawIndirectBuffer);
bindBuffer(gl::BufferBinding::DrawIndirect, bufferGL->getBufferID());
return setGenericDrawState(context); return setGenericDrawState(context);
} }
void StateManagerGL::updateProgramDispatchIndirectBufferBinding(const gl::Context *context) void StateManagerGL::updateDrawIndirectBufferBinding(const gl::Context *context)
{ {
gl::Buffer *dispatchIndirectBuffer = gl::Buffer *drawIndirectBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::DispatchIndirect); context->getGLState().getTargetBuffer(gl::BufferBinding::DrawIndirect);
ASSERT(dispatchIndirectBuffer); if (drawIndirectBuffer != nullptr)
const BufferGL *bufferGL = GetImplAs<BufferGL>(dispatchIndirectBuffer); {
bindBuffer(gl::BufferBinding::DispatchIndirect, bufferGL->getBufferID()); const BufferGL *bufferGL = GetImplAs<BufferGL>(drawIndirectBuffer);
bindBuffer(gl::BufferBinding::DrawIndirect, bufferGL->getBufferID());
}
} }
gl::Error StateManagerGL::setDispatchComputeState(const gl::Context *context, bool isIndirect) void StateManagerGL::updateDispatchIndirectBufferBinding(const gl::Context *context)
{ {
setGenericShaderState(context); gl::Buffer *dispatchIndirectBuffer =
context->getGLState().getTargetBuffer(gl::BufferBinding::DispatchIndirect);
if (isIndirect && mProgramDispatchIndirectBufferDirty) if (dispatchIndirectBuffer != nullptr)
{ {
updateProgramDispatchIndirectBufferBinding(context); const BufferGL *bufferGL = GetImplAs<BufferGL>(dispatchIndirectBuffer);
mProgramDispatchIndirectBufferDirty = false; bindBuffer(gl::BufferBinding::DispatchIndirect, bufferGL->getBufferID());
} }
}
gl::Error StateManagerGL::setDispatchComputeState(const gl::Context *context)
{
setGenericShaderState(context);
return gl::NoError(); return gl::NoError();
} }
...@@ -1946,10 +1946,10 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt ...@@ -1946,10 +1946,10 @@ void StateManagerGL::syncState(const gl::Context *context, const gl::State::Dirt
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:
// TODO: implement this updateDrawIndirectBufferBinding(context);
break; break;
case gl::State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING: case gl::State::DIRTY_BIT_DISPATCH_INDIRECT_BUFFER_BINDING:
mProgramDispatchIndirectBufferDirty = true; updateDispatchIndirectBufferBinding(context);
break; break;
case gl::State::DIRTY_BIT_PROGRAM_BINDING: case gl::State::DIRTY_BIT_PROGRAM_BINDING:
{ {
......
...@@ -168,7 +168,7 @@ class StateManagerGL final : angle::NonCopyable ...@@ -168,7 +168,7 @@ class StateManagerGL final : angle::NonCopyable
const void **outIndices); const void **outIndices);
gl::Error setDrawIndirectState(const gl::Context *context, GLenum type); gl::Error setDrawIndirectState(const gl::Context *context, GLenum type);
gl::Error setDispatchComputeState(const gl::Context *context, bool isIndirect); gl::Error setDispatchComputeState(const gl::Context *context);
void pauseTransformFeedback(); void pauseTransformFeedback();
gl::Error pauseAllQueries(); gl::Error pauseAllQueries();
...@@ -200,7 +200,9 @@ class StateManagerGL final : angle::NonCopyable ...@@ -200,7 +200,9 @@ class StateManagerGL final : angle::NonCopyable
void updateProgramTextureAndSamplerBindings(const gl::Context *context); void updateProgramTextureAndSamplerBindings(const gl::Context *context);
void updateProgramStorageBufferBindings(const gl::Context *context); void updateProgramStorageBufferBindings(const gl::Context *context);
void updateProgramDispatchIndirectBufferBinding(const gl::Context *context);
void updateDispatchIndirectBufferBinding(const gl::Context *context);
void updateDrawIndirectBufferBinding(const gl::Context *context);
void syncTransformFeedbackState(const gl::Context *context); void syncTransformFeedbackState(const gl::Context *context);
...@@ -359,7 +361,6 @@ class StateManagerGL final : angle::NonCopyable ...@@ -359,7 +361,6 @@ class StateManagerGL final : angle::NonCopyable
bool mProgramTexturesAndSamplersDirty; bool mProgramTexturesAndSamplersDirty;
bool mProgramStorageBuffersDirty; bool mProgramStorageBuffersDirty;
bool mProgramDispatchIndirectBufferDirty;
}; };
} }
......
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