Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 1 | /* |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 5 | * |
Jon Ashburn | 43b53e8 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 9 | * |
Jon Ashburn | 43b53e8 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 11 | * |
Jon Ashburn | 43b53e8 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
Courtney Goeltzenleuchter | 96cd795 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 17 | * |
| 18 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 19 | * Author: David Pinedo <david@lunarg.com> |
| 20 | * Author: Mark Lobodzinski <mark@lunarg.com> |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 21 | * Author: Rene Lindsay <rene@lunarg.com> |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 22 | */ |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 23 | #include <assert.h> |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 24 | #include <inttypes.h> |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 25 | #include <stdbool.h> |
| 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 29 | |
Ian Elliott | ea95f5c | 2015-04-17 21:23:34 -0600 | [diff] [blame] | 30 | #ifdef _WIN32 |
David Pinedo | 18fb923 | 2015-04-21 14:45:16 -0600 | [diff] [blame] | 31 | #include <fcntl.h> |
| 32 | #include <io.h> |
Ian Elliott | b5fad79 | 2015-11-20 11:55:46 -0700 | [diff] [blame] | 33 | #endif // _WIN32 |
Ian Elliott | 64070a8 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 34 | |
Mun Gwan-gyeong | 787b627 | 2016-08-20 14:46:22 +0900 | [diff] [blame] | 35 | #if defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR) |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 36 | #include <X11/Xutil.h> |
| 37 | #endif |
| 38 | |
Tony Barbour | 0394191 | 2016-12-07 14:45:12 -0700 | [diff] [blame] | 39 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 40 | #warning "Vulkaninfo does not have code for Mir at this time" |
| 41 | #endif |
| 42 | |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 43 | #include <vulkan/vulkan.h> |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 44 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 45 | #define ERR(err) printf("%s:%d: failed with %s\n", __FILE__, __LINE__, VkResultString(err)); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 46 | |
David Pinedo | 18fb923 | 2015-04-21 14:45:16 -0600 | [diff] [blame] | 47 | #ifdef _WIN32 |
| 48 | |
Ian Elliott | 7c83aa2 | 2015-07-08 17:09:54 -0600 | [diff] [blame] | 49 | #define snprintf _snprintf |
| 50 | |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 51 | // Returns nonzero if the console is used only for this process. Will return |
| 52 | // zero if another process (such as cmd.exe) is also attached. |
| 53 | static int ConsoleIsExclusive(void) { |
| 54 | DWORD pids[2]; |
| 55 | DWORD num_pids = GetConsoleProcessList(pids, ARRAYSIZE(pids)); |
| 56 | return num_pids <= 1; |
| 57 | } |
David Pinedo | 18fb923 | 2015-04-21 14:45:16 -0600 | [diff] [blame] | 58 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 59 | #define WAIT_FOR_CONSOLE_DESTROY \ |
| 60 | do { \ |
| 61 | if (ConsoleIsExclusive()) \ |
| 62 | Sleep(INFINITE); \ |
David Pinedo | 18fb923 | 2015-04-21 14:45:16 -0600 | [diff] [blame] | 63 | } while (0) |
| 64 | #else |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 65 | #define WAIT_FOR_CONSOLE_DESTROY |
David Pinedo | 18fb923 | 2015-04-21 14:45:16 -0600 | [diff] [blame] | 66 | #endif |
| 67 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 68 | #define ERR_EXIT(err) \ |
| 69 | do { \ |
| 70 | ERR(err); \ |
| 71 | fflush(stdout); \ |
| 72 | WAIT_FOR_CONSOLE_DESTROY; \ |
| 73 | exit(-1); \ |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 74 | } while (0) |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 75 | |
Tony Barbour | 22a3086 | 2015-04-22 09:02:32 -0600 | [diff] [blame] | 76 | #if defined(NDEBUG) && defined(__GNUC__) |
| 77 | #define U_ASSERT_ONLY __attribute__((unused)) |
| 78 | #else |
| 79 | #define U_ASSERT_ONLY |
| 80 | #endif |
| 81 | |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 82 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 83 | |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 84 | #define MAX_QUEUE_TYPES 5 |
Ian Elliott | 4e19ed0 | 2015-04-28 10:52:52 -0600 | [diff] [blame] | 85 | #define APP_SHORT_NAME "vulkaninfo" |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 86 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 87 | struct AppGpu; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 88 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 89 | struct AppDev { |
| 90 | struct AppGpu *gpu; /* point back to the GPU */ |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 91 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 92 | VkDevice obj; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 93 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 94 | VkFormatProperties format_props[VK_FORMAT_RANGE_SIZE]; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 95 | }; |
| 96 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 97 | struct LayerExtensionList { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 98 | VkLayerProperties layer_properties; |
| 99 | uint32_t extension_count; |
| 100 | VkExtensionProperties *extension_properties; |
| 101 | }; |
| 102 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 103 | struct AppInstance { |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 104 | VkInstance instance; |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 105 | uint32_t global_layer_count; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 106 | struct LayerExtensionList *global_layers; |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 107 | uint32_t global_extension_count; |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 108 | VkExtensionProperties *global_extensions; // Instance Extensions |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 109 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 110 | PFN_vkGetPhysicalDeviceSurfaceSupportKHR vkGetPhysicalDeviceSurfaceSupportKHR; |
| 111 | PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR vkGetPhysicalDeviceSurfaceCapabilitiesKHR; |
| 112 | PFN_vkGetPhysicalDeviceSurfaceFormatsKHR vkGetPhysicalDeviceSurfaceFormatsKHR; |
| 113 | PFN_vkGetPhysicalDeviceSurfacePresentModesKHR vkGetPhysicalDeviceSurfacePresentModesKHR; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 114 | |
| 115 | VkSurfaceKHR surface; |
| 116 | int width, height; |
| 117 | |
| 118 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 119 | HINSTANCE h_instance; // Windows Instance |
| 120 | HWND h_wnd; // window handle |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 121 | #elif VK_USE_PLATFORM_XCB_KHR |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 122 | xcb_connection_t *xcb_connection; |
| 123 | xcb_screen_t *xcb_screen; |
| 124 | xcb_window_t xcb_window; |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 125 | #elif VK_USE_PLATFORM_XLIB_KHR |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 126 | Display *xlib_display; |
| 127 | Window xlib_window; |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 128 | #elif VK_USE_PLATFORM_ANDROID_KHR // TODO |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 129 | ANativeWindow *window; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 130 | #endif |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 131 | }; |
| 132 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 133 | struct AppGpu { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 134 | uint32_t id; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 135 | VkPhysicalDevice obj; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 136 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 137 | VkPhysicalDeviceProperties props; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 138 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 139 | uint32_t queue_count; |
Cody Northrop | ef72e2a | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 140 | VkQueueFamilyProperties *queue_props; |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 141 | VkDeviceQueueCreateInfo *queue_reqs; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 142 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 143 | VkPhysicalDeviceMemoryProperties memory_props; |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 144 | VkPhysicalDeviceFeatures features; |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 145 | VkPhysicalDevice limits; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 146 | |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 147 | uint32_t device_extension_count; |
| 148 | VkExtensionProperties *device_extensions; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 149 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 150 | struct AppDev dev; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 151 | }; |
| 152 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 153 | static VKAPI_ATTR VkBool32 VKAPI_CALL DbgCallback(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, |
| 154 | size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg, |
| 155 | void *pUserData) { |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 156 | char *message = (char *)malloc(strlen(pMsg) + 100); |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 157 | |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 158 | assert(message); |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 159 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 160 | if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 161 | sprintf(message, "ERROR: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg); |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 162 | } else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 163 | sprintf(message, "WARNING: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg); |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 164 | } else if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 165 | sprintf(message, "INFO: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg); |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 166 | } else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 167 | sprintf(message, "DEBUG: [%s] Code %d : %s", pLayerPrefix, msgCode, pMsg); |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 170 | printf("%s\n", message); |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 171 | fflush(stdout); |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 172 | free(message); |
| 173 | |
| 174 | /* |
| 175 | * false indicates that layer should not bail-out of an |
| 176 | * API call that had validation failures. This may mean that the |
| 177 | * app dies inside the driver due to invalid parameter(s). |
| 178 | * That's what would happen without validation layers, so we'll |
| 179 | * keep that behavior here. |
| 180 | */ |
| 181 | return false; |
| 182 | } |
| 183 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 184 | static const char *VkResultString(VkResult err) { |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 185 | switch (err) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 186 | #define STR(r) \ |
| 187 | case r: \ |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 188 | return #r |
| 189 | STR(VK_SUCCESS); |
| 190 | STR(VK_NOT_READY); |
| 191 | STR(VK_TIMEOUT); |
| 192 | STR(VK_EVENT_SET); |
| 193 | STR(VK_EVENT_RESET); |
| 194 | STR(VK_ERROR_INITIALIZATION_FAILED); |
| 195 | STR(VK_ERROR_OUT_OF_HOST_MEMORY); |
| 196 | STR(VK_ERROR_OUT_OF_DEVICE_MEMORY); |
| 197 | STR(VK_ERROR_DEVICE_LOST); |
| 198 | STR(VK_ERROR_LAYER_NOT_PRESENT); |
| 199 | STR(VK_ERROR_EXTENSION_NOT_PRESENT); |
| 200 | STR(VK_ERROR_MEMORY_MAP_FAILED); |
| 201 | STR(VK_ERROR_INCOMPATIBLE_DRIVER); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 202 | #undef STR |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 203 | default: |
| 204 | return "UNKNOWN_RESULT"; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 205 | } |
| 206 | } |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 207 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 208 | static const char *VkPhysicalDeviceTypeString(VkPhysicalDeviceType type) { |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 209 | switch (type) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 210 | #define STR(r) \ |
| 211 | case VK_PHYSICAL_DEVICE_TYPE_##r: \ |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 212 | return #r |
| 213 | STR(OTHER); |
| 214 | STR(INTEGRATED_GPU); |
| 215 | STR(DISCRETE_GPU); |
| 216 | STR(VIRTUAL_GPU); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 217 | #undef STR |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 218 | default: |
| 219 | return "UNKNOWN_DEVICE"; |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 220 | } |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 221 | } |
| 222 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 223 | static const char *VkFormatString(VkFormat fmt) { |
Jeremy Hayes | 2b7e88a | 2015-01-23 08:51:43 -0700 | [diff] [blame] | 224 | switch (fmt) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 225 | #define STR(r) \ |
| 226 | case VK_FORMAT_##r: \ |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 227 | return #r |
| 228 | STR(UNDEFINED); |
| 229 | STR(R4G4_UNORM_PACK8); |
| 230 | STR(R4G4B4A4_UNORM_PACK16); |
| 231 | STR(B4G4R4A4_UNORM_PACK16); |
| 232 | STR(R5G6B5_UNORM_PACK16); |
| 233 | STR(B5G6R5_UNORM_PACK16); |
| 234 | STR(R5G5B5A1_UNORM_PACK16); |
| 235 | STR(B5G5R5A1_UNORM_PACK16); |
| 236 | STR(A1R5G5B5_UNORM_PACK16); |
| 237 | STR(R8_UNORM); |
| 238 | STR(R8_SNORM); |
| 239 | STR(R8_USCALED); |
| 240 | STR(R8_SSCALED); |
| 241 | STR(R8_UINT); |
| 242 | STR(R8_SINT); |
| 243 | STR(R8_SRGB); |
| 244 | STR(R8G8_UNORM); |
| 245 | STR(R8G8_SNORM); |
| 246 | STR(R8G8_USCALED); |
| 247 | STR(R8G8_SSCALED); |
| 248 | STR(R8G8_UINT); |
| 249 | STR(R8G8_SINT); |
| 250 | STR(R8G8_SRGB); |
| 251 | STR(R8G8B8_UNORM); |
| 252 | STR(R8G8B8_SNORM); |
| 253 | STR(R8G8B8_USCALED); |
| 254 | STR(R8G8B8_SSCALED); |
| 255 | STR(R8G8B8_UINT); |
| 256 | STR(R8G8B8_SINT); |
| 257 | STR(R8G8B8_SRGB); |
| 258 | STR(B8G8R8_UNORM); |
| 259 | STR(B8G8R8_SNORM); |
| 260 | STR(B8G8R8_USCALED); |
| 261 | STR(B8G8R8_SSCALED); |
| 262 | STR(B8G8R8_UINT); |
| 263 | STR(B8G8R8_SINT); |
| 264 | STR(B8G8R8_SRGB); |
| 265 | STR(R8G8B8A8_UNORM); |
| 266 | STR(R8G8B8A8_SNORM); |
| 267 | STR(R8G8B8A8_USCALED); |
| 268 | STR(R8G8B8A8_SSCALED); |
| 269 | STR(R8G8B8A8_UINT); |
| 270 | STR(R8G8B8A8_SINT); |
| 271 | STR(R8G8B8A8_SRGB); |
| 272 | STR(B8G8R8A8_UNORM); |
| 273 | STR(B8G8R8A8_SNORM); |
| 274 | STR(B8G8R8A8_USCALED); |
| 275 | STR(B8G8R8A8_SSCALED); |
| 276 | STR(B8G8R8A8_UINT); |
| 277 | STR(B8G8R8A8_SINT); |
| 278 | STR(B8G8R8A8_SRGB); |
| 279 | STR(A8B8G8R8_UNORM_PACK32); |
| 280 | STR(A8B8G8R8_SNORM_PACK32); |
| 281 | STR(A8B8G8R8_USCALED_PACK32); |
| 282 | STR(A8B8G8R8_SSCALED_PACK32); |
| 283 | STR(A8B8G8R8_UINT_PACK32); |
| 284 | STR(A8B8G8R8_SINT_PACK32); |
| 285 | STR(A8B8G8R8_SRGB_PACK32); |
| 286 | STR(A2R10G10B10_UNORM_PACK32); |
| 287 | STR(A2R10G10B10_SNORM_PACK32); |
| 288 | STR(A2R10G10B10_USCALED_PACK32); |
| 289 | STR(A2R10G10B10_SSCALED_PACK32); |
| 290 | STR(A2R10G10B10_UINT_PACK32); |
| 291 | STR(A2R10G10B10_SINT_PACK32); |
| 292 | STR(A2B10G10R10_UNORM_PACK32); |
| 293 | STR(A2B10G10R10_SNORM_PACK32); |
| 294 | STR(A2B10G10R10_USCALED_PACK32); |
| 295 | STR(A2B10G10R10_SSCALED_PACK32); |
| 296 | STR(A2B10G10R10_UINT_PACK32); |
| 297 | STR(A2B10G10R10_SINT_PACK32); |
| 298 | STR(R16_UNORM); |
| 299 | STR(R16_SNORM); |
| 300 | STR(R16_USCALED); |
| 301 | STR(R16_SSCALED); |
| 302 | STR(R16_UINT); |
| 303 | STR(R16_SINT); |
| 304 | STR(R16_SFLOAT); |
| 305 | STR(R16G16_UNORM); |
| 306 | STR(R16G16_SNORM); |
| 307 | STR(R16G16_USCALED); |
| 308 | STR(R16G16_SSCALED); |
| 309 | STR(R16G16_UINT); |
| 310 | STR(R16G16_SINT); |
| 311 | STR(R16G16_SFLOAT); |
| 312 | STR(R16G16B16_UNORM); |
| 313 | STR(R16G16B16_SNORM); |
| 314 | STR(R16G16B16_USCALED); |
| 315 | STR(R16G16B16_SSCALED); |
| 316 | STR(R16G16B16_UINT); |
| 317 | STR(R16G16B16_SINT); |
| 318 | STR(R16G16B16_SFLOAT); |
| 319 | STR(R16G16B16A16_UNORM); |
| 320 | STR(R16G16B16A16_SNORM); |
| 321 | STR(R16G16B16A16_USCALED); |
| 322 | STR(R16G16B16A16_SSCALED); |
| 323 | STR(R16G16B16A16_UINT); |
| 324 | STR(R16G16B16A16_SINT); |
| 325 | STR(R16G16B16A16_SFLOAT); |
| 326 | STR(R32_UINT); |
| 327 | STR(R32_SINT); |
| 328 | STR(R32_SFLOAT); |
| 329 | STR(R32G32_UINT); |
| 330 | STR(R32G32_SINT); |
| 331 | STR(R32G32_SFLOAT); |
| 332 | STR(R32G32B32_UINT); |
| 333 | STR(R32G32B32_SINT); |
| 334 | STR(R32G32B32_SFLOAT); |
| 335 | STR(R32G32B32A32_UINT); |
| 336 | STR(R32G32B32A32_SINT); |
| 337 | STR(R32G32B32A32_SFLOAT); |
| 338 | STR(R64_UINT); |
| 339 | STR(R64_SINT); |
| 340 | STR(R64_SFLOAT); |
| 341 | STR(R64G64_UINT); |
| 342 | STR(R64G64_SINT); |
| 343 | STR(R64G64_SFLOAT); |
| 344 | STR(R64G64B64_UINT); |
| 345 | STR(R64G64B64_SINT); |
| 346 | STR(R64G64B64_SFLOAT); |
| 347 | STR(R64G64B64A64_UINT); |
| 348 | STR(R64G64B64A64_SINT); |
| 349 | STR(R64G64B64A64_SFLOAT); |
| 350 | STR(B10G11R11_UFLOAT_PACK32); |
| 351 | STR(E5B9G9R9_UFLOAT_PACK32); |
| 352 | STR(D16_UNORM); |
| 353 | STR(X8_D24_UNORM_PACK32); |
| 354 | STR(D32_SFLOAT); |
| 355 | STR(S8_UINT); |
| 356 | STR(D16_UNORM_S8_UINT); |
| 357 | STR(D24_UNORM_S8_UINT); |
| 358 | STR(D32_SFLOAT_S8_UINT); |
| 359 | STR(BC1_RGB_UNORM_BLOCK); |
| 360 | STR(BC1_RGB_SRGB_BLOCK); |
| 361 | STR(BC2_UNORM_BLOCK); |
| 362 | STR(BC2_SRGB_BLOCK); |
| 363 | STR(BC3_UNORM_BLOCK); |
| 364 | STR(BC3_SRGB_BLOCK); |
| 365 | STR(BC4_UNORM_BLOCK); |
| 366 | STR(BC4_SNORM_BLOCK); |
| 367 | STR(BC5_UNORM_BLOCK); |
| 368 | STR(BC5_SNORM_BLOCK); |
| 369 | STR(BC6H_UFLOAT_BLOCK); |
| 370 | STR(BC6H_SFLOAT_BLOCK); |
| 371 | STR(BC7_UNORM_BLOCK); |
| 372 | STR(BC7_SRGB_BLOCK); |
| 373 | STR(ETC2_R8G8B8_UNORM_BLOCK); |
| 374 | STR(ETC2_R8G8B8A1_UNORM_BLOCK); |
| 375 | STR(ETC2_R8G8B8A8_UNORM_BLOCK); |
| 376 | STR(EAC_R11_UNORM_BLOCK); |
| 377 | STR(EAC_R11_SNORM_BLOCK); |
| 378 | STR(EAC_R11G11_UNORM_BLOCK); |
| 379 | STR(EAC_R11G11_SNORM_BLOCK); |
| 380 | STR(ASTC_4x4_UNORM_BLOCK); |
| 381 | STR(ASTC_4x4_SRGB_BLOCK); |
| 382 | STR(ASTC_5x4_UNORM_BLOCK); |
| 383 | STR(ASTC_5x4_SRGB_BLOCK); |
| 384 | STR(ASTC_5x5_UNORM_BLOCK); |
| 385 | STR(ASTC_5x5_SRGB_BLOCK); |
| 386 | STR(ASTC_6x5_UNORM_BLOCK); |
| 387 | STR(ASTC_6x5_SRGB_BLOCK); |
| 388 | STR(ASTC_6x6_UNORM_BLOCK); |
| 389 | STR(ASTC_6x6_SRGB_BLOCK); |
| 390 | STR(ASTC_8x5_UNORM_BLOCK); |
| 391 | STR(ASTC_8x5_SRGB_BLOCK); |
| 392 | STR(ASTC_8x6_UNORM_BLOCK); |
| 393 | STR(ASTC_8x6_SRGB_BLOCK); |
| 394 | STR(ASTC_8x8_UNORM_BLOCK); |
| 395 | STR(ASTC_8x8_SRGB_BLOCK); |
| 396 | STR(ASTC_10x5_UNORM_BLOCK); |
| 397 | STR(ASTC_10x5_SRGB_BLOCK); |
| 398 | STR(ASTC_10x6_UNORM_BLOCK); |
| 399 | STR(ASTC_10x6_SRGB_BLOCK); |
| 400 | STR(ASTC_10x8_UNORM_BLOCK); |
| 401 | STR(ASTC_10x8_SRGB_BLOCK); |
| 402 | STR(ASTC_10x10_UNORM_BLOCK); |
| 403 | STR(ASTC_10x10_SRGB_BLOCK); |
| 404 | STR(ASTC_12x10_UNORM_BLOCK); |
| 405 | STR(ASTC_12x10_SRGB_BLOCK); |
| 406 | STR(ASTC_12x12_UNORM_BLOCK); |
| 407 | STR(ASTC_12x12_SRGB_BLOCK); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 408 | #undef STR |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 409 | default: |
| 410 | return "UNKNOWN_FORMAT"; |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 411 | } |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 412 | } |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 413 | #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 414 | static const char *VkPresentModeString(VkPresentModeKHR mode) { |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 415 | switch (mode) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 416 | #define STR(r) \ |
| 417 | case VK_PRESENT_MODE_##r: \ |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 418 | return #r |
| 419 | STR(IMMEDIATE_KHR); |
| 420 | STR(MAILBOX_KHR); |
| 421 | STR(FIFO_KHR); |
| 422 | STR(FIFO_RELAXED_KHR); |
| 423 | #undef STR |
| 424 | default: |
| 425 | return "UNKNOWN_FORMAT"; |
| 426 | } |
| 427 | } |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 428 | #endif |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 429 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 430 | static void AppDevInitFormats(struct AppDev *dev) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 431 | VkFormat f; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 432 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 433 | for (f = 0; f < VK_FORMAT_RANGE_SIZE; f++) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 434 | const VkFormat fmt = f; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 435 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 436 | vkGetPhysicalDeviceFormatProperties(dev->gpu->obj, fmt, &dev->format_props[f]); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 440 | static void ExtractVersion(uint32_t version, uint32_t *major, uint32_t *minor, uint32_t *patch) { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 441 | *major = version >> 22; |
| 442 | *minor = (version >> 12) & 0x3ff; |
| 443 | *patch = version & 0xfff; |
| 444 | } |
| 445 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 446 | static void AppGetPhysicalDeviceLayerExtensions(struct AppGpu *gpu, char *layer_name, uint32_t *extension_count, |
| 447 | VkExtensionProperties **extension_properties) { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 448 | VkResult err; |
| 449 | uint32_t ext_count = 0; |
| 450 | VkExtensionProperties *ext_ptr = NULL; |
| 451 | |
| 452 | /* repeat get until VK_INCOMPLETE goes away */ |
| 453 | do { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 454 | err = vkEnumerateDeviceExtensionProperties(gpu->obj, layer_name, &ext_count, NULL); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 455 | assert(!err); |
| 456 | |
| 457 | if (ext_ptr) { |
| 458 | free(ext_ptr); |
| 459 | } |
| 460 | ext_ptr = malloc(ext_count * sizeof(VkExtensionProperties)); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 461 | err = vkEnumerateDeviceExtensionProperties(gpu->obj, layer_name, &ext_count, ext_ptr); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 462 | } while (err == VK_INCOMPLETE); |
| 463 | assert(!err); |
| 464 | |
| 465 | *extension_count = ext_count; |
| 466 | *extension_properties = ext_ptr; |
| 467 | } |
| 468 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 469 | static void AppDevInit(struct AppDev *dev, struct AppGpu *gpu) { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 470 | VkDeviceCreateInfo info = { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 471 | .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 472 | .pNext = NULL, |
Tony Barbour | 8173093 | 2016-10-28 13:52:29 -0600 | [diff] [blame] | 473 | .flags = 0, |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 474 | .queueCreateInfoCount = 0, |
| 475 | .pQueueCreateInfos = NULL, |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 476 | .enabledLayerCount = 0, |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 477 | .ppEnabledLayerNames = NULL, |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 478 | .enabledExtensionCount = 0, |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 479 | .ppEnabledExtensionNames = NULL, |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 480 | }; |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 481 | VkResult U_ASSERT_ONLY err; |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 482 | |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 483 | // Device extensions |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 484 | AppGetPhysicalDeviceLayerExtensions(gpu, NULL, &gpu->device_extension_count, &gpu->device_extensions); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 485 | |
Courtney Goeltzenleuchter | 9e42b88 | 2015-06-25 16:24:36 -0600 | [diff] [blame] | 486 | fflush(stdout); |
| 487 | |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 488 | /* request all queues */ |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 489 | info.queueCreateInfoCount = gpu->queue_count; |
| 490 | info.pQueueCreateInfos = gpu->queue_reqs; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 491 | |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 492 | info.enabledLayerCount = 0; |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 493 | info.ppEnabledLayerNames = NULL; |
Jon Ashburn | 4ead55c | 2016-03-25 12:47:06 -0600 | [diff] [blame] | 494 | info.enabledExtensionCount = 0; |
| 495 | info.ppEnabledExtensionNames = NULL; |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 496 | dev->gpu = gpu; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 497 | err = vkCreateDevice(gpu->obj, &info, NULL, &dev->obj); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 498 | if (err) |
| 499 | ERR_EXIT(err); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 500 | } |
| 501 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 502 | static void AppDevDestroy(struct AppDev *dev) { |
Tony Barbour | c7e3fbd | 2016-11-10 16:45:15 -0700 | [diff] [blame] | 503 | vkDeviceWaitIdle(dev->obj); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 504 | vkDestroyDevice(dev->obj, NULL); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 505 | } |
| 506 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 507 | static void AppGetGlobalLayerExtensions(char *layer_name, uint32_t *extension_count, VkExtensionProperties **extension_properties) { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 508 | VkResult err; |
| 509 | uint32_t ext_count = 0; |
| 510 | VkExtensionProperties *ext_ptr = NULL; |
| 511 | |
| 512 | /* repeat get until VK_INCOMPLETE goes away */ |
| 513 | do { |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 514 | // gets the extension count if the last parameter is NULL |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 515 | err = vkEnumerateInstanceExtensionProperties(layer_name, &ext_count, NULL); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 516 | assert(!err); |
| 517 | |
| 518 | if (ext_ptr) { |
| 519 | free(ext_ptr); |
| 520 | } |
| 521 | ext_ptr = malloc(ext_count * sizeof(VkExtensionProperties)); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 522 | // gets the extension properties if the last parameter is not NULL |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 523 | err = vkEnumerateInstanceExtensionProperties(layer_name, &ext_count, ext_ptr); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 524 | } while (err == VK_INCOMPLETE); |
| 525 | assert(!err); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 526 | *extension_count = ext_count; |
| 527 | *extension_properties = ext_ptr; |
| 528 | } |
| 529 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 530 | /* Gets a list of layer and instance extensions */ |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 531 | static void AppGetInstanceExtensions(struct AppInstance *inst) { |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 532 | VkResult U_ASSERT_ONLY err; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 533 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 534 | uint32_t count = 0; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 535 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 536 | /* Scan layers */ |
| 537 | VkLayerProperties *global_layer_properties = NULL; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 538 | struct LayerExtensionList *global_layers = NULL; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 539 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 540 | do { |
| 541 | err = vkEnumerateInstanceLayerProperties(&count, NULL); |
| 542 | assert(!err); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 543 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 544 | if (global_layer_properties) { |
| 545 | free(global_layer_properties); |
| 546 | } |
| 547 | global_layer_properties = malloc(sizeof(VkLayerProperties) * count); |
| 548 | assert(global_layer_properties); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 549 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 550 | if (global_layers) { |
| 551 | free(global_layers); |
| 552 | } |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 553 | global_layers = malloc(sizeof(struct LayerExtensionList) * count); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 554 | assert(global_layers); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 555 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 556 | err = vkEnumerateInstanceLayerProperties(&count, global_layer_properties); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 557 | } while (err == VK_INCOMPLETE); |
| 558 | assert(!err); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 559 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 560 | inst->global_layer_count = count; |
| 561 | inst->global_layers = global_layers; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 562 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 563 | for (uint32_t i = 0; i < inst->global_layer_count; i++) { |
| 564 | VkLayerProperties *src_info = &global_layer_properties[i]; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 565 | struct LayerExtensionList *dst_info = &inst->global_layers[i]; |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 566 | memcpy(&dst_info->layer_properties, src_info, sizeof(VkLayerProperties)); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 567 | |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 568 | // Save away layer extension info for report |
| 569 | // Gets layer extensions, if first parameter is not NULL |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 570 | AppGetGlobalLayerExtensions(src_info->layerName, &dst_info->extension_count, &dst_info->extension_properties); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 571 | } |
| 572 | free(global_layer_properties); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 573 | |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 574 | // Collect global extensions |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 575 | inst->global_extension_count = 0; |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 576 | // Gets instance extensions, if no layer was specified in the first |
| 577 | // paramteter |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 578 | AppGetGlobalLayerExtensions(NULL, &inst->global_extension_count, &inst->global_extensions); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 579 | } |
| 580 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 581 | static void AppCreateInstance(struct AppInstance *inst) { |
| 582 | AppGetInstanceExtensions(inst); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 583 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 584 | //---Build a list of extensions to load--- |
| 585 | #define MAX_EXTENSIONS 4 |
| 586 | uint32_t i = 0; |
| 587 | uint32_t ext_count = 0; |
| 588 | const char *ext_names[MAX_EXTENSIONS]; // array of string pointers to |
| 589 | // extension names |
| 590 | for (i = 0; (i < inst->global_extension_count); i++) { |
| 591 | const char *found_name = inst->global_extensions[i].extensionName; |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 592 | if (!strcmp(VK_KHR_SURFACE_EXTENSION_NAME, found_name)) { |
| 593 | ext_names[ext_count++] = VK_KHR_SURFACE_EXTENSION_NAME; |
| 594 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 597 | #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WAYLAND_KHR) || \ |
| 598 | defined(VK_USE_PLATFORM_WIN32_KHR) || defined(VK_USE_PLATFORM_ANDROID_KHR) |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 599 | if (ext_count) |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 600 | for (i = 0; ((i < inst->global_extension_count) && (ext_count < MAX_EXTENSIONS)); i++) { |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 601 | const char *found_name = inst->global_extensions[i].extensionName; |
| 602 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 603 | if (!strcmp(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, found_name)) { |
| 604 | ext_names[ext_count++] = VK_KHR_WIN32_SURFACE_EXTENSION_NAME; |
| 605 | } |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 606 | #elif VK_USE_PLATFORM_XCB_KHR |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 607 | if (!strcmp(VK_KHR_XCB_SURFACE_EXTENSION_NAME, found_name)) { |
| 608 | ext_names[ext_count++] = VK_KHR_XCB_SURFACE_EXTENSION_NAME; |
| 609 | } |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 610 | #elif VK_USE_PLATFORM_XLIB_KHR |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 611 | if (!strcmp(VK_KHR_XLIB_SURFACE_EXTENSION_NAME, found_name)) { |
| 612 | ext_names[ext_count++] = VK_KHR_XLIB_SURFACE_EXTENSION_NAME; |
| 613 | } |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 614 | #elif VK_USE_PLATFORM_WAYLAND_KHR |
| 615 | if (!strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, found_name)) { |
| 616 | ext_names[ext_count++] = VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME; |
| 617 | } |
| 618 | #elif VK_USE_PLATFORM_ANDROID_KHR |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 619 | if (!strcmp(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, found_name)) { |
| 620 | ext_names[ext_count++] = VK_KHR_ANDROID_SURFACE_EXTENSION_NAME; |
| 621 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 622 | #endif |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 623 | } |
Karl Schultz | fad114e | 2016-09-12 13:28:09 -0600 | [diff] [blame] | 624 | #endif |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 625 | // If we don't find the KHR_SURFACE extension and at least one other |
| 626 | // device-specific extension, |
| 627 | // then give up on reporting presentable surface formats." |
| 628 | if (ext_count < 2) |
| 629 | ext_count = 0; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 630 | //---------------------------------------- |
| 631 | |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 632 | const VkApplicationInfo app_info = { |
| 633 | .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, |
| 634 | .pNext = NULL, |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 635 | .pApplicationName = APP_SHORT_NAME, |
| 636 | .applicationVersion = 1, |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 637 | .pEngineName = APP_SHORT_NAME, |
| 638 | .engineVersion = 1, |
Jon Ashburn | d3995c9 | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 639 | .apiVersion = VK_API_VERSION_1_0, |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 640 | }; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 641 | |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 642 | VkInstanceCreateInfo inst_info = { |
| 643 | .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, |
| 644 | .pNext = NULL, |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 645 | .pApplicationInfo = &app_info, |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 646 | .enabledLayerCount = 0, |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 647 | .ppEnabledLayerNames = NULL, |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 648 | .enabledExtensionCount = ext_count, |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 649 | .ppEnabledExtensionNames = ext_names, |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 650 | }; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 651 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 652 | VkDebugReportCallbackCreateInfoEXT dbg_info; |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 653 | memset(&dbg_info, 0, sizeof(dbg_info)); |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 654 | dbg_info.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 655 | dbg_info.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 656 | dbg_info.pfnCallback = DbgCallback; |
Courtney Goeltzenleuchter | f412d57 | 2015-12-03 13:50:49 -0700 | [diff] [blame] | 657 | inst_info.pNext = &dbg_info; |
| 658 | |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 659 | VkResult U_ASSERT_ONLY err; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 660 | err = vkCreateInstance(&inst_info, NULL, &inst->instance); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 661 | if (err == VK_ERROR_INCOMPATIBLE_DRIVER) { |
| 662 | printf("Cannot create Vulkan instance.\n"); |
| 663 | ERR_EXIT(err); |
| 664 | } else if (err) { |
| 665 | ERR_EXIT(err); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 666 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 667 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 668 | if (ext_count > 0) { |
| 669 | //--Load Extensions-- |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 670 | #define GET_INSTANCE_PROC_ADDR(ENTRYPOINT) \ |
| 671 | { inst->ENTRYPOINT = (void *)vkGetInstanceProcAddr(inst->instance, #ENTRYPOINT); } |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 672 | GET_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceSurfaceSupportKHR) |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 673 | GET_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 674 | GET_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceSurfaceFormatsKHR) |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 675 | GET_INSTANCE_PROC_ADDR(vkGetPhysicalDeviceSurfacePresentModesKHR) |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 676 | #undef GET_INSTANCE_PROC_ADDR |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 677 | } |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 678 | } |
| 679 | |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 680 | //----------------------------------------------------------- |
| 681 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 682 | static void AppDestroyInstance(struct AppInstance *inst) { |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 683 | free(inst->global_extensions); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 684 | vkDestroyInstance(inst->instance, NULL); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 685 | } |
| 686 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 687 | static void AppGpuInit(struct AppGpu *gpu, uint32_t id, VkPhysicalDevice obj) { |
Ian Elliott | aae1a57 | 2015-02-04 16:48:37 -0700 | [diff] [blame] | 688 | uint32_t i; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 689 | |
| 690 | memset(gpu, 0, sizeof(*gpu)); |
| 691 | |
| 692 | gpu->id = id; |
| 693 | gpu->obj = obj; |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 694 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 695 | vkGetPhysicalDeviceProperties(gpu->obj, &gpu->props); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 696 | |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 697 | /* get queue count */ |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 698 | vkGetPhysicalDeviceQueueFamilyProperties(gpu->obj, &gpu->queue_count, NULL); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 699 | |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 700 | gpu->queue_props = malloc(sizeof(gpu->queue_props[0]) * gpu->queue_count); |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 701 | |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 702 | if (!gpu->queue_props) |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 703 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 704 | vkGetPhysicalDeviceQueueFamilyProperties(gpu->obj, &gpu->queue_count, gpu->queue_props); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 705 | |
| 706 | /* set up queue requests */ |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 707 | gpu->queue_reqs = malloc(sizeof(*gpu->queue_reqs) * gpu->queue_count); |
| 708 | if (!gpu->queue_reqs) |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 709 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 710 | for (i = 0; i < gpu->queue_count; i++) { |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 711 | float *queue_priorities = malloc(gpu->queue_props[i].queueCount * sizeof(float)); |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 712 | if (!queue_priorities) |
| 713 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 714 | memset(queue_priorities, 0, gpu->queue_props[i].queueCount * sizeof(float)); |
Courtney Goeltzenleuchter | ea97564 | 2015-09-16 16:23:55 -0600 | [diff] [blame] | 715 | gpu->queue_reqs[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 716 | gpu->queue_reqs[i].pNext = NULL; |
Tony Barbour | 8173093 | 2016-10-28 13:52:29 -0600 | [diff] [blame] | 717 | gpu->queue_reqs[i].flags = 0; |
Chris Forbes | fa6d36e | 2015-07-11 19:11:39 +1200 | [diff] [blame] | 718 | gpu->queue_reqs[i].queueFamilyIndex = i; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 719 | gpu->queue_reqs[i].queueCount = gpu->queue_props[i].queueCount; |
Courtney Goeltzenleuchter | d3a8d36 | 2015-10-23 10:37:02 -0600 | [diff] [blame] | 720 | gpu->queue_reqs[i].pQueuePriorities = queue_priorities; |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 721 | } |
| 722 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 723 | vkGetPhysicalDeviceMemoryProperties(gpu->obj, &gpu->memory_props); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 724 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 725 | vkGetPhysicalDeviceFeatures(gpu->obj, &gpu->features); |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 726 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 727 | AppDevInit(&gpu->dev, gpu); |
| 728 | AppDevInitFormats(&gpu->dev); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 729 | } |
| 730 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 731 | static void AppGpuDestroy(struct AppGpu *gpu) { |
| 732 | AppDevDestroy(&gpu->dev); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 733 | free(gpu->device_extensions); |
Jon Ashburn | 2c09483 | 2015-12-11 17:11:43 -0700 | [diff] [blame] | 734 | |
Courtney Goeltzenleuchter | d3a8d36 | 2015-10-23 10:37:02 -0600 | [diff] [blame] | 735 | for (uint32_t i = 0; i < gpu->queue_count; i++) { |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 736 | free((void *)gpu->queue_reqs[i].pQueuePriorities); |
Courtney Goeltzenleuchter | d3a8d36 | 2015-10-23 10:37:02 -0600 | [diff] [blame] | 737 | } |
Jon Ashburn | 2c09483 | 2015-12-11 17:11:43 -0700 | [diff] [blame] | 738 | free(gpu->queue_reqs); |
Chia-I Wu | 46c29dd | 2014-12-02 21:09:20 +0800 | [diff] [blame] | 739 | free(gpu->queue_props); |
| 740 | } |
| 741 | |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 742 | // clang-format off |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 743 | |
| 744 | //----------------------------------------------------------- |
| 745 | |
| 746 | //---------------------------Win32--------------------------- |
| 747 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 748 | |
| 749 | // MS-Windows event handling function: |
| 750 | LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 751 | return (DefWindowProc(hWnd, uMsg, wParam, lParam)); |
| 752 | } |
| 753 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 754 | static void AppCreateWin32Window(struct AppInstance *inst) { |
| 755 | inst->h_instance = GetModuleHandle(NULL); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 756 | |
| 757 | WNDCLASSEX win_class; |
| 758 | |
| 759 | // Initialize the window class structure: |
| 760 | win_class.cbSize = sizeof(WNDCLASSEX); |
| 761 | win_class.style = CS_HREDRAW | CS_VREDRAW; |
| 762 | win_class.lpfnWndProc = WndProc; |
| 763 | win_class.cbClsExtra = 0; |
| 764 | win_class.cbWndExtra = 0; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 765 | win_class.hInstance = inst->h_instance; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 766 | win_class.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
| 767 | win_class.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 768 | win_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); |
| 769 | win_class.lpszMenuName = NULL; |
| 770 | win_class.lpszClassName = APP_SHORT_NAME; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 771 | win_class.hInstance = inst->h_instance; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 772 | win_class.hIconSm = LoadIcon(NULL, IDI_WINLOGO); |
| 773 | // Register window class: |
| 774 | if (!RegisterClassEx(&win_class)) { |
| 775 | // It didn't work, so try to give a useful error: |
Rene Lindsay | 54cf48a | 2016-06-13 17:20:39 -0600 | [diff] [blame] | 776 | printf("Failed to register the window class!\n"); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 777 | fflush(stdout); |
| 778 | exit(1); |
| 779 | } |
| 780 | // Create window with the registered class: |
| 781 | RECT wr = { 0, 0, inst->width, inst->height }; |
| 782 | AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 783 | inst->h_wnd = CreateWindowEx(0, |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 784 | APP_SHORT_NAME, // class name |
| 785 | APP_SHORT_NAME, // app name |
| 786 | //WS_VISIBLE | WS_SYSMENU | |
| 787 | WS_OVERLAPPEDWINDOW, // window style |
| 788 | 100, 100, // x/y coords |
| 789 | wr.right - wr.left, // width |
| 790 | wr.bottom - wr.top, // height |
| 791 | NULL, // handle to parent |
| 792 | NULL, // handle to menu |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 793 | inst->h_instance, // hInstance |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 794 | NULL); // no extra parameters |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 795 | if (!inst->h_wnd) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 796 | // It didn't work, so try to give a useful error: |
Rene Lindsay | 54cf48a | 2016-06-13 17:20:39 -0600 | [diff] [blame] | 797 | printf("Failed to create a window!\n"); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 798 | fflush(stdout); |
| 799 | exit(1); |
| 800 | } |
| 801 | } |
| 802 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 803 | static void AppCreateWin32Surface(struct AppInstance *inst) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 804 | VkResult U_ASSERT_ONLY err; |
| 805 | VkWin32SurfaceCreateInfoKHR createInfo; |
| 806 | createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; |
| 807 | createInfo.pNext = NULL; |
| 808 | createInfo.flags = 0; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 809 | createInfo.hinstance = inst->h_instance; |
| 810 | createInfo.hwnd = inst->h_wnd; |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 811 | err = vkCreateWin32SurfaceKHR(inst->instance, &createInfo, NULL, &inst->surface); |
| 812 | assert(!err); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 813 | } |
| 814 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 815 | static void AppDestroyWin32Window(struct AppInstance *inst) { |
| 816 | DestroyWindow(inst->h_wnd); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 817 | } |
| 818 | #endif //VK_USE_PLATFORM_WIN32_KHR |
| 819 | //----------------------------------------------------------- |
| 820 | |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 821 | #if defined(VK_USE_PLATFORM_XCB_KHR) || \ |
| 822 | defined(VK_USE_PLATFORM_XLIB_KHR) || \ |
Karl Schultz | fad114e | 2016-09-12 13:28:09 -0600 | [diff] [blame] | 823 | defined(VK_USE_PLATFORM_WIN32_KHR) |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 824 | static void AppDestroySurface(struct AppInstance *inst) { //same for all platforms |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 825 | vkDestroySurfaceKHR(inst->instance, inst->surface, NULL); |
| 826 | } |
Karl Schultz | fad114e | 2016-09-12 13:28:09 -0600 | [diff] [blame] | 827 | #endif |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 828 | |
| 829 | //----------------------------XCB---------------------------- |
Rene Lindsay | 54cf48a | 2016-06-13 17:20:39 -0600 | [diff] [blame] | 830 | |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 831 | #ifdef VK_USE_PLATFORM_XCB_KHR |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 832 | static void AppCreateXcbWindow(struct AppInstance *inst) { |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 833 | //--Init Connection-- |
| 834 | const xcb_setup_t *setup; |
| 835 | xcb_screen_iterator_t iter; |
| 836 | int scr; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 837 | |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 838 | inst->xcb_connection = xcb_connect(NULL, &scr); |
| 839 | if (inst->xcb_connection == NULL) { |
| 840 | printf("XCB failed to connect to the X server.\nExiting ...\n"); |
| 841 | fflush(stdout); |
| 842 | exit(1); |
| 843 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 844 | |
Arda Coskunses | c18eb54 | 2017-01-19 10:41:27 -0700 | [diff] [blame] | 845 | int conn_error = xcb_connection_has_error(inst->xcb_connection); |
| 846 | if (conn_error) { |
| 847 | printf("XCB failed to connect to the X server due to error:%d.\nExiting ...\n", conn_error); |
| 848 | fflush(stdout); |
| 849 | exit(1); |
| 850 | } |
| 851 | |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 852 | setup = xcb_get_setup(inst->xcb_connection); |
| 853 | iter = xcb_setup_roots_iterator(setup); |
| 854 | while (scr-- > 0) { |
| 855 | xcb_screen_next(&iter); |
| 856 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 857 | |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 858 | inst->xcb_screen = iter.data; |
| 859 | //------------------- |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 860 | |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 861 | inst->xcb_window = xcb_generate_id(inst->xcb_connection); |
| 862 | xcb_create_window(inst->xcb_connection, XCB_COPY_FROM_PARENT, inst->xcb_window, |
| 863 | inst->xcb_screen->root, 0, 0, inst->width, inst->height, 0, |
| 864 | XCB_WINDOW_CLASS_INPUT_OUTPUT, inst->xcb_screen->root_visual, |
| 865 | 0, NULL); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 866 | |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 867 | xcb_intern_atom_cookie_t cookie = xcb_intern_atom(inst->xcb_connection, 1, 12, "WM_PROTOCOLS"); |
| 868 | xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(inst->xcb_connection, cookie, 0); |
| 869 | free(reply); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 870 | } |
| 871 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 872 | static void AppCreateXcbSurface(struct AppInstance *inst) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 873 | VkResult U_ASSERT_ONLY err; |
| 874 | VkXcbSurfaceCreateInfoKHR xcb_createInfo; |
| 875 | xcb_createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 876 | xcb_createInfo.pNext = NULL; |
| 877 | xcb_createInfo.flags = 0; |
| 878 | xcb_createInfo.connection = inst->xcb_connection; |
| 879 | xcb_createInfo.window = inst->xcb_window; |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 880 | err = vkCreateXcbSurfaceKHR(inst->instance, &xcb_createInfo, NULL, &inst->surface); |
| 881 | assert(!err); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 882 | } |
| 883 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 884 | static void AppDestroyXcbWindow(struct AppInstance *inst) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 885 | xcb_destroy_window(inst->xcb_connection, inst->xcb_window); |
| 886 | xcb_disconnect(inst->xcb_connection); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 887 | } |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 888 | //VK_USE_PLATFORM_XCB_KHR |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 889 | //----------------------------------------------------------- |
| 890 | |
| 891 | //----------------------------XLib--------------------------- |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 892 | #elif VK_USE_PLATFORM_XLIB_KHR |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 893 | static void AppCreateXlibWindow(struct AppInstance *inst) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 894 | long visualMask = VisualScreenMask; |
| 895 | int numberOfVisuals; |
Rene Lindsay | 54cf48a | 2016-06-13 17:20:39 -0600 | [diff] [blame] | 896 | |
Karl Schultz | 6000787 | 2016-11-14 11:53:08 -0700 | [diff] [blame] | 897 | inst->xlib_display = XOpenDisplay(NULL); |
| 898 | if (inst->xlib_display == NULL) { |
| 899 | printf("XLib failed to connect to the X server.\nExiting ...\n"); |
| 900 | fflush(stdout); |
| 901 | exit(1); |
| 902 | } |
Awais Belal | f231a17 | 2016-11-11 15:13:40 +0500 | [diff] [blame] | 903 | |
Rene Lindsay | 54cf48a | 2016-06-13 17:20:39 -0600 | [diff] [blame] | 904 | XVisualInfo vInfoTemplate={}; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 905 | vInfoTemplate.screen = DefaultScreen(inst->xlib_display); |
| 906 | XVisualInfo *visualInfo = XGetVisualInfo(inst->xlib_display, visualMask, |
| 907 | &vInfoTemplate, &numberOfVisuals); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 908 | inst->xlib_window = XCreateWindow( |
| 909 | inst->xlib_display, RootWindow(inst->xlib_display, vInfoTemplate.screen), 0, 0, |
| 910 | inst->width, inst->height, 0, visualInfo->depth, InputOutput, |
Rene Lindsay | 54cf48a | 2016-06-13 17:20:39 -0600 | [diff] [blame] | 911 | visualInfo->visual, 0, NULL); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 912 | |
Rene Lindsay | aad516e | 2016-06-21 16:42:19 -0600 | [diff] [blame] | 913 | XSync(inst->xlib_display,false); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 914 | } |
| 915 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 916 | static void AppCreateXlibSurface(struct AppInstance *inst) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 917 | VkResult U_ASSERT_ONLY err; |
| 918 | VkXlibSurfaceCreateInfoKHR createInfo; |
| 919 | createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; |
| 920 | createInfo.pNext = NULL; |
| 921 | createInfo.flags = 0; |
| 922 | createInfo.dpy = inst->xlib_display; |
| 923 | createInfo.window = inst->xlib_window; |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 924 | err = vkCreateXlibSurfaceKHR(inst->instance, &createInfo, NULL, &inst->surface); |
| 925 | assert(!err); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 926 | } |
| 927 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 928 | static void AppDestroyXlibWindow(struct AppInstance *inst) { |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 929 | XDestroyWindow(inst->xlib_display, inst->xlib_window); |
| 930 | XCloseDisplay(inst->xlib_display); |
| 931 | } |
| 932 | #endif //VK_USE_PLATFORM_XLIB_KHR |
| 933 | //----------------------------------------------------------- |
| 934 | |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 935 | #if defined(VK_USE_PLATFORM_XCB_KHR) || \ |
| 936 | defined(VK_USE_PLATFORM_XLIB_KHR) || \ |
Karl Schultz | fad114e | 2016-09-12 13:28:09 -0600 | [diff] [blame] | 937 | defined(VK_USE_PLATFORM_WIN32_KHR) |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 938 | static int AppDumpSurfaceFormats(struct AppInstance *inst, struct AppGpu *gpu){ |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 939 | // Get the list of VkFormat's that are supported: |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 940 | VkResult U_ASSERT_ONLY err; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 941 | uint32_t format_count = 0; |
| 942 | err = inst->vkGetPhysicalDeviceSurfaceFormatsKHR(gpu->obj, inst->surface, &format_count, NULL); |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 943 | assert(!err); |
| 944 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 945 | VkSurfaceFormatKHR *surf_formats = (VkSurfaceFormatKHR *)malloc(format_count * sizeof(VkSurfaceFormatKHR)); |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 946 | if (!surf_formats) |
| 947 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 948 | err = inst->vkGetPhysicalDeviceSurfaceFormatsKHR(gpu->obj, inst->surface, &format_count, surf_formats); |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 949 | assert(!err); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 950 | printf("Formats:\t\tcount = %d\n", format_count); |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 951 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 952 | for (uint32_t i = 0; i < format_count; i++) { |
| 953 | printf("\t%s\n", VkFormatString(surf_formats[i].format)); |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 954 | } |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 955 | fflush(stdout); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 956 | return format_count; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 957 | } |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 958 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 959 | static int AppDumpSurfacePresentModes(struct AppInstance *inst, struct AppGpu *gpu) { |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 960 | // Get the list of VkPresentMode's that are supported: |
| 961 | VkResult U_ASSERT_ONLY err; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 962 | uint32_t present_mode_count = 0; |
| 963 | err = inst->vkGetPhysicalDeviceSurfacePresentModesKHR(gpu->obj, inst->surface, &present_mode_count, NULL); |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 964 | assert(!err); |
| 965 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 966 | VkPresentModeKHR *surf_present_modes = (VkPresentModeKHR *)malloc(present_mode_count * sizeof(VkPresentInfoKHR)); |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 967 | if (!surf_present_modes) |
| 968 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 969 | err = inst->vkGetPhysicalDeviceSurfacePresentModesKHR(gpu->obj, inst->surface, &present_mode_count, surf_present_modes); |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 970 | assert(!err); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 971 | printf("Present Modes:\t\tcount = %d\n", present_mode_count); |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 972 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 973 | for (uint32_t i = 0; i < present_mode_count; i++) { |
| 974 | printf("\t%s\n", VkPresentModeString(surf_present_modes[i])); |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 975 | } |
| 976 | printf("\n"); |
| 977 | fflush(stdout); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 978 | return present_mode_count; |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 979 | } |
Karl Schultz | fad114e | 2016-09-12 13:28:09 -0600 | [diff] [blame] | 980 | #endif |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 981 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 982 | static void AppDevDumpFormatProps(const struct AppDev *dev, VkFormat fmt) |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 983 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 984 | const VkFormatProperties *props = &dev->format_props[fmt]; |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 985 | struct { |
| 986 | const char *name; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 987 | VkFlags flags; |
Mark Lobodzinski | 4b36dd4 | 2015-09-03 15:21:52 -0600 | [diff] [blame] | 988 | } features[3]; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 989 | |
Mark Lobodzinski | 4b36dd4 | 2015-09-03 15:21:52 -0600 | [diff] [blame] | 990 | features[0].name = "linearTiling FormatFeatureFlags"; |
| 991 | features[0].flags = props->linearTilingFeatures; |
| 992 | features[1].name = "optimalTiling FormatFeatureFlags"; |
| 993 | features[1].flags = props->optimalTilingFeatures; |
| 994 | features[2].name = "bufferFeatures FormatFeatureFlags"; |
| 995 | features[2].flags = props->bufferFeatures; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 996 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 997 | printf("\nFORMAT_%s:", VkFormatString(fmt)); |
Mark Lobodzinski | ce165d8 | 2016-08-18 08:50:16 -0600 | [diff] [blame] | 998 | for (uint32_t i = 0; i < ARRAY_SIZE(features); i++) { |
Mark Lobodzinski | 4b36dd4 | 2015-09-03 15:21:52 -0600 | [diff] [blame] | 999 | printf("\n\t%s:", features[i].name); |
| 1000 | if (features[i].flags == 0) { |
| 1001 | printf("\n\t\tNone"); |
| 1002 | } else { |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1003 | printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s", |
| 1004 | ((features[i].flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) ? "\n\t\tVK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT" : ""), //0x0001 |
| 1005 | ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_IMAGE_BIT" : ""), //0x0002 |
| 1006 | ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT) ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT" : ""), //0x0004 |
| 1007 | ((features[i].flags & VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT) ? "\n\t\tVK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT" : ""), //0x0008 |
| 1008 | ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT) ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT" : ""), //0x0010 |
| 1009 | ((features[i].flags & VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT) ? "\n\t\tVK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT" : ""), //0x0020 |
| 1010 | ((features[i].flags & VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT) ? "\n\t\tVK_FORMAT_FEATURE_VERTEX_BUFFER_BIT" : ""), //0x0040 |
| 1011 | ((features[i].flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) ? "\n\t\tVK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT" : ""), //0x0080 |
| 1012 | ((features[i].flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT) ? "\n\t\tVK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT" : ""), //0x0100 |
| 1013 | ((features[i].flags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) ? "\n\t\tVK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT" : ""), //0x0200 |
| 1014 | ((features[i].flags & VK_FORMAT_FEATURE_BLIT_SRC_BIT) ? "\n\t\tVK_FORMAT_FEATURE_BLIT_SRC_BIT" : ""), //0x0400 |
| 1015 | ((features[i].flags & VK_FORMAT_FEATURE_BLIT_DST_BIT) ? "\n\t\tVK_FORMAT_FEATURE_BLIT_DST_BIT" : ""), //0x0800 |
| 1016 | ((features[i].flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) ? "\n\t\tVK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT" : ""), //0x1000 |
| 1017 | ((features[i].flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG) ? "\n\t\tVK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG" : "")); //0x2000 |
Mark Lobodzinski | 4b36dd4 | 2015-09-03 15:21:52 -0600 | [diff] [blame] | 1018 | } |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1019 | } |
Mark Lobodzinski | 4b36dd4 | 2015-09-03 15:21:52 -0600 | [diff] [blame] | 1020 | printf("\n"); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1021 | } |
| 1022 | |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1023 | |
| 1024 | static void |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1025 | AppDevDump(const struct AppDev *dev) |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1026 | { |
Rene Lindsay | 7850344 | 2016-06-21 17:37:26 -0600 | [diff] [blame] | 1027 | printf("Format Properties:\n"); |
| 1028 | printf("=================="); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1029 | VkFormat fmt; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1030 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1031 | for (fmt = 0; fmt < VK_FORMAT_RANGE_SIZE; fmt++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1032 | AppDevDumpFormatProps(dev, fmt); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1033 | } |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1034 | } |
| 1035 | |
Mike Stroyan | 009d8ca | 2015-05-27 13:09:15 -0600 | [diff] [blame] | 1036 | #ifdef _WIN32 |
| 1037 | #define PRINTF_SIZE_T_SPECIFIER "%Iu" |
| 1038 | #else |
| 1039 | #define PRINTF_SIZE_T_SPECIFIER "%zu" |
| 1040 | #endif |
| 1041 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1042 | static void AppGpuDumpFeatures(const struct AppGpu *gpu) |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 1043 | { |
| 1044 | const VkPhysicalDeviceFeatures *features = &gpu->features; |
| 1045 | |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1046 | printf("VkPhysicalDeviceFeatures:\n"); |
| 1047 | printf("=========================\n"); |
| 1048 | |
| 1049 | printf("\trobustBufferAccess = %u\n", features->robustBufferAccess ); |
| 1050 | printf("\tfullDrawIndexUint32 = %u\n", features->fullDrawIndexUint32 ); |
| 1051 | printf("\timageCubeArray = %u\n", features->imageCubeArray ); |
| 1052 | printf("\tindependentBlend = %u\n", features->independentBlend ); |
| 1053 | printf("\tgeometryShader = %u\n", features->geometryShader ); |
| 1054 | printf("\ttessellationShader = %u\n", features->tessellationShader ); |
| 1055 | printf("\tsampleRateShading = %u\n", features->sampleRateShading ); |
Chia-I Wu | c04519c | 2015-10-27 17:53:18 +0800 | [diff] [blame] | 1056 | printf("\tdualSrcBlend = %u\n", features->dualSrcBlend ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1057 | printf("\tlogicOp = %u\n", features->logicOp ); |
| 1058 | printf("\tmultiDrawIndirect = %u\n", features->multiDrawIndirect ); |
Jon Ashburn | 0bdccbb | 2015-12-31 12:47:52 -0700 | [diff] [blame] | 1059 | printf("\tdrawIndirectFirstInstance = %u\n", features->drawIndirectFirstInstance ); |
Chia-I Wu | c04519c | 2015-10-27 17:53:18 +0800 | [diff] [blame] | 1060 | printf("\tdepthClamp = %u\n", features->depthClamp ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1061 | printf("\tdepthBiasClamp = %u\n", features->depthBiasClamp ); |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 1062 | printf("\tfillModeNonSolid = %u\n", features->fillModeNonSolid ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1063 | printf("\tdepthBounds = %u\n", features->depthBounds ); |
| 1064 | printf("\twideLines = %u\n", features->wideLines ); |
| 1065 | printf("\tlargePoints = %u\n", features->largePoints ); |
| 1066 | printf("\ttextureCompressionETC2 = %u\n", features->textureCompressionETC2 ); |
| 1067 | printf("\ttextureCompressionASTC_LDR = %u\n", features->textureCompressionASTC_LDR ); |
| 1068 | printf("\ttextureCompressionBC = %u\n", features->textureCompressionBC ); |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1069 | printf("\tocclusionQueryPrecise = %u\n", features->occlusionQueryPrecise ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1070 | printf("\tpipelineStatisticsQuery = %u\n", features->pipelineStatisticsQuery ); |
Chia-I Wu | fd4bfc4 | 2015-10-26 17:04:32 +0800 | [diff] [blame] | 1071 | printf("\tvertexSideEffects = %u\n", features->vertexPipelineStoresAndAtomics ); |
| 1072 | printf("\ttessellationSideEffects = %u\n", features->fragmentStoresAndAtomics ); |
| 1073 | printf("\tgeometrySideEffects = %u\n", features->shaderTessellationAndGeometryPointSize ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1074 | printf("\tshaderImageGatherExtended = %u\n", features->shaderImageGatherExtended ); |
| 1075 | printf("\tshaderStorageImageExtendedFormats = %u\n", features->shaderStorageImageExtendedFormats ); |
| 1076 | printf("\tshaderStorageImageMultisample = %u\n", features->shaderStorageImageMultisample ); |
Chia-I Wu | 221f2f2 | 2015-10-27 18:52:05 +0800 | [diff] [blame] | 1077 | printf("\tshaderStorageImageReadWithoutFormat = %u\n", features->shaderStorageImageReadWithoutFormat ); |
| 1078 | printf("\tshaderStorageImageWriteWithoutFormat = %u\n", features->shaderStorageImageWriteWithoutFormat ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1079 | printf("\tshaderUniformBufferArrayDynamicIndexing = %u\n", features->shaderUniformBufferArrayDynamicIndexing); |
| 1080 | printf("\tshaderSampledImageArrayDynamicIndexing = %u\n", features->shaderSampledImageArrayDynamicIndexing ); |
| 1081 | printf("\tshaderStorageBufferArrayDynamicIndexing = %u\n", features->shaderStorageBufferArrayDynamicIndexing); |
| 1082 | printf("\tshaderStorageImageArrayDynamicIndexing = %u\n", features->shaderStorageImageArrayDynamicIndexing ); |
| 1083 | printf("\tshaderClipDistance = %u\n", features->shaderClipDistance ); |
| 1084 | printf("\tshaderCullDistance = %u\n", features->shaderCullDistance ); |
| 1085 | printf("\tshaderFloat64 = %u\n", features->shaderFloat64 ); |
| 1086 | printf("\tshaderInt64 = %u\n", features->shaderInt64 ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1087 | printf("\tshaderInt16 = %u\n", features->shaderInt16 ); |
| 1088 | printf("\tshaderResourceResidency = %u\n", features->shaderResourceResidency ); |
Chia-I Wu | d3f9934 | 2015-10-27 18:58:00 +0800 | [diff] [blame] | 1089 | printf("\tshaderResourceMinLod = %u\n", features->shaderResourceMinLod ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1090 | printf("\talphaToOne = %u\n", features->alphaToOne ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1091 | printf("\tsparseBinding = %u\n", features->sparseBinding ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1092 | printf("\tsparseResidencyBuffer = %u\n", features->sparseResidencyBuffer ); |
| 1093 | printf("\tsparseResidencyImage2D = %u\n", features->sparseResidencyImage2D ); |
| 1094 | printf("\tsparseResidencyImage3D = %u\n", features->sparseResidencyImage3D ); |
| 1095 | printf("\tsparseResidency2Samples = %u\n", features->sparseResidency2Samples ); |
| 1096 | printf("\tsparseResidency4Samples = %u\n", features->sparseResidency4Samples ); |
| 1097 | printf("\tsparseResidency8Samples = %u\n", features->sparseResidency8Samples ); |
| 1098 | printf("\tsparseResidency16Samples = %u\n", features->sparseResidency16Samples ); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1099 | printf("\tsparseResidencyAliased = %u\n", features->sparseResidencyAliased ); |
Chia-I Wu | d507261 | 2015-10-27 18:52:46 +0800 | [diff] [blame] | 1100 | printf("\tvariableMultisampleRate = %u\n", features->variableMultisampleRate ); |
Karl Schultz | c183840 | 2016-10-07 08:51:59 -0600 | [diff] [blame] | 1101 | printf("\tinheritedQueries = %u\n", features->inheritedQueries ); |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 1102 | } |
| 1103 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1104 | static void AppDumpSparseProps(const VkPhysicalDeviceSparseProperties *sparse_props) |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 1105 | { |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 1106 | |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1107 | printf("\tVkPhysicalDeviceSparseProperties:\n"); |
| 1108 | printf("\t---------------------------------\n"); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1109 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1110 | printf("\t\tresidencyStandard2DBlockShape = %u\n", sparse_props->residencyStandard2DBlockShape ); |
| 1111 | printf("\t\tresidencyStandard2DMultisampleBlockShape = %u\n", sparse_props->residencyStandard2DMultisampleBlockShape); |
| 1112 | printf("\t\tresidencyStandard3DBlockShape = %u\n", sparse_props->residencyStandard3DBlockShape ); |
| 1113 | printf("\t\tresidencyAlignedMipSize = %u\n", sparse_props->residencyAlignedMipSize ); |
| 1114 | printf("\t\tresidencyNonResidentStrict = %u\n", sparse_props->residencyNonResidentStrict ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1115 | } |
| 1116 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1117 | static void AppDumpLimits(const VkPhysicalDeviceLimits *limits) |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1118 | { |
| 1119 | printf("\tVkPhysicalDeviceLimits:\n"); |
| 1120 | printf("\t-----------------------\n"); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1121 | printf("\t\tmaxImageDimension1D = %u\n", limits->maxImageDimension1D ); |
| 1122 | printf("\t\tmaxImageDimension2D = %u\n", limits->maxImageDimension2D ); |
| 1123 | printf("\t\tmaxImageDimension3D = %u\n", limits->maxImageDimension3D ); |
| 1124 | printf("\t\tmaxImageDimensionCube = %u\n", limits->maxImageDimensionCube ); |
| 1125 | printf("\t\tmaxImageArrayLayers = %u\n", limits->maxImageArrayLayers ); |
Chia-I Wu | 7e47070 | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1126 | printf("\t\tmaxTexelBufferElements = 0x%" PRIxLEAST32 "\n", limits->maxTexelBufferElements ); |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1127 | printf("\t\tmaxUniformBufferRange = 0x%" PRIxLEAST32 "\n", limits->maxUniformBufferRange ); |
| 1128 | printf("\t\tmaxStorageBufferRange = 0x%" PRIxLEAST32 "\n", limits->maxStorageBufferRange ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1129 | printf("\t\tmaxPushConstantsSize = %u\n", limits->maxPushConstantsSize ); |
| 1130 | printf("\t\tmaxMemoryAllocationCount = %u\n", limits->maxMemoryAllocationCount ); |
| 1131 | printf("\t\tmaxSamplerAllocationCount = %u\n", limits->maxSamplerAllocationCount ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1132 | printf("\t\tbufferImageGranularity = 0x%" PRIxLEAST64 "\n", limits->bufferImageGranularity ); |
Tony Barbour | a0258a5 | 2015-10-27 11:01:20 -0600 | [diff] [blame] | 1133 | printf("\t\tsparseAddressSpaceSize = 0x%" PRIxLEAST64 "\n", limits->sparseAddressSpaceSize ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1134 | printf("\t\tmaxBoundDescriptorSets = %u\n", limits->maxBoundDescriptorSets ); |
| 1135 | printf("\t\tmaxPerStageDescriptorSamplers = %u\n", limits->maxPerStageDescriptorSamplers ); |
| 1136 | printf("\t\tmaxPerStageDescriptorUniformBuffers = %u\n", limits->maxPerStageDescriptorUniformBuffers ); |
| 1137 | printf("\t\tmaxPerStageDescriptorStorageBuffers = %u\n", limits->maxPerStageDescriptorStorageBuffers ); |
| 1138 | printf("\t\tmaxPerStageDescriptorSampledImages = %u\n", limits->maxPerStageDescriptorSampledImages ); |
| 1139 | printf("\t\tmaxPerStageDescriptorStorageImages = %u\n", limits->maxPerStageDescriptorStorageImages ); |
| 1140 | printf("\t\tmaxPerStageDescriptorInputAttachments = %u\n", limits->maxPerStageDescriptorInputAttachments ); |
| 1141 | printf("\t\tmaxPerStageResources = %u\n", limits->maxPerStageResources ); |
| 1142 | printf("\t\tmaxDescriptorSetSamplers = %u\n", limits->maxDescriptorSetSamplers ); |
| 1143 | printf("\t\tmaxDescriptorSetUniformBuffers = %u\n", limits->maxDescriptorSetUniformBuffers ); |
| 1144 | printf("\t\tmaxDescriptorSetUniformBuffersDynamic = %u\n", limits->maxDescriptorSetUniformBuffersDynamic ); |
| 1145 | printf("\t\tmaxDescriptorSetStorageBuffers = %u\n", limits->maxDescriptorSetStorageBuffers ); |
| 1146 | printf("\t\tmaxDescriptorSetStorageBuffersDynamic = %u\n", limits->maxDescriptorSetStorageBuffersDynamic ); |
| 1147 | printf("\t\tmaxDescriptorSetSampledImages = %u\n", limits->maxDescriptorSetSampledImages ); |
| 1148 | printf("\t\tmaxDescriptorSetStorageImages = %u\n", limits->maxDescriptorSetStorageImages ); |
| 1149 | printf("\t\tmaxDescriptorSetInputAttachments = %u\n", limits->maxDescriptorSetInputAttachments ); |
| 1150 | printf("\t\tmaxVertexInputAttributes = %u\n", limits->maxVertexInputAttributes ); |
| 1151 | printf("\t\tmaxVertexInputBindings = %u\n", limits->maxVertexInputBindings ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1152 | printf("\t\tmaxVertexInputAttributeOffset = 0x%" PRIxLEAST32 "\n", limits->maxVertexInputAttributeOffset ); |
| 1153 | printf("\t\tmaxVertexInputBindingStride = 0x%" PRIxLEAST32 "\n", limits->maxVertexInputBindingStride ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1154 | printf("\t\tmaxVertexOutputComponents = %u\n", limits->maxVertexOutputComponents ); |
| 1155 | printf("\t\tmaxTessellationGenerationLevel = %u\n", limits->maxTessellationGenerationLevel ); |
| 1156 | printf("\t\tmaxTessellationPatchSize = %u\n", limits->maxTessellationPatchSize ); |
| 1157 | printf("\t\tmaxTessellationControlPerVertexInputComponents = %u\n", limits->maxTessellationControlPerVertexInputComponents ); |
| 1158 | printf("\t\tmaxTessellationControlPerVertexOutputComponents = %u\n", limits->maxTessellationControlPerVertexOutputComponents); |
| 1159 | printf("\t\tmaxTessellationControlPerPatchOutputComponents = %u\n", limits->maxTessellationControlPerPatchOutputComponents ); |
| 1160 | printf("\t\tmaxTessellationControlTotalOutputComponents = %u\n", limits->maxTessellationControlTotalOutputComponents ); |
| 1161 | printf("\t\tmaxTessellationEvaluationInputComponents = %u\n", limits->maxTessellationEvaluationInputComponents ); |
| 1162 | printf("\t\tmaxTessellationEvaluationOutputComponents = %u\n", limits->maxTessellationEvaluationOutputComponents ); |
| 1163 | printf("\t\tmaxGeometryShaderInvocations = %u\n", limits->maxGeometryShaderInvocations ); |
| 1164 | printf("\t\tmaxGeometryInputComponents = %u\n", limits->maxGeometryInputComponents ); |
| 1165 | printf("\t\tmaxGeometryOutputComponents = %u\n", limits->maxGeometryOutputComponents ); |
| 1166 | printf("\t\tmaxGeometryOutputVertices = %u\n", limits->maxGeometryOutputVertices ); |
| 1167 | printf("\t\tmaxGeometryTotalOutputComponents = %u\n", limits->maxGeometryTotalOutputComponents ); |
| 1168 | printf("\t\tmaxFragmentInputComponents = %u\n", limits->maxFragmentInputComponents ); |
| 1169 | printf("\t\tmaxFragmentOutputAttachments = %u\n", limits->maxFragmentOutputAttachments ); |
| 1170 | printf("\t\tmaxFragmentDualSrcAttachments = %u\n", limits->maxFragmentDualSrcAttachments ); |
| 1171 | printf("\t\tmaxFragmentCombinedOutputResources = %u\n", limits->maxFragmentCombinedOutputResources ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1172 | printf("\t\tmaxComputeSharedMemorySize = 0x%" PRIxLEAST32 "\n", limits->maxComputeSharedMemorySize ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1173 | printf("\t\tmaxComputeWorkGroupCount[0] = %u\n", limits->maxComputeWorkGroupCount[0] ); |
| 1174 | printf("\t\tmaxComputeWorkGroupCount[1] = %u\n", limits->maxComputeWorkGroupCount[1] ); |
| 1175 | printf("\t\tmaxComputeWorkGroupCount[2] = %u\n", limits->maxComputeWorkGroupCount[2] ); |
| 1176 | printf("\t\tmaxComputeWorkGroupInvocations = %u\n", limits->maxComputeWorkGroupInvocations ); |
| 1177 | printf("\t\tmaxComputeWorkGroupSize[0] = %u\n", limits->maxComputeWorkGroupSize[0] ); |
| 1178 | printf("\t\tmaxComputeWorkGroupSize[1] = %u\n", limits->maxComputeWorkGroupSize[1] ); |
| 1179 | printf("\t\tmaxComputeWorkGroupSize[2] = %u\n", limits->maxComputeWorkGroupSize[2] ); |
| 1180 | printf("\t\tsubPixelPrecisionBits = %u\n", limits->subPixelPrecisionBits ); |
| 1181 | printf("\t\tsubTexelPrecisionBits = %u\n", limits->subTexelPrecisionBits ); |
| 1182 | printf("\t\tmipmapPrecisionBits = %u\n", limits->mipmapPrecisionBits ); |
| 1183 | printf("\t\tmaxDrawIndexedIndexValue = %u\n", limits->maxDrawIndexedIndexValue ); |
| 1184 | printf("\t\tmaxDrawIndirectCount = %u\n", limits->maxDrawIndirectCount ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1185 | printf("\t\tmaxSamplerLodBias = %f\n", limits->maxSamplerLodBias ); |
| 1186 | printf("\t\tmaxSamplerAnisotropy = %f\n", limits->maxSamplerAnisotropy ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1187 | printf("\t\tmaxViewports = %u\n", limits->maxViewports ); |
| 1188 | printf("\t\tmaxViewportDimensions[0] = %u\n", limits->maxViewportDimensions[0] ); |
| 1189 | printf("\t\tmaxViewportDimensions[1] = %u\n", limits->maxViewportDimensions[1] ); |
Rene Lindsay | 8a0cc4b | 2016-06-15 08:55:32 -0700 | [diff] [blame] | 1190 | printf("\t\tviewportBoundsRange[0] =%13f\n", limits->viewportBoundsRange[0] ); |
| 1191 | printf("\t\tviewportBoundsRange[1] =%13f\n", limits->viewportBoundsRange[1] ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1192 | printf("\t\tviewportSubPixelBits = %u\n", limits->viewportSubPixelBits ); |
Chia-I Wu | 3ffcd73 | 2015-10-26 17:08:33 +0800 | [diff] [blame] | 1193 | printf("\t\tminMemoryMapAlignment = " PRINTF_SIZE_T_SPECIFIER "\n", limits->minMemoryMapAlignment ); |
| 1194 | printf("\t\tminTexelBufferOffsetAlignment = 0x%" PRIxLEAST64 "\n", limits->minTexelBufferOffsetAlignment ); |
| 1195 | printf("\t\tminUniformBufferOffsetAlignment = 0x%" PRIxLEAST64 "\n", limits->minUniformBufferOffsetAlignment ); |
| 1196 | printf("\t\tminStorageBufferOffsetAlignment = 0x%" PRIxLEAST64 "\n", limits->minStorageBufferOffsetAlignment ); |
Rene Lindsay | 8a0cc4b | 2016-06-15 08:55:32 -0700 | [diff] [blame] | 1197 | printf("\t\tminTexelOffset =%3d\n", limits->minTexelOffset ); |
| 1198 | printf("\t\tmaxTexelOffset =%3d\n", limits->maxTexelOffset ); |
| 1199 | printf("\t\tminTexelGatherOffset =%3d\n", limits->minTexelGatherOffset ); |
| 1200 | printf("\t\tmaxTexelGatherOffset =%3d\n", limits->maxTexelGatherOffset ); |
| 1201 | printf("\t\tminInterpolationOffset =%9f\n", limits->minInterpolationOffset ); |
| 1202 | printf("\t\tmaxInterpolationOffset =%9f\n", limits->maxInterpolationOffset ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1203 | printf("\t\tsubPixelInterpolationOffsetBits = %u\n", limits->subPixelInterpolationOffsetBits ); |
| 1204 | printf("\t\tmaxFramebufferWidth = %u\n", limits->maxFramebufferWidth ); |
| 1205 | printf("\t\tmaxFramebufferHeight = %u\n", limits->maxFramebufferHeight ); |
| 1206 | printf("\t\tmaxFramebufferLayers = %u\n", limits->maxFramebufferLayers ); |
| 1207 | printf("\t\tframebufferColorSampleCounts = %u\n", limits->framebufferColorSampleCounts ); |
| 1208 | printf("\t\tframebufferDepthSampleCounts = %u\n", limits->framebufferDepthSampleCounts ); |
| 1209 | printf("\t\tframebufferStencilSampleCounts = %u\n", limits->framebufferStencilSampleCounts ); |
| 1210 | printf("\t\tframebufferNoAttachmentsSampleCounts = %u\n", limits->framebufferNoAttachmentsSampleCounts ); |
| 1211 | printf("\t\tmaxColorAttachments = %u\n", limits->maxColorAttachments ); |
| 1212 | printf("\t\tsampledImageColorSampleCounts = %u\n", limits->sampledImageColorSampleCounts ); |
| 1213 | printf("\t\tsampledImageDepthSampleCounts = %u\n", limits->sampledImageDepthSampleCounts ); |
| 1214 | printf("\t\tsampledImageStencilSampleCounts = %u\n", limits->sampledImageStencilSampleCounts ); |
| 1215 | printf("\t\tsampledImageIntegerSampleCounts = %u\n", limits->sampledImageIntegerSampleCounts ); |
| 1216 | printf("\t\tstorageImageSampleCounts = %u\n", limits->storageImageSampleCounts ); |
| 1217 | printf("\t\tmaxSampleMaskWords = %u\n", limits->maxSampleMaskWords ); |
Jon Ashburn | fef7f08 | 2015-12-29 14:57:48 -0700 | [diff] [blame] | 1218 | printf("\t\ttimestampComputeAndGraphics = %u\n", limits->timestampComputeAndGraphics ); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1219 | printf("\t\ttimestampPeriod = %f\n", limits->timestampPeriod ); |
| 1220 | printf("\t\tmaxClipDistances = %u\n", limits->maxClipDistances ); |
| 1221 | printf("\t\tmaxCullDistances = %u\n", limits->maxCullDistances ); |
| 1222 | printf("\t\tmaxCombinedClipAndCullDistances = %u\n", limits->maxCombinedClipAndCullDistances ); |
| 1223 | printf("\t\tdiscreteQueuePriorities = %u\n", limits->discreteQueuePriorities ); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1224 | printf("\t\tpointSizeRange[0] = %f\n", limits->pointSizeRange[0] ); |
| 1225 | printf("\t\tpointSizeRange[1] = %f\n", limits->pointSizeRange[1] ); |
| 1226 | printf("\t\tlineWidthRange[0] = %f\n", limits->lineWidthRange[0] ); |
| 1227 | printf("\t\tlineWidthRange[1] = %f\n", limits->lineWidthRange[1] ); |
| 1228 | printf("\t\tpointSizeGranularity = %f\n", limits->pointSizeGranularity ); |
| 1229 | printf("\t\tlineWidthGranularity = %f\n", limits->lineWidthGranularity ); |
Chia-I Wu | 3c33210 | 2015-10-26 16:47:26 +0800 | [diff] [blame] | 1230 | printf("\t\tstrictLines = %u\n", limits->strictLines ); |
Chia-I Wu | a3939fc | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1231 | printf("\t\tstandardSampleLocations = %u\n", limits->standardSampleLocations ); |
Chia-I Wu | ee0eaa1 | 2015-11-06 10:37:51 +0800 | [diff] [blame] | 1232 | printf("\t\toptimalBufferCopyOffsetAlignment = 0x%" PRIxLEAST64 "\n", limits->optimalBufferCopyOffsetAlignment ); |
| 1233 | printf("\t\toptimalBufferCopyRowPitchAlignment = 0x%" PRIxLEAST64 "\n", limits->optimalBufferCopyRowPitchAlignment ); |
| 1234 | printf("\t\tnonCoherentAtomSize = 0x%" PRIxLEAST64 "\n", limits->nonCoherentAtomSize ); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1235 | } |
| 1236 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1237 | static void AppGpuDumpProps(const struct AppGpu *gpu) |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1238 | { |
| 1239 | const VkPhysicalDeviceProperties *props = &gpu->props; |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1240 | const uint32_t apiVersion=props->apiVersion; |
| 1241 | const uint32_t major = VK_VERSION_MAJOR(apiVersion); |
| 1242 | const uint32_t minor = VK_VERSION_MINOR(apiVersion); |
| 1243 | const uint32_t patch = VK_VERSION_PATCH(apiVersion); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1244 | |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1245 | printf("VkPhysicalDeviceProperties:\n"); |
| 1246 | printf("===========================\n"); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1247 | printf("\tapiVersion = 0x%" PRIxLEAST32 " (%d.%d.%d)\n", apiVersion, major, minor, patch); |
| 1248 | printf("\tdriverVersion = %u (0x%" PRIxLEAST32 ")\n",props->driverVersion, props->driverVersion); |
| 1249 | printf("\tvendorID = 0x%04x\n", props->vendorID); |
| 1250 | printf("\tdeviceID = 0x%04x\n", props->deviceID); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1251 | printf("\tdeviceType = %s\n", VkPhysicalDeviceTypeString(props->deviceType)); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1252 | printf("\tdeviceName = %s\n", props->deviceName); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1253 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1254 | AppDumpLimits(&gpu->props.limits); |
| 1255 | AppDumpSparseProps(&gpu->props.sparseProperties); |
Mark Lobodzinski | 7dae686 | 2015-09-07 12:56:17 -0600 | [diff] [blame] | 1256 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1257 | fflush(stdout); |
| 1258 | } |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1259 | // clang-format on |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1260 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1261 | static void AppDumpExtensions(const char *indent, const char *layer_name, const uint32_t extension_count, |
| 1262 | const VkExtensionProperties *extension_properties) { |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 1263 | uint32_t i; |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1264 | if (layer_name && (strlen(layer_name) > 0)) { |
| 1265 | printf("%s%s Extensions", indent, layer_name); |
| 1266 | } else { |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1267 | printf("%sExtensions", indent); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 1268 | } |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1269 | printf("\tcount = %d\n", extension_count); |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1270 | for (i = 0; i < extension_count; i++) { |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1271 | VkExtensionProperties const *ext_prop = &extension_properties[i]; |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 1272 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1273 | printf("%s\t", indent); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1274 | printf("%-36s: extension revision %2d\n", ext_prop->extensionName, ext_prop->specVersion); |
Courtney Goeltzenleuchter | ff87c82 | 2014-10-03 18:05:10 -0600 | [diff] [blame] | 1275 | } |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1276 | fflush(stdout); |
Courtney Goeltzenleuchter | ff87c82 | 2014-10-03 18:05:10 -0600 | [diff] [blame] | 1277 | } |
| 1278 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1279 | #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_WIN32_KHR) |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1280 | // Returns true if the named extension is in the list of extensions. |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1281 | static bool HasExtension(const char *extension_name, const uint32_t extension_count, |
| 1282 | const VkExtensionProperties *extension_properties) { |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1283 | for (uint32_t i = 0; i < extension_count; i++) { |
| 1284 | if (!strcmp(extension_name, extension_properties[i].extensionName)) |
| 1285 | return true; |
| 1286 | } |
| 1287 | return false; |
| 1288 | } |
Karl Schultz | fad114e | 2016-09-12 13:28:09 -0600 | [diff] [blame] | 1289 | #endif |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1290 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1291 | static void AppGpuDumpQueueProps(const struct AppGpu *gpu, uint32_t id) { |
Cody Northrop | ef72e2a | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 1292 | const VkQueueFamilyProperties *props = &gpu->queue_props[id]; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1293 | |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1294 | printf("VkQueueFamilyProperties[%d]:\n", id); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1295 | printf("===========================\n"); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1296 | char *sep = ""; // separator character |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1297 | printf("\tqueueFlags = "); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1298 | if (props->queueFlags & VK_QUEUE_GRAPHICS_BIT) { |
| 1299 | printf("GRAPHICS"); |
| 1300 | sep = " | "; |
| 1301 | } |
| 1302 | if (props->queueFlags & VK_QUEUE_COMPUTE_BIT) { |
| 1303 | printf("%sCOMPUTE", sep); |
| 1304 | sep = " | "; |
| 1305 | } |
| 1306 | if (props->queueFlags & VK_QUEUE_TRANSFER_BIT) { |
| 1307 | printf("%sTRANSFER", sep); |
| 1308 | sep = " | "; |
| 1309 | } |
| 1310 | if (props->queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) { |
| 1311 | printf("%sSPARSE", sep); |
| 1312 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1313 | printf("\n"); |
| 1314 | |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1315 | printf("\tqueueCount = %u\n", props->queueCount); |
| 1316 | printf("\ttimestampValidBits = %u\n", props->timestampValidBits); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1317 | printf("\tminImageTransferGranularity = (%d, %d, %d)\n", props->minImageTransferGranularity.width, |
| 1318 | props->minImageTransferGranularity.height, props->minImageTransferGranularity.depth); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1319 | fflush(stdout); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1320 | } |
| 1321 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1322 | static void AppGpuDumpMemoryProps(const struct AppGpu *gpu) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1323 | const VkPhysicalDeviceMemoryProperties *props = &gpu->memory_props; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1324 | |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1325 | printf("VkPhysicalDeviceMemoryProperties:\n"); |
| 1326 | printf("=================================\n"); |
| 1327 | printf("\tmemoryTypeCount = %u\n", props->memoryTypeCount); |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1328 | for (uint32_t i = 0; i < props->memoryTypeCount; i++) { |
| 1329 | printf("\tmemoryTypes[%u] : \n", i); |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1330 | printf("\t\theapIndex = %u\n", props->memoryTypes[i].heapIndex); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1331 | printf("\t\tpropertyFlags = 0x%" PRIxLEAST32 ":\n", props->memoryTypes[i].propertyFlags); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1332 | |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1333 | // Print each named flag, if it is set. |
| 1334 | VkFlags flags = props->memoryTypes[i].propertyFlags; |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1335 | #define PRINT_FLAG(FLAG) \ |
| 1336 | if (flags & FLAG) \ |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1337 | printf("\t\t\t" #FLAG "\n"); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1338 | PRINT_FLAG(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) |
| 1339 | PRINT_FLAG(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) |
| 1340 | PRINT_FLAG(VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) |
| 1341 | PRINT_FLAG(VK_MEMORY_PROPERTY_HOST_CACHED_BIT) |
| 1342 | PRINT_FLAG(VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1343 | #undef PRINT_FLAG |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1344 | } |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1345 | printf("\n"); |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1346 | printf("\tmemoryHeapCount = %u\n", props->memoryHeapCount); |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1347 | for (uint32_t i = 0; i < props->memoryHeapCount; i++) { |
| 1348 | printf("\tmemoryHeaps[%u] : \n", i); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1349 | const VkDeviceSize memSize = props->memoryHeaps[i].size; |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1350 | printf("\t\tsize = " PRINTF_SIZE_T_SPECIFIER " (0x%" PRIxLEAST64 ")\n", (size_t)memSize, memSize); |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1351 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1352 | VkMemoryHeapFlags heap_flags = props->memoryHeaps[i].flags; |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1353 | printf("\t\tflags: \n\t\t\t"); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1354 | printf((heap_flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) ? "VK_MEMORY_HEAP_DEVICE_LOCAL_BIT\n" : "None\n"); |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 1355 | } |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1356 | fflush(stdout); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1357 | } |
| 1358 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1359 | static void AppGpuDump(const struct AppGpu *gpu) { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1360 | uint32_t i; |
Chia-I Wu | f5c46f4 | 2014-08-05 15:33:40 +0800 | [diff] [blame] | 1361 | |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1362 | printf("\nDevice Properties and Extensions :\n"); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1363 | printf("==================================\n"); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1364 | printf("GPU%u\n", gpu->id); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1365 | AppGpuDumpProps(gpu); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1366 | printf("\n"); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1367 | AppDumpExtensions("", "Device", gpu->device_extension_count, gpu->device_extensions); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1368 | printf("\n"); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1369 | for (i = 0; i < gpu->queue_count; i++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1370 | AppGpuDumpQueueProps(gpu, i); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1371 | printf("\n"); |
| 1372 | } |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1373 | AppGpuDumpMemoryProps(gpu); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1374 | printf("\n"); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1375 | AppGpuDumpFeatures(gpu); |
Chris Forbes | a048b31 | 2015-06-21 20:09:12 +1200 | [diff] [blame] | 1376 | printf("\n"); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1377 | AppDevDump(&gpu->dev); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1378 | } |
| 1379 | |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 1380 | #ifdef _WIN32 |
| 1381 | // Enlarges the console window to have a large scrollback size. |
| 1382 | static void ConsoleEnlarge() { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1383 | HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE); |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 1384 | |
| 1385 | // make the console window bigger |
| 1386 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1387 | COORD buffer_size; |
| 1388 | if (GetConsoleScreenBufferInfo(console_handle, &csbi)) { |
| 1389 | buffer_size.X = csbi.dwSize.X + 30; |
| 1390 | buffer_size.Y = 20000; |
| 1391 | SetConsoleScreenBufferSize(console_handle, buffer_size); |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | SMALL_RECT r; |
| 1395 | r.Left = r.Top = 0; |
| 1396 | r.Right = csbi.dwSize.X - 1 + 30; |
| 1397 | r.Bottom = 50; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1398 | SetConsoleWindowInfo(console_handle, true, &r); |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 1399 | |
| 1400 | // change the console window title |
| 1401 | SetConsoleTitle(TEXT(APP_SHORT_NAME)); |
| 1402 | } |
| 1403 | #endif |
| 1404 | |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1405 | int main(int argc, char **argv) { |
David Pinedo | 7b4e9ec | 2015-10-19 15:22:28 -0600 | [diff] [blame] | 1406 | unsigned int major, minor, patch; |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 1407 | struct AppGpu *gpus; |
| 1408 | VkPhysicalDevice *objs; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1409 | uint32_t gpu_count, i; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1410 | VkResult err; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1411 | struct AppInstance inst; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1412 | |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 1413 | #ifdef _WIN32 |
| 1414 | if (ConsoleIsExclusive()) |
| 1415 | ConsoleEnlarge(); |
| 1416 | #endif |
| 1417 | |
Rene Lindsay | 3c877cd | 2016-05-23 13:00:53 -0700 | [diff] [blame] | 1418 | major = VK_VERSION_MAJOR(VK_API_VERSION_1_0); |
| 1419 | minor = VK_VERSION_MINOR(VK_API_VERSION_1_0); |
| 1420 | patch = VK_VERSION_PATCH(VK_HEADER_VERSION); |
| 1421 | |
David Pinedo | 7b4e9ec | 2015-10-19 15:22:28 -0600 | [diff] [blame] | 1422 | printf("===========\n"); |
Karl Schultz | 481756e | 2016-02-02 15:37:51 -0700 | [diff] [blame] | 1423 | printf("VULKAN INFO\n"); |
David Pinedo | b5ec4c2 | 2015-10-19 15:15:34 -0600 | [diff] [blame] | 1424 | printf("===========\n\n"); |
Mark Lobodzinski | ab5e3be | 2016-01-13 10:36:44 -0700 | [diff] [blame] | 1425 | printf("Vulkan API Version: %d.%d.%d\n\n", major, minor, patch); |
David Pinedo | b5ec4c2 | 2015-10-19 15:15:34 -0600 | [diff] [blame] | 1426 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1427 | AppCreateInstance(&inst); |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 1428 | |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1429 | printf("\nInstance Extensions:\n"); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1430 | printf("====================\n"); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1431 | AppDumpExtensions("", "Instance", inst.global_extension_count, inst.global_extensions); |
Mark Lobodzinski | 825cc51 | 2015-08-14 10:30:30 -0600 | [diff] [blame] | 1432 | |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 1433 | err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, NULL); |
Jon Ashburn | 07b309a | 2015-04-15 11:31:12 -0600 | [diff] [blame] | 1434 | if (err) |
| 1435 | ERR_EXIT(err); |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 1436 | objs = malloc(sizeof(objs[0]) * gpu_count); |
| 1437 | if (!objs) |
| 1438 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
Courtney Goeltzenleuchter | 3c1ccf5 | 2015-06-04 16:20:06 -0600 | [diff] [blame] | 1439 | err = vkEnumeratePhysicalDevices(inst.instance, &gpu_count, objs); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1440 | if (err) |
| 1441 | ERR_EXIT(err); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1442 | |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 1443 | gpus = malloc(sizeof(gpus[0]) * gpu_count); |
| 1444 | if (!gpus) |
| 1445 | ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1446 | for (i = 0; i < gpu_count; i++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1447 | AppGpuInit(&gpus[i], i, objs[i]); |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1448 | printf("\n\n"); |
| 1449 | } |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1450 | |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1451 | //---Layer-Device-Extensions--- |
| 1452 | printf("Layers: count = %d\n", inst.global_layer_count); |
| 1453 | printf("=======\n"); |
| 1454 | for (uint32_t i = 0; i < inst.global_layer_count; i++) { |
| 1455 | uint32_t major, minor, patch; |
| 1456 | char spec_version[64], layer_version[64]; |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1457 | VkLayerProperties const *layer_prop = &inst.global_layers[i].layer_properties; |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1458 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1459 | ExtractVersion(layer_prop->specVersion, &major, &minor, &patch); |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1460 | snprintf(spec_version, sizeof(spec_version), "%d.%d.%d", major, minor, patch); |
| 1461 | snprintf(layer_version, sizeof(layer_version), "%d", layer_prop->implementationVersion); |
| 1462 | printf("%s (%s) Vulkan version %s, layer version %s\n", layer_prop->layerName, (char *)layer_prop->description, |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1463 | spec_version, layer_version); |
| 1464 | |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1465 | AppDumpExtensions("\t", "Layer", inst.global_layers[i].extension_count, inst.global_layers[i].extension_properties); |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1466 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1467 | char *layer_name = inst.global_layers[i].layer_properties.layerName; |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1468 | printf("\tDevices \tcount = %d\n", gpu_count); |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1469 | for (uint32_t j = 0; j < gpu_count; j++) { |
| 1470 | printf("\t\tGPU id : %u (%s)\n", j, gpus[j].props.deviceName); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1471 | uint32_t count = 0; |
| 1472 | VkExtensionProperties *props; |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1473 | AppGetPhysicalDeviceLayerExtensions(&gpus[j], layer_name, &count, &props); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1474 | AppDumpExtensions("\t\t", "Layer-Device", count, props); |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1475 | free(props); |
| 1476 | } |
| 1477 | printf("\n"); |
| 1478 | } |
| 1479 | fflush(stdout); |
| 1480 | //----------------------------- |
| 1481 | |
joey-lunarg | 7b3aade | 2016-11-02 14:36:19 -0600 | [diff] [blame] | 1482 | printf("Presentable Surfaces:\n"); |
| 1483 | printf("=====================\n"); |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1484 | inst.width = 256; |
| 1485 | inst.height = 256; |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1486 | int format_count = 0; |
| 1487 | int present_mode_count = 0; |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1488 | |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 1489 | #if defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1490 | if (getenv("DISPLAY") == NULL) { |
| 1491 | printf("'DISPLAY' environment variable not set... Exiting!\n"); |
| 1492 | fflush(stdout); |
| 1493 | exit(1); |
| 1494 | } |
| 1495 | #endif |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1496 | //--WIN32-- |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1497 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1498 | if (HasExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, inst.global_extension_count, inst.global_extensions)) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1499 | AppCreateWin32Window(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1500 | for (i = 0; i < gpu_count; i++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1501 | AppCreateWin32Surface(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1502 | printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName); |
| 1503 | printf("Surface type : %s\n", VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1504 | format_count += AppDumpSurfaceFormats(&inst, &gpus[i]); |
| 1505 | present_mode_count += AppDumpSurfacePresentModes(&inst, &gpus[i]); |
| 1506 | AppDestroySurface(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1507 | } |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1508 | AppDestroyWin32Window(&inst); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1509 | } |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1510 | //--XCB-- |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 1511 | #elif VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1512 | if (HasExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME, inst.global_extension_count, inst.global_extensions)) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1513 | AppCreateXcbWindow(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1514 | for (i = 0; i < gpu_count; i++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1515 | AppCreateXcbSurface(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1516 | printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName); |
| 1517 | printf("Surface type : %s\n", VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1518 | format_count += AppDumpSurfaceFormats(&inst, &gpus[i]); |
| 1519 | present_mode_count += AppDumpSurfacePresentModes(&inst, &gpus[i]); |
| 1520 | AppDestroySurface(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1521 | } |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1522 | AppDestroyXcbWindow(&inst); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1523 | } |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1524 | //--XLIB-- |
Tony Barbour | b6bbc99 | 2016-12-09 11:27:26 -0700 | [diff] [blame] | 1525 | #elif VK_USE_PLATFORM_XLIB_KHR |
Mark Lobodzinski | bc9caa5 | 2017-01-26 12:16:30 -0700 | [diff] [blame^] | 1526 | if (HasExtension(VK_KHR_XLIB_SURFACE_EXTENSION_NAME, inst.global_extension_count, inst.global_extensions)) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1527 | AppCreateXlibWindow(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1528 | for (i = 0; i < gpu_count; i++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1529 | AppCreateXlibSurface(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1530 | printf("GPU id : %u (%s)\n", i, gpus[i].props.deviceName); |
| 1531 | printf("Surface type : %s\n", VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1532 | format_count += AppDumpSurfaceFormats(&inst, &gpus[i]); |
| 1533 | present_mode_count += AppDumpSurfacePresentModes(&inst, &gpus[i]); |
| 1534 | AppDestroySurface(&inst); |
Rene Lindsay | 9652e55 | 2016-06-22 15:46:48 -0700 | [diff] [blame] | 1535 | } |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1536 | AppDestroyXlibWindow(&inst); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1537 | } |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1538 | #endif |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1539 | // TODO: Android / Wayland / MIR |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1540 | if (!format_count && !present_mode_count) |
Rene Lindsay | 7fb1e01 | 2016-06-10 15:33:08 -0700 | [diff] [blame] | 1541 | printf("None found\n"); |
Rene Lindsay | a155d62 | 2016-06-10 08:26:26 -0700 | [diff] [blame] | 1542 | //--------- |
| 1543 | |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1544 | for (i = 0; i < gpu_count; i++) { |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1545 | AppGpuDump(&gpus[i]); |
Rene Lindsay | cb6b5ca | 2016-06-21 15:02:10 -0700 | [diff] [blame] | 1546 | printf("\n\n"); |
| 1547 | } |
| 1548 | |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1549 | for (i = 0; i < gpu_count; i++) |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1550 | AppGpuDestroy(&gpus[i]); |
Karl Schultz | 242a9c9 | 2017-01-11 12:15:58 -0700 | [diff] [blame] | 1551 | free(gpus); |
| 1552 | free(objs); |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1553 | |
joey-lunarg | f0743b0 | 2016-11-07 11:27:00 -0700 | [diff] [blame] | 1554 | AppDestroyInstance(&inst); |
Chia-I Wu | 0b9a737 | 2014-08-06 12:09:19 +0800 | [diff] [blame] | 1555 | |
Hugo Landau | a3b7170 | 2016-02-16 15:44:03 +0000 | [diff] [blame] | 1556 | fflush(stdout); |
| 1557 | #ifdef _WIN32 |
| 1558 | if (ConsoleIsExclusive()) |
| 1559 | Sleep(INFINITE); |
| 1560 | #endif |
| 1561 | |
Chia-I Wu | 190ebdc | 2014-08-06 12:04:13 +0800 | [diff] [blame] | 1562 | return 0; |
Chia-I Wu | d4bae36 | 2014-07-29 11:15:00 +0800 | [diff] [blame] | 1563 | } |