Help with vkCreateSwapchainKHR
error on RTX 3050 Ti - VK_IMAGE_USAGE_STORAGE_BIT
not supported
Hello,
I’m working on a Vulkan application and I get this validation error when creating the swapchain:
Validation error
validation layer: vkCreateSwapchainKHR(): pCreateInfo->imageFormat VK_FORMAT_B8G8R8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL does not support usage that includes VK_IMAGE_USAGE_STORAGE_BIT.
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.313.2/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)
validation layer: vkCreateSwapchainKHR(): pCreateInfo vkGetPhysicalDeviceImageFormatProperties() unexpectedly failed, with following VkImageCreateInfo
format (VK_FORMAT_B8G8R8A8_SRGB)
type (VK_IMAGE_TYPE_2D)
tiling (VK_IMAGE_TILING_OPTIMAL)
usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_STORAGE_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
flags (VkImageCreateFlags(0))
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.313.2/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)
validation layer: vkCreateSwapchainKHR(): pCreateInfo->imageArrayLayers 1, but Maximum value returned by vkGetPhysicalDeviceImageFormatProperties() is 0 for imageFormat VK_FORMAT_B8G8R8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL.
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.313.2/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)
validation layer: vkCreateSwapchainKHR(): pCreateInfo->imageExtent (width = 1280, height = 720), which is bigger than max extent (width = 0, height = 0, depth = 0) returned by vkGetPhysicalDeviceImageFormatProperties() for imageFormat VK_FORMAT_B8G8R8A8_SRGB with tiling VK_IMAGE_TILING_OPTIMAL.
The Vulkan spec states: The implied image creation parameters of the swapchain must be supported as reported by vkGetPhysicalDeviceImageFormatProperties (https://vulkan.lunarg.com/doc/view/1.4.313.2/windows/antora/spec/latest/chapters/VK_KHR_surface/wsi.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)
I suspect the problem is in the usage flags I’m setting for the swapchain images.
My Vulkan setup and relevant code snippets:
Vulkan setup
- GPU: NVIDIA GeForce RTX 3050 Ti Laptop GPU
- OS: Windows 11 Pro
- Compiler: MSVC
- Vulkan SDK version: 1.4.312.2
How I create the swapchain:
VkImageUsageFlags usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
if (swapChainSupport.capabilities.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) {
usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
}
// Removed VK_IMAGE_USAGE_STORAGE_BIT because it causes validation errors
VkSwapchainCreateInfoKHR createInfo{};
createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
createInfo.surface = *surface;
createInfo.minImageCount = imageCount;
createInfo.imageFormat = surfaceFormat.format;
createInfo.imageColorSpace = surfaceFormat.colorSpace;
createInfo.imageExtent = extent;
createInfo.imageArrayLayers = 1;
createInfo.imageUsage = usage;
...
Error details:
- The validation layers complain that
VK_IMAGE_USAGE_STORAGE_BIT
is not supported withVK_FORMAT_B8G8R8A8_SRGB
andVK_IMAGE_TILING_OPTIMAL
. vkGetPhysicalDeviceImageFormatProperties
returns 0 max image array layers and zero max extent for this format with those usage flags.
Question:
- Is it normal that
VK_IMAGE_USAGE_STORAGE_BIT
is unsupported on swapchain images for this format and tiling? - What is the recommended set of usage flags for a swapchain on RTX 3050 Ti?
- How can I achieve a usage similar to
VK_IMAGE_USAGE_STORAGE_BIT
on swapchain images if needed? - Are there known workarounds or best practices for this?
Please let me know if you need help editing or preparing the post further!