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

vulkan_object.py missing Extension Requires Depends info

Open charles-lunarg opened this issue 1 year ago • 1 comments

The Vulkan XML has various depends tags attached to requires block. This data is useful for generating command dependencies on extensions, but is not accessible in vulkan_object.py.

For example, vkGetDeviceGroupSurfacePresentModes2EXT is provided by VK_EXT_full_screen_exclusive but requires either VK_KHR_device_group or VK_VERSION_1_1 to be enabled.

An XML description taken from the spec:

<extension name="VK_EXT_full_screen_exclusive" ...>           

    <require depends="VK_KHR_device_group,VK_VERSION_1_1">
        <command name="vkGetDeviceGroupSurfacePresentModes2EXT"/>
    </require>
</extension>

This was found while trying to update the Vulkan-Loader codegen to use vulkan_object.py, and while it was possible to hardcode this, it would be helpful to have this information.

charles-lunarg avatar Feb 25 '25 14:02 charles-lunarg

Ok, trying envision how this would actually look now. Using 2 edge case of vkGetDeviceGroupPresentCapabilitiesKHR and vkGetDeviceGroupSurfacePresentModes2EXT

  1. vkGetDeviceGroupPresentCapabilitiesKHR is found in
<extension name="VK_KHR_swapchain">
    <require depends="VK_VERSION_1_1">
        <command name="vkGetDeviceGroupPresentCapabilitiesKHR"/>
    </require>
</extension>
<extension name="VK_KHR_device_group">
    <require depends="VK_KHR_surface">
        <command name="vkGetDeviceGroupPresentCapabilitiesKHR"/>
    </require>
</extension>

and going self.vk.commands['vkGetDeviceGroupPresentCapabilitiesKHR'].extensions gives you the array of VK_KHR_swapchain and VK_KHR_device_group

  1. vkGetDeviceGroupSurfacePresentModes2EXT
<extension name="VK_EXT_full_screen_exclusive">
    <require depends="VK_KHR_device_group,VK_VERSION_1_1">
        <command name="vkGetDeviceGroupSurfacePresentModes2EXT"/>
    </require>
</extension>

and going self.vk.commands['vkGetDeviceGroupSurfacePresentModes2EXT'].extensions gives you just VK_EXT_full_screen_exclusive


I guess not how to best represent this whole extension relationship together

spencer-lunarg avatar Mar 04 '25 00:03 spencer-lunarg

I am going to close the issue as this request really isn't necessary.

The problem attempting to be solved is making sure that commands which aren't in the Vulkan-Headers aren't able to be compiled. So commands which come from an extension must have that extension defined in the headers in order for the Vulkan-Loader dispatch table(s) to include it.

What I failed to realize is that the extension.depends field defines the runtime requirements, not the compile time availability. For commands, their 'extension' list defines the list of extensions that 'define' the extension. So if any of those extensions are present, then we can assume the command is safe to include.

I'll make a Loader PR to address this fact shortly, and close the issue in response (just to track it).

charles-lunarg avatar Jun 23 '25 18:06 charles-lunarg

Or wait, the loader is doing runtime checks of the dependency info. But that a reason to go back and remove the 'depends' logic and not make overbearing assumptions about the driver here, as the loader is only doing the preliminary checks that the function is available, and not able to (easily) determine if the function must be available.

charles-lunarg avatar Jun 23 '25 18:06 charles-lunarg

Adding the PR that 'resolves' this issue for posterity. https://github.com/KhronosGroup/Vulkan-Loader/pull/1733

charles-lunarg avatar Jun 23 '25 20:06 charles-lunarg