KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
777 stars 407 forks source link

VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 could be more detailed: the sequel #6570

Open zmike opened 1 year ago

zmike commented 1 year ago

Validation for this has improved since the last ticket I opened, but it's still not at all useful:

VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251(ERROR / SPEC): msgNum: -1094930823 - Validation Error: [ VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 ] | MessageID = 0xbebcae79 | vkCreateImage(): pCreateInfo The following parameters -
format (VK_FORMAT_B8G8R8A8_UNORM)
type (VK_IMAGE_TYPE_2D)
tiling (VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)
usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT|VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT)
flags (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)
drmFormatModifier (144115188085373698) from pDrmFormatModifiers[0]
returned (VK_ERROR_FORMAT_NOT_SUPPORTED) when calling VkGetPhysicalDeviceImageFormatProperties2. The Vulkan spec states: Each of the following values (as described in Image Creation Limits) must not be undefined : imageCreateMaxMipLevels, imageCreateMaxArrayLayers, imageCreateMaxExtent, and imageCreateSampleCounts (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251)

What is the problem here? I have no idea, and none of the provided info is helpful in figuring it out.

spencer-lunarg commented 1 year ago

We are calling VkGetPhysicalDeviceImageFormatProperties2 for you with the VkImageCreateInfo information, it returned back VK_ERROR_FORMAT_NOT_SUPPORTED... I feel this is an issue with the fact the function has a single error message. The driver doesn't like this combo and not sure how the validation layers could automatically probe it to find when it is happy

zmike commented 1 year ago

To me, this error message having the text The Vulkan spec states: Each of the following values (as described in Image Creation Limits) must not be undefined : imageCreateMaxMipLevels, imageCreateMaxArrayLayers, imageCreateMaxExtent, and imageCreateSampleCounts implies that one of these values is undefined, and the undefined nature of the value is what's causing the error.

spencer-lunarg commented 1 year ago

ok, (deep breath) so this part of the spec is honestly one my least favorite (and I have read most the spec)

lets take imageCreateMaxMipLevels

it is defined as

minimum value of VkImageFormatProperties::maxMipLevels in imageCreateImageFormatPropertiesList. The value is undefined if imageCreateImageFormatPropertiesList is empty.

which points to

imageCreateImageFormatPropertiesList is the list of structures obtained by calling vkGetPhysicalDeviceImageFormatProperties2

and then lastly

If any call to vkGetPhysicalDeviceImageFormatProperties2 returns an error, then imageCreateImageFormatPropertiesList is defined to be the empty list.

So there is quite not literally anything the app or layer level can detect to know which value is undefined... we just have to query vkGetPhysicalDeviceImageFormatProperties2 for you and make sure it didn't return VK_ERROR_FORMAT_NOT_SUPPORTED

... also we just print out the VU text, which I also think is not helpful at all

spencer-lunarg commented 8 months ago

created https://gitlab.khronos.org/vulkan/vulkan/-/issues/3825 - I feel the issue is Image Creation Limits is so hard to parse

devshgraphicsprogramming commented 8 months ago

I'm getting a new validation error message afdter upgrading the SDK from 265 to 275

