From bd68f05c9bfc922ecd513140e605ad3cb4f017d9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 12 Jul 2022 16:51:17 +0200 Subject: [PATCH] [dxvk] Make emitRenderTargetReadbackBarrier more generic And also remove the redundant pipeline barrier. --- src/d3d9/d3d9_device.cpp | 2 +- src/dxvk/dxvk_context.cpp | 18 ++++++------------ src/dxvk/dxvk_context.h | 10 ++++++---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 7ff58a5b..d2c24b3e 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -6084,7 +6084,7 @@ namespace dxvk { void D3D9DeviceEx::PrepareDraw(D3DPRIMITIVETYPE PrimitiveType) { if (unlikely(m_activeHazardsRT != 0)) { EmitCs([](DxvkContext* ctx) { - ctx->emitRenderTargetReadbackBarrier(); + ctx->emitGraphicsBarrier(); }); if (m_d3d9Options.generalHazards) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 71d79b32..b51c4329 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1441,18 +1441,6 @@ namespace dxvk { } - void DxvkContext::emitRenderTargetReadbackBarrier() { - if (m_flags.test(DxvkContextFlag::GpRenderPassBound)) - this->spillRenderPass(true); - - emitMemoryBarrier(0, - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, - VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, - VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, - VK_ACCESS_SHADER_READ_BIT); - } - - void DxvkContext::initBuffer( const Rc& buffer) { auto slice = buffer->getSliceHandle(); @@ -1570,6 +1558,12 @@ namespace dxvk { } + void DxvkContext::emitGraphicsBarrier() { + if (!m_barrierControl.test(DxvkBarrierControl::IgnoreGraphicsBarriers)) + this->spillRenderPass(true); + } + + void DxvkContext::generateMipmaps( const Rc& imageView, VkFilter filter) { diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 29a07155..d61ef9f6 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -707,12 +707,14 @@ namespace dxvk { uint32_t counterBias); /** - * \brief Emits barrier for render target readback + * \brief Emits graphics barrier * - * Use between draw calls if the fragment shader - * reads one of the currently bound render targets. + * Needs to be used when the fragment shader reads a bound + * render target, or when subsequent draw calls access any + * given resource for writing. It is assumed that no hazards + * can happen between storage descriptors and other resources. */ - void emitRenderTargetReadbackBarrier(); + void emitGraphicsBarrier(); /** * \brief Generates mip maps