diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py index abb9de91c..b5c5f6626 100644 --- a/scripts/vulkaninfo_generator.py +++ b/scripts/vulkaninfo_generator.py @@ -114,8 +114,7 @@ {'extends': 'VkPhysicalDeviceProperties2', 'type': EXTENSION_TYPE_BOTH, 'holder_type': 'VkPhysicalDeviceProperties2', - 'print_iterator': True, - 'exclude': ['VkPhysicalDeviceHostImageCopyPropertiesEXT', 'VkPhysicalDeviceLayeredApiPropertiesListKHR']}), + 'print_iterator': True}), ('phys_device_mem_props2', {'extends': 'VkPhysicalDeviceMemoryProperties2', 'type': EXTENSION_TYPE_DEVICE, @@ -131,7 +130,9 @@ 'type': EXTENSION_TYPE_BOTH, 'holder_type': 'VkSurfaceCapabilities2KHR', 'print_iterator': True, - 'exclude': ['VkSurfacePresentScalingCapabilitiesEXT', 'VkSurfacePresentModeCompatibilityEXT']}), + 'exclude': [# VK_EXT_surface_maintenance1 is difficult to code-gen + 'VkSurfacePresentScalingCapabilitiesEXT', 'VkSurfacePresentModeCompatibilityEXT' + ]}), ('format_properties2', {'extends': 'VkFormatProperties2', 'type': EXTENSION_TYPE_DEVICE, @@ -318,7 +319,7 @@ def endFile(self): out += PrintBitMaskToString(bitmask, flag.name, self) for s in (x for x in self.all_structures if x.name in types_to_gen and x.name not in STRUCT_BLACKLIST): - out += PrintStructure(s, types_to_gen) + out += PrintStructure(s) for key, value in EXTENSION_CATEGORIES.items(): out += PrintChainStruct(key, self.extension_sets[key], self.all_structures, value, self.extTypes, self.aliases, self.vulkan_versions) @@ -600,7 +601,7 @@ def PrintBitMaskToString(bitmask, name, generator): return out -def PrintStructure(struct, types_to_gen): +def PrintStructure(struct): if len(struct.members) == 0: return '' out = '' @@ -655,21 +656,12 @@ def PrintStructure(struct, types_to_gen): out += f' for (uint32_t i = 0; i < {v.arrayLength}; i++) {{ p.PrintElement(obj.{v.name}[i]); }}\n' out += ' }\n' else: # dynamic array length based on other member - out += f' if (obj.{v.arrayLength} == 0) {{\n' + out += f' if (obj.{v.arrayLength} == 0 || obj.{v.name} == nullptr) {{\n' out += f' p.PrintKeyString("{v.name}", "NULL");\n' out += ' } else {\n' out += f' ArrayWrapper arr(p,"{v.name}", obj.{v.arrayLength});\n' out += f' for (uint32_t i = 0; i < obj.{v.arrayLength}; i++) {{\n' - if v.typeID in types_to_gen: - out += f' if (obj.{v.name} != nullptr) {{\n' - out += ' p.SetElementIndex(i);\n' - out += ' if (p.Type() == OutputType::json)\n' - out += f' p.PrintString(std::string("VK_") + {v.typeID}String(obj.{v.name}[i]));\n' - out += ' else\n' - out += f' p.PrintString({v.typeID}String(obj.{v.name}[i]));\n' - out += ' }\n' - else: - out += f' p.PrintElement(obj.{v.name}[i]);\n' + out += f' Dump{v.typeID}(p, std::to_string(i), obj.{v.name}[i]);\n' out += ' }\n' out += ' }\n' elif v.typeID == 'VkBool32': @@ -750,6 +742,10 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp # members which don't exist. if s.name in ['VkPhysicalDeviceShaderIntegerDotProductFeatures', 'VkPhysicalDeviceHostImageCopyFeaturesEXT']: out += f' char {s.name}_padding[64];\n' + if s.hasLengthmember: + for member in s.members: + if member.lengthMember: + out += f' std::vector<{member.typeID}> {s.name}_{member.name};\n' out += AddGuardFooter(s) out += ' void initialize_chain(' if chain_details.get('type') in [EXTENSION_TYPE_INSTANCE, EXTENSION_TYPE_BOTH]: @@ -919,6 +915,32 @@ def PrintChainStruct(listName, structures, all_structures, chain_details, extTyp out += ' }\n' out += '}\n' + should_print_twocall_func = False + for s in structs_to_print: + if not s.hasLengthmember: + continue + if s.name in STRUCT_BLACKLIST: + continue + should_print_twocall_func = True + + if not should_print_twocall_func: + return out + + out += '\n' + out += f'void prepare_{listName}_twocall_chain_vectors(std::unique_ptr<{listName}_chain>& chain) {{\n' + for s in structs_to_print: + if not s.hasLengthmember: + continue + if s.name in STRUCT_BLACKLIST: + continue + out += AddGuardHeader(s) + for member in s.members: + if member.lengthMember: + out += f' chain->{s.name}_{member.name}.resize(chain->{s.name[2:]}.{member.arrayLength});\n' + out += f' chain->{s.name[2:]}.{member.name} = chain->{s.name}_{member.name}.data();\n' + out += AddGuardFooter(s) + out += '}\n' + return out @@ -1112,12 +1134,18 @@ def __init__(self, name, rootNode, constants, extTypes): self.guard = None self.sTypeName = None self.extendsStruct = rootNode.get('structextends') + self.hasLengthmember = False for node in rootNode.findall('member'): if node.get('values') is not None: self.sTypeName = node.get('values') self.members.append(VulkanVariable(node, constants)) + for member in self.members: + if member.lengthMember: + self.hasLengthmember = True + break + for k, elem in extTypes.items(): if k == self.name: for e in elem: diff --git a/vulkaninfo/generated/vulkaninfo.hpp b/vulkaninfo/generated/vulkaninfo.hpp index d67d84f50..f0cc2f2d3 100644 --- a/vulkaninfo/generated/vulkaninfo.hpp +++ b/vulkaninfo/generated/vulkaninfo.hpp @@ -425,6 +425,22 @@ void DumpVkImageTiling(Printer &p, std::string name, VkImageTiling value) { else p.PrintKeyString(name, VkImageTilingString(value)); } +std::string VkPhysicalDeviceLayeredApiKHRString(VkPhysicalDeviceLayeredApiKHR value) { + switch (value) { + case (VK_PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR): return "PHYSICAL_DEVICE_LAYERED_API_VULKAN_KHR"; + case (VK_PHYSICAL_DEVICE_LAYERED_API_D3D12_KHR): return "PHYSICAL_DEVICE_LAYERED_API_D3D12_KHR"; + case (VK_PHYSICAL_DEVICE_LAYERED_API_METAL_KHR): return "PHYSICAL_DEVICE_LAYERED_API_METAL_KHR"; + case (VK_PHYSICAL_DEVICE_LAYERED_API_OPENGL_KHR): return "PHYSICAL_DEVICE_LAYERED_API_OPENGL_KHR"; + case (VK_PHYSICAL_DEVICE_LAYERED_API_OPENGLES_KHR): return "PHYSICAL_DEVICE_LAYERED_API_OPENGLES_KHR"; + default: return std::string("UNKNOWN_VkPhysicalDeviceLayeredApiKHR_value") + std::to_string(value); + } +} +void DumpVkPhysicalDeviceLayeredApiKHR(Printer &p, std::string name, VkPhysicalDeviceLayeredApiKHR value) { + if (p.Type() == OutputType::json) + p.PrintKeyString(name, std::string("VK_") + VkPhysicalDeviceLayeredApiKHRString(value)); + else + p.PrintKeyString(name, VkPhysicalDeviceLayeredApiKHRString(value)); +} std::string VkPhysicalDeviceTypeString(VkPhysicalDeviceType value) { switch (value) { case (VK_PHYSICAL_DEVICE_TYPE_OTHER): return "PHYSICAL_DEVICE_TYPE_OTHER"; @@ -1989,33 +2005,21 @@ void DumpVkPhysicalDeviceHostImageCopyPropertiesEXT(Printer &p, std::string name ObjectWrapper object{p, name}; p.SetMinKeyWidth(35); p.PrintKeyValue("copySrcLayoutCount", obj.copySrcLayoutCount); - if (obj.copySrcLayoutCount == 0) { + if (obj.copySrcLayoutCount == 0 || obj.pCopySrcLayouts == nullptr) { p.PrintKeyString("pCopySrcLayouts", "NULL"); } else { ArrayWrapper arr(p,"pCopySrcLayouts", obj.copySrcLayoutCount); for (uint32_t i = 0; i < obj.copySrcLayoutCount; i++) { - if (obj.pCopySrcLayouts != nullptr) { - p.SetElementIndex(i); - if (p.Type() == OutputType::json) - p.PrintString(std::string("VK_") + VkImageLayoutString(obj.pCopySrcLayouts[i])); - else - p.PrintString(VkImageLayoutString(obj.pCopySrcLayouts[i])); - } + DumpVkImageLayout(p, std::to_string(i), obj.pCopySrcLayouts[i]); } } p.PrintKeyValue("copyDstLayoutCount", obj.copyDstLayoutCount); - if (obj.copyDstLayoutCount == 0) { + if (obj.copyDstLayoutCount == 0 || obj.pCopyDstLayouts == nullptr) { p.PrintKeyString("pCopyDstLayouts", "NULL"); } else { ArrayWrapper arr(p,"pCopyDstLayouts", obj.copyDstLayoutCount); for (uint32_t i = 0; i < obj.copyDstLayoutCount; i++) { - if (obj.pCopyDstLayouts != nullptr) { - p.SetElementIndex(i); - if (p.Type() == OutputType::json) - p.PrintString(std::string("VK_") + VkImageLayoutString(obj.pCopyDstLayouts[i])); - else - p.PrintString(VkImageLayoutString(obj.pCopyDstLayouts[i])); - } + DumpVkImageLayout(p, std::to_string(i), obj.pCopyDstLayouts[i]); } } p.PrintKeyValue("optimalTilingLayoutUUID", obj.optimalTilingLayoutUUID); @@ -2093,6 +2097,27 @@ void DumpVkPhysicalDeviceInlineUniformBlockProperties(Printer &p, std::string na p.PrintKeyValue("maxDescriptorSetInlineUniformBlocks", obj.maxDescriptorSetInlineUniformBlocks); p.PrintKeyValue("maxDescriptorSetUpdateAfterBindInlineUniformBlocks", obj.maxDescriptorSetUpdateAfterBindInlineUniformBlocks); } +void DumpVkPhysicalDeviceLayeredApiPropertiesKHR(Printer &p, std::string name, const VkPhysicalDeviceLayeredApiPropertiesKHR &obj) { + ObjectWrapper object{p, name}; + p.SetMinKeyWidth(15); + p.PrintKeyValue("vendorID", obj.vendorID); + p.PrintKeyValue("deviceID", obj.deviceID); + DumpVkPhysicalDeviceLayeredApiKHR(p, "layeredAPI", obj.layeredAPI); + p.PrintKeyString("deviceName", obj.deviceName); +} +void DumpVkPhysicalDeviceLayeredApiPropertiesListKHR(Printer &p, std::string name, const VkPhysicalDeviceLayeredApiPropertiesListKHR &obj) { + ObjectWrapper object{p, name}; + p.SetMinKeyWidth(29); + p.PrintKeyValue("layeredApiCount", obj.layeredApiCount); + if (obj.layeredApiCount == 0 || obj.pLayeredApis == nullptr) { + p.PrintKeyString("pLayeredApis", "NULL"); + } else { + ArrayWrapper arr(p,"pLayeredApis", obj.layeredApiCount); + for (uint32_t i = 0; i < obj.layeredApiCount; i++) { + DumpVkPhysicalDeviceLayeredApiPropertiesKHR(p, std::to_string(i), obj.pLayeredApis[i]); + } + } +} void DumpVkPhysicalDeviceLegacyDitheringFeaturesEXT(Printer &p, std::string name, const VkPhysicalDeviceLegacyDitheringFeaturesEXT &obj) { ObjectWrapper object{p, name}; p.SetMinKeyWidth(15); @@ -3341,18 +3366,12 @@ void DumpVkSurfacePresentModeCompatibilityEXT(Printer &p, std::string name, cons ObjectWrapper object{p, name}; p.SetMinKeyWidth(31); p.PrintKeyValue("presentModeCount", obj.presentModeCount); - if (obj.presentModeCount == 0) { + if (obj.presentModeCount == 0 || obj.pPresentModes == nullptr) { p.PrintKeyString("pPresentModes", "NULL"); } else { ArrayWrapper arr(p,"pPresentModes", obj.presentModeCount); for (uint32_t i = 0; i < obj.presentModeCount; i++) { - if (obj.pPresentModes != nullptr) { - p.SetElementIndex(i); - if (p.Type() == OutputType::json) - p.PrintString(std::string("VK_") + VkPresentModeKHRString(obj.pPresentModes[i])); - else - p.PrintString(VkPresentModeKHRString(obj.pPresentModes[i])); - } + DumpVkPresentModeKHR(p, std::to_string(i), obj.pPresentModes[i]); } } } @@ -3396,8 +3415,13 @@ struct phys_device_props2_chain { VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR PhysicalDeviceFragmentShaderBarycentricPropertiesKHR{}; VkPhysicalDeviceFragmentShadingRatePropertiesKHR PhysicalDeviceFragmentShadingRatePropertiesKHR{}; VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT PhysicalDeviceGraphicsPipelineLibraryPropertiesEXT{}; + VkPhysicalDeviceHostImageCopyPropertiesEXT PhysicalDeviceHostImageCopyPropertiesEXT{}; + std::vector VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopySrcLayouts; + std::vector VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopyDstLayouts; VkPhysicalDeviceIDProperties PhysicalDeviceIDProperties{}; VkPhysicalDeviceInlineUniformBlockProperties PhysicalDeviceInlineUniformBlockProperties{}; + VkPhysicalDeviceLayeredApiPropertiesListKHR PhysicalDeviceLayeredApiPropertiesListKHR{}; + std::vector VkPhysicalDeviceLayeredApiPropertiesListKHR_pLayeredApis; VkPhysicalDeviceLegacyVertexAttributesPropertiesEXT PhysicalDeviceLegacyVertexAttributesPropertiesEXT{}; VkPhysicalDeviceLineRasterizationPropertiesKHR PhysicalDeviceLineRasterizationPropertiesKHR{}; VkPhysicalDeviceMaintenance3Properties PhysicalDeviceMaintenance3Properties{}; @@ -3460,8 +3484,10 @@ struct phys_device_props2_chain { PhysicalDeviceFragmentShaderBarycentricPropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_PROPERTIES_KHR; PhysicalDeviceFragmentShadingRatePropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR; PhysicalDeviceGraphicsPipelineLibraryPropertiesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT; + PhysicalDeviceHostImageCopyPropertiesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT; PhysicalDeviceIDProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES; PhysicalDeviceInlineUniformBlockProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES; + PhysicalDeviceLayeredApiPropertiesListKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LAYERED_API_PROPERTIES_LIST_KHR; PhysicalDeviceLegacyVertexAttributesPropertiesEXT.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_VERTEX_ATTRIBUTES_PROPERTIES_EXT; PhysicalDeviceLineRasterizationPropertiesKHR.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_KHR; PhysicalDeviceMaintenance3Properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES; @@ -3548,6 +3574,8 @@ struct phys_device_props2_chain { chain_members.push_back(reinterpret_cast(&PhysicalDeviceFragmentShadingRatePropertiesKHR)); if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME)) chain_members.push_back(reinterpret_cast(&PhysicalDeviceGraphicsPipelineLibraryPropertiesEXT)); + if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME)) + chain_members.push_back(reinterpret_cast(&PhysicalDeviceHostImageCopyPropertiesEXT)); if ((inst.CheckExtensionEnabled(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) || inst.CheckExtensionEnabled(VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME) || inst.CheckExtensionEnabled(VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME)) @@ -3556,6 +3584,8 @@ struct phys_device_props2_chain { if ((gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME)) && gpu.api_version < VK_API_VERSION_1_3) chain_members.push_back(reinterpret_cast(&PhysicalDeviceInlineUniformBlockProperties)); + if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_MAINTENANCE_7_EXTENSION_NAME)) + chain_members.push_back(reinterpret_cast(&PhysicalDeviceLayeredApiPropertiesListKHR)); if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_LEGACY_VERTEX_ATTRIBUTES_EXTENSION_NAME)) chain_members.push_back(reinterpret_cast(&PhysicalDeviceLegacyVertexAttributesPropertiesEXT)); if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME) @@ -3789,6 +3819,12 @@ void chain_iterator_phys_device_props2(Printer &p, AppInstance &inst, AppGpu &gp DumpVkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT(p, "VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT", *props); p.AddNewline(); } + if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT && + (gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME))) { + VkPhysicalDeviceHostImageCopyPropertiesEXT* props = (VkPhysicalDeviceHostImageCopyPropertiesEXT*)structure; + DumpVkPhysicalDeviceHostImageCopyPropertiesEXT(p, "VkPhysicalDeviceHostImageCopyPropertiesEXT", *props); + p.AddNewline(); + } if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES && ((inst.CheckExtensionEnabled(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME) || inst.CheckExtensionEnabled(VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME) || inst.CheckExtensionEnabled(VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME)) && gpu.api_version < VK_API_VERSION_1_1)) { @@ -3803,6 +3839,12 @@ void chain_iterator_phys_device_props2(Printer &p, AppInstance &inst, AppGpu &gp DumpVkPhysicalDeviceInlineUniformBlockProperties(p, gpu.api_version >= VK_API_VERSION_1_3 ?"VkPhysicalDeviceInlineUniformBlockProperties":"VkPhysicalDeviceInlineUniformBlockPropertiesEXT", *props); p.AddNewline(); } + if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LAYERED_API_PROPERTIES_LIST_KHR && + (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_MAINTENANCE_7_EXTENSION_NAME))) { + VkPhysicalDeviceLayeredApiPropertiesListKHR* props = (VkPhysicalDeviceLayeredApiPropertiesListKHR*)structure; + DumpVkPhysicalDeviceLayeredApiPropertiesListKHR(p, "VkPhysicalDeviceLayeredApiPropertiesListKHR", *props); + p.AddNewline(); + } if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_VERTEX_ATTRIBUTES_PROPERTIES_EXT && (gpu.CheckPhysicalDeviceExtensionIncluded(VK_EXT_LEGACY_VERTEX_ATTRIBUTES_EXTENSION_NAME))) { VkPhysicalDeviceLegacyVertexAttributesPropertiesEXT* props = (VkPhysicalDeviceLegacyVertexAttributesPropertiesEXT*)structure; @@ -4051,6 +4093,15 @@ void chain_iterator_phys_device_props2(Printer &p, AppInstance &inst, AppGpu &gp place = structure->pNext; } } + +void prepare_phys_device_props2_twocall_chain_vectors(std::unique_ptr& chain) { + chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopySrcLayouts.resize(chain->PhysicalDeviceHostImageCopyPropertiesEXT.copySrcLayoutCount); + chain->PhysicalDeviceHostImageCopyPropertiesEXT.pCopySrcLayouts = chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopySrcLayouts.data(); + chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopyDstLayouts.resize(chain->PhysicalDeviceHostImageCopyPropertiesEXT.copyDstLayoutCount); + chain->PhysicalDeviceHostImageCopyPropertiesEXT.pCopyDstLayouts = chain->VkPhysicalDeviceHostImageCopyPropertiesEXT_pCopyDstLayouts.data(); + chain->VkPhysicalDeviceLayeredApiPropertiesListKHR_pLayeredApis.resize(chain->PhysicalDeviceLayeredApiPropertiesListKHR.layeredApiCount); + chain->PhysicalDeviceLayeredApiPropertiesListKHR.pLayeredApis = chain->VkPhysicalDeviceLayeredApiPropertiesListKHR_pLayeredApis.data(); +} struct phys_device_mem_props2_chain { phys_device_mem_props2_chain() = default; phys_device_mem_props2_chain(const phys_device_mem_props2_chain &) = delete; diff --git a/vulkaninfo/outputprinter.h b/vulkaninfo/outputprinter.h index 687231807..d515b62d7 100644 --- a/vulkaninfo/outputprinter.h +++ b/vulkaninfo/outputprinter.h @@ -438,8 +438,7 @@ class Printer { } else { get_top().is_first_item = false; } - out << std::string(static_cast(get_top().indents), '\t') << "\"" << array_name << "\": " - << "[\n"; + out << std::string(static_cast(get_top().indents), '\t') << "\"" << array_name << "\": " << "[\n"; assert(get_top().is_array == false && "Cant start an array object inside another array, must be enclosed in an object"); break; @@ -471,6 +470,12 @@ class Printer { // value_description is for reference information and is displayed inside parenthesis after the value template void PrintKeyValue(std::string key, T value) { + // If we are inside of an array, Print the value as an element + if (get_top().is_array) { + PrintElement(value); + return; + } + switch (output_type) { case (OutputType::text): out << std::string(static_cast(get_top().indents), '\t') << key; @@ -568,6 +573,11 @@ class Printer { // print inside array template void PrintElement(T element) { + // If we are inside of an object, just use an empty string as the key + if (!get_top().is_array) { + PrintKeyValue("placeholder", element); + return; + } switch (output_type) { case (OutputType::text): out << std::string(static_cast(get_top().indents), '\t') << element << "\n"; diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index 648959446..a7cb852a5 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -93,7 +93,7 @@ void DumpLayers(Printer &p, std::vector layers, const std::v ObjectWrapper obj(p, header); DumpExtensions(p, "Layer Extensions", layer.extension_properties); - ArrayWrapper arr_devices(p, "Devices", gpus.size()); + ObjectWrapper arr_devices(p, "Devices", gpus.size()); for (auto &gpu : gpus) { p.SetValueDescription(std::string(gpu->props.deviceName)).PrintKeyValue("GPU id", gpu->id); auto exts = gpu->inst.AppGetPhysicalDeviceLayerExtensions(gpu->phys_device, props.layerName); @@ -351,28 +351,6 @@ void DumpGroups(Printer &p, AppInstance &inst) { } } -void GetAndDumpHostImageCopyPropertiesEXT(Printer &p, AppGpu &gpu) { - if (!gpu.CheckPhysicalDeviceExtensionIncluded("VK_EXT_host_image_copy")) { - return; - } - - // Manually implement VkPhysicalDeviceHostImageCopyPropertiesEXT due to it needing to be called twice - VkPhysicalDeviceHostImageCopyPropertiesEXT host_image_copy_properties_ext{}; - host_image_copy_properties_ext.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT; - VkPhysicalDeviceProperties2KHR props2{}; - props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; - props2.pNext = static_cast(&host_image_copy_properties_ext); - vkGetPhysicalDeviceProperties2KHR(gpu.phys_device, &props2); - std::vector src_layouts(host_image_copy_properties_ext.copySrcLayoutCount); - host_image_copy_properties_ext.pCopySrcLayouts = src_layouts.data(); - std::vector dst_layouts(host_image_copy_properties_ext.copyDstLayoutCount); - host_image_copy_properties_ext.pCopyDstLayouts = dst_layouts.data(); - vkGetPhysicalDeviceProperties2KHR(gpu.phys_device, &props2); - p.SetSubHeader(); - DumpVkPhysicalDeviceHostImageCopyPropertiesEXT(p, "VkPhysicalDeviceHostImageCopyPropertiesEXT", host_image_copy_properties_ext); - p.AddNewline(); -} - void GpuDumpProps(Printer &p, AppGpu &gpu) { auto props = gpu.GetDeviceProperties(); p.SetSubHeader(); @@ -401,7 +379,6 @@ void GpuDumpProps(Printer &p, AppGpu &gpu) { if (gpu.inst.CheckExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) { void *place = gpu.props2.pNext; chain_iterator_phys_device_props2(p, gpu.inst, gpu, place); - GetAndDumpHostImageCopyPropertiesEXT(p, gpu); } } @@ -942,21 +919,28 @@ const char *help_message_body = "[-o , --output ]\n" " Print output to a new file whose name is specified by filename.\n" " File will be written to the current working directory.\n" - "[--text] Produce a text version of " APP_SHORT_NAME " output to stdout. This is\n" + "[--text] Produce a text version of " APP_SHORT_NAME + " output to stdout. This is\n" " the default output.\n" - "[--html] Produce an html version of " APP_SHORT_NAME " output, saved as\n" - " \"" APP_SHORT_NAME ".html\" in the directory in which the command\n" + "[--html] Produce an html version of " APP_SHORT_NAME + " output, saved as\n" + " \"" APP_SHORT_NAME + ".html\" in the directory in which the command\n" " is run.\n" - "[-j, --json] Produce a json version of " APP_SHORT_NAME " output conforming to the Vulkan\n" + "[-j, --json] Produce a json version of " APP_SHORT_NAME + " output conforming to the Vulkan\n" " Profiles schema, saved as \n" - " \"VP_" APP_UPPER_CASE_NAME "_[DEVICE_NAME]_[DRIVER_VERSION].json\"\n" + " \"VP_" APP_UPPER_CASE_NAME + "_[DEVICE_NAME]_[DRIVER_VERSION].json\"\n" " of the first gpu in the system.\n" "[-j=, --json=]\n" " For a multi-gpu system, a single gpu can be targetted by\n" " specifying the gpu-number associated with the gpu of \n" " interest. This number can be determined by running\n" - " " APP_SHORT_NAME " without any options specified.\n" - "[--show-tool-props] Show the active VkPhysicalDeviceToolPropertiesEXT that " APP_SHORT_NAME " finds.\n" + " " APP_SHORT_NAME + " without any options specified.\n" + "[--show-tool-props] Show the active VkPhysicalDeviceToolPropertiesEXT that " APP_SHORT_NAME + " finds.\n" "[--show-formats] Display the format properties of each physical device.\n" " Note: This only affects text output.\n"; diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h index a3f356b1e..7abe10bd7 100644 --- a/vulkaninfo/vulkaninfo.h +++ b/vulkaninfo/vulkaninfo.h @@ -274,6 +274,8 @@ void setup_surface_capabilities2_chain(VkSurfaceCapabilities2KHR &start, std::un void setup_format_properties2_chain(VkFormatProperties2 &start, std::unique_ptr &chain, AppGpu &gpu); void setup_queue_properties2_chain(VkQueueFamilyProperties2 &start, std::unique_ptr &chain, AppGpu &gpu); +void prepare_phys_device_props2_twocall_chain_vectors(std::unique_ptr &chain); + /* An ptional contains either a value or nothing. The optional asserts if a value is trying to be gotten but none exist. * The interface is taken from C++17's with many aspects removed. * This class assumes the template type is 'trivial' @@ -1474,6 +1476,8 @@ struct AppGpu { props2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; setup_phys_device_props2_chain(props2, chain_for_phys_device_props2, inst, *this); + vkGetPhysicalDeviceProperties2KHR(phys_device, &props2); + prepare_phys_device_props2_twocall_chain_vectors(chain_for_phys_device_props2); vkGetPhysicalDeviceProperties2KHR(phys_device, &props2); // VkPhysicalDeviceMemoryProperties2