aboutsummaryrefslogtreecommitdiff
path: root/vulkaninfo/vulkaninfo.cpp
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2022-02-22 16:38:43 -0700
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-03-22 17:20:50 -0600
commit38ecbcdb7cd53b3463f15a2076ab36daa2df1207 (patch)
tree3c51e421ed3c362800d8d6af5b7d25dc821dcbb9 /vulkaninfo/vulkaninfo.cpp
parent74f007dcd75712891c23f9051cb775d22610a794 (diff)
downloadusermoji-38ecbcdb7cd53b3463f15a2076ab36daa2df1207.tar.xz
vulkaninfo: Replace devsim with Profile json output
Make vulkaninfo capable of printing Vulkan Profiles with the json output. This replaces the current DevSim output and folds the portability schema output into the regular JSON output. Changes include: * Printing to file by default if json output is chosen * Cleaning up codegen for extension structs * Fixing up the help message * Consolidating the portability schema output into just json
Diffstat (limited to 'vulkaninfo/vulkaninfo.cpp')
-rw-r--r--vulkaninfo/vulkaninfo.cpp527
1 files changed, 256 insertions, 271 deletions
diff --git a/vulkaninfo/vulkaninfo.cpp b/vulkaninfo/vulkaninfo.cpp
index b57b0261..7f56657b 100644
--- a/vulkaninfo/vulkaninfo.cpp
+++ b/vulkaninfo/vulkaninfo.cpp
@@ -31,7 +31,7 @@
// =========== Dump Functions ========= //
-void DumpExtensions(Printer &p, std::string layer_name, std::vector<VkExtensionProperties> extensions, bool do_indent) {
+void DumpExtensions(Printer &p, std::string section_name, std::vector<VkExtensionProperties> extensions, bool do_indent = false) {
std::sort(extensions.begin(), extensions.end(), [](VkExtensionProperties &a, VkExtensionProperties &b) -> int {
return std::string(a.extensionName) < std::string(b.extensionName);
});
@@ -40,17 +40,20 @@ void DumpExtensions(Printer &p, std::string layer_name, std::vector<VkExtensionP
for (const auto &ext : extensions) {
max_length = std::max(max_length, std::strlen(ext.extensionName));
}
-
- ObjectWrapper obj(p, layer_name + " Extensions", extensions.size());
+#if defined(VK_ENABLE_BETA_EXTENSIONS)
+ const std::string portability_ext_name = VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME;
+#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
+ ObjectWrapper obj(p, section_name, extensions.size());
if (do_indent) p.IndentDecrease();
for (auto &ext : extensions) {
+#if defined(VK_ENABLE_BETA_EXTENSIONS)
+ if (p.Type() == OutputType::json && portability_ext_name == ext.extensionName) continue;
+#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
p.PrintExtension(ext.extensionName, ext.specVersion, max_length);
}
if (do_indent) p.IndentIncrease();
}
-void DumpExtensions(Printer &p, std::string layer_name, std::vector<VkExtensionProperties> extensions) {
- DumpExtensions(p, layer_name, extensions, false);
-}
+
void DumpLayers(Printer &p, std::vector<LayerExtensionList> layers, const std::vector<std::unique_ptr<AppGpu>> &gpus) {
std::sort(layers.begin(), layers.end(), [](LayerExtensionList &left, LayerExtensionList &right) -> int {
return std::strncmp(left.layer_properties.layerName, right.layer_properties.layerName, VK_MAX_DESCRIPTION_SIZE) < 0;
@@ -70,13 +73,13 @@ void DumpLayers(Printer &p, std::vector<LayerExtensionList> layers, const std::v
p.DecorateAsValue(v_str) + ", layer version " +
p.DecorateAsValue(std::to_string(props.implementationVersion));
ObjectWrapper obj(p, header);
- DumpExtensions(p, "Layer", layer.extension_properties);
+ DumpExtensions(p, "Layer Extensions", layer.extension_properties);
ArrayWrapper arr_devices(p, "Devices", gpus.size());
for (auto &gpu : gpus) {
p.PrintKeyValue("GPU id", gpu->id, gpu->props.deviceName);
auto exts = gpu->inst.AppGetPhysicalDeviceLayerExtensions(gpu->phys_device, props.layerName);
- DumpExtensions(p, "Layer-Device", exts);
+ DumpExtensions(p, "Layer-Device Extensions", exts);
p.AddNewline();
}
}
@@ -84,12 +87,7 @@ void DumpLayers(Printer &p, std::vector<LayerExtensionList> layers, const std::v
}
case OutputType::json: {
- ArrayWrapper arr(p, "ArrayOfVkLayerProperties", layers.size());
- int i = 0;
- for (auto &layer : layers) {
- p.SetElementIndex(i++);
- DumpVkLayerProperties(p, "layerProperty", layer.layer_properties);
- }
+ assert(false && "unimplemented");
break;
}
case OutputType::vkconfig_output: {
@@ -101,13 +99,13 @@ void DumpLayers(Printer &p, std::vector<LayerExtensionList> layers, const std::v
p.PrintKeyString("version", VkVersionString(layer.layer_properties.specVersion));
p.PrintKeyValue("implementation version", layer.layer_properties.implementationVersion);
p.PrintKeyString("description", layer.layer_properties.description);
- DumpExtensions(p, "Layer", layer.extension_properties);
+ DumpExtensions(p, "Layer Extensions", layer.extension_properties);
ObjectWrapper obj_devices(p, "Devices");
for (auto &gpu : gpus) {
ObjectWrapper obj_gpu(p, gpu->props.deviceName);
p.PrintKeyValue("GPU id", gpu->id, gpu->props.deviceName);
auto exts = gpu->inst.AppGetPhysicalDeviceLayerExtensions(gpu->phys_device, layer.layer_properties.layerName);
- DumpExtensions(p, "Layer-Device", exts);
+ DumpExtensions(p, "Layer-Device Extensions", exts);
}
}
break;
@@ -313,25 +311,6 @@ void GpuDumpProps(Printer &p, AppGpu &gpu) {
p.AddNewline();
}
}
-void GpuDumpPropsJson(Printer &p, AppGpu &gpu) {
- auto props = gpu.GetDeviceProperties();
- ObjectWrapper obj(p, "VkPhysicalDeviceProperties");
- p.PrintKeyValue("apiVersion", props.apiVersion, VkVersionString(props.apiVersion));
- p.PrintKeyValue("driverVersion", props.driverVersion, to_hex_str(props.driverVersion));
- p.PrintKeyValue("vendorID", props.vendorID);
- p.PrintKeyValue("deviceID", props.deviceID);
- p.PrintKeyValue("deviceType", props.deviceType);
- p.PrintKeyString("deviceName", props.deviceName);
- {
- ArrayWrapper arr(p, "pipelineCacheUUID", VK_UUID_SIZE);
- for (uint32_t i = 0; i < VK_UUID_SIZE; ++i) {
- p.PrintElement(static_cast<uint32_t>(props.pipelineCacheUUID[i]));
- }
- }
-
- DumpVkPhysicalDeviceLimits(p, "VkPhysicalDeviceLimits", gpu.props.limits);
- DumpVkPhysicalDeviceSparseProperties(p, "VkPhysicalDeviceSparseProperties", gpu.props.sparseProperties);
-}
void GpuDumpQueueProps(Printer &p, AppGpu &gpu, const AppQueueFamilyProperties &queue) {
VkQueueFamilyProperties props = queue.props;
@@ -365,14 +344,6 @@ void GpuDumpQueueProps(Printer &p, AppGpu &gpu, const AppQueueFamilyProperties &
p.AddNewline();
}
-void GpuDumpQueuePropsJson(Printer &p, std::vector<SurfaceExtension> &surfaces, VkQueueFamilyProperties props) {
- ObjectWrapper obj(p, "");
- DumpVkExtent3D(p, "minImageTransferGranularity", props.minImageTransferGranularity);
- p.PrintKeyValue("queueCount", props.queueCount);
- p.PrintKeyValue("queueFlags", props.queueFlags);
- p.PrintKeyValue("timestampValidBits", props.timestampValidBits);
-}
-
// This prints a number of bytes in a human-readable format according to prefixes of the International System of Quantities (ISQ),
// defined in ISO/IEC 80000. The prefixes used here are not SI prefixes, but rather the binary prefixes based on powers of 1024
// (kibi-, mebi-, gibi- etc.).
@@ -482,26 +453,6 @@ void GpuDumpMemoryProps(Printer &p, AppGpu &gpu) {
p.AddNewline();
}
-void GpuDumpMemoryPropsJson(Printer &p, AppGpu &gpu) {
- ObjectWrapper obj_mem_props(p, "VkPhysicalDeviceMemoryProperties");
- {
- ArrayWrapper arr(p, "memoryHeaps", gpu.memory_props.memoryHeapCount);
- for (uint32_t i = 0; i < gpu.memory_props.memoryHeapCount; ++i) {
- ObjectWrapper obj(p, "");
- p.PrintKeyValue("flags", gpu.memory_props.memoryHeaps[i].flags);
- p.PrintKeyValue("size", gpu.memory_props.memoryHeaps[i].size);
- }
- }
- {
- ArrayWrapper arr(p, "memoryTypes", gpu.memory_props.memoryTypeCount);
- for (uint32_t i = 0; i < gpu.memory_props.memoryTypeCount; ++i) {
- ObjectWrapper obj(p, "");
- p.PrintKeyValue("heapIndex", gpu.memory_props.memoryTypes[i].heapIndex);
- p.PrintKeyValue("propertyFlags", gpu.memory_props.memoryTypes[i].propertyFlags);
- }
- }
-}
-
void GpuDumpFeatures(Printer &p, AppGpu &gpu) {
p.SetHeader();
DumpVkPhysicalDeviceFeatures(p, "VkPhysicalDeviceFeatures", gpu.features);
@@ -513,41 +464,33 @@ void GpuDumpFeatures(Printer &p, AppGpu &gpu) {
}
void GpuDumpFormatProperty(Printer &p, VkFormat fmt, VkFormatProperties prop) {
+ std::string name{};
switch (p.Type()) {
case OutputType::text: {
- ObjectWrapper obj(p, "Properties");
- DumpVkFormatFeatureFlags(p, "linearTiling", prop.linearTilingFeatures);
- DumpVkFormatFeatureFlags(p, "optimalTiling", prop.optimalTilingFeatures);
- DumpVkFormatFeatureFlags(p, "bufferFeatures", prop.bufferFeatures);
+ name = "Properties";
break;
}
case OutputType::html: {
- p.SetTitleAsType();
- ObjectWrapper obj(p, VkFormatString(fmt));
- p.SetOpenDetails();
- DumpVkFormatFeatureFlags(p, "linearTiling", prop.linearTilingFeatures);
- p.SetOpenDetails();
- DumpVkFormatFeatureFlags(p, "optimalTiling", prop.optimalTilingFeatures);
- p.SetOpenDetails();
- DumpVkFormatFeatureFlags(p, "bufferFeatures", prop.bufferFeatures);
+ name = VkFormatString(fmt);
break;
}
case OutputType::json: {
- ObjectWrapper obj(p, "");
- p.PrintKeyValue("formatID", fmt);
- p.PrintKeyValue("linearTilingFeatures", prop.linearTilingFeatures);
- p.PrintKeyValue("optimalTilingFeatures", prop.optimalTilingFeatures);
- p.PrintKeyValue("bufferFeatures", prop.bufferFeatures);
+ name = "VkFormatProperties";
break;
}
case OutputType::vkconfig_output: {
- ObjectWrapper obj(p, VkFormatString(fmt));
- DumpVkFormatFeatureFlags(p, "linearTiling", prop.linearTilingFeatures);
- DumpVkFormatFeatureFlags(p, "optimalTiling", prop.optimalTilingFeatures);
- DumpVkFormatFeatureFlags(p, "bufferFeatures", prop.bufferFeatures);
+ name = VkFormatString(fmt);
break;
}
}
+ 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);
}
void GpuDumpToolingInfo(Printer &p, AppGpu &gpu) {
@@ -617,32 +560,14 @@ void GpuDevDump(Printer &p, AppGpu &gpu) {
p.AddNewline();
}
-void GpuDevDumpJson(Printer &p, AppGpu &gpu) {
- ArrayWrapper arr(p, "ArrayOfVkFormatProperties");
- 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);
-
- VkFormatProperties props;
- gpu.inst.dll.fp_vkGetPhysicalDeviceFormatProperties(gpu.phys_device, fmt, &props);
-
- // don't print format properties that are unsupported
- if ((props.linearTilingFeatures || props.optimalTilingFeatures || props.bufferFeatures) == 0) continue;
-
- GpuDumpFormatProperty(p, fmt, props);
- }
- }
- }
-}
// Print gpu info for text, html, & vkconfig_output
-// Uses a seperate function than schema-json for clarity
+// Uses a separate function than schema-json for clarity
void DumpGpu(Printer &p, AppGpu &gpu, bool show_tooling_info, bool show_formats) {
ObjectWrapper obj_gpu(p, "GPU" + std::to_string(gpu.id));
IndentWrapper indent(p);
GpuDumpProps(p, gpu);
- DumpExtensions(p, "Device", gpu.device_extensions);
+ DumpExtensions(p, "Device Extensions", gpu.device_extensions);
p.AddNewline();
{
p.SetHeader();
@@ -664,31 +589,178 @@ void DumpGpu(Printer &p, AppGpu &gpu, bool show_tooling_info, bool show_formats)
p.AddNewline();
}
-// Print gpu info for json
-void DumpGpuJson(Printer &p, AppGpu &gpu) {
- GpuDumpPropsJson(p, gpu);
+// Print capabilities section of profiles schema
+void DumpGpuProfileCapabilities(Printer &p, AppGpu &gpu) {
+ ObjectWrapper capabilities(p, "capabilities");
{
- ArrayWrapper arr(p, "ArrayOfVkQueueFamilyProperties");
- for (const auto &queue_prop : gpu.queue_props) {
- GpuDumpQueuePropsJson(p, gpu.inst.surface_extensions, queue_prop);
+ ObjectWrapper temp_name_obj(p, "device");
+ DumpExtensions(p, "extensions", gpu.device_extensions);
+ {
+ ObjectWrapper obj(p, "features");
+ GpuDumpFeatures(p, gpu);
+ }
+ {
+ ObjectWrapper obj(p, "properties");
+ {
+ ObjectWrapper props_obj(p, "VkPhysicalDeviceProperties");
+ auto props = gpu.GetDeviceProperties();
+ p.PrintKeyValue("apiVersion", props.apiVersion, VkVersionString(props.apiVersion));
+ p.PrintKeyValue("deviceID", props.deviceID);
+ p.PrintKeyString("deviceName", props.deviceName);
+ p.PrintKeyString("deviceType", std::string("VK_") + VkPhysicalDeviceTypeString(props.deviceType));
+ p.PrintKeyValue("driverVersion", props.driverVersion);
+ DumpVkPhysicalDeviceLimits(p, "VkPhysicalDeviceLimits", gpu.props.limits);
+ {
+ ArrayWrapper arr(p, "pipelineCacheUUID");
+ for (const auto &uuid : props.pipelineCacheUUID) p.PrintElement(static_cast<uint32_t>(uuid));
+ }
+ DumpVkPhysicalDeviceSparseProperties(p, "VkPhysicalDeviceSparseProperties", gpu.props.sparseProperties);
+ p.PrintKeyValue("vendorID", props.vendorID);
+ }
+ 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);
+ }
+ }
+ {
+ ObjectWrapper obj(p, "formats");
+ 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);
+
+ VkFormatProperties props;
+ gpu.inst.dll.fp_vkGetPhysicalDeviceFormatProperties(gpu.phys_device, fmt, &props);
+
+ // don't print format properties that are unsupported
+ if ((props.linearTilingFeatures || props.optimalTilingFeatures || props.bufferFeatures) == 0) continue;
+
+ ObjectWrapper format_obj(p, std::string("VK_") + VkFormatString(fmt));
+ {
+ GpuDumpFormatProperty(p, fmt, props);
+
+ VkFormatProperties2 format_props2{};
+ format_props2.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
+ format_props2.formatProperties = 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);
+ chain_iterator_format_properties2(p, gpu, format_props2.pNext);
+ }
+ }
+ }
+ }
+ }
+ {
+ ArrayWrapper arr(p, "queueFamiliesProperties");
+ for (const auto &extended_queue_prop : gpu.extended_queue_props) {
+ ObjectWrapper queue_obj(p, "");
+ {
+ ObjectWrapper obj_queue_props(p, "VkQueueFamilyProperties");
+ VkQueueFamilyProperties props = extended_queue_prop.props;
+ DumpVkExtent3D(p, "minImageTransferGranularity", props.minImageTransferGranularity);
+ p.PrintKeyValue("queueCount", props.queueCount);
+ DumpVkQueueFlags(p, "queueFlags", props.queueFlags);
+ p.PrintKeyValue("timestampValidBits", props.timestampValidBits);
+ }
+ chain_iterator_queue_properties2(p, gpu, extended_queue_prop.pNext);
+ }
}
}
- {
- ArrayWrapper arr(p, "ArrayOfVkExtensionProperties");
- for (auto &ext : gpu.device_extensions) {
- p.PrintExtension(ext.extensionName, ext.specVersion);
+#if defined(VK_ENABLE_BETA_EXTENSIONS)
+ // Print portability subset extension, features, and properties if available
+ if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) &&
+ (gpu.inst.CheckExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) ||
+ gpu.inst.instance_version >= VK_API_VERSION_1_1)) {
+ ObjectWrapper macos_obj(p, "macos-specific");
+ {
+ ObjectWrapper ext_obj(p, "extensions");
+ const std::string portability_ext_name = VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME;
+ for (const auto &ext : gpu.device_extensions) {
+ if (portability_ext_name == ext.extensionName) {
+ p.PrintExtension(ext.extensionName, ext.specVersion);
+ }
+ }
+ }
+ {
+ ObjectWrapper features_obj(p, "features");
+ void *feats_place = gpu.features2.pNext;
+ while (feats_place) {
+ VkBaseOutStructure *structure = static_cast<VkBaseOutStructure *>(feats_place);
+ if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR) {
+ auto *features = reinterpret_cast<VkPhysicalDevicePortabilitySubsetFeaturesKHR *>(structure);
+ DumpVkPhysicalDevicePortabilitySubsetFeaturesKHR(p, "VkPhysicalDevicePortabilitySubsetFeaturesKHR", *features);
+ break;
+ }
+ feats_place = structure->pNext;
+ }
+ }
+ {
+ ObjectWrapper property_obj(p, "properties");
+ void *props_place = gpu.props2.pNext;
+ while (props_place) {
+ VkBaseOutStructure *structure = static_cast<VkBaseOutStructure *>(props_place);
+ if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR) {
+ auto *props = reinterpret_cast<VkPhysicalDevicePortabilitySubsetPropertiesKHR *>(structure);
+ DumpVkPhysicalDevicePortabilitySubsetPropertiesKHR(p, "VkPhysicalDevicePortabilitySubsetPropertiesKHR", *props);
+ break;
+ }
+ props_place = structure->pNext;
+ }
}
}
+#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
+}
+void PrintProfileBaseInfo(Printer &p, const std::string &device_name, uint32_t apiVersion, const std::string &device_label,
+ const std::vector<std::string> &capabilities) {
+ ObjectWrapper vk_info(p, device_name);
+ p.PrintKeyValue("version", 1);
+ p.PrintKeyString("api-version", VkVersionString(apiVersion));
+ p.PrintKeyString("label", device_label);
+ p.PrintKeyString("description", "Exported from vulkaninfo");
+ { ObjectWrapper contributors(p, "contributors"); }
+ {
+ ArrayWrapper contributors(p, "history");
+ ObjectWrapper element(p, "");
+ p.PrintKeyValue("revision", 1);
+ std::time_t t = std::time(0); // get time now
+ std::tm *now = std::localtime(&t);
+ std::string date =
+ std::to_string(now->tm_year + 1900) + '-' + std::to_string(now->tm_mon + 1) + '-' + std::to_string(now->tm_mday);
+ p.PrintKeyString("date", date);
+ p.PrintKeyString("author", "Automated export from vulkaninfo");
+ p.PrintKeyString("comment", "");
+ }
+ ArrayWrapper contributors(p, "capabilities");
+ for (const auto &str : capabilities) p.PrintString(str);
+}
- GpuDumpMemoryPropsJson(p, gpu);
- DumpVkPhysicalDeviceFeatures(p, "VkPhysicalDeviceFeatures", gpu.features);
- GpuDevDumpJson(p, gpu);
+// Prints profiles section of profiles schema
+void DumpGpuProfileInfo(Printer &p, AppGpu &gpu) {
+ ObjectWrapper profiles(p, "profiles");
+
+ std::string device_label = std::string(gpu.props.deviceName) + " driver " + VkVersionString(gpu.props.driverVersion);
+ std::string device_name =
+ std::string("VP_VULKANINFO_") + std::string(gpu.props.deviceName) + "_" + VkVersionString(gpu.props.driverVersion);
+ ;
+ for (auto &c : device_name) {
+ if (c == ' ' || c == '.') c = '_';
+ }
+ PrintProfileBaseInfo(p, device_name, gpu.props.apiVersion, device_label, {"device"});
+#if defined(VK_ENABLE_BETA_EXTENSIONS)
+ if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME) &&
+ (gpu.inst.CheckExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) ||
+ gpu.inst.instance_version >= VK_API_VERSION_1_1)) {
+ PrintProfileBaseInfo(p, device_name + "_portability_subset", gpu.props.apiVersion, device_label + " subset",
+ {"device", "macos-specific"});
+ }
+#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
}
// Print summary of system
void DumpSummaryInstance(Printer &p, AppInstance &inst) {
p.SetSubHeader();
- DumpExtensions(p, "Instance", inst.global_extensions, true);
+ DumpExtensions(p, "Instance Extensions", inst.global_extensions, true);
p.AddNewline();
p.SetSubHeader();
@@ -742,7 +814,7 @@ void DumpSummaryGPU(Printer &p, AppGpu &gpu) {
DumpVkDriverId(p, "driverID", driver_props->driverID);
p.PrintKeyString("driverName", driver_props->driverName);
p.PrintKeyString("driverInfo", driver_props->driverInfo);
- DumpVkConformanceVersion(p, "conformanceVersion", driver_props->conformanceVersion);
+ p.PrintKeyString("conformanceVersion", VkConformanceVersionString(driver_props->conformanceVersion));
}
if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES) {
VkPhysicalDeviceIDProperties *device_id_props = reinterpret_cast<VkPhysicalDeviceIDProperties *>(structure);
@@ -754,38 +826,6 @@ void DumpSummaryGPU(Printer &p, AppGpu &gpu) {
}
}
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
-void DumpPortability(Printer &p, AppGpu &gpu) {
- if (gpu.CheckPhysicalDeviceExtensionIncluded(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME)) {
- if (gpu.inst.CheckExtensionEnabled(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) {
- void *props_place = gpu.props2.pNext;
- while (props_place) {
- VkBaseOutStructure *structure = static_cast<VkBaseOutStructure *>(props_place);
- if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR) {
- VkPhysicalDevicePortabilitySubsetPropertiesKHR *props =
- reinterpret_cast<VkPhysicalDevicePortabilitySubsetPropertiesKHR *>(structure);
- DumpVkPhysicalDevicePortabilitySubsetPropertiesKHR(p, "VkPhysicalDevicePortabilitySubsetPropertiesKHR", *props);
- break;
- }
- props_place = structure->pNext;
- }
-
- void *feats_place = gpu.features2.pNext;
- while (feats_place) {
- VkBaseOutStructure *structure = static_cast<VkBaseOutStructure *>(feats_place);
- if (structure->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR) {
- VkPhysicalDevicePortabilitySubsetFeaturesKHR *features =
- reinterpret_cast<VkPhysicalDevicePortabilitySubsetFeaturesKHR *>(structure);
- DumpVkPhysicalDevicePortabilitySubsetFeaturesKHR(p, "VkPhysicalDevicePortabilitySubsetFeaturesKHR", *features);
- break;
- }
- feats_place = structure->pNext;
- }
- }
- }
-}
-#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
-
// ============ Printing Logic ============= //
#ifdef _WIN32
@@ -814,49 +854,42 @@ static void ConsoleEnlarge() {
#endif
// Global configuration
-enum class OutputCategory {
- text,
- html,
- devsim_json,
- vkconfig_output,
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
- portability_json,
-#endif
- summary
-};
-
-void print_usage(const char *argv0) {
+enum class OutputCategory { text, html, profile_json, vkconfig_output, summary };
+const char *help_message_body =
+ "OPTIONS:\n"
+ "[-h, --help] Print this help.\n"
+ "[--summary] Show a summary of the instance and GPU's on a system.\n"
+ "[-o <filename>, --output <filename>]\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 vulkaninfo output to stdout. This is\n"
+ " the default output.\n"
+ "[--html] Produce an html version of vulkaninfo output, saved as\n"
+ " \"vulkaninfo.html\" in the directory in which the command\n"
+ " is run.\n"
+ "[-j, --json] Produce a json version of vulkaninfo output conforming to the Vulkan\n"
+ " Profiles schema, saved as \"vulkaninfo.json\", of the first gpu in the\n"
+ " system.\n"
+ "[-j=<gpu-number>, --json=<gpu-number>]\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"
+ " vulkaninfo without any options specified.\n"
+ "[--show-tool-props] Show the active VkPhysicalDeviceToolPropertiesEXT that vulkaninfo finds.\n"
+ "[--show-formats] Display the format properties of each physical device.\n"
+ " Note: This only affects text output.\n";
+
+void print_usage(const std::string &executable_name) {
std::cout << "\nvulkaninfo - Summarize Vulkan information in relation to the current environment.\n\n";
- std::cout << "USAGE: " << argv0 << " [options]\n\n";
- std::cout << "OPTIONS:\n";
- std::cout << "-h, --help Print this help.\n";
- std::cout << "--summary Show a summary of the instance and GPU's on a system.\n";
- std::cout << "--text Produce a text version of vulkaninfo output to stdout. This is\n";
- std::cout << " the default output.\n";
- std::cout << "--html Produce an html version of vulkaninfo output, saved as\n";
- std::cout << " \"vulkaninfo.html\" in the directory in which the command\n";
- std::cout << " is run.\n";
- std::cout << "-j, --json Produce a json version of vulkaninfo to standard output of the\n";
- std::cout << " first gpu in the system conforming to the DevSim schema.\n";
- std::cout << "--json=<gpu-number> For a multi-gpu system, a single gpu can be targetted by\n";
- std::cout << " specifying the gpu-number associated with the gpu of \n";
- std::cout << " interest. This number can be determined by running\n";
- std::cout << " vulkaninfo without any options specified.\n";
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
- std::cout << "--portability Produce a json version of vulkaninfo to standard output of the first\n";
- std::cout << " gpu in the system conforming to the DevSim Portability Subset schema.\n";
- std::cout << "--portability=<N> Produce the json output conforming to the DevSim Portability\n";
- std::cout << " Subset Schema for the GPU specified to standard output,\n";
- std::cout << " where N is the GPU desired.\n";
-#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
- std::cout << "--show-tool-props Show the active VkPhysicalDeviceToolPropertiesEXT that vulkaninfo finds.\n";
- std::cout << "--show-formats Display the format properties of each physical device.\n";
- std::cout << " Note: This option does not affect html or json output;\n";
- std::cout << " they will always print format properties.\n";
- std::cout << "-o <filename>, --output<filename>\n";
- std::cout << " Print output to a new file whose name is specified by filename.\n";
- std::cout << " File will be written to the current working directory.\n";
- std::cout << "\n";
+ std::cout << "USAGE: \n";
+ std::cout << " " << executable_name << " --summary\n";
+ std::cout << " " << executable_name << " -o <filename> | --output <filename>\n";
+ std::cout << " " << executable_name << " -j | -j=<gpu-number> | --json | --json=<gpu-number>\n";
+ std::cout << " " << executable_name << " --text\n";
+ std::cout << " " << executable_name << " --html\n";
+ std::cout << " " << executable_name << " --show-formats\n";
+ std::cout << " " << executable_name << " --show-tool-props\n";
+ std::cout << "\n" << help_message_body << std::endl;
}
struct ParsedResults {
@@ -870,7 +903,7 @@ struct ParsedResults {
std::string default_filename;
};
-util::vulkaninfo_optional<ParsedResults> parse_arguments(int argc, char **argv) {
+util::vulkaninfo_optional<ParsedResults> parse_arguments(int argc, char **argv, std::string executable_name) {
ParsedResults results{}; // default it to zero init everything
results.output_category = OutputCategory::text; // default output category
results.default_filename = "vulkaninfo.txt";
@@ -895,17 +928,9 @@ util::vulkaninfo_optional<ParsedResults> parse_arguments(int argc, char **argv)
results.selected_gpu = static_cast<uint32_t>(strtol(argv[i] + 7, nullptr, 10));
results.has_selected_gpu = true;
}
- results.output_category = OutputCategory::devsim_json;
+ results.output_category = OutputCategory::profile_json;
results.default_filename = "vulkaninfo.json";
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
- } else if (strncmp("--portability", argv[i], 13) == 0) {
- if (strlen(argv[i]) > 14 && strncmp("--portability=", argv[i], 14) == 0) {
- results.selected_gpu = static_cast<uint32_t>(strtol(argv[i] + 14, nullptr, 10));
- results.has_selected_gpu = true;
- }
- results.output_category = OutputCategory::portability_json;
- results.default_filename = "portability.json";
-#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
+ results.print_to_file = true;
} else if (strcmp(argv[i], "--summary") == 0) {
results.output_category = OutputCategory::summary;
} else if (strcmp(argv[i], "--text") == 0) {
@@ -928,10 +953,10 @@ util::vulkaninfo_optional<ParsedResults> parse_arguments(int argc, char **argv)
results.filename = argv[i + 1];
++i;
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
- print_usage(argv[0]);
+ print_usage(executable_name);
return {};
} else {
- print_usage(argv[0]);
+ print_usage(executable_name);
return {};
}
}
@@ -951,36 +976,11 @@ PrinterCreateDetails get_printer_create_details(ParsedResults &parse_data, AppIn
case (OutputCategory::html):
create.output_type = OutputType::html;
break;
- case (OutputCategory::devsim_json):
- create.output_type = OutputType::json;
- create.start_string = std::string("{\n\t\"$schema\": \"https://schema.khronos.org/vulkan/devsim_1_0_0.json#\",\n") +
- "\t\"comments\": {\n\t\t\"desc\": \"JSON configuration file describing GPU " +
- std::to_string(parse_data.selected_gpu) + " (" + selected_gpu.props.deviceName +
- "). Generated using the " + executable_name + " program.\",\n\t\t\"vulkanApiVersion\": \"" +
- VkVersionString(inst.vk_version) + "\"\n" + "\t}";
-#ifdef VK_USE_PLATFORM_IOS_MVK
- create.print_to_file = true;
-#endif
- break;
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
- case (OutputCategory::portability_json):
+ case (OutputCategory::profile_json):
create.output_type = OutputType::json;
create.start_string =
- std::string(
- "{\n\t\"$schema\": "
- "\"https://schema.khronos.org/vulkan/devsim_VK_KHR_portability_subset-provisional-1.json#\",\n") +
- "\t\"comments\": {\n\t\t\"desc\": \"JSON configuration file describing GPU " +
- std::to_string(parse_data.selected_gpu) + "'s (" + selected_gpu.props.deviceName +
- ") portability features and properties. Generated using the " + executable_name +
- " program.\",\n\t\t\"vulkanApiVersion\": "
- "\"" +
- VkVersionString(inst.vk_version) + "\"\n" + "\t}";
-#ifdef VK_USE_PLATFORM_IOS_MVK
- create.print_to_file = true;
-#endif
+ std::string("{\n\t\"$schema\": ") + "\"https://schema.khronos.org/vulkan/profiles-0.8-latest.json\"";
break;
-#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
-
case (OutputCategory::vkconfig_output):
create.output_type = OutputType::vkconfig_output;
create.start_string = "{\n\t\"Vulkan Instance Version\": \"" + VkVersionString(inst.vk_version) + "\"";
@@ -1002,18 +1002,13 @@ void RunPrinter(Printer &p, ParsedResults parse_data, AppInstance &instance, std
for (auto &gpu : gpus) {
DumpSummaryGPU(p, *(gpu.get()));
}
- }
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
- else if (parse_data.output_category == OutputCategory::portability_json) {
- DumpPortability(p, *(gpus.at(parse_data.selected_gpu).get()));
-#endif // defined(VK_ENABLE_BETA_EXTENSIONS)
- } else if (parse_data.output_category == OutputCategory::devsim_json) {
- DumpLayers(p, instance.global_layers, gpus);
- DumpGpuJson(p, *(gpus.at(parse_data.selected_gpu).get()));
+ } else if (parse_data.output_category == OutputCategory::profile_json) {
+ DumpGpuProfileCapabilities(p, *(gpus.at(parse_data.selected_gpu).get()));
+ DumpGpuProfileInfo(p, *(gpus.at(parse_data.selected_gpu).get()));
} else {
// text, html, vkconfig_output
p.SetHeader();
- DumpExtensions(p, "Instance", instance.global_extensions);
+ DumpExtensions(p, "Instance Extensions", instance.global_extensions);
p.AddNewline();
DumpLayers(p, instance.global_layers, gpus);
@@ -1040,7 +1035,23 @@ int vulkanInfoMain(int argc, char **argv) {
int main(int argc, char **argv) {
#endif
- auto parsing_return = parse_arguments(argc, argv);
+ // Figure out the name of the executable, pull out the name if given a path
+ // Default is `vulkaninfo`
+ std::string executable_name = "vulkaninfo";
+ if (argc >= 1) {
+ const auto argv_0 = std::string(argv[0]);
+ // don't include path separator
+ // Look for forward slash first, only look for backslash if that found nothing
+ auto last_occurrence = argv_0.rfind('/');
+ if (last_occurrence == std::string::npos) {
+ last_occurrence = argv_0.rfind('\\');
+ }
+ if (last_occurrence != std::string::npos && last_occurrence + 1 < argv_0.size()) {
+ executable_name = argv_0.substr(last_occurrence + 1);
+ }
+ }
+
+ auto parsing_return = parse_arguments(argc, argv, executable_name);
if (!parsing_return) return 1;
ParsedResults parse_data = parsing_return.value();
@@ -1060,22 +1071,6 @@ int main(int argc, char **argv) {
}
#endif
- // Figure out the name of the executable, pull out the name if given a path
- // Default is `vulkaninfo`
- std::string executable_name = "vulkaninfo";
- if (argc >= 1) {
- const auto argv_0 = std::string(argv[0]);
- // don't include path separator
- // Look for forward slash first, only look for backslash if that found nothing
- auto last_occurrence = argv_0.rfind('/');
- if (last_occurrence == std::string::npos) {
- last_occurrence = argv_0.rfind('\\');
- }
- if (last_occurrence != std::string::npos && last_occurrence + 1 < argv_0.size()) {
- executable_name = argv_0.substr(last_occurrence + 1);
- }
- }
-
int return_code = 0; // set in case of error
std::unique_ptr<Printer> printer;
std::ostream std_out(std::cout.rdbuf());
@@ -1121,27 +1116,17 @@ int main(int argc, char **argv) {
}
return 1;
}
- } else if (parse_data.output_category == OutputCategory::devsim_json ||
- parse_data.output_category == OutputCategory::portability_json) {
+ } else if (parse_data.output_category == OutputCategory::profile_json) {
std::cout << "vulkaninfo could not find any GPU's.\n";
}
}
-#if defined(VK_ENABLE_BETA_EXTENSIONS)
- if (parse_data.output_category == OutputCategory::portability_json &&
- !gpus.at(parse_data.selected_gpu)->CheckPhysicalDeviceExtensionIncluded(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME)) {
- std::cerr << "Cannot create a json because the current selected GPU (" << parse_data.selected_gpu
- << ") does not support the VK_KHR_portability_subset extension.\n";
- return 1;
- }
-#endif
-
auto printer_data = get_printer_create_details(parse_data, instance, *gpus.at(parse_data.selected_gpu), executable_name);
if (printer_data.print_to_file) {
file_out = std::ofstream(printer_data.file_name);
out = &file_out;
}
- printer = std::unique_ptr<Printer>(new Printer(printer_data, *out, parse_data.selected_gpu, instance.vk_version));
+ printer = std::unique_ptr<Printer>(new Printer(printer_data, *out, instance.vk_version));
RunPrinter(*(printer.get()), parse_data, instance, gpus, surfaces);