Validation layer warnings on ray tracing samples
With the ray tracing samples ray_tracing_basic, ray_tracing_extended, ray_tracing_position_fetch, and ray_tracing_reflection I get this validation layer warning:
vkCmdTraceRaysKHR(): the storage image descriptor [VkDescriptorSet 0x6c000000006c, Set 0, Binding 1, Index 0, variable "image"] is accessed by a OpTypeImage that has a Format operand Rgba8 (equivalent to VK_FORMAT_R8G8B8A8_UNORM) which doesn't match the VkImageView 0x500000000050 format (VK_FORMAT_B8G8R8A8_UNORM). Any loads or stores with the variable will produce undefined values to the whole image (not just the texel being accessed). While the formats are compatible, Storage Images must exactly match. Few ways to resolve this are
1. Set your ImageView to VK_FORMAT_R8G8B8A8_UNORM and swizzle the values in the shader to match the desired results.
2. Use the Unknown format in your shader (will need the widely supported shaderStorageImageWriteWithoutFormat feature)
Spec information at https://docs.vulkan.org/spec/latest/chapters/textures.html#textures-format-validation
Simply changing the VkImage's and VkImageView's format to VK_FORMAT_R8G8B8A8_UNORM would resolve the warning, but of course changes the visual output of those samples.
I don't know where that OpTypeImage, mentioned in the VVL warning above comes from, or how I could change that to some bgra-format.
The warning is resolved if I
- create a render context with
VK_FORMAT_R8G8B8A8_SRGB, instead ofVK_FORMAT_B8G8R8A8_SRGB, and - use an image format of
VK_FORMAT_R8G8B8A8_UNORM, instead ofVK_FORMAT_B8G8R8A8_UNORM, and - use that same image view format.
But I don't know if that's the way to go.
Does anybody know how to change the OpTypeImage, instead?
I'll take a look at this. There is a widely supported extension to fix this, I used that in my own code to get around this problem.
Ok, it's in the raygen shader:
layout(binding = 1, set = 0, rgba8) uniform image2D image;
And apparently, there's nothing like a bgra8 for the layout.
That is, one would either use that extension or just switch to rgba, as described above.