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

Split out *Fn generated structures with dependencies on multiple extensions #635

Open
MarijnS95 opened this issue Jun 5, 2022 · 1 comment

Comments

@MarijnS95
Copy link
Collaborator

Sparked from the discussion in #629:

vk.xml currently models which types, enums and commands (functions) a particular extension pulls in (provides?) by a <require> element inside <extension>. It also has support for nested extension and Vulkan version dependencies through <require extension="XXX"> / <require feature="XXX">.

Currently our generator globs them all under the name of the top-level <extension> into a single loadable struct, whereas we'd like to preserve a strict feature/extension -> struct mapping. With #629/#631 the helpers are now also clobbered with functions that are only available when two extensions are available (mixed in with functions that are available when the "root" extension is enabled.

One of the options is to glue these names together, resulting in something potentially odd to read like KhrSwapchainPlusVulkan11Fn, but at least makes the dependency clear. This becomes more complicated for the functions added in #629 which have multiple mixed (disjoint) dependencies on for example VK_KHR_swapchain + Vulkan 1.1, but also VK_KHR_device_group + VK_KHR_surface or VK_KHR_device_group + VK_KHR_swapchain. Having two loader structs containing the same doesn't seem too outrageous here.


A list of all <require extension="XXX"> blocks containing one or more command elements, generated on v1.3.211 using:

xmlstarlet sel -t -c "//extension/require[(@extension or @feature) and command]" generator/Vulkan-Headers/registry/vk.xml
<require feature="VK_VERSION_1_1">
    <comment>This duplicates definitions in VK_KHR_device_group below</comment>
    <enum extends="VkStructureType" extnumber="61" offset="7" name="VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR"/>
    <enum extends="VkStructureType" extnumber="61" offset="8" name="VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR"/>
    <enum extends="VkStructureType" extnumber="61" offset="9" name="VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR"/>
    <enum extends="VkStructureType" extnumber="61" offset="10" name="VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR"/>
    <enum extends="VkStructureType" extnumber="61" offset="11" name="VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR"/>
    <enum extends="VkStructureType" extnumber="61" offset="12" name="VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR"/>
    <enum bitpos="0" extends="VkSwapchainCreateFlagBitsKHR" name="VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR" comment="Allow images with VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT"/>
    <type name="VkImageSwapchainCreateInfoKHR"/>
    <type name="VkBindImageMemorySwapchainInfoKHR"/>
    <type name="VkAcquireNextImageInfoKHR"/>
    <type name="VkDeviceGroupPresentModeFlagBitsKHR"/>
    <type name="VkDeviceGroupPresentModeFlagsKHR"/>
    <type name="VkDeviceGroupPresentCapabilitiesKHR"/>
    <type name="VkDeviceGroupPresentInfoKHR"/>
    <type name="VkDeviceGroupSwapchainCreateInfoKHR"/>
    <command name="vkGetDeviceGroupPresentCapabilitiesKHR"/>
    <command name="vkGetDeviceGroupSurfacePresentModesKHR"/>
    <command name="vkGetPhysicalDevicePresentRectanglesKHR"/>
    <command name="vkAcquireNextImage2KHR"/>
    <enum bitpos="1" extends="VkSwapchainCreateFlagBitsKHR" name="VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR" comment="Swapchain is protected"/>
</require><require extension="VK_KHR_surface">
    <enum offset="7" extends="VkStructureType" name="VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR"/>
    <type name="VkDeviceGroupPresentModeFlagBitsKHR"/>
    <type name="VkDeviceGroupPresentModeFlagsKHR"/>
    <type name="VkDeviceGroupPresentCapabilitiesKHR"/>
    <command name="vkGetDeviceGroupPresentCapabilitiesKHR"/>
    <command name="vkGetDeviceGroupSurfacePresentModesKHR"/>
    <command name="vkGetPhysicalDevicePresentRectanglesKHR"/>
</require><require extension="VK_KHR_swapchain">
    <enum offset="8" extends="VkStructureType" name="VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR"/>
    <enum offset="9" extends="VkStructureType" name="VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR"/>
    <enum offset="10" extends="VkStructureType" name="VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR"/>
    <enum offset="11" extends="VkStructureType" name="VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR"/>
    <enum offset="12" extends="VkStructureType" name="VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR"/>
    <enum bitpos="0" extends="VkSwapchainCreateFlagBitsKHR" name="VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR" comment="Allow images with VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT"/>
    <type name="VkImageSwapchainCreateInfoKHR"/>
    <type name="VkBindImageMemorySwapchainInfoKHR"/>
    <type name="VkAcquireNextImageInfoKHR"/>
    <type name="VkDeviceGroupPresentInfoKHR"/>
    <type name="VkDeviceGroupSwapchainCreateInfoKHR"/>
    <command name="vkAcquireNextImage2KHR"/>
</require><require feature="VK_VERSION_1_1">
    <command name="vkCmdPushDescriptorSetWithTemplateKHR"/>
    <enum value="1" extends="VkDescriptorUpdateTemplateType" name="VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR" comment="Create descriptor update template for pushed descriptor updates"/>
</require><require extension="VK_KHR_descriptor_update_template">
    <command name="vkCmdPushDescriptorSetWithTemplateKHR"/>
    <enum value="1" extends="VkDescriptorUpdateTemplateType" name="VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR" comment="Create descriptor update template for pushed descriptor updates"/>
</require><require extension="VK_KHR_push_descriptor">
    <command name="vkCmdPushDescriptorSetWithTemplateKHR"/>
    <enum value="1" extends="VkDescriptorUpdateTemplateType" name="VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR" comment="Create descriptor update template for pushed descriptor updates"/>
</require><require extension="VK_KHR_device_group">
    <command name="vkGetDeviceGroupSurfacePresentModes2EXT"/>
</require><require feature="VK_VERSION_1_1">
    <command name="vkGetDeviceGroupSurfacePresentModes2EXT"/>
</require><require extension="VK_AMD_buffer_marker">
    <command name="vkCmdWriteBufferMarker2AMD"/>
</require><require extension="VK_NV_device_diagnostic_checkpoints">
    <type name="VkQueueFamilyCheckpointProperties2NV"/>
    <type name="VkCheckpointData2NV"/>
    <command name="vkGetQueueCheckpointData2NV"/>
    <enum offset="8" extends="VkStructureType" name="VK_STRUCTURE_TYPE_QUEUE_FAMILY_CHECKPOINT_PROPERTIES_2_NV"/>
    <enum offset="9" extends="VkStructureType" name="VK_STRUCTURE_TYPE_CHECKPOINT_DATA_2_NV"/>
</require>
@MarijnS95
Copy link
Collaborator Author

MarijnS95 commented Mar 28, 2023

Fwiw extension= and feature= attributes on <require> have been renamed to depends=, with a predefined AND and OR syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant