Skip to content

Commit

Permalink
vulkaninfo: Add --show-all-structs option
Browse files Browse the repository at this point in the history
This option restores behavior which will query all structs regardless of
whether they were promoted or replaced by another struct. 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-all-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.
  • Loading branch information
charles-lunarg committed Jun 17, 2024
1 parent 345af47 commit 974eb48
Show file tree
Hide file tree
Showing 4 changed files with 353 additions and 597 deletions.
80 changes: 34 additions & 46 deletions scripts/vulkaninfo_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,39 @@
'type': EXTENSION_TYPE_BOTH,
'holder_type': 'VkPhysicalDeviceProperties2',
'print_iterator': True,
'exclude': ['VkPhysicalDeviceHostImageCopyPropertiesEXT']}),
'can_show_all_structs': True,
'exclude': ['VkPhysicalDeviceHostImageCopyPropertiesEXT']}),
('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_all_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_all_structs': True}),
('surface_capabilities2',
{'extends': 'VkSurfaceCapabilities2KHR',
'type': EXTENSION_TYPE_BOTH,
'holder_type': 'VkSurfaceCapabilities2KHR',
'print_iterator': True,
'exclude': ['VkSurfacePresentScalingCapabilitiesEXT', 'VkSurfacePresentModeCompatibilityEXT']}),
'type': EXTENSION_TYPE_BOTH,
'holder_type': 'VkSurfaceCapabilities2KHR',
'print_iterator': True,
'can_show_all_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_all_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_all_structs': False})
))
class VulkanInfoGeneratorOptions(GeneratorOptions):
def __init__(self,
Expand Down Expand Up @@ -756,6 +762,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_all_structs'):
out += ', bool show_all_structs'
out += ') noexcept {\n'
for s in structs_to_print:
if s.name in STRUCT_BLACKLIST:
Expand Down Expand Up @@ -805,12 +813,13 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp
else:
assert False, 'Should never get here'
if has_version:
str_show_all_structs = '|| show_all_structs' if chain_details.get('can_show_all_structs') else ''
if s.name in STRUCT_1_1_LIST:
out += f'{version_desc} == {version.constant}'
out += f'{version_desc} == {version.constant} {str_show_all_structs}'
elif has_printed_condition:
out += f')\n && {version_desc} < {version.constant}'
out += f')\n && ({version_desc} < {version.constant} {str_show_all_structs})'
else:
out += f'{version_desc} >= {version.constant}'
out += f'({version_desc} >= {version.constant} {str_show_all_structs})'
out += ')\n '
else:
out += ' '
Expand All @@ -824,6 +833,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_all_structs'):
chain_param_list.append('bool show_all_structs')
chain_arg_list.append('show_all_structs')

out += f'''
if (!chain_members.empty()) {{
Expand All @@ -847,6 +859,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_all_structs'):
out += 'bool show_all_structs, '
out += 'void * place) {\n'
out += ' while (place) {\n'
out += ' struct VkBaseOutStructure *structure = (struct VkBaseOutStructure *)place;\n'
Expand Down Expand Up @@ -878,32 +892,6 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp
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, '
Expand Down
Loading

0 comments on commit 974eb48

Please sign in to comment.