Vulkan-Samples icon indicating copy to clipboard operation
Vulkan-Samples copied to clipboard

Headless mode seems to be broken

Open SaschaWillems opened this issue 1 year ago • 2 comments

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

SaschaWillems avatar Oct 15 '23 16:10 SaschaWillems

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

JoseEmilio-ARM avatar Jan 31 '24 14:01 JoseEmilio-ARM

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

SaschaWillems avatar Feb 05 '24 16:02 SaschaWillems