Reputation: 319
I'm trying to use a compute shader to render directly to the swap chain.
For this, I need to create the swapchain
with the usage VK_IMAGE_USAGE_STORAGE_BIT
.
The problem is that the swapchain
needs to be created with the format VK_FORMAT_B8G8R8A8_UNORM
or VK_FORMAT_B8G8R8A8_SRGB
and neither of the 2 allows the format feature VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT
with the physical device I use.
Do I said something wrong or it's impossible to render to the swapchain
with compute shader using my configuration?
Upvotes: 3
Views: 1001
Reputation: 474436
Vulkan imposes no requirement on the implementation that it permit direct usage of a swapchain image in a compute shader operation (FYI: "rendering" typically refers to a very specific operation; it's not something that happens in a compute shader). Therefore, it is entirely possible that the implementation will forbid you from using a swapchain image in a CS through various means.
If you cannot create a swapchain image in your preferred format, then your next best bet is to see if you can find a compatible format for an image view of the format you can use as a storage image. This however requires that the implementation support the KHR extension swapchain_mutable_format, and the creation flags for the swapchain must include VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR
as well as a VkImageFormatListCreateInfoKHR
list of formats that you intend to create views for.
Also, given support, this would mean that your CS will have to swap the ordering of the data. And don't forget that, when you create the swapchain, you have to ask it if you can use its images as storage images (imageUsage
). It may directly forbid this.
Upvotes: 3