KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.34k stars 648 forks source link

Headless mode seems to be broken #830

Closed SaschaWillems closed 3 days ago

SaschaWillems commented 1 year ago

None of the samples seem to work in headless mode anymore. I get the following validation error when running with --headless:

[error] [framework\core\instance.cpp:50] -437968512 - VUID-vkCreateInstance-ppEnabledExtensionNames-01388: Validation Error: [ VUID-vkCreateInstance-ppEnabledExtensionNames-01388 ] Object 0: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0xe5e52180 | Missing extension required by the instance extension VK_EXT_headless_surface: VK_KHR_surface. The Vulkan spec states: All required extensions for each extension in the VkInstanceCreateInfo::ppEnabledExtensionNames list must also be present in that list (https://vulkan.lunarg.com/doc/view/1.3.261.1/windows/1.3-extensions/vkspec.html#VUID-vkCreateInstance-ppEnabledExtensionNames-01388)

As per the spec VK_EXT_headless_surface requires VK_KHR_surface, yet at instance creation we do this:

    // Try to enable headless surface extension if it exists
    if (headless)
    {
        const bool has_headless_surface = enable_extension(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME,
                                                           available_instance_extensions, enabled_extensions);
        if (!has_headless_surface)
        {
            LOGW("{} is not available, disabling swapchain creation", VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME);
        }
    }
    else
    {
        enabled_extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
    }

Imo this is wrong and the else path should always be run. But even changing that will then cause the sample to fail at surface creation, as the base sample class always expects a valid surface:

    if (!surface)
    {
        throw std::runtime_error("Failed to create window surface.");
    }

It looks like headless isn't properly handled, at least not on windows and possibly completely broken.

Refs #314

JoseEmilio-ARM commented 9 months ago

Hi @SaschaWillems , did you have a chance to investigate this further? We have an internal solution and I think we can share in the next couple of months after some refining

SaschaWillems commented 9 months ago

I did some initial testing, but nothing that's ready to be merged. So feel free to fix it :)