diff options
| author | Charles Giessen <charles@lunarg.com> | 2023-11-10 11:29:52 -0700 |
|---|---|---|
| committer | Charles Giessen <46324611+charles-lunarg@users.noreply.github.com> | 2023-11-15 12:26:36 -0700 |
| commit | d4f91cf4e25012aa868b4d8f009b299aea78b522 (patch) | |
| tree | 546492577167a512bcde1f5ae0d84588a0dd27c2 /vulkaninfo/vulkaninfo.cpp | |
| parent | 90e25ec83a56f0e1c79480b934d7e255fde7869e (diff) | |
| download | usermoji-d4f91cf4e25012aa868b4d8f009b299aea78b522.tar.xz | |
vulkaninfo: Autogenerate Format list
The rewrite of vulkaninfo to use autogen did not include generating all possible
VkFormats. This commit fixes that by generating the lists of formats and their
corresponding extension/feature version requirements needed to correctly query
their support.
Use of std::set is explicit here since we want the output order to be consistent.
std::set will use the enum values to sort it, giving a nice orderly output.
Before, std::vector maintained the order in a similar fashion, but since it didn't
de-duplicate, it could potentially print the same format many times.
Diffstat (limited to 'vulkaninfo/vulkaninfo.cpp')
| -rw-r--r-- | vulkaninfo/vulkaninfo.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp index daa7c9dd..4ebe3514 100644 --- a/vulkaninfo/vulkaninfo.cpp +++ b/vulkaninfo/vulkaninfo.cpp @@ -32,6 +32,20 @@ #endif #include "vulkaninfo.hpp" +// Used to sort the formats into buckets by their properties. +std::unordered_map<PropFlags, std::set<VkFormat>> FormatPropMap(AppGpu &gpu) { + std::unordered_map<PropFlags, std::set<VkFormat>> map; + for (const auto fmtRange : format_ranges) { + if (gpu.FormatRangeSupported(fmtRange)) { + for (int32_t fmt = fmtRange.first_format; fmt <= fmtRange.last_format; ++fmt) { + PropFlags pf = get_format_properties(gpu, static_cast<VkFormat>(fmt)); + map[pf].insert(static_cast<VkFormat>(fmt)); + } + } + } + return map; +} + // =========== Dump Functions ========= // void DumpExtensions(Printer &p, std::string section_name, std::vector<VkExtensionProperties> extensions, bool do_indent = false) { @@ -533,7 +547,7 @@ void GpuDumpFeatures(Printer &p, AppGpu &gpu) { } } -void GpuDumpTextFormatProperty(Printer &p, const AppGpu &gpu, PropFlags formats, std::vector<VkFormat> format_list, +void GpuDumpTextFormatProperty(Printer &p, const AppGpu &gpu, PropFlags formats, const std::set<VkFormat> &format_list, uint32_t counter) { p.SetElementIndex(counter); ObjectWrapper obj_common_group(p, "Common Format Group"); @@ -576,9 +590,8 @@ void GpuDevDump(Printer &p, AppGpu &gpu) { if (p.Type() == OutputType::text) { auto fmtPropMap = FormatPropMap(gpu); - int counter = 0; - std::vector<VkFormat> unsupported_formats; + std::set<VkFormat> unsupported_formats; for (auto &prop : fmtPropMap) { VkFormatProperties props = prop.first.props; VkFormatProperties3 props3 = prop.first.props3; @@ -595,20 +608,23 @@ void GpuDevDump(Printer &p, AppGpu &gpu) { p.SetAsType().PrintString(VkFormatString(fmt)); } } else { - for (auto &format : gpu.supported_format_ranges) { - 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); - 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); - } + std::set<VkFormat> formats_to_print; + for (auto &format_range : format_ranges) { + if (gpu.FormatRangeSupported(format_range)) { + for (int32_t fmt_counter = format_range.first_format; fmt_counter <= format_range.last_format; ++fmt_counter) { + formats_to_print.insert(static_cast<VkFormat>(fmt_counter)); } } } + for (const auto &fmt : formats_to_print) { + 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); + } + } } p.AddNewline(); @@ -680,10 +696,14 @@ void DumpGpuProfileCapabilities(Printer &p, AppGpu &gpu) { } { ObjectWrapper obj(p, "formats"); - for (auto &format : gpu.supported_format_ranges) { + std::set<VkFormat> already_printed_formats; + for (const auto &format : format_ranges) { 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); + if (already_printed_formats.count(fmt) > 0) { + continue; + } auto formats = get_format_properties(gpu, fmt); // don't print format properties that are unsupported @@ -704,6 +724,7 @@ void DumpGpuProfileCapabilities(Printer &p, AppGpu &gpu) { gpu.inst.ext_funcs.vkGetPhysicalDeviceFormatProperties2KHR(gpu.phys_device, fmt, &format_props2); chain_iterator_format_properties2(p, gpu, format_props2.pNext); } + already_printed_formats.insert(fmt); } } } |
