11#!/usr/bin/python3
22#
3- # Copyright (c) 2019-2022 Valve Corporation
4- # Copyright (c) 2019-2022 LunarG, Inc.
3+ # Copyright (c) 2019-2026 Valve Corporation
4+ # Copyright (c) 2019-2026 LunarG, Inc.
55# Copyright (c) 2019-2022 Google Inc.
66# Copyright (c) 2023-2024 RasterGrid Kft.
77#
2525
2626LICENSE_HEADER = '''
2727/*
28- * Copyright (c) 2019-2022 The Khronos Group Inc.
29- * Copyright (c) 2019-2022 Valve Corporation
30- * Copyright (c) 2019-2022 LunarG, Inc.
28+ * Copyright (c) 2019-2026 The Khronos Group Inc.
29+ * Copyright (c) 2019-2026 Valve Corporation
30+ * Copyright (c) 2019-2026 LunarG, Inc.
3131 * Copyright (c) 2023-2024 RasterGrid Kft.
3232 *
3333 * Licensed under the Apache License, Version 2.0 (the "License");
7777 'VkSurfaceCapabilitiesKHR' , 'VkSurfaceFormatKHR' , 'VkLayerProperties' , 'VkPhysicalDeviceToolProperties' , 'VkFormatProperties' ,
7878 'VkSurfacePresentScalingCapabilitiesKHR' , 'VkSurfacePresentModeCompatibilityKHR' , 'VkPhysicalDeviceHostImageCopyProperties' ,
7979 'VkVideoProfileInfoKHR' , 'VkVideoCapabilitiesKHR' , 'VkVideoFormatPropertiesKHR' , 'VkCooperativeMatrixPropertiesKHR' ,
80- 'VkPhysicalDeviceFragmentShadingRateKHR' , 'VkMultisamplePropertiesEXT' ]
80+ 'VkPhysicalDeviceFragmentShadingRateKHR' , 'VkMultisamplePropertiesEXT' ,
81+ 'VkDisplayPropertiesKHR' , 'VkDisplayPlanePropertiesKHR' , 'VkDisplayPlaneCapabilitiesKHR' , 'VkDisplayModePropertiesKHR' ,
82+ 'VkDisplayModeParametersKHR' ]
83+
8184ENUMS_TO_GEN = ['VkResult' , 'VkFormat' , 'VkPresentModeKHR' ,
8285 'VkPhysicalDeviceType' , 'VkImageTiling' , 'VkTimeDomainKHR' ]
8386FLAGS_TO_GEN = ['VkSurfaceTransformFlagsKHR' , 'VkCompositeAlphaFlagsKHR' , 'VkSurfaceCounterFlagsEXT' , 'VkQueueFlags' ,
8487 'VkDeviceGroupPresentModeFlagsKHR' , 'VkFormatFeatureFlags' , 'VkFormatFeatureFlags2' , 'VkMemoryPropertyFlags' , 'VkMemoryHeapFlags' ]
8588FLAG_STRINGS_TO_GEN = ['VkQueueFlags' ]
8689
87- STRUCT_SHORT_VERSIONS_TO_GEN = ['VkExtent3D' ]
90+ STRUCT_SHORT_VERSIONS_TO_GEN = ['VkExtent3D' , 'VkExtent2D' ]
8891
8992STRUCT_COMPARISONS_TO_GEN = ['VkSurfaceFormatKHR' , 'VkSurfaceFormat2KHR' , 'VkSurfaceCapabilitiesKHR' ,
9093 'VkSurfaceCapabilities2KHR' , 'VkSurfaceCapabilities2EXT' ]
100103PREDEFINED_TYPES = ['char' , 'VkBool32' , 'uint32_t' , 'uint8_t' , 'int32_t' ,
101104 'float' , 'uint64_t' , 'size_t' , 'VkDeviceSize' , 'int64_t' ]
102105
103- NAMES_TO_IGNORE = ['sType' , 'pNext' ]
106+ NAMES_TO_IGNORE = ['sType' , 'pNext' , 'displayMode' , 'display' , 'currentDisplay' ]
104107
105108EXTENSION_TYPE_INSTANCE = 'instance'
106109EXTENSION_TYPE_DEVICE = 'device'
@@ -229,9 +232,11 @@ def generate(self):
229232
230233 if bitmask .flagName in FLAG_STRINGS_TO_GEN :
231234 out .extend (self .PrintBitMaskToString (bitmask , bitmask .flagName ))
232-
235+ # make sure dump functions for nested structures are declared before use
236+ for s in (x for x in types_to_gen if x in self .vk .structs and x not in STRUCT_BLACKLIST ):
237+ out .extend (self .PrintStructure (self .vk .structs [s ], True ))
233238 for s in (x for x in types_to_gen if x in self .vk .structs and x not in STRUCT_BLACKLIST ):
234- out .extend (self .PrintStructure (self .vk .structs [s ]))
239+ out .extend (self .PrintStructure (self .vk .structs [s ], False ))
235240
236241 for key , value in EXTENSION_CATEGORIES .items ():
237242 out .extend (self .PrintChainStruct (key , extension_types [key ], value ))
@@ -782,7 +787,7 @@ def PrintBitMaskToString(self, bitmask, name):
782787 return out
783788
784789
785- def PrintStructure (self ,struct ):
790+ def PrintStructure (self ,struct , declare_only ):
786791 if len (struct .members ) == 0 :
787792 return []
788793 out = []
@@ -791,8 +796,12 @@ def PrintStructure(self,struct):
791796 for v in struct .members :
792797 if (v .type in PREDEFINED_TYPES or v .type in STRUCT_BLACKLIST ) and (v .length is None or v .type in ['char' ] or v .fixedSizeArray [0 ] in ['VK_UUID_SIZE' , 'VK_LUID_SIZE' ]):
793798 max_key_len = max (max_key_len , len (v .name ))
794-
795- out .append (f'void Dump{ struct .name } (Printer &p, std::string name, const { struct .name } &obj) {{\n ' )
799+ out .append (f'void Dump{ struct .name } (Printer &p, std::string name, const { struct .name } &obj)' )
800+ if declare_only :
801+ out .append (';\n ' )
802+ out .append (self .AddGuardFooter (struct ))
803+ return out
804+ out .append (' {\n ' )
796805 if struct .name == 'VkPhysicalDeviceLimits' :
797806 out .append (' if (p.Type() == OutputType::json)\n ' )
798807 out .append (' p.ObjectStart("limits");\n ' )
0 commit comments