Vulkan-ValidationLayers icon indicating copy to clipboard operation
Vulkan-ValidationLayers copied to clipboard

VK_IMAGE_CREATE_EXTENDED_USAGE_BIT should allow for images to be created with flags not supported by the current image format

Open cyanreg opened this issue 2 years ago • 5 comments

The issue happens with multiplane images. The spec says:

For images created with VK_IMAGE_CREATE_EXTENDED_USAGE_BIT a usage bit is valid if it is supported for at least one of the formats a VkImageView created from the image can have (see Image Views for more detail).

Which indicates e.g. that using VK_IMAGE_USAGE_STORAGE_BIT on VK_FORMAT_G8_B8R8_2PLANE_420_UNORM is a valid usage, even if the driver does not flag STORAGE as being supported on that particular format, as long as at least one of the valid formats an VkImageView can be created with for that format supports VK_IMAGE_USAGE_STORAGE_BIT.

However, the validation layer currently errors with the message:

VK_FORMAT_G8_B8R8_2PLANE_420_UNORM with tiling VK_IMAGE_TILING_OPTIMAL does not support usage that includes VK_IMAGE_USAGE_STORAGE_BIT

Claiming that for that particular combination of format, creation flags and tiling, VK_IMAGE_USAGE_STORAGE_BIT is not a supported usage flag.

@zlatinski mentioned that Nvidia's drivers require that VK_IMAGE_USAGE_STORAGE_BIT is set at image creation level for any views' storage feature to work correctly, even if the VK_IMAGE_CREATE_EXTENDED_USAGE_BIT flag is set.

cyanreg avatar Oct 05 '23 02:10 cyanreg

@cyanreg can you print out the full message, I am not sure where we are falsely printing this message and tried to write a test but can't find it (probably because I can't match which features are allowed on your device testing on)

spencer-lunarg avatar Oct 06 '23 15:10 spencer-lunarg

@cyanreg friendly ping on this, currently still not able to reproduce or know where in the code to try and fix this

spencer-lunarg avatar Nov 20 '23 01:11 spencer-lunarg

Happens on at least RADV.

Full text:

Validation Error: [ VUID-VkImageCreateInfo-pNext-06811 ] | MessageID = 0x30f4ac70 | vkCreateImage(): pCreateInfo image creation parameters (flags: 0x00000508, format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, imageType: VK_IMAGE_TYPE_2D, tiling: VK_IMAGE_TILING_OPTIMAL) are not supported by any of the supported video format properties for the video profiles specified in the VkVideoProfileListInfoKHR structure included in the pCreateInfo->pNext chain, as reported by vkGetPhysicalDeviceVideoFormatPropertiesKHR for the same video profiles and the image usage flags specified in pCreateInfo->usage (0x00000405). The Vulkan spec states: If the pNext chain includes a VkVideoProfileListInfoKHR structure with profileCount greater than 0, then supportedVideoFormat must be VK_TRUE (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageCreateInfo-pNext-06811)

To replicate, run FFmpeg 6.1 with the following command line: ffmpeg -threads 1 -init_hw_device "vulkan=vk:0,debug=1" -hwaccel vulkan -hwaccel_output_format vulkan -i <TEST_H264.mkv> -f null -

cyanreg avatar Nov 20 '23 02:11 cyanreg

ok, I just got a RADV laptop locally to test on (for other stuff) so will add this to my queue of things I can now fix!

Thanks for the information

spencer-lunarg avatar Nov 20 '23 02:11 spencer-lunarg

I'm also seeing this issue with my own application so maybe this capture helps? https://drive.google.com/file/d/17Mp7dhF52vU4_tL1UUHjeSiK5TjbMGS7/view?usp=drive_link

My use case my be simpler to reproduce since I'm attempting to recreate a D3D idiom: Prior to feature level 12_0 not all GPUs supported typed UAV loads so it was a common pattern to create a R8G8B8A8_UNORM or R10G10B10A2_UNORM texture and alias that with a R32_UINT UAV since they are the same size. D3D allows this aliasing specifically despite them not being DXGI formats of the same base type. This allowed you to use the texture as a render target and support things like blending, but also later use it in a compute shader as a UAV, assuming the shader was ok with doing manual bit packing/unpacking.

I'm trying to do the same thing here but with a VK_FORMAT_A2R10G10B10_UNORM_PACK32 image and image view for rendering and creating a VK_FORMAT_R32_UINT image view for my storage image binding. My understanding is that passing VK_IMAGE_CREATE_EXTENDED_USAGE_BIT | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT when creating the image should allow this, and it seems to work, however the validation layer complains:

VUID-VkImageViewCreateInfo-usage-02275: Validation Error: [ VUID-VkImageViewCreateInfo-usage-02275 ] Object 0: handle = 0x6bbcea000000008f, name = GBufferPlane2, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0x618ab1e7 | vkCreateImageView(): pCreateInfo->format VK_FORMAT_A2R10G10B10_UNORM_PACK32 with tiling VK_IMAGE_TILING_OPTIMAL only supports VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT|VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT|VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT|VK_FORMAT_FEATURE_2_BLIT_SRC_BIT|VK_FORMAT_FEATURE_2_BLIT_DST_BIT|VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT|VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT|VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT|VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT|VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT. The Vulkan spec states: If usage contains VK_IMAGE_USAGE_STORAGE_BIT, then the image view's format features must contain VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-usage-02275)

lmagder avatar Jan 06 '24 21:01 lmagder