From c44d30d78b1a84f7dc8a226978c003a354a53d4f Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 26 Oct 2019 03:34:43 +0200 Subject: [PATCH] [dxvk] Consider indirect draw buffer in graphics pipeline barriers --- src/dxvk/dxvk_context.cpp | 21 +++++++++++++++++++-- src/dxvk/dxvk_context.h | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 168bbf17f..ff721753a 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -4353,7 +4353,7 @@ namespace dxvk { } if (m_state.gp.flags.test(DxvkGraphicsPipelineFlag::HasStorageDescriptors)) - this->commitGraphicsBarriers(); + this->commitGraphicsBarriers(); if (m_flags.test(DxvkContextFlag::GpDirtyFramebuffer)) this->updateFramebuffer(); @@ -4538,7 +4538,7 @@ namespace dxvk { } - template + template void DxvkContext::commitGraphicsBarriers() { auto layout = m_state.gp.pipeline->layout(); @@ -4548,6 +4548,23 @@ namespace dxvk { bool requiresBarrier = false; + // Check the draw buffer for indirect draw calls + if (m_flags.test(DxvkContextFlag::DirtyDrawBuffer) && Indirect) { + std::array slices = {{ + &m_state.id.argBuffer, + &m_state.id.cntBuffer, + }}; + + for (uint32_t i = 0; i < slices.size() && !requiresBarrier; i++) { + if (slices[i]->defined() + && slices[i]->bufferInfo().usage & storageBufferUsage) { + requiresBarrier = this->checkGfxBufferBarrier(*slices[i], + VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT, + VK_ACCESS_INDIRECT_COMMAND_READ_BIT).test(DxvkAccess::Write); + } + } + } + // Read-only stage, so we only have to check this if // the bindngs have actually changed between draws if (m_flags.test(DxvkContextFlag::GpDirtyIndexBuffer) && !requiresBarrier && Indexed) { diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index b75521a72..c80da5cb0 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -1183,7 +1183,7 @@ namespace dxvk { void commitComputeInitBarriers(); void commitComputePostBarriers(); - template + template void commitGraphicsBarriers(); DxvkAccessFlags checkGfxBufferBarrier(