[14.03.2024 16:40:02:505453][ERROR]: Validation Error: [ VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 ] | MessageID = 0xbebcae79 | vkCreateImage(): pCreateInfo The following parameters -
format (VK_FORMAT_R8G8B8A8_SRGB)
type (VK_IMAGE_TYPE_2D)
tiling (VK_IMAGE_TILING_OPTIMAL)
usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
flags (VkImageCreateFlags(0))
returned (VK_ERROR_FORMAT_NOT_SUPPORTED) when calling vkGetPhysicalDeviceImageFormatProperties2. The Vulkan spec states: Each of the following values (as described in Image Creation Limits) must not be undefined : imageCreateMaxMipLevels, imageCreateMaxArrayLayers, imageCreateMaxExtent, and imageCreateSampleCounts (https://vulkan.lunarg.com/doc/view/1.3.275.0/windows/1.3-extensions/vkspec.html#VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251)

The thing is I'm creating a pretty vanilla RGBA_SRGB image with only TRANSFER_SRC and COLOR_ATTACHMENT USAGES that kind thats supposed to be supported on every GPU image

Seems that the validation of vkCreateImage itself is calling the vkGetPhysicalDeviceImageFormatProperties2 with bad parameters (because I don't call vkGetPhysicalDeviceImageFormatProperties2) and produces validation errors.

spencer-lunarg commented 8 months ago

@devshgraphicsprogramming yes we currently call vkGetPhysicalDeviceImageFormatProperties2 for you (with all the pNext passed in as well)

that kind thats supposed to be supported on every GPU

I guess the use of VkImageStencilUsageCreateInfo is where this going wrong.. the "can prove this is supported" is call vkGetPhysicalDeviceImageFormatProperties2 with that stencilUsage in it and see if it works... my biggest fear is there is a driver bug that "actually" will make the image but doesn't expose vkGetPhysicalDeviceImageFormatProperties2 correctly when using that pNext

devshgraphicsprogramming commented 8 months ago

@devshgraphicsprogramming yes we currently call vkGetPhysicalDeviceImageFormatProperties2 for you (with all the pNext passed in as well)

that kind thats supposed to be supported on every GPU

I guess the use of VkImageStencilUsageCreateInfo is where this going wrong.. the "can prove this is supported" is call vkGetPhysicalDeviceImageFormatProperties2 with that stencilUsage in it and see if it works... my biggest fear is there is a driver bug that "actually" will make the image but doesn't expose vkGetPhysicalDeviceImageFormatProperties2 correctly when using that pNext

I'll try "disconnecting" the stencil usage for non stencil formats.

devshgraphicsprogramming commented 8 months ago

yep that worked.

Stehsaer commented 8 months ago

Getting similar validation error here. I'm currently following the tutorials on vulkan-tutorial.com and tried creating a image with the nearly the same parameters on the website except using R8G8B8_SRGB, using VMA. Sadly I can't create the image because I run into a validation layer error.

My Wrapper

    Result<Image, VkResult> Image::create(
        const Vma_allocator&  allocator,
        VkImageType           type,
        VkExtent3D            extent,
        VkFormat              format,
        VkImageTiling         tiling_mode,
        VkImageUsageFlags     image_usage,
        VmaMemoryUsage        mem_usage,
        VkSharingMode         sharing_mode,
        VkImageLayout         initial_layout,
        VkSampleCountFlagBits samples,
        uint32_t              mipmap_level,
        uint32_t              array_layers
    )
    {
        VkImageCreateInfo create_info{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO};
        create_info.imageType     = type;
        create_info.extent        = extent;
        create_info.format        = format;
        create_info.tiling        = tiling_mode;
        create_info.sharingMode   = sharing_mode;
        create_info.usage         = image_usage;
        create_info.initialLayout = initial_layout;
        create_info.mipLevels     = mipmap_level;
        create_info.arrayLayers   = array_layers;
        create_info.samples       = samples;
        create_info.flags         = 0;

        VmaAllocationCreateInfo vma_alloc_create_info;
        vma_alloc_create_info.priority = 1.0f;
        vma_alloc_create_info.usage    = mem_usage;

        VkImage           image_handle;
        VmaAllocation     vma_allocation;
        VmaAllocationInfo vma_alloc_info;

        auto result = vmaCreateImage(
            *allocator,
            &create_info,
            &vma_alloc_create_info,
            &image_handle,
            &vma_allocation,
            &vma_alloc_info
        );

        if (result != VK_SUCCESS)
            return result;
        else
            return Image(
                allocator,
                {
                  image_handle,
                  {*allocator, vma_allocation, vma_alloc_info}
            }
            );
    }

My code

    auto image_create_result = Image::create(
        allocator,
        VK_IMAGE_TYPE_2D,
        VkExtent3D(image_x, image_y, 1),
        VK_FORMAT_R8G8B8_SRGB,
        VK_IMAGE_TILING_OPTIMAL,
        VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
        VMA_MEMORY_USAGE_GPU_ONLY,
        VK_SHARING_MODE_EXCLUSIVE
    );

Validation Error Output

Validation Error: [ VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251 ] | MessageID = 0xbebcae79 | vkCreateImage(): The following parameters -
format (VK_FORMAT_R8G8B8_SRGB)
type (VK_IMAGE_TYPE_2D)
tiling (VK_IMAGE_TILING_OPTIMAL)
usage (VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT)
flags (VkImageCreateFlags(0))
returned (VK_ERROR_FORMAT_NOT_SUPPORTED) when calling VkGetPhysicalDeviceImageFormatProperties2. The Vulkan spec states: Each of the following values (as described in Image Creation Limits) must not be undefined : imageCreateMaxMipLevels, imageCreateMaxArrayLayers, imageCreateMaxExtent, and imageCreateSampleCounts (https://vulkan.lunarg.com/doc/view/1.3.261.1/windows/1.3-extensions/vkspec.html#VUID-VkImageCreateInfo-imageCreateMaxMipLevels-02251)

This is really frustrating for a beginner :-( Anyone has ideas about it? Will it be fine to just disable the validation layer and move on regardless of the potential errors?

Edit

Edit: problem solved. The format is the key to error. Still this validation info should be made better. It's easy to cause confusion especially for beginners