Jesse Hall | d02edcb | 2015-09-08 07:44:48 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jesse Hall | 4da3bd6 | 2016-01-16 22:14:40 -0800 | [diff] [blame] | 17 | #include <algorithm> |
| 18 | #include <array> |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 19 | #include <inttypes.h> |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 20 | #include <stdlib.h> |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 21 | #include <sstream> |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 22 | #include <vector> |
| 23 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 24 | #include <vulkan/vulkan.h> |
| 25 | |
| 26 | #define LOG_TAG "vkinfo" |
| 27 | #include <log/log.h> |
| 28 | |
| 29 | namespace { |
| 30 | |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 31 | struct Options { |
| 32 | bool layer_description; |
| 33 | bool layer_extensions; |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 34 | bool unsupported_features; |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 35 | bool validate; |
| 36 | }; |
| 37 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 38 | struct GpuInfo { |
| 39 | VkPhysicalDeviceProperties properties; |
| 40 | VkPhysicalDeviceMemoryProperties memory; |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 41 | VkPhysicalDeviceFeatures features; |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 42 | std::vector<VkQueueFamilyProperties> queue_families; |
Jesse Hall | 6e4ab31 | 2016-01-07 22:26:20 -0800 | [diff] [blame] | 43 | std::vector<VkExtensionProperties> extensions; |
| 44 | std::vector<VkLayerProperties> layers; |
| 45 | std::vector<std::vector<VkExtensionProperties>> layer_extensions; |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 46 | }; |
| 47 | struct VulkanInfo { |
| 48 | std::vector<VkExtensionProperties> extensions; |
| 49 | std::vector<VkLayerProperties> layers; |
| 50 | std::vector<std::vector<VkExtensionProperties>> layer_extensions; |
| 51 | std::vector<GpuInfo> gpus; |
| 52 | }; |
| 53 | |
| 54 | // ---------------------------------------------------------------------------- |
| 55 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 56 | [[noreturn]] void die(const char* proc, VkResult result) { |
| 57 | const char* result_str; |
| 58 | switch (result) { |
| 59 | // clang-format off |
| 60 | case VK_SUCCESS: result_str = "VK_SUCCESS"; break; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 61 | case VK_NOT_READY: result_str = "VK_NOT_READY"; break; |
| 62 | case VK_TIMEOUT: result_str = "VK_TIMEOUT"; break; |
| 63 | case VK_EVENT_SET: result_str = "VK_EVENT_SET"; break; |
| 64 | case VK_EVENT_RESET: result_str = "VK_EVENT_RESET"; break; |
| 65 | case VK_INCOMPLETE: result_str = "VK_INCOMPLETE"; break; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 66 | case VK_ERROR_OUT_OF_HOST_MEMORY: result_str = "VK_ERROR_OUT_OF_HOST_MEMORY"; break; |
| 67 | case VK_ERROR_OUT_OF_DEVICE_MEMORY: result_str = "VK_ERROR_OUT_OF_DEVICE_MEMORY"; break; |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 68 | case VK_ERROR_INITIALIZATION_FAILED: result_str = "VK_ERROR_INITIALIZATION_FAILED"; break; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 69 | case VK_ERROR_DEVICE_LOST: result_str = "VK_ERROR_DEVICE_LOST"; break; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 70 | case VK_ERROR_MEMORY_MAP_FAILED: result_str = "VK_ERROR_MEMORY_MAP_FAILED"; break; |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 71 | case VK_ERROR_LAYER_NOT_PRESENT: result_str = "VK_ERROR_LAYER_NOT_PRESENT"; break; |
| 72 | case VK_ERROR_EXTENSION_NOT_PRESENT: result_str = "VK_ERROR_EXTENSION_NOT_PRESENT"; break; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 73 | case VK_ERROR_INCOMPATIBLE_DRIVER: result_str = "VK_ERROR_INCOMPATIBLE_DRIVER"; break; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 74 | default: result_str = "<unknown VkResult>"; break; |
| 75 | // clang-format on |
| 76 | } |
| 77 | fprintf(stderr, "%s failed: %s (%d)\n", proc, result_str, result); |
| 78 | exit(1); |
| 79 | } |
| 80 | |
Jesse Hall | 4da3bd6 | 2016-01-16 22:14:40 -0800 | [diff] [blame] | 81 | bool HasExtension(const std::vector<VkExtensionProperties>& extensions, |
| 82 | const char* name) { |
| 83 | return std::find_if(extensions.cbegin(), extensions.cend(), |
| 84 | [=](const VkExtensionProperties& prop) { |
| 85 | return strcmp(prop.extensionName, name) == 0; |
| 86 | }) != extensions.end(); |
| 87 | } |
| 88 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 89 | void EnumerateInstanceExtensions( |
| 90 | const char* layer_name, |
| 91 | std::vector<VkExtensionProperties>* extensions) { |
| 92 | VkResult result; |
| 93 | uint32_t count; |
| 94 | result = |
| 95 | vkEnumerateInstanceExtensionProperties(layer_name, &count, nullptr); |
| 96 | if (result != VK_SUCCESS) |
| 97 | die("vkEnumerateInstanceExtensionProperties (count)", result); |
| 98 | do { |
| 99 | extensions->resize(count); |
| 100 | result = vkEnumerateInstanceExtensionProperties(layer_name, &count, |
| 101 | extensions->data()); |
| 102 | } while (result == VK_INCOMPLETE); |
| 103 | if (result != VK_SUCCESS) |
| 104 | die("vkEnumerateInstanceExtensionProperties (data)", result); |
| 105 | } |
| 106 | |
Jesse Hall | 6e4ab31 | 2016-01-07 22:26:20 -0800 | [diff] [blame] | 107 | void EnumerateDeviceExtensions(VkPhysicalDevice gpu, |
| 108 | const char* layer_name, |
| 109 | std::vector<VkExtensionProperties>* extensions) { |
| 110 | VkResult result; |
| 111 | uint32_t count; |
| 112 | result = |
| 113 | vkEnumerateDeviceExtensionProperties(gpu, layer_name, &count, nullptr); |
| 114 | if (result != VK_SUCCESS) |
| 115 | die("vkEnumerateDeviceExtensionProperties (count)", result); |
| 116 | do { |
| 117 | extensions->resize(count); |
| 118 | result = vkEnumerateDeviceExtensionProperties(gpu, layer_name, &count, |
| 119 | extensions->data()); |
| 120 | } while (result == VK_INCOMPLETE); |
| 121 | if (result != VK_SUCCESS) |
| 122 | die("vkEnumerateDeviceExtensionProperties (data)", result); |
| 123 | } |
| 124 | |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 125 | void GatherGpuInfo(VkPhysicalDevice gpu, |
| 126 | const Options &options, |
| 127 | GpuInfo& info) { |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 128 | VkResult result; |
| 129 | uint32_t count; |
| 130 | |
| 131 | vkGetPhysicalDeviceProperties(gpu, &info.properties); |
| 132 | vkGetPhysicalDeviceMemoryProperties(gpu, &info.memory); |
| 133 | vkGetPhysicalDeviceFeatures(gpu, &info.features); |
| 134 | |
| 135 | vkGetPhysicalDeviceQueueFamilyProperties(gpu, &count, nullptr); |
| 136 | info.queue_families.resize(count); |
| 137 | vkGetPhysicalDeviceQueueFamilyProperties(gpu, &count, |
| 138 | info.queue_families.data()); |
| 139 | |
| 140 | result = vkEnumerateDeviceLayerProperties(gpu, &count, nullptr); |
| 141 | if (result != VK_SUCCESS) |
| 142 | die("vkEnumerateDeviceLayerProperties (count)", result); |
| 143 | do { |
| 144 | info.layers.resize(count); |
| 145 | result = |
| 146 | vkEnumerateDeviceLayerProperties(gpu, &count, info.layers.data()); |
| 147 | } while (result == VK_INCOMPLETE); |
| 148 | if (result != VK_SUCCESS) |
| 149 | die("vkEnumerateDeviceLayerProperties (data)", result); |
| 150 | info.layer_extensions.resize(info.layers.size()); |
| 151 | |
| 152 | EnumerateDeviceExtensions(gpu, nullptr, &info.extensions); |
| 153 | for (size_t i = 0; i < info.layers.size(); i++) { |
| 154 | EnumerateDeviceExtensions(gpu, info.layers[i].layerName, |
| 155 | &info.layer_extensions[i]); |
| 156 | } |
| 157 | |
| 158 | const std::array<const char*, 1> kDesiredExtensions = { |
| 159 | {VK_KHR_SWAPCHAIN_EXTENSION_NAME}, |
| 160 | }; |
| 161 | const char* extensions[kDesiredExtensions.size()]; |
| 162 | uint32_t num_extensions = 0; |
| 163 | for (const auto& desired_ext : kDesiredExtensions) { |
| 164 | bool available = HasExtension(info.extensions, desired_ext); |
| 165 | for (size_t i = 0; !available && i < info.layer_extensions.size(); i++) |
| 166 | available = HasExtension(info.layer_extensions[i], desired_ext); |
| 167 | if (available) |
| 168 | extensions[num_extensions++] = desired_ext; |
| 169 | } |
| 170 | |
| 171 | VkDevice device; |
Courtney Goeltzenleuchter | ca472ab | 2016-02-01 20:09:00 -0700 | [diff] [blame] | 172 | float queue_priorities[] = {0.0}; |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 173 | const VkDeviceQueueCreateInfo queue_create_info = { |
| 174 | .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, |
| 175 | .queueFamilyIndex = 0, |
| 176 | .queueCount = 1, |
Courtney Goeltzenleuchter | ca472ab | 2016-02-01 20:09:00 -0700 | [diff] [blame] | 177 | queue_priorities |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 178 | }; |
Courtney Goeltzenleuchter | b1e7d59 | 2016-02-08 20:31:25 -0700 | [diff] [blame] | 179 | // clang-format off |
| 180 | const char *kValidationLayers[] = { |
| 181 | "VK_LAYER_GOOGLE_threading", |
| 182 | "VK_LAYER_LUNARG_device_limits", |
| 183 | "VK_LAYER_LUNARG_draw_state", |
| 184 | "VK_LAYER_LUNARG_image", |
| 185 | "VK_LAYER_LUNARG_mem_tracker", |
| 186 | "VK_LAYER_LUNARG_object_tracker", |
| 187 | "VK_LAYER_LUNARG_param_checker", |
| 188 | "VK_LAYER_LUNARG_swapchain", |
| 189 | "VK_LAYER_GOOGLE_unique_objects" |
| 190 | }; |
| 191 | // clang-format on |
| 192 | uint32_t num_layers = sizeof(kValidationLayers) / sizeof(char*); |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 193 | const VkDeviceCreateInfo create_info = { |
| 194 | .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, |
| 195 | .queueCreateInfoCount = 1, |
| 196 | .pQueueCreateInfos = &queue_create_info, |
| 197 | .enabledExtensionCount = num_extensions, |
| 198 | .ppEnabledExtensionNames = extensions, |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 199 | .enabledLayerCount = (options.validate) ? num_layers : 0, |
Courtney Goeltzenleuchter | b1e7d59 | 2016-02-08 20:31:25 -0700 | [diff] [blame] | 200 | .ppEnabledLayerNames = kValidationLayers, |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 201 | .pEnabledFeatures = &info.features, |
| 202 | }; |
| 203 | result = vkCreateDevice(gpu, &create_info, nullptr, &device); |
| 204 | if (result != VK_SUCCESS) |
| 205 | die("vkCreateDevice", result); |
| 206 | vkDestroyDevice(device, nullptr); |
| 207 | } |
| 208 | |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 209 | void GatherInfo(VulkanInfo* info, const Options& options) { |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 210 | VkResult result; |
| 211 | uint32_t count; |
| 212 | |
| 213 | result = vkEnumerateInstanceLayerProperties(&count, nullptr); |
| 214 | if (result != VK_SUCCESS) |
| 215 | die("vkEnumerateInstanceLayerProperties (count)", result); |
| 216 | do { |
| 217 | info->layers.resize(count); |
| 218 | result = |
| 219 | vkEnumerateInstanceLayerProperties(&count, info->layers.data()); |
| 220 | } while (result == VK_INCOMPLETE); |
| 221 | if (result != VK_SUCCESS) |
| 222 | die("vkEnumerateInstanceLayerProperties (data)", result); |
| 223 | info->layer_extensions.resize(info->layers.size()); |
| 224 | |
| 225 | EnumerateInstanceExtensions(nullptr, &info->extensions); |
| 226 | for (size_t i = 0; i < info->layers.size(); i++) { |
| 227 | EnumerateInstanceExtensions(info->layers[i].layerName, |
| 228 | &info->layer_extensions[i]); |
| 229 | } |
| 230 | |
Jesse Hall | ae3b70d | 2016-01-17 22:05:29 -0800 | [diff] [blame] | 231 | const char* kDesiredExtensions[] = { |
| 232 | VK_EXT_DEBUG_REPORT_EXTENSION_NAME, |
Jesse Hall | 4da3bd6 | 2016-01-16 22:14:40 -0800 | [diff] [blame] | 233 | }; |
Jesse Hall | ae3b70d | 2016-01-17 22:05:29 -0800 | [diff] [blame] | 234 | const char* |
| 235 | extensions[sizeof(kDesiredExtensions) / sizeof(kDesiredExtensions[0])]; |
Jesse Hall | 4da3bd6 | 2016-01-16 22:14:40 -0800 | [diff] [blame] | 236 | uint32_t num_extensions = 0; |
| 237 | for (const auto& desired_ext : kDesiredExtensions) { |
| 238 | bool available = HasExtension(info->extensions, desired_ext); |
| 239 | for (size_t i = 0; !available && i < info->layer_extensions.size(); i++) |
| 240 | available = HasExtension(info->layer_extensions[i], desired_ext); |
| 241 | if (available) |
| 242 | extensions[num_extensions++] = desired_ext; |
| 243 | } |
| 244 | |
Courtney Goeltzenleuchter | b1e7d59 | 2016-02-08 20:31:25 -0700 | [diff] [blame] | 245 | // clang-format off |
| 246 | const char *kValidationLayers[] = { |
| 247 | "VK_LAYER_GOOGLE_threading", |
| 248 | "VK_LAYER_LUNARG_device_limits", |
| 249 | "VK_LAYER_LUNARG_draw_state", |
| 250 | "VK_LAYER_LUNARG_image", |
| 251 | "VK_LAYER_LUNARG_mem_tracker", |
| 252 | "VK_LAYER_LUNARG_object_tracker", |
| 253 | "VK_LAYER_LUNARG_param_checker", |
| 254 | "VK_LAYER_LUNARG_swapchain", |
| 255 | "VK_LAYER_GOOGLE_unique_objects" |
| 256 | }; |
| 257 | // clang-format on |
| 258 | uint32_t num_layers = sizeof(kValidationLayers) / sizeof(char*); |
| 259 | |
Jesse Hall | dc7f6a6 | 2016-02-24 16:44:42 -0800 | [diff] [blame] | 260 | const VkApplicationInfo application_info = { |
| 261 | .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, |
| 262 | .pApplicationName = "vkinfo", |
| 263 | .applicationVersion = 0, |
| 264 | .pEngineName = "vkinfo", |
| 265 | .engineVersion = 0, |
| 266 | .apiVersion = VK_API_VERSION, |
| 267 | }; |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 268 | const VkInstanceCreateInfo create_info = { |
| 269 | .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, |
Jesse Hall | dc7f6a6 | 2016-02-24 16:44:42 -0800 | [diff] [blame] | 270 | .pApplicationInfo = &application_info, |
Jesse Hall | 4da3bd6 | 2016-01-16 22:14:40 -0800 | [diff] [blame] | 271 | .enabledExtensionCount = num_extensions, |
| 272 | .ppEnabledExtensionNames = extensions, |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 273 | .enabledLayerCount = (options.validate) ? num_layers : 0, |
Courtney Goeltzenleuchter | b1e7d59 | 2016-02-08 20:31:25 -0700 | [diff] [blame] | 274 | .ppEnabledLayerNames = kValidationLayers, |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 275 | }; |
Jesse Hall | 4da3bd6 | 2016-01-16 22:14:40 -0800 | [diff] [blame] | 276 | VkInstance instance; |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 277 | result = vkCreateInstance(&create_info, nullptr, &instance); |
| 278 | if (result != VK_SUCCESS) |
| 279 | die("vkCreateInstance", result); |
| 280 | |
| 281 | uint32_t num_gpus; |
| 282 | result = vkEnumeratePhysicalDevices(instance, &num_gpus, nullptr); |
| 283 | if (result != VK_SUCCESS) |
| 284 | die("vkEnumeratePhysicalDevices (count)", result); |
| 285 | std::vector<VkPhysicalDevice> gpus(num_gpus, VK_NULL_HANDLE); |
| 286 | do { |
| 287 | gpus.resize(num_gpus, VK_NULL_HANDLE); |
| 288 | result = vkEnumeratePhysicalDevices(instance, &num_gpus, gpus.data()); |
| 289 | } while (result == VK_INCOMPLETE); |
| 290 | if (result != VK_SUCCESS) |
| 291 | die("vkEnumeratePhysicalDevices (data)", result); |
| 292 | |
| 293 | info->gpus.resize(num_gpus); |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 294 | for (size_t i = 0; i < gpus.size(); i++) |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 295 | GatherGpuInfo(gpus[i], options, info->gpus.at(i)); |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 296 | |
| 297 | vkDestroyInstance(instance, nullptr); |
| 298 | } |
| 299 | |
| 300 | // ---------------------------------------------------------------------------- |
| 301 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 302 | const size_t kMaxIndent = 8; |
| 303 | const size_t kIndentSize = 3; |
| 304 | std::array<char, kMaxIndent * kIndentSize + 1> kIndent; |
| 305 | const char* Indent(size_t n) { |
| 306 | static bool initialized = false; |
| 307 | if (!initialized) { |
| 308 | kIndent.fill(' '); |
| 309 | kIndent.back() = '\0'; |
| 310 | initialized = true; |
| 311 | } |
| 312 | return kIndent.data() + |
| 313 | (kIndent.size() - (kIndentSize * std::min(n, kMaxIndent) + 1)); |
| 314 | } |
| 315 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 316 | const char* VkPhysicalDeviceTypeStr(VkPhysicalDeviceType type) { |
| 317 | switch (type) { |
| 318 | case VK_PHYSICAL_DEVICE_TYPE_OTHER: |
| 319 | return "OTHER"; |
| 320 | case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: |
| 321 | return "INTEGRATED_GPU"; |
| 322 | case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: |
| 323 | return "DISCRETE_GPU"; |
| 324 | case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: |
| 325 | return "VIRTUAL_GPU"; |
| 326 | case VK_PHYSICAL_DEVICE_TYPE_CPU: |
| 327 | return "CPU"; |
| 328 | default: |
| 329 | return "<UNKNOWN>"; |
| 330 | } |
| 331 | } |
| 332 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 333 | void PrintExtensions(const std::vector<VkExtensionProperties>& extensions, |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 334 | const Options& /*options*/, |
| 335 | size_t indent) { |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 336 | for (const auto& e : extensions) |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 337 | printf("%s%s (v%u)\n", Indent(indent), e.extensionName, e.specVersion); |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 338 | } |
Jesse Hall | c1ab303 | 2016-01-04 07:26:53 -0800 | [diff] [blame] | 339 | |
Jesse Hall | aa41094 | 2016-01-17 13:07:10 -0800 | [diff] [blame] | 340 | void PrintLayers( |
| 341 | const std::vector<VkLayerProperties>& layers, |
| 342 | const std::vector<std::vector<VkExtensionProperties>> extensions, |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 343 | const Options& options, |
| 344 | size_t indent) { |
Jesse Hall | aa41094 | 2016-01-17 13:07:10 -0800 | [diff] [blame] | 345 | for (size_t i = 0; i < layers.size(); i++) { |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 346 | printf("%s%s %u.%u.%u/%u\n", Indent(indent), layers[i].layerName, |
Jesse Hall | e2948d8 | 2016-02-25 04:19:32 -0800 | [diff] [blame^] | 347 | VK_VERSION_MAJOR(layers[i].specVersion), |
| 348 | VK_VERSION_MINOR(layers[i].specVersion), |
| 349 | VK_VERSION_PATCH(layers[i].specVersion), |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 350 | layers[i].implementationVersion); |
| 351 | if (options.layer_description) |
| 352 | printf("%s%s\n", Indent(indent + 1), layers[i].description); |
| 353 | if (options.layer_extensions && !extensions[i].empty()) { |
| 354 | if (!extensions[i].empty()) { |
| 355 | printf("%sExtensions [%zu]:\n", Indent(indent + 1), |
| 356 | extensions[i].size()); |
| 357 | PrintExtensions(extensions[i], options, indent + 2); |
| 358 | } |
| 359 | } |
Jesse Hall | aa41094 | 2016-01-17 13:07:10 -0800 | [diff] [blame] | 360 | } |
| 361 | } |
| 362 | |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 363 | void PrintAllFeatures(const char* indent, |
| 364 | const VkPhysicalDeviceFeatures& features) { |
| 365 | // clang-format off |
| 366 | printf("%srobustBufferAccess: %s\n", indent, features.robustBufferAccess ? "YES" : "NO"); |
| 367 | printf("%sfullDrawIndexUint32: %s\n", indent, features.fullDrawIndexUint32 ? "YES" : "NO"); |
| 368 | printf("%simageCubeArray: %s\n", indent, features.imageCubeArray ? "YES" : "NO"); |
| 369 | printf("%sindependentBlend: %s\n", indent, features.independentBlend ? "YES" : "NO"); |
| 370 | printf("%sgeometryShader: %s\n", indent, features.geometryShader ? "YES" : "NO"); |
| 371 | printf("%stessellationShader: %s\n", indent, features.tessellationShader ? "YES" : "NO"); |
| 372 | printf("%ssampleRateShading: %s\n", indent, features.sampleRateShading ? "YES" : "NO"); |
| 373 | printf("%sdualSrcBlend: %s\n", indent, features.dualSrcBlend ? "YES" : "NO"); |
| 374 | printf("%slogicOp: %s\n", indent, features.logicOp ? "YES" : "NO"); |
| 375 | printf("%smultiDrawIndirect: %s\n", indent, features.multiDrawIndirect ? "YES" : "NO"); |
| 376 | printf("%sdrawIndirectFirstInstance: %s\n", indent, features.drawIndirectFirstInstance ? "YES" : "NO"); |
| 377 | printf("%sdepthClamp: %s\n", indent, features.depthClamp ? "YES" : "NO"); |
| 378 | printf("%sdepthBiasClamp: %s\n", indent, features.depthBiasClamp ? "YES" : "NO"); |
| 379 | printf("%sfillModeNonSolid: %s\n", indent, features.fillModeNonSolid ? "YES" : "NO"); |
| 380 | printf("%sdepthBounds: %s\n", indent, features.depthBounds ? "YES" : "NO"); |
| 381 | printf("%swideLines: %s\n", indent, features.wideLines ? "YES" : "NO"); |
| 382 | printf("%slargePoints: %s\n", indent, features.largePoints ? "YES" : "NO"); |
| 383 | printf("%salphaToOne: %s\n", indent, features.alphaToOne ? "YES" : "NO"); |
| 384 | printf("%smultiViewport: %s\n", indent, features.multiViewport ? "YES" : "NO"); |
| 385 | printf("%ssamplerAnisotropy: %s\n", indent, features.samplerAnisotropy ? "YES" : "NO"); |
| 386 | printf("%stextureCompressionETC2: %s\n", indent, features.textureCompressionETC2 ? "YES" : "NO"); |
| 387 | printf("%stextureCompressionASTC_LDR: %s\n", indent, features.textureCompressionASTC_LDR ? "YES" : "NO"); |
| 388 | printf("%stextureCompressionBC: %s\n", indent, features.textureCompressionBC ? "YES" : "NO"); |
| 389 | printf("%socclusionQueryPrecise: %s\n", indent, features.occlusionQueryPrecise ? "YES" : "NO"); |
| 390 | printf("%spipelineStatisticsQuery: %s\n", indent, features.pipelineStatisticsQuery ? "YES" : "NO"); |
| 391 | printf("%svertexPipelineStoresAndAtomics: %s\n", indent, features.vertexPipelineStoresAndAtomics ? "YES" : "NO"); |
| 392 | printf("%sfragmentStoresAndAtomics: %s\n", indent, features.fragmentStoresAndAtomics ? "YES" : "NO"); |
| 393 | printf("%sshaderTessellationAndGeometryPointSize: %s\n", indent, features.shaderTessellationAndGeometryPointSize ? "YES" : "NO"); |
| 394 | printf("%sshaderImageGatherExtended: %s\n", indent, features.shaderImageGatherExtended ? "YES" : "NO"); |
| 395 | printf("%sshaderStorageImageExtendedFormats: %s\n", indent, features.shaderStorageImageExtendedFormats ? "YES" : "NO"); |
| 396 | printf("%sshaderStorageImageMultisample: %s\n", indent, features.shaderStorageImageMultisample ? "YES" : "NO"); |
| 397 | printf("%sshaderStorageImageReadWithoutFormat: %s\n", indent, features.shaderStorageImageReadWithoutFormat ? "YES" : "NO"); |
| 398 | printf("%sshaderStorageImageWriteWithoutFormat: %s\n", indent, features.shaderStorageImageWriteWithoutFormat ? "YES" : "NO"); |
| 399 | printf("%sshaderUniformBufferArrayDynamicIndexing: %s\n", indent, features.shaderUniformBufferArrayDynamicIndexing ? "YES" : "NO"); |
| 400 | printf("%sshaderSampledImageArrayDynamicIndexing: %s\n", indent, features.shaderSampledImageArrayDynamicIndexing ? "YES" : "NO"); |
| 401 | printf("%sshaderStorageBufferArrayDynamicIndexing: %s\n", indent, features.shaderStorageBufferArrayDynamicIndexing ? "YES" : "NO"); |
| 402 | printf("%sshaderStorageImageArrayDynamicIndexing: %s\n", indent, features.shaderStorageImageArrayDynamicIndexing ? "YES" : "NO"); |
| 403 | printf("%sshaderClipDistance: %s\n", indent, features.shaderClipDistance ? "YES" : "NO"); |
| 404 | printf("%sshaderCullDistance: %s\n", indent, features.shaderCullDistance ? "YES" : "NO"); |
| 405 | printf("%sshaderFloat64: %s\n", indent, features.shaderFloat64 ? "YES" : "NO"); |
| 406 | printf("%sshaderInt64: %s\n", indent, features.shaderInt64 ? "YES" : "NO"); |
| 407 | printf("%sshaderInt16: %s\n", indent, features.shaderInt16 ? "YES" : "NO"); |
| 408 | printf("%sshaderResourceResidency: %s\n", indent, features.shaderResourceResidency ? "YES" : "NO"); |
| 409 | printf("%sshaderResourceMinLod: %s\n", indent, features.shaderResourceMinLod ? "YES" : "NO"); |
| 410 | printf("%ssparseBinding: %s\n", indent, features.sparseBinding ? "YES" : "NO"); |
| 411 | printf("%ssparseResidencyBuffer: %s\n", indent, features.sparseResidencyBuffer ? "YES" : "NO"); |
| 412 | printf("%ssparseResidencyImage2D: %s\n", indent, features.sparseResidencyImage2D ? "YES" : "NO"); |
| 413 | printf("%ssparseResidencyImage3D: %s\n", indent, features.sparseResidencyImage3D ? "YES" : "NO"); |
| 414 | printf("%ssparseResidency2Samples: %s\n", indent, features.sparseResidency2Samples ? "YES" : "NO"); |
| 415 | printf("%ssparseResidency4Samples: %s\n", indent, features.sparseResidency4Samples ? "YES" : "NO"); |
| 416 | printf("%ssparseResidency8Samples: %s\n", indent, features.sparseResidency8Samples ? "YES" : "NO"); |
| 417 | printf("%ssparseResidency16Samples: %s\n", indent, features.sparseResidency16Samples ? "YES" : "NO"); |
| 418 | printf("%ssparseResidencyAliased: %s\n", indent, features.sparseResidencyAliased ? "YES" : "NO"); |
| 419 | printf("%svariableMultisampleRate: %s\n", indent, features.variableMultisampleRate ? "YES" : "NO"); |
| 420 | printf("%sinheritedQueries: %s\n", indent, features.inheritedQueries ? "YES" : "NO"); |
| 421 | // clang-format on |
| 422 | } |
| 423 | |
| 424 | void PrintSupportedFeatures(const char* indent, |
| 425 | const VkPhysicalDeviceFeatures& features) { |
| 426 | // clang-format off |
| 427 | if (features.robustBufferAccess) printf("%srobustBufferAccess\n", indent); |
| 428 | if (features.fullDrawIndexUint32) printf("%sfullDrawIndexUint32\n", indent); |
| 429 | if (features.imageCubeArray) printf("%simageCubeArray\n", indent); |
| 430 | if (features.independentBlend) printf("%sindependentBlend\n", indent); |
| 431 | if (features.geometryShader) printf("%sgeometryShader\n", indent); |
| 432 | if (features.tessellationShader) printf("%stessellationShader\n", indent); |
| 433 | if (features.sampleRateShading) printf("%ssampleRateShading\n", indent); |
| 434 | if (features.dualSrcBlend) printf("%sdualSrcBlend\n", indent); |
| 435 | if (features.logicOp) printf("%slogicOp\n", indent); |
| 436 | if (features.multiDrawIndirect) printf("%smultiDrawIndirect\n", indent); |
| 437 | if (features.drawIndirectFirstInstance) printf("%sdrawIndirectFirstInstance\n", indent); |
| 438 | if (features.depthClamp) printf("%sdepthClamp\n", indent); |
| 439 | if (features.depthBiasClamp) printf("%sdepthBiasClamp\n", indent); |
| 440 | if (features.fillModeNonSolid) printf("%sfillModeNonSolid\n", indent); |
| 441 | if (features.depthBounds) printf("%sdepthBounds\n", indent); |
| 442 | if (features.wideLines) printf("%swideLines\n", indent); |
| 443 | if (features.largePoints) printf("%slargePoints\n", indent); |
| 444 | if (features.alphaToOne) printf("%salphaToOne\n", indent); |
| 445 | if (features.multiViewport) printf("%smultiViewport\n", indent); |
| 446 | if (features.samplerAnisotropy) printf("%ssamplerAnisotropy\n", indent); |
| 447 | if (features.textureCompressionETC2) printf("%stextureCompressionETC2\n", indent); |
| 448 | if (features.textureCompressionASTC_LDR) printf("%stextureCompressionASTC_LDR\n", indent); |
| 449 | if (features.textureCompressionBC) printf("%stextureCompressionBC\n", indent); |
| 450 | if (features.occlusionQueryPrecise) printf("%socclusionQueryPrecise\n", indent); |
| 451 | if (features.pipelineStatisticsQuery) printf("%spipelineStatisticsQuery\n", indent); |
| 452 | if (features.vertexPipelineStoresAndAtomics) printf("%svertexPipelineStoresAndAtomics\n", indent); |
| 453 | if (features.fragmentStoresAndAtomics) printf("%sfragmentStoresAndAtomics\n", indent); |
| 454 | if (features.shaderTessellationAndGeometryPointSize) printf("%sshaderTessellationAndGeometryPointSize\n", indent); |
| 455 | if (features.shaderImageGatherExtended) printf("%sshaderImageGatherExtended\n", indent); |
| 456 | if (features.shaderStorageImageExtendedFormats) printf("%sshaderStorageImageExtendedFormats\n", indent); |
| 457 | if (features.shaderStorageImageMultisample) printf("%sshaderStorageImageMultisample\n", indent); |
| 458 | if (features.shaderStorageImageReadWithoutFormat) printf("%sshaderStorageImageReadWithoutFormat\n", indent); |
| 459 | if (features.shaderStorageImageWriteWithoutFormat) printf("%sshaderStorageImageWriteWithoutFormat\n", indent); |
| 460 | if (features.shaderUniformBufferArrayDynamicIndexing) printf("%sshaderUniformBufferArrayDynamicIndexing\n", indent); |
| 461 | if (features.shaderSampledImageArrayDynamicIndexing) printf("%sshaderSampledImageArrayDynamicIndexing\n", indent); |
| 462 | if (features.shaderStorageBufferArrayDynamicIndexing) printf("%sshaderStorageBufferArrayDynamicIndexing\n", indent); |
| 463 | if (features.shaderStorageImageArrayDynamicIndexing) printf("%sshaderStorageImageArrayDynamicIndexing\n", indent); |
| 464 | if (features.shaderClipDistance) printf("%sshaderClipDistance\n", indent); |
| 465 | if (features.shaderCullDistance) printf("%sshaderCullDistance\n", indent); |
| 466 | if (features.shaderFloat64) printf("%sshaderFloat64\n", indent); |
| 467 | if (features.shaderInt64) printf("%sshaderInt64\n", indent); |
| 468 | if (features.shaderInt16) printf("%sshaderInt16\n", indent); |
| 469 | if (features.shaderResourceResidency) printf("%sshaderResourceResidency\n", indent); |
| 470 | if (features.shaderResourceMinLod) printf("%sshaderResourceMinLod\n", indent); |
| 471 | if (features.sparseBinding) printf("%ssparseBinding\n", indent); |
| 472 | if (features.sparseResidencyBuffer) printf("%ssparseResidencyBuffer\n", indent); |
| 473 | if (features.sparseResidencyImage2D) printf("%ssparseResidencyImage2D\n", indent); |
| 474 | if (features.sparseResidencyImage3D) printf("%ssparseResidencyImage3D\n", indent); |
| 475 | if (features.sparseResidency2Samples) printf("%ssparseResidency2Samples\n", indent); |
| 476 | if (features.sparseResidency4Samples) printf("%ssparseResidency4Samples\n", indent); |
| 477 | if (features.sparseResidency8Samples) printf("%ssparseResidency8Samples\n", indent); |
| 478 | if (features.sparseResidency16Samples) printf("%ssparseResidency16Samples\n", indent); |
| 479 | if (features.sparseResidencyAliased) printf("%ssparseResidencyAliased\n", indent); |
| 480 | if (features.variableMultisampleRate) printf("%svariableMultisampleRate\n", indent); |
| 481 | if (features.inheritedQueries) printf("%sinheritedQueries\n", indent); |
| 482 | // clang-format on |
| 483 | } |
| 484 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 485 | void PrintGpuInfo(const GpuInfo& info, const Options& options, size_t indent) { |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 486 | VkResult result; |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 487 | std::ostringstream strbuf; |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 488 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 489 | printf("%s\"%s\" (%s) %u.%u.%u/%#x [%04x:%04x]\n", Indent(indent), |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 490 | info.properties.deviceName, |
| 491 | VkPhysicalDeviceTypeStr(info.properties.deviceType), |
Jesse Hall | e2948d8 | 2016-02-25 04:19:32 -0800 | [diff] [blame^] | 492 | VK_VERSION_MAJOR(info.properties.apiVersion), |
| 493 | VK_VERSION_MINOR(info.properties.apiVersion), |
| 494 | VK_VERSION_PATCH(info.properties.apiVersion), |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 495 | info.properties.driverVersion, info.properties.vendorID, |
| 496 | info.properties.deviceID); |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 497 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 498 | for (uint32_t heap = 0; heap < info.memory.memoryHeapCount; heap++) { |
| 499 | if ((info.memory.memoryHeaps[heap].flags & |
Jesse Hall | d1af812 | 2015-11-29 23:50:38 -0800 | [diff] [blame] | 500 | VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0) |
| 501 | strbuf << "DEVICE_LOCAL"; |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 502 | printf("%sHeap %u: %" PRIu64 " MiB (0x%" PRIx64 " B) %s\n", |
| 503 | Indent(indent + 1), heap, |
Jesse Hall | 00f10fe | 2016-02-08 21:20:20 -0800 | [diff] [blame] | 504 | info.memory.memoryHeaps[heap].size / 0x100000, |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 505 | info.memory.memoryHeaps[heap].size, strbuf.str().c_str()); |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 506 | strbuf.str(std::string()); |
| 507 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 508 | for (uint32_t type = 0; type < info.memory.memoryTypeCount; type++) { |
| 509 | if (info.memory.memoryTypes[type].heapIndex != heap) |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 510 | continue; |
| 511 | VkMemoryPropertyFlags flags = |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 512 | info.memory.memoryTypes[type].propertyFlags; |
Jesse Hall | d1af812 | 2015-11-29 23:50:38 -0800 | [diff] [blame] | 513 | if ((flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0) |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 514 | strbuf << " DEVICE_LOCAL"; |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 515 | if ((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0) |
Jesse Hall | 1f91d39 | 2015-12-11 16:28:44 -0800 | [diff] [blame] | 516 | strbuf << " HOST_VISIBLE"; |
Jesse Hall | d1af812 | 2015-11-29 23:50:38 -0800 | [diff] [blame] | 517 | if ((flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0) |
| 518 | strbuf << " COHERENT"; |
| 519 | if ((flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) != 0) |
| 520 | strbuf << " CACHED"; |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 521 | if ((flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) != 0) |
| 522 | strbuf << " LAZILY_ALLOCATED"; |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 523 | printf("%sType %u:%s\n", Indent(indent + 2), type, |
| 524 | strbuf.str().c_str()); |
Jesse Hall | 73ab0ac | 2015-08-25 15:09:15 +0100 | [diff] [blame] | 525 | strbuf.str(std::string()); |
| 526 | } |
| 527 | } |
Jesse Hall | 5ae3abb | 2015-10-08 14:00:22 -0700 | [diff] [blame] | 528 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 529 | for (uint32_t family = 0; family < info.queue_families.size(); family++) { |
| 530 | const VkQueueFamilyProperties& qprops = info.queue_families[family]; |
Jesse Hall | 8966bf4 | 2016-01-16 17:26:48 -0800 | [diff] [blame] | 531 | VkQueueFlags flags = qprops.queueFlags; |
| 532 | char flags_str[5]; |
| 533 | flags_str[0] = (flags & VK_QUEUE_GRAPHICS_BIT) ? 'G' : '_'; |
| 534 | flags_str[1] = (flags & VK_QUEUE_COMPUTE_BIT) ? 'C' : '_'; |
| 535 | flags_str[2] = (flags & VK_QUEUE_TRANSFER_BIT) ? 'T' : '_'; |
| 536 | flags_str[3] = (flags & VK_QUEUE_SPARSE_BINDING_BIT) ? 'S' : '_'; |
| 537 | flags_str[4] = '\0'; |
| 538 | printf( |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 539 | "%sQueue Family %u: %ux %s\n" |
| 540 | "%stimestampValidBits: %ub\n" |
| 541 | "%sminImageTransferGranularity: (%u,%u,%u)\n", |
| 542 | Indent(indent + 1), family, qprops.queueCount, flags_str, |
| 543 | Indent(indent + 2), qprops.timestampValidBits, Indent(indent + 2), |
Jesse Hall | 8966bf4 | 2016-01-16 17:26:48 -0800 | [diff] [blame] | 544 | qprops.minImageTransferGranularity.width, |
| 545 | qprops.minImageTransferGranularity.height, |
| 546 | qprops.minImageTransferGranularity.depth); |
Jesse Hall | b147127 | 2016-01-17 21:36:58 -0800 | [diff] [blame] | 547 | } |
Jesse Hall | 6e4ab31 | 2016-01-07 22:26:20 -0800 | [diff] [blame] | 548 | |
Jesse Hall | c5cec28 | 2016-01-18 04:01:10 -0800 | [diff] [blame] | 549 | printf("%sFeatures:\n", Indent(indent + 1)); |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 550 | if (options.unsupported_features) { |
| 551 | PrintAllFeatures(Indent(indent + 2), info.features); |
| 552 | } else { |
| 553 | PrintSupportedFeatures(Indent(indent + 2), info.features); |
| 554 | } |
Jesse Hall | c5cec28 | 2016-01-18 04:01:10 -0800 | [diff] [blame] | 555 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 556 | printf("%sExtensions [%zu]:\n", Indent(indent + 1), info.extensions.size()); |
| 557 | if (!info.extensions.empty()) |
| 558 | PrintExtensions(info.extensions, options, indent + 2); |
| 559 | printf("%sLayers [%zu]:\n", Indent(indent + 1), info.layers.size()); |
| 560 | if (!info.layers.empty()) |
| 561 | PrintLayers(info.layers, info.layer_extensions, options, indent + 2); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 562 | } |
| 563 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 564 | void PrintInfo(const VulkanInfo& info, const Options& options) { |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 565 | std::ostringstream strbuf; |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 566 | size_t indent = 0; |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 567 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 568 | printf("%sInstance Extensions [%zu]:\n", Indent(indent), |
| 569 | info.extensions.size()); |
| 570 | PrintExtensions(info.extensions, options, indent + 1); |
| 571 | printf("%sInstance Layers [%zu]:\n", Indent(indent), info.layers.size()); |
| 572 | if (!info.layers.empty()) |
| 573 | PrintLayers(info.layers, info.layer_extensions, options, indent + 1); |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 574 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 575 | printf("%sPhysicalDevices [%zu]:\n", Indent(indent), info.gpus.size()); |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 576 | for (const auto& gpu : info.gpus) |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 577 | PrintGpuInfo(gpu, options, indent + 1); |
Jesse Hall | c1ab303 | 2016-01-04 07:26:53 -0800 | [diff] [blame] | 578 | } |
| 579 | |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 580 | const char kUsageString[] = |
| 581 | "usage: vkinfo [options]\n" |
| 582 | " -v enable all the following verbose options\n" |
| 583 | " -layer_description print layer description strings\n" |
| 584 | " -layer_extensions print extensions supported by each layer\n" |
| 585 | " -unsupported_features print all physical device features\n" |
| 586 | " -validate enable validation layers if present\n" |
| 587 | " -debug_pause pause at start until resumed via debugger\n"; |
| 588 | |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 589 | } // namespace |
| 590 | |
Jesse Hall | 09559b5 | 2016-01-07 21:50:19 -0800 | [diff] [blame] | 591 | // ---------------------------------------------------------------------------- |
| 592 | |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 593 | int main(int argc, char const* argv[]) { |
Courtney Goeltzenleuchter | c2a7709 | 2016-02-08 20:31:46 -0700 | [diff] [blame] | 594 | static volatile bool startup_pause = false; |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 595 | Options options = { |
| 596 | .layer_description = false, .layer_extensions = false, |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 597 | .unsupported_features = false, |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 598 | .validate = false, |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 599 | }; |
| 600 | for (int argi = 1; argi < argc; argi++) { |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 601 | if (strcmp(argv[argi], "-h") == 0) { |
| 602 | fputs(kUsageString, stdout); |
| 603 | return 0; |
| 604 | } |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 605 | if (strcmp(argv[argi], "-v") == 0) { |
| 606 | options.layer_description = true; |
| 607 | options.layer_extensions = true; |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 608 | options.unsupported_features = true; |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 609 | } else if (strcmp(argv[argi], "-layer_description") == 0) { |
| 610 | options.layer_description = true; |
| 611 | } else if (strcmp(argv[argi], "-layer_extensions") == 0) { |
| 612 | options.layer_extensions = true; |
Jesse Hall | f63e445 | 2016-02-08 21:22:23 -0800 | [diff] [blame] | 613 | } else if (strcmp(argv[argi], "-unsupported_features") == 0) { |
| 614 | options.unsupported_features = true; |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 615 | } else if (strcmp(argv[argi], "-validate") == 0) { |
| 616 | options.validate = true; |
Courtney Goeltzenleuchter | c2a7709 | 2016-02-08 20:31:46 -0700 | [diff] [blame] | 617 | } else if (strcmp(argv[argi], "-debug_pause") == 0) { |
| 618 | startup_pause = true; |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 619 | } |
| 620 | } |
| 621 | |
Courtney Goeltzenleuchter | c2a7709 | 2016-02-08 20:31:46 -0700 | [diff] [blame] | 622 | while (startup_pause) { |
| 623 | sleep(0); |
| 624 | } |
| 625 | |
Jesse Hall | c1ab303 | 2016-01-04 07:26:53 -0800 | [diff] [blame] | 626 | VulkanInfo info; |
Chia-I Wu | d0bba37 | 2016-02-22 11:41:27 +0800 | [diff] [blame] | 627 | GatherInfo(&info, options); |
Jesse Hall | 38cb840 | 2016-01-18 03:41:35 -0800 | [diff] [blame] | 628 | PrintInfo(info, options); |
Jesse Hall | 04f4f47 | 2015-08-16 19:51:04 -0700 | [diff] [blame] | 629 | return 0; |
| 630 | } |