From c9ec2eeab22c9828a14efd8af833f12e3a829067 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 2 Oct 2024 14:45:54 +0200 Subject: [PATCH] [dxvk] Ensure image is in correct layout for invalidation Otherwise, layout tracking might track a dead image and get confused. --- src/dxvk/dxvk_context.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 7abf8a304..021375c24 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -1901,6 +1901,9 @@ namespace dxvk { void DxvkContext::invalidateImage( const Rc& image, Rc&& slice) { + // Ensure image is in the correct layout and not currently tracked + prepareImage(image, image->getAvailableSubresources()); + invalidateImageWithUsage(image, std::move(slice), DxvkImageUsageInfo()); } @@ -6546,6 +6549,13 @@ namespace dxvk { if (!bufferCount && !imageCount) return; + // Ensure images are in the expected layout and any sort of layout + // tracking does not happen after the backing storage is swapped. + for (size_t i = 0; i < imageCount; i++) + prepareImage(imageInfos[i].image, imageInfos[i].image->getAvailableSubresources()); + + m_execBarriers.recordCommands(m_cmd); + small_vector imageBarriers; VkMemoryBarrier2 bufferBarrier = { VK_STRUCTURE_TYPE_MEMORY_BARRIER_2 };