Validation layer Errors when creating swap chain. vkCreateSwapchainKHR returns VK_SUCCESS

I am getting validation errors when running vkCreateSwapchainKHR even though the call in itself returns VK_SUCCESS.

The errors that I am getting are these

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] Object 0: handle = 0x1db0b05a108, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xc036022f | 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.2.176.1/windows/1.2-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] Object 0: handle = 0x1db0b05a108, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xc036022f | vkGetPhysicalDeviceImageFormatProperties() unexpectedly failed, when called for vkCreateSwapchainKHR() validation with following params: format: VK_FORMAT_B8G8R8A8_SRGB, imageType: 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: Unhandled VkImageCreateFlagBits. 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.2.176.1/windows/1.2-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] Object 0: handle = 0x1db0b05a108, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xc036022f | vkCreateSwapchainKHR() called with a non-supported imageArrayLayers (i.e. 1). 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.2.176.1/windows/1.2-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-017

 Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageFormat-01778 ] Object 0: handle = 0x1db0b05a108, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xc036022f | vkCreateSwapchainKHR() called with imageExtent = (800,600), which is bigger than max extent (0,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.2.176.1/windows/1.2-extensions/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageFormat-01778)

The values like image format, extents look as expected to me in the log message. I also checked my create info struct which looks correct to me. Here is the value as per vs debugger

- createInfo {sType=VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR (1000001000) pNext=0x0000000000000000 flags=0 …} VkSwapchainCreateInfoKHR
sType VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR (1000001000) VkStructureType
pNext 0x0000000000000000 const void *
flags 0 unsigned int
surface 0x0683e70000000002 {…} VkSurfaceKHR_T *
minImageCount 3 unsigned int
imageFormat VK_FORMAT_B8G8R8A8_SRGB (50) VkFormat
imageColorSpace VK_COLOR_SPACE_SRGB_NONLINEAR_KHR (0) VkColorSpaceKHR
+ imageExtent {width=800 height=600 } VkExtent2D
imageArrayLayers 1 unsigned int
imageUsage 16 unsigned int
imageSharingMode VK_SHARING_MODE_CONCURRENT (1) VkSharingMode
queueFamilyIndexCount 2 unsigned int
+ pQueueFamilyIndices 0x000000346cb6ebc8 {0} const unsigned int *
preTransform VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR (1) VkSurfaceTransformFlagBitsKHR
compositeAlpha VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR (1) VkCompositeAlphaFlagBitsKHR
presentMode VK_PRESENT_MODE_IMMEDIATE_KHR (0) VkPresentModeKHR
clipped 0 unsigned int
oldSwapchain 0x0000000000000000 VkSwapchainKHR_T *

That’s 100% normal. The whole point of validation is that it checks for things that the implementation doesn’t check for.

imageUsage 16

This is either the decimal value 16 (0x10) or the hexadecimal value 0x16. Which it is doesn’t really matter because neither interpretation of this parameter specifies that you can use the swapchain image as a storage image. The bit for storage images is 0x08, and that is included in neither 0x10 nor 0x16.

So the validation layer is entirely correct: you cannot use the swapchain image as a storage image because you didn’t ask for it. Also, swapchain images don’t belong to you; they belong to the display engine, and you can only use them in the ways the display engine says you can. The only required usage flag is VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, which is 0x10.

In my code I am setting the imageUsage parameter to exactly VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT which in vulkan_core.h expands to 0x00000010. is that not correct?

I don’t completely understand this. so the value I am specifying for imageUsage (0x00000010) does not contain the storage bit. is that why the validation is failing?. should I also specify the storage bit?. Is that always necessary.?

Sorry if my questions don’t make much sense, I’m still working my way towards understanding Vulkan

The driver seems buggy, or the errors are misreported. VK_FORMAT_B8G8R8A8_SRGB is guaranteed with at least 4096x4096.

Your SDK is old, so firstly you could try to update. Then also update the GPU drivers and tell us which platform it is in the first place.

Additionally look in your code if you are not using VkSwapchainCreateInfoKHR after delete or something along those lines.

If you want to use the image as a storage image, then you have to tell Vulkan you want to use it as a storage image. That’s what the imageUsage bits are for.

Furthermore, since swapchain images don’t belong to you, you have to check to see if they even can be used as storage images.

