From a0cf5926d89a812b9932e793e34e036fe68c6230 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sun, 14 Feb 2021 04:21:08 +0100 Subject: [PATCH] [dxvk] Add parameter to prepareImage to ignore clears Otherwise we may flush clears while clearing a render target, which is silly and undoes the layout optimizations. --- src/dxvk/dxvk_context.cpp | 7 ++++--- src/dxvk/dxvk_context.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index a08e2353..6baa2ad8 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -577,7 +577,7 @@ namespace dxvk { // will indirectly emit barriers for the given render target. // If there is overlap, we need to explicitly transition affected attachments. this->spillRenderPass(true); - this->prepareImage(m_execBarriers, imageView->image(), imageView->subresources()); + this->prepareImage(m_execBarriers, imageView->image(), imageView->subresources(), false); } if (m_flags.test(DxvkContextFlag::GpRenderPassBound)) @@ -4169,14 +4169,15 @@ namespace dxvk { void DxvkContext::prepareImage( DxvkBarrierSet& barriers, const Rc& image, - const VkImageSubresourceRange& subresources) { + const VkImageSubresourceRange& subresources, + bool flushClears) { // Images that can't be used as attachments are always in their // default layout, so we don't have to do anything in this case if (!(image->info().usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))) return; // Flush clears if there are any since they may affect the image - if (!m_deferredClears.empty()) + if (!m_deferredClears.empty() && flushClears) this->spillRenderPass(false); // All images are in their default layout for suspended passes diff --git a/src/dxvk/dxvk_context.h b/src/dxvk/dxvk_context.h index 91458359..324b43a5 100644 --- a/src/dxvk/dxvk_context.h +++ b/src/dxvk/dxvk_context.h @@ -1166,7 +1166,8 @@ namespace dxvk { void prepareImage( DxvkBarrierSet& barriers, const Rc& image, - const VkImageSubresourceRange& subresources); + const VkImageSubresourceRange& subresources, + bool flushClears = true); bool updateIndexBufferBinding(); void updateVertexBufferBindings();