VK_IMAGE_USAGE_TRANSFER_SRC_BIT flag magically added to swapchain images

Viewed 149

Is the VkImageUsageFlagBits::VK_IMAGE_USAGE_TRANSFER_SRC_BIT supposed to automatically be set for swapchain images?

I've been looking it up, and I don'd see any indication that this flag is supposed to be automatically added to swapchain images.

However, I have tested that in SDK 1.2.148.1 (haven't tried others), on NVIDIA GTX 1080ti with the latest drivers, that flag is automatically added, even when not requested. I'm not sure whether it's the SDK or the driver that it's setting it, but one of them is.

I first verified it in my own code, then tried it using the Sascha Willem's Triangle example, by commenting out the following line: https://github.com/SaschaWillems/Vulkan/blob/master/base/VulkanSwapChain.cpp#L347

This is an image with the Triangle app running on NVIDIA Nsight. It shouldn't have the flag:

enter image description here

1 Answers

Vulkan has no mechanism to tell you what the usage flags are on an image, whether swapchain or not. As such, you are relying on layers and debugging tools to feed that information to you.

However, these tools themselves are perfectly capable of setting these flags. If a debugging tool wants to be able to show you the image data in a swapchain image, then that image must be usable as the source for a transfer operation. So such a tool must set those flags. The same goes for any layers that might be involved in debugging.

Indeed, the fact that the debugging tool knows that the flag has been set is evidence that the Vulkan implementation didn't set it. If it had set the flag, nobody outside of the implementation would know about it.

So in all likelihood, this is the act of a debugging layer. Unfortunately, it is setting this flag before the validation layer sees it. And to validate uses of the imageless framebuffer feature, the validation layer needs to look at those flags.

To fix this, you may be able to reorder the layers you have activated. ppEnabledLayerNames is an ordered list of layers; if you aren't doing so already, put the validation layers first in this list. If you're enabling layers more globally, see if you can play around with the order of those layers.

Related