From f597ade450e81129249adfce95ee54c4581c7653 Mon Sep 17 00:00:00 2001 From: Sergey Kosarevsky Date: Wed, 20 Sep 2023 13:14:24 -0700 Subject: [PATCH] igl | vulkan | Add full image barrier for debugging Summary: Define `IGL_DEBUG_ENFORCE_FULL_IMAGE_BARRIER` to be `1` to ensure any image layout transition causes a full barrier. Reviewed By: EricGriffith Differential Revision: D49444499 fbshipit-source-id: b775b1e38104da29a515474015f4725cc85d1494 --- src/igl/vulkan/VulkanImage.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/igl/vulkan/VulkanImage.cpp b/src/igl/vulkan/VulkanImage.cpp index 36d19fbe73..1149f8529c 100644 --- a/src/igl/vulkan/VulkanImage.cpp +++ b/src/igl/vulkan/VulkanImage.cpp @@ -17,6 +17,9 @@ #include #endif +// any image layout transition causes a full barrier +#define IGL_DEBUG_ENFORCE_FULL_IMAGE_BARRIER 0 + namespace { uint32_t ivkGetMemoryTypeIndex(const VkPhysicalDeviceMemoryProperties& memProps, const uint32_t typeBits, @@ -630,7 +633,7 @@ std::shared_ptr VulkanImage::createImageView(VkImageViewType ty debugName); } -void VulkanImage::transitionLayout(VkCommandBuffer commandBuffer, +void VulkanImage::transitionLayout(VkCommandBuffer cmdBuf, VkImageLayout newImageLayout, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, @@ -717,7 +720,16 @@ void VulkanImage::transitionLayout(VkCommandBuffer commandBuffer, dstAccessMask |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; } - ivkImageMemoryBarrier(commandBuffer, +#if IGL_DEBUG_ENFORCE_FULL_IMAGE_BARRIER + // full image barrier + srcAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT; + dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT; + + srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; + dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; +#endif // IGL_DEBUG_ENFORCE_FULL_IMAGE_BARRIER + + ivkImageMemoryBarrier(cmdBuf, vkImage_, srcAccessMask, dstAccessMask,