Vulkan backend helper function question #7830

Closed
opened 2024-07-29 09:29:32 +00:00 by mihaly-sisak · 0 comments
mihaly-sisak commented 2024-07-29 09:29:32 +00:00 (Migrated from github.com)

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];
        }
    }
### 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](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_vulkan.cpp#L1255) However the standard states that here the Vulkan API can not give back `VK_FORMAT_UNDEFINED`: [Vulkan 1.0 vkGetPhysicalDeviceSurfaceFormatsKHR](https://registry.khronos.org/vulkan/specs/1.0-extensions/html/chap34.html#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: ```cpp // 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]; } } ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#7830
No description provided.