Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Error no WSI support on physical device 0 #4012

Closed
ragerma opened this issue Apr 6, 2021 · 3 comments
Closed

Vulkan Error no WSI support on physical device 0 #4012

ragerma opened this issue Apr 6, 2021 · 3 comments

Comments

@ragerma
Copy link

ragerma commented Apr 6, 2021

I compiled the example_glfw_vulkan and example_sdl_vulkan using g++ on CentOS 8. But when I try to run the compiled apps, both examples give me an error message saying "Error no WSI support on physical device 0". After doing some debugging, I found the issue is caused by the Intel GPU and the RTX 2060 GPU in my laptop. In line 120 of main.cpp, the code g_PhysicalDevice = gpus[0]; is using the first GPU without checking if it supports vulkan. And it turns out the first GPU (intel integrated) does not support vulkan. After changing the code to use the 2nd GPU, g_PhysicalDevice = gpus[1]; the program works properly.

rokups added a commit to rokups/imgui that referenced this issue Apr 6, 2021
…ble, or use first GPU otherwise. (ocornut#4012)

Fixes examples failing on optimus laptops with integrated graphics not supporting Vulkan.
rokups added a commit to rokups/imgui that referenced this issue Apr 6, 2021
…ble, or use first GPU otherwise. (ocornut#4012)

Fixes examples failing on optimus laptops with integrated graphics not supporting Vulkan.
@rokups
Copy link
Contributor

rokups commented Apr 6, 2021

Hey @ragerma could you please test a fix? I cant get my laptop into state that would make both GPUs detectable.

@ragerma
Copy link
Author

ragerma commented Apr 7, 2021

I've tested the following change and it works properly on my laptop.

    // If a number >1 of GPUs got reported, find discrete GPU if present, or use first one available. This covers
    // most common cases (multi-gpu/integrated+dedicated graphics). Handling more complicated setups (multiple
    // dedicated GPUs) is out of scope of this sample.
    int use_gpu = 0;
    for (int i = 0; i < (int)gpu_count; i++)
    {
        VkPhysicalDeviceProperties properties;
        vkGetPhysicalDeviceProperties(gpus[i], &properties);
        if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
        {
            use_gpu = i;
            break;
        }
    }

    g_PhysicalDevice = gpus[use_gpu];`

ocornut pushed a commit that referenced this issue Apr 7, 2021
…ble, or use first GPU otherwise. (#4012)

Fixes examples failing on optimus laptops with integrated graphics not supporting Vulkan.
@ocornut
Copy link
Owner

ocornut commented Apr 7, 2021

Merged fix by @rokups. Thank you both!

@ocornut ocornut closed this as completed Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants