imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Vulkan backend helper function question

Open mihaly-sisak opened this issue 6 months ago • 2 comments

Version/Branch of Dear ImGui:

v1.91.0 WIP, master branch

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_vulkan.cpp

Compiler, OS:

any

Full config/build information:

No response

Details:

My Issue/Question:

I am currently learning Vulkan, and I found the ImGui example/backed helper functions incredibly helpful. However I came trough this line of code and I would like to ask for clarification.

In the Vulkan implementation helper function ImGui_ImplVulkanH_SelectSurfaceFormat there is a check for VK_FORMAT_UNDEFINED returned from vkGetPhysicalDeviceSurfaceFormatsKHR. imgui_impl_vulkan code in question

However the standard states that here the Vulkan API can not give back VK_FORMAT_UNDEFINED: Vulkan 1.0 vkGetPhysicalDeviceSurfaceFormatsKHR

The number of format pairs supported must be greater than or equal to 1. pSurfaceFormats must not contain an entry whose value for format is VK_FORMAT_UNDEFINED.

What is the reasoning behind checking for it? Is this code a workaround of some buggy Vulkan drivers?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

    // First check if only one format, VK_FORMAT_UNDEFINED, is available, which would imply that any format is available
    if (avail_count == 1)
    {
        if (avail_format[0].format == VK_FORMAT_UNDEFINED)
        {
            VkSurfaceFormatKHR ret;
            ret.format = request_formats[0];
            ret.colorSpace = request_color_space;
            return ret;
        }
        else
        {
            // No point in searching another format
            return avail_format[0];
        }
    }

mihaly-sisak avatar Jul 29 '24 09:07 mihaly-sisak