diff options
| -rw-r--r-- | scripts/vulkaninfo_generator.py | 4 | ||||
| -rw-r--r-- | vulkaninfo/generated/vulkaninfo.hpp | 13 | ||||
| -rw-r--r-- | vulkaninfo/vulkaninfo.cpp | 95 | ||||
| -rw-r--r-- | vulkaninfo/vulkaninfo.h | 72 |
4 files changed, 109 insertions, 75 deletions
diff --git a/scripts/vulkaninfo_generator.py b/scripts/vulkaninfo_generator.py index a66d1d6a..37ca830b 100644 --- a/scripts/vulkaninfo_generator.py +++ b/scripts/vulkaninfo_generator.py @@ -81,7 +81,7 @@ std::string to_hex_str(Printer &p, const T i) { # used in the .cpp code structures_to_gen = ['VkExtent3D', 'VkExtent2D', 'VkPhysicalDeviceLimits', 'VkPhysicalDeviceFeatures', 'VkPhysicalDeviceSparseProperties', - 'VkSurfaceCapabilitiesKHR', 'VkSurfaceFormatKHR', 'VkLayerProperties', 'VkPhysicalDeviceToolProperties'] + 'VkSurfaceCapabilitiesKHR', 'VkSurfaceFormatKHR', 'VkLayerProperties', 'VkPhysicalDeviceToolProperties', 'VkFormatProperties'] enums_to_gen = ['VkResult', 'VkFormat', 'VkPresentModeKHR', 'VkPhysicalDeviceType', 'VkImageTiling'] flags_to_gen = ['VkSurfaceTransformFlagsKHR', 'VkCompositeAlphaFlagsKHR', 'VkSurfaceCounterFlagsEXT', 'VkQueueFlags', @@ -587,6 +587,8 @@ def PrintStructure(struct, types_to_gen, structure_names, aliases): out += f' p.PrintKeyValue("{v.name}", obj.{v.name});\n' elif v.name not in names_to_ignore: # if it is an enum/flag/bitmask + if v.typeID in ['VkFormatFeatureFlags', 'VkFormatFeatureFlags2']: + out += ' p.SetOpenDetails();\n' # special case so that feature flags are open in html output out += f' Dump{v.typeID}(p, "{v.name}", obj.{v.name});\n' if struct.name in ["VkPhysicalDeviceLimits", "VkPhysicalDeviceSparseProperties"]: diff --git a/vulkaninfo/generated/vulkaninfo.hpp b/vulkaninfo/generated/vulkaninfo.hpp index 6e509e0a..6993a13f 100644 --- a/vulkaninfo/generated/vulkaninfo.hpp +++ b/vulkaninfo/generated/vulkaninfo.hpp @@ -1334,6 +1334,7 @@ void DumpVkDrmFormatModifierProperties2EXT(Printer &p, std::string name, const V p.SetMinKeyWidth(27); p.PrintKeyValue("drmFormatModifier", obj.drmFormatModifier); p.PrintKeyValue("drmFormatModifierPlaneCount", obj.drmFormatModifierPlaneCount); + p.SetOpenDetails(); DumpVkFormatFeatureFlags2(p, "drmFormatModifierTilingFeatures", obj.drmFormatModifierTilingFeatures); } void DumpVkExtent2D(Printer &p, std::string name, const VkExtent2D &obj) { @@ -1349,10 +1350,22 @@ void DumpVkExtent3D(Printer &p, std::string name, const VkExtent3D &obj) { p.PrintKeyValue("height", obj.height); p.PrintKeyValue("depth", obj.depth); } +void DumpVkFormatProperties(Printer &p, std::string name, const VkFormatProperties &obj) { + ObjectWrapper object{p, name}; + p.SetOpenDetails(); + DumpVkFormatFeatureFlags(p, "linearTilingFeatures", obj.linearTilingFeatures); + p.SetOpenDetails(); + DumpVkFormatFeatureFlags(p, "optimalTilingFeatures", obj.optimalTilingFeatures); + p.SetOpenDetails(); + DumpVkFormatFeatureFlags(p, "bufferFeatures", obj.bufferFeatures); +} void DumpVkFormatProperties3(Printer &p, std::string name, const VkFormatProperties3 &obj) { ObjectWrapper object{p, name}; + p.SetOpenDetails(); DumpVkFormatFeatureFlags2(p, "linearTilingFeatures", obj.linearTilingFeatures); + p.SetOpenDetails(); DumpVkFormatFeatureFlags2(p, "optimalTilingFeatures", obj.optimalTilingFeatures); + p.SetOpenDetails(); DumpVkFormatFeatureFlags2(p, "bufferFeatures", obj.bufferFeatures); } void DumpVkLayerProperties(Printer &p, std::string name, const VkLayerProperties &obj) { diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index 0464daff..7119475b 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -472,34 +472,28 @@ void GpuDumpFeatures(Printer &p, AppGpu &gpu) { } } -void GpuDumpFormatProperty(Printer &p, VkFormat fmt, VkFormatProperties prop) { - std::string name{}; - switch (p.Type()) { - case OutputType::text: { - name = "Properties"; - break; - } - case OutputType::html: { - name = VkFormatString(fmt); - break; - } - case OutputType::json: { - name = "VkFormatProperties"; - break; - } - case OutputType::vkconfig_output: { - name = VkFormatString(fmt); - break; +void GpuDumpTextFormatProperty(Printer &p, const AppGpu &gpu, PropFlags formats, std::vector<VkFormat> format_list, + uint32_t counter) { + p.SetElementIndex(counter); + ObjectWrapper obj_common_group(p, "Common Format Group"); + IndentWrapper indent_inner(p); + { + ArrayWrapper arr_formats(p, "Formats", format_list.size()); + for (auto &fmt : format_list) { + p.SetAsType().PrintString(VkFormatString(fmt)); } } - p.SetTitleAsType(); - ObjectWrapper obj(p, name); - p.SetOpenDetails(); - DumpVkFormatFeatureFlags(p, "linearTilingFeatures", prop.linearTilingFeatures); - p.SetOpenDetails(); - DumpVkFormatFeatureFlags(p, "optimalTilingFeatures", prop.optimalTilingFeatures); - p.SetOpenDetails(); - DumpVkFormatFeatureFlags(p, "bufferFeatures", prop.bufferFeatures); + ObjectWrapper obj(p, "Properties"); + if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME)) { + DumpVkFormatFeatureFlags2(p, "linearTilingFeatures", formats.props3.linearTilingFeatures); + DumpVkFormatFeatureFlags2(p, "optimalTilingFeatures", formats.props3.optimalTilingFeatures); + DumpVkFormatFeatureFlags2(p, "bufferFeatures", formats.props3.bufferFeatures); + } else { + DumpVkFormatFeatureFlags(p, "linearTilingFeatures", formats.props.linearTilingFeatures); + DumpVkFormatFeatureFlags(p, "optimalTilingFeatures", formats.props.optimalTilingFeatures); + DumpVkFormatFeatureFlags(p, "bufferFeatures", formats.props.bufferFeatures); + } + p.AddNewline(); } void GpuDumpToolingInfo(Printer &p, AppGpu &gpu) { @@ -525,26 +519,14 @@ void GpuDevDump(Printer &p, AppGpu &gpu) { int counter = 0; std::vector<VkFormat> unsupported_formats; for (auto &prop : fmtPropMap) { - VkFormatProperties props; - props.linearTilingFeatures = prop.first.linear; - props.optimalTilingFeatures = prop.first.optimal; - props.bufferFeatures = prop.first.buffer; - if (props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0 && props.bufferFeatures == 0) { + VkFormatProperties props = prop.first.props; + VkFormatProperties3 props3 = prop.first.props3; + if (props.linearTilingFeatures == 0 && props.optimalTilingFeatures == 0 && props.bufferFeatures == 0 && + props3.linearTilingFeatures == 0 && props3.optimalTilingFeatures == 0 && props3.bufferFeatures == 0) { unsupported_formats = prop.second; continue; } - - p.SetElementIndex(counter++); - ObjectWrapper obj_common_group(p, "Common Format Group"); - IndentWrapper indent_inner(p); - { - ArrayWrapper arr_formats(p, "Formats", prop.second.size()); - for (auto &fmt : prop.second) { - p.SetAsType().PrintString(VkFormatString(fmt)); - } - } - GpuDumpFormatProperty(p, VK_FORMAT_UNDEFINED, props); - p.AddNewline(); + GpuDumpTextFormatProperty(p, gpu, prop.first, prop.second, counter++); } ArrayWrapper arr_unsupported_formats(p, "Unsupported Formats", unsupported_formats.size()); @@ -556,11 +538,13 @@ void GpuDevDump(Printer &p, AppGpu &gpu) { if (gpu.FormatRangeSupported(format)) { for (int32_t fmt_counter = format.first_format; fmt_counter <= format.last_format; ++fmt_counter) { VkFormat fmt = static_cast<VkFormat>(fmt_counter); - - VkFormatProperties props; - gpu.inst.dll.fp_vkGetPhysicalDeviceFormatProperties(gpu.phys_device, fmt, &props); - - GpuDumpFormatProperty(p, fmt, props); + auto formats = get_format_properties(gpu, fmt); + p.SetTitleAsType(); + if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME)) { + DumpVkFormatProperties3(p, VkFormatString(fmt), formats.props3); + } else { + DumpVkFormatProperties(p, VkFormatString(fmt), formats.props); + } } } } @@ -638,20 +622,21 @@ void DumpGpuProfileCapabilities(Printer &p, AppGpu &gpu) { if (gpu.FormatRangeSupported(format)) { for (int32_t fmt_counter = format.first_format; fmt_counter <= format.last_format; ++fmt_counter) { VkFormat fmt = static_cast<VkFormat>(fmt_counter); - - VkFormatProperties props; - gpu.inst.dll.fp_vkGetPhysicalDeviceFormatProperties(gpu.phys_device, fmt, &props); + auto formats = get_format_properties(gpu, fmt); // don't print format properties that are unsupported - if ((props.linearTilingFeatures || props.optimalTilingFeatures || props.bufferFeatures) == 0) continue; + if (formats.props.linearTilingFeatures == 0 && formats.props.optimalTilingFeatures == 0 && + formats.props.bufferFeatures == 0 && formats.props3.linearTilingFeatures == 0 && + formats.props3.optimalTilingFeatures == 0 && formats.props3.bufferFeatures == 0) + continue; ObjectWrapper format_obj(p, std::string("VK_") + VkFormatString(fmt)); { - GpuDumpFormatProperty(p, fmt, props); - + // Want to explicitly list VkFormatProperties in addition to VkFormatProperties3 if available + DumpVkFormatProperties(p, "VkFormatProperties", formats.props); VkFormatProperties2 format_props2{}; format_props2.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2; - format_props2.formatProperties = props; + format_props2.formatProperties = formats.props; std::unique_ptr<format_properties2_chain> chain_for_format_props2; setup_format_properties2_chain(format_props2, chain_for_format_props2); gpu.inst.ext_funcs.vkGetPhysicalDeviceFormatProperties2KHR(gpu.phys_device, fmt, &format_props2); diff --git a/vulkaninfo/vulkaninfo.h b/vulkaninfo/vulkaninfo.h index d75a3efb..8f3ea926 100644 --- a/vulkaninfo/vulkaninfo.h +++ b/vulkaninfo/vulkaninfo.h @@ -695,7 +695,7 @@ struct AppInstance { AppInstance(const AppInstance &) = delete; const AppInstance &operator=(const AppInstance &) = delete; - bool CheckExtensionEnabled(std::string extension_to_check) { + bool CheckExtensionEnabled(std::string extension_to_check) const { return std::any_of(inst_extensions.begin(), inst_extensions.end(), [extension_to_check](std::string str) { return str == extension_to_check; }); } @@ -1574,7 +1574,7 @@ struct AppGpu { } inst.ext_funcs.vkGetPhysicalDeviceQueueFamilyProperties2KHR(phys_device, &queue_prop2_count, queue_props2.data()); - if ((CheckPhysicalDeviceExtensionIncluded(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME) || api_version.minor >= 2)) { + if (CheckPhysicalDeviceExtensionIncluded(VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME) || api_version.minor >= 2) { void *place = props2.pNext; while (place) { VkBaseOutStructure *structure = static_cast<VkBaseOutStructure *>(place); @@ -1758,13 +1758,14 @@ struct AppGpu { AppGpu(const AppGpu &) = delete; const AppGpu &operator=(const AppGpu &) = delete; - bool CheckPhysicalDeviceExtensionIncluded(std::string extension_to_check) { - return std::any_of(device_extensions.begin(), device_extensions.end(), - [extension_to_check](VkExtensionProperties &prop) { return prop.extensionName == extension_to_check; }); + bool CheckPhysicalDeviceExtensionIncluded(std::string extension_to_check) const { + return std::any_of( + device_extensions.begin(), device_extensions.end(), + [extension_to_check](const VkExtensionProperties &prop) { return prop.extensionName == extension_to_check; }); } // Helper function to determine whether a format range is currently supported. - bool FormatRangeSupported(FormatRange &format_range) { + bool FormatRangeSupported(FormatRange &format_range) const { // True if standard and supported by both this instance and this GPU if (format_range.minimum_instance_version > 0 && inst.instance_version >= format_range.minimum_instance_version && props.apiVersion >= format_range.minimum_instance_version) { @@ -1816,23 +1817,60 @@ std::vector<VkPhysicalDeviceToolPropertiesEXT> GetToolingInfo(AppGpu &gpu) { } // --------- Format Properties ----------// +// can't use autogen because that is put in a header that we can't include because that header depends on stuff defined here +bool operator==(const VkFormatProperties &a, const VkFormatProperties b) { + return a.linearTilingFeatures == b.linearTilingFeatures && a.optimalTilingFeatures == b.optimalTilingFeatures && + a.bufferFeatures == b.bufferFeatures; +} +bool operator==(const VkFormatProperties3 &a, const VkFormatProperties3 b) { + return a.linearTilingFeatures == b.linearTilingFeatures && a.optimalTilingFeatures == b.optimalTilingFeatures && + a.bufferFeatures == b.bufferFeatures; +} struct PropFlags { - uint32_t linear; - uint32_t optimal; - uint32_t buffer; + VkFormatProperties props; + VkFormatProperties3 props3; - bool operator==(const PropFlags &other) const { - return (linear == other.linear && optimal == other.optimal && buffer == other.buffer); - } + bool operator==(const PropFlags &other) const { return props == other.props && props3 == other.props3; } }; +PropFlags get_format_properties(const AppGpu &gpu, VkFormat fmt) { + VkFormatProperties props; + gpu.inst.dll.fp_vkGetPhysicalDeviceFormatProperties(gpu.phys_device, fmt, &props); + + VkFormatProperties3 props3{}; + props3.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3; + + if (gpu.inst.CheckExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) && + gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME)) { + VkFormatProperties2 props2{}; + props2.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2; + props2.formatProperties = props; + props2.pNext = static_cast<void *>(&props3); + gpu.inst.ext_funcs.vkGetPhysicalDeviceFormatProperties2KHR(gpu.phys_device, fmt, &props2); + } + return {props, props3}; +} + namespace std { template <> +struct hash<VkFormatProperties> { + std::size_t operator()(const VkFormatProperties &k) const { + return ((std::hash<uint32_t>()(k.linearTilingFeatures) ^ (std::hash<uint32_t>()(k.optimalTilingFeatures) << 1)) >> 1) ^ + (std::hash<uint32_t>()(k.bufferFeatures) << 1); + } +}; +template <> +struct hash<VkFormatProperties3> { + std::size_t operator()(const VkFormatProperties3 &k) const { + return ((std::hash<uint64_t>()(k.linearTilingFeatures) ^ (std::hash<uint64_t>()(k.optimalTilingFeatures) << 1)) >> 1) ^ + (std::hash<uint64_t>()(k.bufferFeatures) << 1); + } +}; +template <> struct hash<PropFlags> { std::size_t operator()(const PropFlags &k) const { - return ((std::hash<uint32_t>()(k.linear) ^ (std::hash<uint32_t>()(k.optimal) << 1)) >> 1) ^ - (std::hash<uint32_t>()(k.buffer) << 1); + return (std::hash<VkFormatProperties>()(k.props) ^ std::hash<VkFormatProperties3>()(k.props3)) >> 1; } }; } // namespace std @@ -1842,11 +1880,7 @@ std::unordered_map<PropFlags, std::vector<VkFormat>> FormatPropMap(AppGpu &gpu) std::unordered_map<PropFlags, std::vector<VkFormat>> map; for (auto fmtRange : gpu.supported_format_ranges) { for (int32_t fmt = fmtRange.first_format; fmt <= fmtRange.last_format; ++fmt) { - VkFormatProperties props; - gpu.inst.dll.fp_vkGetPhysicalDeviceFormatProperties(gpu.phys_device, static_cast<VkFormat>(fmt), &props); - - PropFlags pf = {props.linearTilingFeatures, props.optimalTilingFeatures, props.bufferFeatures}; - + PropFlags pf = get_format_properties(gpu, static_cast<VkFormat>(fmt)); map[pf].push_back(static_cast<VkFormat>(fmt)); } } |
