From 76b63efedb72177c02a07f9174b1a19018b223c8 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 30 Oct 2018 14:11:27 +0100 Subject: [PATCH] [dxvk] Use self-dependency to synchronize SSBO writes While this doesn't support vertex stages yet, it should be faster when the pipeline writes to storage resources from the fragment shader. We should analyze the vertex stage shaders for SSBO writes in order to determine whether to spill the render pass. --- src/dxvk/dxvk_context.cpp | 13 ++++++++----- src/dxvk/dxvk_renderpass.cpp | 9 +++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index e9d777a1..b5097c46 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -3032,11 +3032,14 @@ namespace dxvk { void DxvkContext::commitGraphicsPostBarriers() { - // Render pass dependencies always act as a full memory barrier. We - // have to do this because writes from the vertex shader in one draw - // need to be visible to the fragment shader in the next draw, etc. - if (m_state.gp.flags.test(DxvkGraphicsPipelineFlag::HasStorageDescriptors)) - this->spillRenderPass(); + if (m_state.gp.flags.test(DxvkGraphicsPipelineFlag::HasStorageDescriptors)) { + // FIXME support vertex stage SSBO synchronization + this->emitMemoryBarrier( + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + VK_ACCESS_SHADER_WRITE_BIT, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + VK_ACCESS_SHADER_READ_BIT); + } } diff --git a/src/dxvk/dxvk_renderpass.cpp b/src/dxvk/dxvk_renderpass.cpp index fff1d9cb..075b761d 100644 --- a/src/dxvk/dxvk_renderpass.cpp +++ b/src/dxvk/dxvk_renderpass.cpp @@ -121,7 +121,7 @@ namespace dxvk { if (m_format.depth.format == VK_FORMAT_UNDEFINED) subpass.pDepthStencilAttachment = nullptr; - const std::array subpassDeps = {{ + const std::array subpassDeps = {{ { VK_SUBPASS_EXTERNAL, 0, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, @@ -132,9 +132,14 @@ namespace dxvk { VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, 0 }, { 0, 0, VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT, - VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT, /* XXX */ + VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT, VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT, 0 }, + { 0, 0, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + VK_ACCESS_SHADER_WRITE_BIT, + VK_ACCESS_SHADER_READ_BIT, 0 }, { 0, VK_SUBPASS_EXTERNAL, VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,