Skip to content

Commit

Permalink
igl | vulkan | Add full image barrier for debugging
Browse files Browse the repository at this point in the history
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
  • Loading branch information
corporateshark authored and facebook-github-bot committed Sep 20, 2023
1 parent ec449e5 commit f597ade
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/igl/vulkan/VulkanImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <unistd.h>
#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,
Expand Down Expand Up @@ -630,7 +633,7 @@ std::shared_ptr<VulkanImageView> VulkanImage::createImageView(VkImageViewType ty
debugName);
}

void VulkanImage::transitionLayout(VkCommandBuffer commandBuffer,
void VulkanImage::transitionLayout(VkCommandBuffer cmdBuf,
VkImageLayout newImageLayout,
VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f597ade

Please sign in to comment.