diff options
| author | Charles Giessen <charles@lunarg.com> | 2024-06-17 14:48:29 -0500 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2024-08-21 12:10:17 -0600 |
| commit | 40294f25aa4522fe309504aaf30c1c259e11b75b (patch) | |
| tree | f3d958977bec7b24cd21eacf325ff3baba716aa4 /scripts | |
| parent | f993f9722589d339a2e2766332b4d591157b5ade (diff) | |
| download | usermoji-40294f25aa4522fe309504aaf30c1c259e11b75b.tar.xz | |
vulkaninfo: Add --show-promoted-structs option
This option restores behavior that prints out structures which have
been promoted to core vulkan and their members combined into the
VkPhysicalDeviceVulkanXXX structs.
For example, VkPhysicalDeviceVulkan12Features contains all of the features
that VkPhysicalDeviceVulkanMemoryModelFeatures does, so only the former
needs to be output. However, some users will want both structs present
regardless and the --show-promoted-structs option allows that behavior.
This commit also removes redundant checks when iterating the pNext chains
while printing, as those same checks occur when the chain is being created,
removing duplicate code-gen and runtime checks.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/vulkaninfo_generator.py | 82 |
1 files changed, 34 insertions, 48 deletions
diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py index b5c5f662..46125f98 100644 --- a/scripts/vulkaninfo_generator.py +++ b/scripts/vulkaninfo_generator.py @@ -114,35 +114,39 @@ EXTENSION_CATEGORIES = OrderedDict(( {'extends': 'VkPhysicalDeviceProperties2', 'type': EXTENSION_TYPE_BOTH, 'holder_type': 'VkPhysicalDeviceProperties2', - 'print_iterator': True}), + 'print_iterator': True, + 'can_show_promoted_structs': True}), ('phys_device_mem_props2', {'extends': 'VkPhysicalDeviceMemoryProperties2', - 'type': EXTENSION_TYPE_DEVICE, - 'holder_type':'VkPhysicalDeviceMemoryProperties2', - 'print_iterator': False}), + 'type': EXTENSION_TYPE_DEVICE, + 'holder_type':'VkPhysicalDeviceMemoryProperties2', + 'print_iterator': False, + 'can_show_promoted_structs': False}), ('phys_device_features2', {'extends': 'VkPhysicalDeviceFeatures2,VkDeviceCreateInfo', - 'type': EXTENSION_TYPE_DEVICE, - 'holder_type': 'VkPhysicalDeviceFeatures2', - 'print_iterator': True}), + 'type': EXTENSION_TYPE_DEVICE, + 'holder_type': 'VkPhysicalDeviceFeatures2', + 'print_iterator': True, + 'can_show_promoted_structs': True}), ('surface_capabilities2', {'extends': 'VkSurfaceCapabilities2KHR', - 'type': EXTENSION_TYPE_BOTH, - 'holder_type': 'VkSurfaceCapabilities2KHR', - 'print_iterator': True, - 'exclude': [# VK_EXT_surface_maintenance1 is difficult to code-gen - 'VkSurfacePresentScalingCapabilitiesEXT', 'VkSurfacePresentModeCompatibilityEXT' - ]}), + 'type': EXTENSION_TYPE_BOTH, + 'holder_type': 'VkSurfaceCapabilities2KHR', + 'print_iterator': True, + 'can_show_promoted_structs': False, + 'exclude': ['VkSurfacePresentScalingCapabilitiesEXT', 'VkSurfacePresentModeCompatibilityEXT']}), ('format_properties2', {'extends': 'VkFormatProperties2', - 'type': EXTENSION_TYPE_DEVICE, - 'holder_type':'VkFormatProperties2', - 'print_iterator': True}), + 'type': EXTENSION_TYPE_DEVICE, + 'holder_type':'VkFormatProperties2', + 'print_iterator': True, + 'can_show_promoted_structs': False}), ('queue_properties2', {'extends': 'VkQueueFamilyProperties2', - 'type': EXTENSION_TYPE_DEVICE, - 'holder_type': 'VkQueueFamilyProperties2', - 'print_iterator': True}) + 'type': EXTENSION_TYPE_DEVICE, + 'holder_type': 'VkQueueFamilyProperties2', + 'print_iterator': True, + 'can_show_promoted_structs': False}) )) class VulkanInfoGeneratorOptions(GeneratorOptions): def __init__(self, @@ -752,6 +756,8 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp out += 'AppInstance &inst, ' if chain_details.get('type') in [EXTENSION_TYPE_DEVICE, EXTENSION_TYPE_BOTH]: out += 'AppGpu &gpu ' + if chain_details.get('can_show_promoted_structs'): + out += ', bool show_promoted_structs' out += ') noexcept {\n' for s in structs_to_print: if s.name in STRUCT_BLACKLIST: @@ -801,12 +807,13 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp else: assert False, 'Should never get here' if has_version: + str_show_promoted_structs = '|| show_promoted_structs' if chain_details.get('can_show_promoted_structs') else '' if s.name in STRUCT_1_1_LIST: - out += f'{version_desc} == {version.constant}' + out += f'{version_desc} == {version.constant} {str_show_promoted_structs}' elif has_printed_condition: - out += f')\n && {version_desc} < {version.constant}' + out += f')\n && ({version_desc} < {version.constant} {str_show_promoted_structs})' else: - out += f'{version_desc} >= {version.constant}' + out += f'({version_desc} >= {version.constant})' out += ')\n ' else: out += ' ' @@ -820,6 +827,9 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp if chain_details.get('type') in [EXTENSION_TYPE_DEVICE, EXTENSION_TYPE_BOTH]: chain_param_list.append('AppGpu &gpu') chain_arg_list.append('gpu') + if chain_details.get('can_show_promoted_structs'): + chain_param_list.append('bool show_promoted_structs') + chain_arg_list.append('show_promoted_structs') out += f''' if (!chain_members.empty()) {{ @@ -843,6 +853,8 @@ void setup_{listName}_chain({chain_details['holder_type']}& start, std::unique_p out += 'AppInstance &inst, ' if chain_details.get('type') in [EXTENSION_TYPE_DEVICE, EXTENSION_TYPE_BOTH]: out += 'AppGpu &gpu, ' + if chain_details.get('can_show_promoted_structs'): + out += 'bool show_promoted_structs, ' out += 'void * place) {\n' out += ' while (place) {\n' out += ' struct VkBaseOutStructure *structure = (struct VkBaseOutStructure *)place;\n' @@ -874,32 +886,6 @@ void setup_{listName}_chain({chain_details['holder_type']}& start, std::unique_p out += ' && p.Type() != OutputType::json' has_version = version is not None has_extNameStr = len(extEnables) > 0 or s.name in aliases.keys() - - if has_version or has_extNameStr: - out += ' &&\n (' - has_printed_condition = False - if has_extNameStr: - for key, value in extEnables.items(): - if has_printed_condition: - out += ' || ' - else: - has_printed_condition = True - if has_version: - out += '(' - if value == EXTENSION_TYPE_DEVICE: - out += f'gpu.CheckPhysicalDeviceExtensionIncluded({key})' - elif value == EXTENSION_TYPE_INSTANCE: - out += f'inst.CheckExtensionEnabled({key})' - else: - assert False, 'Should never get here' - if has_version: - if s.name in STRUCT_1_1_LIST: - out += f'{version_desc} == {version.constant}' - elif has_printed_condition: - out += f') &&\n {version_desc} < {version.constant}' - else: - out += f'{version_desc} >= {version.constant}' - out += ')' out += ') {\n' out += f' {s.name}* props = ({s.name}*)structure;\n' out += f' Dump{s.name}(p, ' |