@Alfonse_Reinheart but what if I don’t want to use the swap chain images as storage images. can I make it work without that ?. Right now I’m just trying to get a basic setup working following this tutorial. Is there any other error in the specified setting

As far as I can see from the errors reported by the validation layer vkGetPhysicalDeviceImageFormatProperties() is the culprit here which is unexpectedly failing. Because of which I’m getting messages like

vkCreateSwapchainKHR() called with imageExtent = (800,600), which is bigger than max extent (0,0)returned by vkGetPhysicalDeviceImageFormatProperties()

and

vkCreateSwapchainKHR() called with a non-supported imageArrayLayers (i.e. 1). Maximum value returned by vkGetPhysicalDeviceImageFormatProperties() is 0 for imageFormat VK_FORMAT_B8G8R8A8_SRGB

These values for imageExtent and imageArrayLayers should be correct as I queried these values using the vkGetPhysicalDeviceSurfaceCapabilitiesKHR function.
If that is the case here , is there any reason this function is failing during validation

… can you make what work without that? According to your validation layers, whatever you’re doing involves using a swapchain image as a storage image. Since I don’t know what you’re doing, I can’t advise you any further than that.

That being said, I am inclined to believe krOoze’s suggestion that the implementation may be doing something wrong here, at least with regard to the sizes you’re using.

I am just trying to create a basic Vulkan application to render a triangle based on the Vulkan-tutorial here. I am only using the basic VK_LAYER_KHRONOS_validation validation layer. According to the tutorial, th only imageUsage bit that’s required is VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT which is the only one I am supplying. Even after that, why would it still try calling the vkCreateSwapchainKHR with usage parameters as VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_STORAGE_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT as seen in the error message. Shouldn’t it just be the first one ?.

In that case How do I fix that, or can I just ignore these messages

  • tell us your platform
  • update your SDK
  • update your driver(s)
  • check your code for use-past-delete or unitialized memory use, otherwise we should try to figure out what added flags to your input
  • check what implicit layers are running. Since deprecation of device layers in stone ages of Vulkan, you should be able to do that with vkEnumerateDeviceLayers. Alternatively in debugger you should see all the dlls that are loaded.
  • My application is running on windows 10
  • Vulkan version1.2.182.0 (updated was earlier using 1.2.176.1)
  • GPU - RTX 2070 (laptop)

Updated this, still getting the same errors

My drivers are up to date as per the Gefore application

I’m pretty sure this isn’t happening. I checked my code from start to end to make sure this isn’t happening

I used vulkan configurator to disable layers openend by OBS and steam. Here are all the layers that are running

Another wierd thing that I noted while debugging was that vkCreateSwapchainKHR modifies the value of the imageUsage parameter in the createInfo that I pass. I put a breakpoint before and after running vkCreateSwapchainKHR, and the value passed is 16 which changes to 25 after the function runs. 25 does include the VK_IMAGE_USAGE_STORAGE_BIT. What does this mean?

I think the trace and nomad are debug tools and should not be implicitly on on every app. EOS is Epic overlay I think, and you could also try disabling it.

GPU - RTX 2070 (laptop)

Alright, so switchable graphics. That is another gift that keeps on giving.

My drivers are up to date as per the Gefore application

Also update the integrated GPU.

My intel drivers are also up to date.

Does this by any chance mean that my swap chain images have to have the storage bit ?

No, I still think it is some rogue layer. Changing the bit in place is bad practice, and no layers should be changing your structs that you passed as constant.

To eliminate another possibility you should run vkcube --validate if the same happens.

I tried this, I got a few similar warnings all saying invalid layer manifest file version 1.2.0 for different json files. However, No errors regarding storage bit or swap chains.

I also noticed one more thing. All the errors disappear if I replace image format from VK_FORMAT_B8G8R8A8_SRGB to VK_FORMAT_B8G8R8A8_UNORM

Those warnings are normal as per SDK release notes.

Still pretty much boils down to what adds the STORAGE flag, which throws a wrench in everything. Any of the layers are the primary culprit. But I guess driver could be bad too.

Put a data breakpoint on the VkSwapchainCreateInfoKHR::imageUsage. And check on which dll it lands on. That’s gonna be the buggy culprit.