Commit 6e8cdd39 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Don't break the render pass on indirect calls

The render pass is now only broken if the indirect buffer was used as transform feedback. Any other write to the indirect buffer is synchronized with `glMemoryBarrier`. Bug: angleproject:5070 Change-Id: I67868ae9a8f08e1ab186440a3cbdc7439c66808e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2698996 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent c03a4235
......@@ -398,7 +398,6 @@ ContextVk::ContextVk(const gl::State &state, gl::ErrorSet *errorSet, RendererVk
mPerfCounters{},
mObjectPerfCounters{},
mContextPriority(renderer->getDriverPriority(GetContextPriority(state))),
mCurrentIndirectBuffer(nullptr),
mShareGroupVk(vk::GetImpl(state.getShareGroup()))
{
ANGLE_TRACE_EVENT0("gpu.angle", "ContextVk::ContextVk");
......@@ -922,18 +921,20 @@ angle::Result ContextVk::setupIndirectDraw(const gl::Context *context,
GLsizei vertexCount = 0;
GLsizei instanceCount = 1;
if (indirectBuffer != mCurrentIndirectBuffer)
// Break the render pass if the indirect buffer was previously used as the output from transform
// feedback.
if (mCurrentTransformFeedbackBuffers.contains(indirectBuffer))
{
ANGLE_TRY(flushCommandsAndEndRenderPass());
mCurrentIndirectBuffer = indirectBuffer;
}
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, indirectBuffer);
ANGLE_TRY(setupDraw(context, mode, firstVertex, vertexCount, instanceCount,
gl::DrawElementsType::InvalidEnum, nullptr, dirtyBitMask));
// Process indirect buffer after render pass has started.
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, indirectBuffer);
return angle::Result::Continue;
}
......@@ -2446,9 +2447,6 @@ angle::Result ContextVk::drawArraysIndirect(const gl::Context *context,
if (mVertexArray->getStreamingVertexAttribsMask().any())
{
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, currentIndirectBuf);
// We have instanced vertex attributes that need to be emulated for Vulkan.
// invalidate any cache and map the buffer so that we can read the indirect data.
// Mapping the buffer will cause a flush.
......@@ -2500,9 +2498,6 @@ angle::Result ContextVk::drawElementsIndirect(const gl::Context *context,
if (mVertexArray->getStreamingVertexAttribsMask().any())
{
mRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, currentIndirectBuf);
// We have instanced vertex attributes that need to be emulated for Vulkan.
// invalidate any cache and map the buffer so that we can read the indirect data.
// Mapping the buffer will cause a flush.
......@@ -3946,10 +3941,19 @@ angle::Result ContextVk::dispatchCompute(const gl::Context *context,
angle::Result ContextVk::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
{
ANGLE_TRY(setupDispatch(context));
gl::Buffer *glBuffer = getState().getTargetBuffer(gl::BufferBinding::DispatchIndirect);
vk::BufferHelper &buffer = vk::GetImpl(glBuffer)->getBuffer();
// Break the render pass if the indirect buffer was previously used as the output from transform
// feedback.
if (mCurrentTransformFeedbackBuffers.contains(&buffer))
{
ANGLE_TRY(flushCommandsAndEndRenderPass());
}
ANGLE_TRY(setupDispatch(context));
// Process indirect buffer after command buffer has started.
mOutsideRenderPassCommands->bufferRead(this, VK_ACCESS_INDIRECT_COMMAND_READ_BIT,
vk::PipelineStage::DrawIndirect, &buffer);
......@@ -5083,7 +5087,6 @@ angle::Result ContextVk::flushCommandsAndEndRenderPassImpl()
}
mCurrentTransformFeedbackBuffers.clear();
mCurrentIndirectBuffer = nullptr;
// Reset serials for XFB if active.
if (mState.isTransformFeedbackActiveUnpaused())
......
......@@ -1071,8 +1071,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText
egl::ContextPriority mContextPriority;
const vk::BufferHelper *mCurrentIndirectBuffer;
// Storage for vkUpdateDescriptorSets
std::vector<VkDescriptorBufferInfo> mDescriptorBufferInfos;
std::vector<VkDescriptorImageInfo> mDescriptorImageInfos;
......
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