Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 1 | /* |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 2 | * |
Courtney Goeltzenleuchter | fcbe16f | 2015-10-29 13:50:34 -0600 | [diff] [blame] | 3 | * Copyright (C) 2015 Valve Corporation |
Michael Lentine | 64e2ebd | 2015-12-03 14:33:09 -0800 | [diff] [blame] | 4 | * Copyright (C) 2015 Google Inc. |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 23 | * |
| 24 | * Author: Jon Ashburn <jon@lunarg.com> |
| 25 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 26 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 27 | */ |
| 28 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 29 | #include "vulkan/vk_layer.h" |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 30 | #include "vk_layer_extension_utils.h" |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 31 | #include "vk_enum_string_helper.h" |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 32 | |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 33 | // Object Tracker ERROR codes |
| 34 | typedef enum _OBJECT_TRACK_ERROR |
| 35 | { |
Chia-I Wu | 09cf5f0 | 2015-01-05 14:33:42 +0800 | [diff] [blame] | 36 | OBJTRACK_NONE, // Used for INFO & other non-error messages |
| 37 | OBJTRACK_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list |
| 38 | OBJTRACK_INTERNAL_ERROR, // Bug with data tracking within the layer |
| 39 | OBJTRACK_DESTROY_OBJECT_FAILED, // Couldn't find object to be destroyed |
Chia-I Wu | 09cf5f0 | 2015-01-05 14:33:42 +0800 | [diff] [blame] | 40 | OBJTRACK_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed |
| 41 | OBJTRACK_OBJCOUNT_MAX_EXCEEDED, // Request for Object data in excess of max obj count |
Tobin Ehlis | 803cc49 | 2015-06-08 17:36:28 -0600 | [diff] [blame] | 42 | OBJTRACK_INVALID_OBJECT, // Object used that has never been created |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 43 | OBJTRACK_DESCRIPTOR_POOL_MISMATCH, // Descriptor Pools specified incorrectly |
| 44 | OBJTRACK_COMMAND_POOL_MISMATCH, // Command Pools specified incorrectly |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 45 | } OBJECT_TRACK_ERROR; |
| 46 | |
Tobin Ehlis | 91ce77e | 2015-01-16 08:56:30 -0700 | [diff] [blame] | 47 | // Object Status -- used to track state of individual objects |
Mark Lobodzinski | 38f0db2 | 2015-05-20 17:33:47 -0500 | [diff] [blame] | 48 | typedef VkFlags ObjectStatusFlags; |
| 49 | typedef enum _ObjectStatusFlagBits |
Tobin Ehlis | 91ce77e | 2015-01-16 08:56:30 -0700 | [diff] [blame] | 50 | { |
Mark Lobodzinski | 4037087 | 2015-02-03 10:06:31 -0600 | [diff] [blame] | 51 | OBJSTATUS_NONE = 0x00000000, // No status is set |
| 52 | OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted |
| 53 | OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound |
| 54 | OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound |
| 55 | OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound |
| 56 | OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound |
Mark Lobodzinski | 4988dea | 2015-02-03 11:52:26 -0600 | [diff] [blame] | 57 | OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped |
Mark Lobodzinski | 38f0db2 | 2015-05-20 17:33:47 -0500 | [diff] [blame] | 58 | } ObjectStatusFlagBits; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 59 | |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 60 | typedef struct _OBJTRACK_NODE { |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 61 | uint64_t vkObj; // Object handle |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 62 | VkDebugReportObjectTypeLUNARG objType; // Object type identifier |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 63 | ObjectStatusFlags status; // Object state |
| 64 | uint64_t parentObj; // Parent object |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 65 | } OBJTRACK_NODE; |
Mark Lobodzinski | aae93e5 | 2015-02-09 10:20:53 -0600 | [diff] [blame] | 66 | |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 67 | // prototype for extension functions |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 68 | uint64_t objTrackGetObjectCount(VkDevice device); |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 69 | uint64_t objTrackGetObjectsOfTypeCount(VkDevice, VkDebugReportObjectTypeLUNARG type); |
Mark Lobodzinski | aae93e5 | 2015-02-09 10:20:53 -0600 | [diff] [blame] | 70 | |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 71 | // Func ptr typedefs |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 72 | typedef uint64_t (*OBJ_TRACK_GET_OBJECT_COUNT)(VkDevice); |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 73 | typedef uint64_t (*OBJ_TRACK_GET_OBJECTS_OF_TYPE_COUNT)(VkDevice, VkDebugReportObjectTypeLUNARG); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 74 | |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 75 | struct layer_data { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 76 | debug_report_data *report_data; |
| 77 | //TODO: put instance data here |
Courtney Goeltzenleuchter | 107a0d2 | 2015-11-25 14:07:05 -0700 | [diff] [blame] | 78 | VkDebugReportCallbackLUNARG logging_callback; |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 79 | bool wsi_enabled; |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 80 | bool objtrack_extensions_enabled; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 81 | |
| 82 | layer_data() : |
| 83 | report_data(nullptr), |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 84 | logging_callback(VK_NULL_HANDLE), |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 85 | wsi_enabled(false), |
| 86 | objtrack_extensions_enabled(false) |
| 87 | {}; |
| 88 | }; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 89 | |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 90 | struct instExts { |
| 91 | bool wsi_enabled; |
| 92 | }; |
| 93 | |
| 94 | static std::unordered_map<void *, struct instExts> instanceExtMap; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 95 | static std::unordered_map<void*, layer_data *> layer_data_map; |
| 96 | static device_table_map ObjectTracker_device_table_map; |
| 97 | static instance_table_map ObjectTracker_instance_table_map; |
| 98 | |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 99 | // We need additionally validate image usage using a separate map |
| 100 | // of swapchain-created images |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 101 | static unordered_map<uint64_t, OBJTRACK_NODE*> swapchainImageMap; |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 102 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 103 | static long long unsigned int object_track_index = 0; |
| 104 | static int objLockInitialized = 0; |
| 105 | static loader_platform_thread_mutex objLock; |
| 106 | |
| 107 | // Objects stored in a global map w/ struct containing basic info |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 108 | // unordered_map<const void*, OBJTRACK_NODE*> objMap; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 109 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 110 | #define NUM_OBJECT_TYPES VK_OBJECT_TYPE_NUM |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 111 | |
| 112 | static uint64_t numObjs[NUM_OBJECT_TYPES] = {0}; |
| 113 | static uint64_t numTotalObjs = 0; |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 114 | static VkQueueFamilyProperties *queueInfo = NULL; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 115 | static uint32_t queueCount = 0; |
| 116 | |
| 117 | template layer_data *get_my_data_ptr<layer_data>( |
| 118 | void *data_key, std::unordered_map<void *, layer_data *> &data_map); |
| 119 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 120 | static inline const char* string_VkDebugReportObjectTypeLUNARG(VkDebugReportObjectTypeLUNARG input_value) |
Mark Lobodzinski | 2eeb3c6 | 2015-09-01 08:52:55 -0600 | [diff] [blame] | 121 | { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 122 | switch ((VkDebugReportObjectTypeLUNARG)input_value) |
Mark Lobodzinski | 2eeb3c6 | 2015-09-01 08:52:55 -0600 | [diff] [blame] | 123 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 124 | case VK_OBJECT_TYPE_COMMAND_POOL: |
| 125 | return "VK_OBJECT_TYPE_COMMAND_POOL"; |
Mark Lobodzinski | 2eeb3c6 | 2015-09-01 08:52:55 -0600 | [diff] [blame] | 126 | case VK_OBJECT_TYPE_BUFFER: |
| 127 | return "VK_OBJECT_TYPE_BUFFER"; |
| 128 | case VK_OBJECT_TYPE_BUFFER_VIEW: |
| 129 | return "VK_OBJECT_TYPE_BUFFER_VIEW"; |
| 130 | case VK_OBJECT_TYPE_ATTACHMENT_VIEW: |
| 131 | return "VK_OBJECT_TYPE_ATTACHMENT_VIEW"; |
| 132 | case VK_OBJECT_TYPE_COMMAND_BUFFER: |
| 133 | return "VK_OBJECT_TYPE_COMMAND_BUFFER"; |
| 134 | case VK_OBJECT_TYPE_DESCRIPTOR_POOL: |
| 135 | return "VK_OBJECT_TYPE_DESCRIPTOR_POOL"; |
| 136 | case VK_OBJECT_TYPE_DESCRIPTOR_SET: |
| 137 | return "VK_OBJECT_TYPE_DESCRIPTOR_SET"; |
| 138 | case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT: |
| 139 | return "VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT"; |
| 140 | case VK_OBJECT_TYPE_DEVICE: |
| 141 | return "VK_OBJECT_TYPE_DEVICE"; |
| 142 | case VK_OBJECT_TYPE_DEVICE_MEMORY: |
| 143 | return "VK_OBJECT_TYPE_DEVICE_MEMORY"; |
Mark Lobodzinski | 2eeb3c6 | 2015-09-01 08:52:55 -0600 | [diff] [blame] | 144 | case VK_OBJECT_TYPE_EVENT: |
| 145 | return "VK_OBJECT_TYPE_EVENT"; |
| 146 | case VK_OBJECT_TYPE_FENCE: |
| 147 | return "VK_OBJECT_TYPE_FENCE"; |
| 148 | case VK_OBJECT_TYPE_FRAMEBUFFER: |
| 149 | return "VK_OBJECT_TYPE_FRAMEBUFFER"; |
| 150 | case VK_OBJECT_TYPE_IMAGE: |
| 151 | return "VK_OBJECT_TYPE_IMAGE"; |
| 152 | case VK_OBJECT_TYPE_IMAGE_VIEW: |
| 153 | return "VK_OBJECT_TYPE_IMAGE_VIEW"; |
| 154 | case VK_OBJECT_TYPE_INSTANCE: |
| 155 | return "VK_OBJECT_TYPE_INSTANCE"; |
| 156 | case VK_OBJECT_TYPE_PHYSICAL_DEVICE: |
| 157 | return "VK_OBJECT_TYPE_PHYSICAL_DEVICE"; |
| 158 | case VK_OBJECT_TYPE_PIPELINE: |
| 159 | return "VK_OBJECT_TYPE_PIPELINE"; |
| 160 | case VK_OBJECT_TYPE_PIPELINE_LAYOUT: |
| 161 | return "VK_OBJECT_TYPE_PIPELINE_LAYOUT"; |
| 162 | case VK_OBJECT_TYPE_PIPELINE_CACHE: |
| 163 | return "VK_OBJECT_TYPE_PIPELINE_CACHE"; |
| 164 | case VK_OBJECT_TYPE_QUERY_POOL: |
| 165 | return "VK_OBJECT_TYPE_QUERY_POOL"; |
| 166 | case VK_OBJECT_TYPE_QUEUE: |
| 167 | return "VK_OBJECT_TYPE_QUEUE"; |
| 168 | case VK_OBJECT_TYPE_RENDER_PASS: |
| 169 | return "VK_OBJECT_TYPE_RENDER_PASS"; |
| 170 | case VK_OBJECT_TYPE_SAMPLER: |
| 171 | return "VK_OBJECT_TYPE_SAMPLER"; |
| 172 | case VK_OBJECT_TYPE_SEMAPHORE: |
| 173 | return "VK_OBJECT_TYPE_SEMAPHORE"; |
| 174 | case VK_OBJECT_TYPE_SHADER: |
| 175 | return "VK_OBJECT_TYPE_SHADER"; |
| 176 | case VK_OBJECT_TYPE_SHADER_MODULE: |
| 177 | return "VK_OBJECT_TYPE_SHADER_MODULE"; |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 178 | case VK_OBJECT_TYPE_SWAPCHAIN_KHR: |
| 179 | return "VK_OBJECT_TYPE_SWAPCHAIN_KHR"; |
Mark Lobodzinski | 2eeb3c6 | 2015-09-01 08:52:55 -0600 | [diff] [blame] | 180 | default: |
| 181 | return "Unhandled VkObjectType"; |
| 182 | } |
| 183 | } |
| 184 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 185 | // |
| 186 | // Internal Object Tracker Functions |
| 187 | // |
| 188 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 189 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo* pCreateInfo, VkDevice device) |
| 190 | { |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 191 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
Jon Ashburn | 8acd233 | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 192 | VkLayerDispatchTable *pDisp = get_dispatch_table(ObjectTracker_device_table_map, device); |
| 193 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
Jon Ashburn | 8acd233 | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 194 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) gpa(device, "vkCreateSwapchainKHR"); |
| 195 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) gpa(device, "vkDestroySwapchainKHR"); |
| 196 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) gpa(device, "vkGetSwapchainImagesKHR"); |
| 197 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) gpa(device, "vkAcquireNextImageKHR"); |
| 198 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR) gpa(device, "vkQueuePresentKHR"); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 199 | my_device_data->wsi_enabled = false; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 200 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 201 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 202 | my_device_data->wsi_enabled = true; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 203 | |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 204 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], "OBJTRACK_EXTENSIONS") == 0) |
| 205 | my_device_data->objtrack_extensions_enabled = true; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 206 | } |
| 207 | } |
| 208 | |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 209 | static void createInstanceRegisterExtensions(const VkInstanceCreateInfo* pCreateInfo, VkInstance instance) |
| 210 | { |
| 211 | uint32_t i; |
| 212 | VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(ObjectTracker_instance_table_map, instance); |
| 213 | PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; |
| 214 | pDisp->GetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 215 | pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); |
| 216 | pDisp->GetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"); |
| 217 | pDisp->GetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"); |
Mark Lobodzinski | e86e138 | 2015-11-24 15:50:44 -0700 | [diff] [blame] | 218 | |
| 219 | #if VK_USE_PLATFORM_WIN32_KHR |
| 220 | pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) gpa(instance, "vkCreateWin32SurfaceKHR"); |
| 221 | pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 222 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 223 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | e86e138 | 2015-11-24 15:50:44 -0700 | [diff] [blame] | 224 | pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR) gpa(instance, "vkCreateXcbSurfaceKHR"); |
| 225 | pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 226 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 227 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
| 228 | pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR) gpa(instance, "vkCreateXlibSurfaceKHR"); |
| 229 | pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); |
| 230 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 231 | #ifdef VK_USE_PLATFORM_MIR_KHR |
| 232 | pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR) gpa(instance, "vkCreateMirSurfaceKHR"); |
| 233 | pDisp->GetPhysicalDeviceMirPresentationSupportKHR = (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR"); |
| 234 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 235 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
| 236 | pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR) gpa(instance, "vkCreateWaylandSurfaceKHR"); |
| 237 | pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR) gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); |
| 238 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 239 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 240 | pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR) gpa(instance, "vkCreateAndroidSurfaceKHR"); |
| 241 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | e86e138 | 2015-11-24 15:50:44 -0700 | [diff] [blame] | 242 | |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 243 | instanceExtMap[pDisp].wsi_enabled = false; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 244 | for (i = 0; i < pCreateInfo->enabledExtensionNameCount; i++) { |
Ian Elliott | 1dcd109 | 2015-11-17 17:29:40 -0700 | [diff] [blame] | 245 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 246 | instanceExtMap[pDisp].wsi_enabled = true; |
| 247 | |
| 248 | } |
| 249 | } |
| 250 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 251 | // Indicate device or instance dispatch table type |
| 252 | typedef enum _DispTableType |
| 253 | { |
| 254 | DISP_TBL_TYPE_INSTANCE, |
| 255 | DISP_TBL_TYPE_DEVICE, |
| 256 | } DispTableType; |
| 257 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 258 | debug_report_data *mdd(const void* object) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 259 | { |
| 260 | dispatch_key key = get_dispatch_key(object); |
| 261 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 262 | return my_data->report_data; |
| 263 | } |
| 264 | |
| 265 | debug_report_data *mid(VkInstance object) |
| 266 | { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 267 | dispatch_key key = get_dispatch_key(object); |
| 268 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 269 | return my_data->report_data; |
| 270 | } |
| 271 | |
| 272 | // For each Queue's doubly linked-list of mem refs |
| 273 | typedef struct _OT_MEM_INFO { |
| 274 | VkDeviceMemory mem; |
| 275 | struct _OT_MEM_INFO *pNextMI; |
| 276 | struct _OT_MEM_INFO *pPrevMI; |
| 277 | |
| 278 | } OT_MEM_INFO; |
| 279 | |
| 280 | // Track Queue information |
| 281 | typedef struct _OT_QUEUE_INFO { |
| 282 | OT_MEM_INFO *pMemRefList; |
| 283 | struct _OT_QUEUE_INFO *pNextQI; |
| 284 | uint32_t queueNodeIndex; |
| 285 | VkQueue queue; |
| 286 | uint32_t refCount; |
| 287 | } OT_QUEUE_INFO; |
| 288 | |
| 289 | // Global list of QueueInfo structures, one per queue |
| 290 | static OT_QUEUE_INFO *g_pQueueInfo = NULL; |
| 291 | |
| 292 | // Convert an object type enum to an object type array index |
| 293 | static uint32_t |
| 294 | objTypeToIndex( |
| 295 | uint32_t objType) |
| 296 | { |
| 297 | uint32_t index = objType; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 298 | return index; |
| 299 | } |
| 300 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 301 | // Add new queue to head of global queue list |
| 302 | static void |
| 303 | addQueueInfo( |
| 304 | uint32_t queueNodeIndex, |
| 305 | VkQueue queue) |
| 306 | { |
| 307 | OT_QUEUE_INFO *pQueueInfo = new OT_QUEUE_INFO; |
| 308 | |
| 309 | if (pQueueInfo != NULL) { |
| 310 | memset(pQueueInfo, 0, sizeof(OT_QUEUE_INFO)); |
| 311 | pQueueInfo->queue = queue; |
| 312 | pQueueInfo->queueNodeIndex = queueNodeIndex; |
| 313 | pQueueInfo->pNextQI = g_pQueueInfo; |
| 314 | g_pQueueInfo = pQueueInfo; |
| 315 | } |
| 316 | else { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 317 | log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_QUEUE, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_INTERNAL_ERROR, "OBJTRACK", |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 318 | "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information"); |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | // Destroy memRef lists and free all memory |
| 323 | static void |
| 324 | destroyQueueMemRefLists(void) |
| 325 | { |
| 326 | OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo; |
| 327 | OT_QUEUE_INFO *pDelQueueInfo = NULL; |
| 328 | while (pQueueInfo != NULL) { |
| 329 | OT_MEM_INFO *pMemInfo = pQueueInfo->pMemRefList; |
| 330 | while (pMemInfo != NULL) { |
| 331 | OT_MEM_INFO *pDelMemInfo = pMemInfo; |
| 332 | pMemInfo = pMemInfo->pNextMI; |
| 333 | delete pDelMemInfo; |
| 334 | } |
| 335 | pDelQueueInfo = pQueueInfo; |
| 336 | pQueueInfo = pQueueInfo->pNextQI; |
| 337 | delete pDelQueueInfo; |
| 338 | } |
| 339 | g_pQueueInfo = pQueueInfo; |
| 340 | } |
| 341 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 342 | static void |
| 343 | setGpuQueueInfoState( |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 344 | uint32_t count, |
| 345 | void *pData) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 346 | { |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 347 | queueCount = count; |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 348 | queueInfo = (VkQueueFamilyProperties*)realloc((void*)queueInfo, count * sizeof(VkQueueFamilyProperties)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 349 | if (queueInfo != NULL) { |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 350 | memcpy(queueInfo, pData, count * sizeof(VkQueueFamilyProperties)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | |
| 354 | // Check Queue type flags for selected queue operations |
| 355 | static void |
| 356 | validateQueueFlags( |
| 357 | VkQueue queue, |
| 358 | const char *function) |
| 359 | { |
| 360 | OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo; |
| 361 | while ((pQueueInfo != NULL) && (pQueueInfo->queue != queue)) { |
| 362 | pQueueInfo = pQueueInfo->pNextQI; |
| 363 | } |
| 364 | if (pQueueInfo != NULL) { |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 365 | if ((queueInfo != NULL) && (queueInfo[pQueueInfo->queueNodeIndex].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == 0) { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 366 | log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_QUEUE, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 367 | "Attempting %s on a non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not set", function); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 368 | } else { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 369 | log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_QUEUE, reinterpret_cast<uint64_t>(queue), 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 370 | "Attempting %s on a possibly non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not known", function); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 371 | } |
| 372 | } |
| 373 | } |
| 374 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 375 | /* TODO: Port to new type safety */ |
| 376 | #if 0 |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 377 | // Check object status for selected flag state |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 378 | static VkBool32 |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 379 | validate_status( |
| 380 | VkObject dispatchable_object, |
| 381 | VkObject vkObj, |
| 382 | VkObjectType objType, |
| 383 | ObjectStatusFlags status_mask, |
| 384 | ObjectStatusFlags status_flag, |
| 385 | VkFlags msg_flags, |
| 386 | OBJECT_TRACK_ERROR error_code, |
| 387 | const char *fail_msg) |
| 388 | { |
| 389 | if (objMap.find(vkObj) != objMap.end()) { |
| 390 | OBJTRACK_NODE* pNode = objMap[vkObj]; |
| 391 | if ((pNode->status & status_mask) != status_flag) { |
| 392 | char str[1024]; |
| 393 | log_msg(mdd(dispatchable_object), msg_flags, pNode->objType, vkObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
| 394 | "OBJECT VALIDATION WARNING: %s object 0x%" PRIxLEAST64 ": %s", string_VkObjectType(objType), |
Courtney Goeltzenleuchter | dee721d | 2015-08-26 15:09:25 -0600 | [diff] [blame] | 395 | reinterpret_cast<uint64_t>(vkObj), fail_msg); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 396 | return VK_FALSE; |
| 397 | } |
| 398 | return VK_TRUE; |
| 399 | } |
| 400 | else { |
| 401 | // If we do not find it print an error |
| 402 | log_msg(mdd(dispatchable_object), msg_flags, (VkObjectType) 0, vkObj, 0, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
| 403 | "Unable to obtain status for non-existent object 0x%" PRIxLEAST64 " of %s type", |
Courtney Goeltzenleuchter | dee721d | 2015-08-26 15:09:25 -0600 | [diff] [blame] | 404 | reinterpret_cast<uint64_t>(vkObj), string_VkObjectType(objType)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 405 | return VK_FALSE; |
| 406 | } |
| 407 | } |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 408 | #endif |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 409 | |
| 410 | #include "vk_dispatch_table_helper.h" |
| 411 | static void |
| 412 | initObjectTracker( |
Courtney Goeltzenleuchter | 6d8e818 | 2015-11-25 14:31:49 -0700 | [diff] [blame] | 413 | layer_data *my_data, |
| 414 | const VkAllocationCallbacks *pAllocator) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 415 | { |
| 416 | uint32_t report_flags = 0; |
| 417 | uint32_t debug_action = 0; |
| 418 | FILE *log_output = NULL; |
| 419 | const char *option_str; |
| 420 | // initialize ObjectTracker options |
| 421 | report_flags = getLayerOptionFlags("ObjectTrackerReportFlags", 0); |
| 422 | getLayerOptionEnum("ObjectTrackerDebugAction", (uint32_t *) &debug_action); |
| 423 | |
| 424 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 425 | { |
| 426 | option_str = getLayerOption("ObjectTrackerLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 427 | log_output = getLayerLogOutput(option_str, "ObjectTracker"); |
Courtney Goeltzenleuchter | 05854bf | 2015-11-30 12:13:14 -0700 | [diff] [blame^] | 428 | VkDebugReportCallbackCreateInfoLUNARG dbgInfo; |
| 429 | memset(&dbgInfo, 0, sizeof(dbgInfo)); |
| 430 | dbgInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_LUNARG; |
| 431 | dbgInfo.pfnCallback = log_callback; |
| 432 | dbgInfo.pUserData = log_output; |
| 433 | dbgInfo.flags = report_flags; |
| 434 | layer_create_msg_callback(my_data->report_data, &dbgInfo, pAllocator, &my_data->logging_callback); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | if (!objLockInitialized) |
| 438 | { |
| 439 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
| 440 | // suggestion is to call this during vkCreateInstance(), and then we |
| 441 | // can clean it up during vkDestroyInstance(). However, that requires |
| 442 | // that the layer have per-instance locks. We need to come back and |
| 443 | // address this soon. |
| 444 | loader_platform_thread_create_mutex(&objLock); |
| 445 | objLockInitialized = 1; |
| 446 | } |
| 447 | } |
| 448 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 449 | // |
| 450 | // Forward declares of generated routines |
| 451 | // |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 452 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 453 | static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeLUNARG objType); |
| 454 | static void create_instance(VkInstance dispatchable_object, VkInstance object, VkDebugReportObjectTypeLUNARG objType); |
| 455 | static void create_device(VkDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeLUNARG objType); |
| 456 | static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeLUNARG objType); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 457 | static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object); |
| 458 | static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object); |
| 459 | static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object); |
| 460 | static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object); |
| 461 | static VkBool32 validate_instance(VkInstance dispatchable_object, VkInstance object); |
| 462 | static VkBool32 validate_device(VkDevice dispatchable_object, VkDevice object); |
| 463 | static VkBool32 validate_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object); |
| 464 | static VkBool32 validate_descriptor_set_layout(VkDevice dispatchable_object, VkDescriptorSetLayout object); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 465 | static VkBool32 validate_command_pool(VkDevice dispatchable_object, VkCommandPool object); |
| 466 | static void destroy_command_pool(VkDevice dispatchable_object, VkCommandPool object); |
| 467 | static void destroy_command_buffer(VkCommandBuffer dispatchable_object, VkCommandBuffer object); |
| 468 | static void destroy_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object); |
| 469 | static void destroy_descriptor_set(VkDevice dispatchable_object, VkDescriptorSet object); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 470 | static void destroy_instance(VkInstance dispatchable_object, VkInstance object); |
| 471 | static void destroy_device_memory(VkDevice dispatchable_object, VkDeviceMemory object); |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 472 | static VkBool32 set_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeLUNARG objType, ObjectStatusFlags status_flag); |
| 473 | static VkBool32 reset_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeLUNARG objType, ObjectStatusFlags status_flag); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 474 | #if 0 |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 475 | static VkBool32 validate_status(VkDevice dispatchable_object, VkFence object, VkDebugReportObjectTypeLUNARG objType, |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 476 | ObjectStatusFlags status_mask, ObjectStatusFlags status_flag, VkFlags msg_flags, OBJECT_TRACK_ERROR error_code, |
| 477 | const char *fail_msg); |
| 478 | #endif |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 479 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkPhysicalDeviceMap; |
| 480 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkImageMap; |
| 481 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkQueueMap; |
| 482 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkDescriptorSetMap; |
| 483 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkBufferMap; |
| 484 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkFenceMap; |
| 485 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSemaphoreMap; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 486 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandPoolMap; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 487 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandBufferMap; |
| 488 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSwapchainKHRMap; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 489 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 490 | static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 491 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 492 | if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) && |
| 493 | (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 494 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 495 | "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 496 | } |
| 497 | return VK_FALSE; |
| 498 | } |
| 499 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 500 | static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 501 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 502 | if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) && |
| 503 | (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 504 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 505 | "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 506 | } |
| 507 | return VK_FALSE; |
| 508 | } |
| 509 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 510 | static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 511 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 512 | if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 513 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, reinterpret_cast<uint64_t>(object), 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 514 | "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 515 | } |
| 516 | return VK_FALSE; |
| 517 | } |
| 518 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 519 | static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 520 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 521 | if (VkDescriptorSetMap.find(reinterpret_cast<uint64_t>(object)) == VkDescriptorSetMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 522 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 523 | "Invalid VkDescriptorSet Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 524 | } |
| 525 | return VK_FALSE; |
| 526 | } |
| 527 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 528 | static VkBool32 validate_buffer(VkQueue dispatchable_object, VkBuffer object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 529 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 530 | if (VkBufferMap.find(reinterpret_cast<uint64_t>(object)) != VkBufferMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 531 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 532 | "Invalid VkBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 533 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 534 | return VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 535 | } |
| 536 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 537 | static VkBool32 set_status(VkQueue dispatchable_object, VkFence object, VkDebugReportObjectTypeLUNARG objType, ObjectStatusFlags status_flag) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 538 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 539 | VkBool32 skipCall = VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 540 | if (object != VK_NULL_HANDLE) { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 541 | if (VkFenceMap.find(reinterpret_cast<uint64_t>(object)) != VkFenceMap.end()) { |
| 542 | OBJTRACK_NODE* pNode = VkFenceMap[reinterpret_cast<uint64_t>(object)]; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 543 | pNode->status |= status_flag; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 544 | } |
| 545 | else { |
| 546 | // If we do not find it print an error |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 547 | skipCall |= log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK", |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 548 | "Unable to set status for non-existent object 0x%" PRIxLEAST64 " of %s type", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 549 | reinterpret_cast<uint64_t>(object), string_VkDebugReportObjectTypeLUNARG(objType)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 550 | } |
| 551 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 552 | return skipCall; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 553 | } |
| 554 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 555 | static VkBool32 validate_semaphore(VkQueue dispatchable_object, VkSemaphore object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 556 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 557 | if (VkSemaphoreMap.find(reinterpret_cast<uint64_t>(object)) == VkSemaphoreMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 558 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 559 | "Invalid VkSemaphore Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 560 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 561 | return VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 562 | } |
| 563 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 564 | static VkBool32 validate_command_buffer(VkDevice dispatchable_object, VkCommandBuffer object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 565 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 566 | if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 567 | return log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, reinterpret_cast<uint64_t>(object), 0, OBJTRACK_INVALID_OBJECT, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 568 | "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 569 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 570 | return VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 571 | } |
| 572 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 573 | static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 574 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 575 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 576 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeLUNARG(objType), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 577 | reinterpret_cast<uint64_t>(vkObj)); |
| 578 | |
| 579 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 580 | pNewObjNode->objType = objType; |
| 581 | pNewObjNode->status = OBJSTATUS_NONE; |
| 582 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 583 | VkPhysicalDeviceMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 584 | uint32_t objIndex = objTypeToIndex(objType); |
| 585 | numObjs[objIndex]++; |
| 586 | numTotalObjs++; |
| 587 | } |
| 588 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 589 | static void create_surface_khr(VkInstance instance, VkSurfaceKHR surface, VkDebugReportObjectTypeLUNARG objType) |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 590 | { |
| 591 | // TODO: Add tracking of surface objects |
| 592 | } |
| 593 | |
| 594 | static void destroy_surface_khr(VkInstance instance, VkSurfaceKHR surface) |
| 595 | { |
| 596 | // TODO: Add tracking of surface objects |
| 597 | } |
| 598 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 599 | static void alloc_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 600 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 601 | log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 602 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeLUNARG(objType), |
Courtney Goeltzenleuchter | dee721d | 2015-08-26 15:09:25 -0600 | [diff] [blame] | 603 | reinterpret_cast<uint64_t>(vkObj)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 604 | |
| 605 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 606 | pNewObjNode->objType = objType; |
| 607 | pNewObjNode->status = OBJSTATUS_NONE; |
| 608 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
| 609 | pNewObjNode->parentObj = (uint64_t) commandPool; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 610 | VkCommandBufferMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 611 | uint32_t objIndex = objTypeToIndex(objType); |
| 612 | numObjs[objIndex]++; |
| 613 | numTotalObjs++; |
| 614 | } |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 615 | |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 616 | static void free_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer) |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 617 | { |
| 618 | uint64_t object_handle = reinterpret_cast<uint64_t>(commandBuffer); |
| 619 | if (VkCommandBufferMap.find(object_handle) != VkCommandBufferMap.end()) { |
| 620 | OBJTRACK_NODE* pNode = VkCommandBufferMap[(uint64_t)commandBuffer]; |
| 621 | |
| 622 | if (pNode->parentObj != reinterpret_cast<uint64_t>(commandPool)) { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 623 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT, pNode->objType, object_handle, 0, OBJTRACK_COMMAND_POOL_MISMATCH, "OBJTRACK", |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 624 | "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 625 | reinterpret_cast<uint64_t>(commandBuffer), pNode->parentObj, reinterpret_cast<uint64_t>(commandPool)); |
| 626 | } else { |
| 627 | |
| 628 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 629 | assert(numTotalObjs > 0); |
| 630 | numTotalObjs--; |
| 631 | assert(numObjs[objIndex] > 0); |
| 632 | numObjs[objIndex]--; |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 633 | log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT, pNode->objType, object_handle, 0, OBJTRACK_NONE, "OBJTRACK", |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 634 | "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 635 | string_VkDebugReportObjectTypeLUNARG(pNode->objType), reinterpret_cast<uint64_t>(commandBuffer), numTotalObjs, numObjs[objIndex], |
| 636 | string_VkDebugReportObjectTypeLUNARG(pNode->objType)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 637 | delete pNode; |
| 638 | VkCommandBufferMap.erase(object_handle); |
| 639 | } |
| 640 | } else { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 641 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, object_handle, 0, OBJTRACK_NONE, "OBJTRACK", |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 642 | "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
| 643 | object_handle); |
| 644 | } |
| 645 | } |
| 646 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 647 | static void alloc_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet vkObj, VkDebugReportObjectTypeLUNARG objType) |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 648 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 649 | log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 650 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeLUNARG(objType), |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 651 | reinterpret_cast<uint64_t>(vkObj)); |
| 652 | |
| 653 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 654 | pNewObjNode->objType = objType; |
| 655 | pNewObjNode->status = OBJSTATUS_NONE; |
| 656 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
| 657 | pNewObjNode->parentObj = (uint64_t) descriptorPool; |
| 658 | VkDescriptorSetMap[(uint64_t)vkObj] = pNewObjNode; |
| 659 | uint32_t objIndex = objTypeToIndex(objType); |
| 660 | numObjs[objIndex]++; |
| 661 | numTotalObjs++; |
| 662 | } |
| 663 | |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 664 | static void free_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet descriptorSet) |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 665 | { |
| 666 | uint64_t object_handle = reinterpret_cast<uint64_t>(descriptorSet); |
| 667 | if (VkDescriptorSetMap.find(object_handle) != VkDescriptorSetMap.end()) { |
| 668 | OBJTRACK_NODE* pNode = VkDescriptorSetMap[(uint64_t)descriptorSet]; |
| 669 | |
| 670 | if (pNode->parentObj != reinterpret_cast<uint64_t>(descriptorPool)) { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 671 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT, pNode->objType, object_handle, 0, OBJTRACK_DESCRIPTOR_POOL_MISMATCH, "OBJTRACK", |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 672 | "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 673 | reinterpret_cast<uint64_t>(descriptorSet), pNode->parentObj, reinterpret_cast<uint64_t>(descriptorPool)); |
| 674 | } else { |
| 675 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 676 | assert(numTotalObjs > 0); |
| 677 | numTotalObjs--; |
| 678 | assert(numObjs[objIndex] > 0); |
| 679 | numObjs[objIndex]--; |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 680 | log_msg(mdd(device), VK_DEBUG_REPORT_INFO_BIT, pNode->objType, object_handle, 0, OBJTRACK_NONE, "OBJTRACK", |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 681 | "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 682 | string_VkDebugReportObjectTypeLUNARG(pNode->objType), reinterpret_cast<uint64_t>(descriptorSet), numTotalObjs, numObjs[objIndex], |
| 683 | string_VkDebugReportObjectTypeLUNARG(pNode->objType)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 684 | delete pNode; |
| 685 | VkDescriptorSetMap.erase(object_handle); |
| 686 | } |
| 687 | } else { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 688 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, object_handle, 0, OBJTRACK_NONE, "OBJTRACK", |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 689 | "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
| 690 | object_handle); |
| 691 | } |
| 692 | } |
| 693 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 694 | static void create_swapchain_khr(VkDevice dispatchable_object, VkSwapchainKHR vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 695 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 696 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT, objType, (uint64_t) vkObj, 0, OBJTRACK_NONE, "OBJTRACK", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 697 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeLUNARG(objType), |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 698 | reinterpret_cast<uint64_t>(vkObj)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 699 | |
| 700 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 701 | pNewObjNode->objType = objType; |
| 702 | pNewObjNode->status = OBJSTATUS_NONE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 703 | pNewObjNode->vkObj = (uint64_t) vkObj; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 704 | VkSwapchainKHRMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 705 | uint32_t objIndex = objTypeToIndex(objType); |
| 706 | numObjs[objIndex]++; |
| 707 | numTotalObjs++; |
| 708 | } |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 709 | static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 710 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 711 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT, objType, reinterpret_cast<uint64_t>(vkObj), 0, OBJTRACK_NONE, "OBJTRACK", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 712 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, string_VkDebugReportObjectTypeLUNARG(objType), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 713 | reinterpret_cast<uint64_t>(vkObj)); |
| 714 | |
| 715 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 716 | pNewObjNode->objType = objType; |
| 717 | pNewObjNode->status = OBJSTATUS_NONE; |
| 718 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 719 | VkQueueMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 720 | uint32_t objIndex = objTypeToIndex(objType); |
| 721 | numObjs[objIndex]++; |
| 722 | numTotalObjs++; |
| 723 | } |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 724 | static void create_swapchain_image_obj(VkDevice dispatchable_object, VkImage vkObj, VkSwapchainKHR swapchain) |
| 725 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 726 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT, VK_OBJECT_TYPE_IMAGE, (uint64_t) vkObj, 0, OBJTRACK_NONE, "OBJTRACK", |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 727 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, "SwapchainImage", |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 728 | reinterpret_cast<uint64_t>(vkObj)); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 729 | |
| 730 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 731 | pNewObjNode->objType = VK_OBJECT_TYPE_IMAGE; |
| 732 | pNewObjNode->status = OBJSTATUS_NONE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 733 | pNewObjNode->vkObj = (uint64_t) vkObj; |
| 734 | pNewObjNode->parentObj = (uint64_t) swapchain; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 735 | swapchainImageMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 736 | } |
| 737 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 738 | static void destroy_swapchain(VkDevice dispatchable_object, VkSwapchainKHR object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 739 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 740 | if (VkSwapchainKHRMap.find(reinterpret_cast<uint64_t>(object)) != VkSwapchainKHRMap.end()) { |
| 741 | OBJTRACK_NODE* pNode = VkSwapchainKHRMap[reinterpret_cast<uint64_t>(object)]; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 742 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 743 | assert(numTotalObjs > 0); |
| 744 | numTotalObjs--; |
| 745 | assert(numObjs[objIndex] > 0); |
| 746 | numObjs[objIndex]--; |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 747 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFO_BIT, pNode->objType, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK", |
Michael Lentine | 010f469 | 2015-11-03 16:19:46 -0800 | [diff] [blame] | 748 | "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 749 | string_VkDebugReportObjectTypeLUNARG(pNode->objType), (uint64_t) object, numTotalObjs, numObjs[objIndex], |
| 750 | string_VkDebugReportObjectTypeLUNARG(pNode->objType)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 751 | delete pNode; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 752 | VkSwapchainKHRMap.erase(reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 753 | } else { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame] | 754 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT, (VkDebugReportObjectTypeLUNARG) 0, (uint64_t) object, 0, OBJTRACK_NONE, "OBJTRACK", |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 755 | "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 756 | reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 757 | } |
| 758 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 759 | // |
| 760 | // Non-auto-generated API functions called by generated code |
| 761 | // |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 762 | VkResult |
| 763 | explicit_CreateInstance( |
| 764 | const VkInstanceCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 765 | const VkAllocationCallbacks * pAllocator, |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 766 | VkInstance * pInstance) |
| 767 | { |
David Pinedo | c0fa1ab | 2015-07-31 10:46:25 -0600 | [diff] [blame] | 768 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 769 | VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, *pInstance); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 770 | VkResult result = pInstanceTable->CreateInstance(pCreateInfo, pAllocator, pInstance); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 771 | |
| 772 | if (result == VK_SUCCESS) { |
| 773 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 774 | my_data->report_data = debug_report_create_instance( |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 775 | pInstanceTable, |
| 776 | *pInstance, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 777 | pCreateInfo->enabledExtensionNameCount, |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 778 | pCreateInfo->ppEnabledExtensionNames); |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 779 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 780 | |
Courtney Goeltzenleuchter | 6d8e818 | 2015-11-25 14:31:49 -0700 | [diff] [blame] | 781 | initObjectTracker(my_data, pAllocator); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 782 | create_instance(*pInstance, *pInstance, VK_OBJECT_TYPE_INSTANCE); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 783 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 784 | return result; |
| 785 | } |
| 786 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 787 | void |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 788 | explicit_GetPhysicalDeviceQueueFamilyProperties( |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 789 | VkPhysicalDevice gpu, |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 790 | uint32_t* pCount, |
| 791 | VkQueueFamilyProperties* pProperties) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 792 | { |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 793 | get_dispatch_table(ObjectTracker_instance_table_map, gpu)->GetPhysicalDeviceQueueFamilyProperties(gpu, pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 794 | |
| 795 | loader_platform_thread_lock_mutex(&objLock); |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 796 | if (pProperties != NULL) |
| 797 | setGpuQueueInfoState(*pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 798 | loader_platform_thread_unlock_mutex(&objLock); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | VkResult |
| 802 | explicit_CreateDevice( |
| 803 | VkPhysicalDevice gpu, |
| 804 | const VkDeviceCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 805 | const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 806 | VkDevice *pDevice) |
| 807 | { |
| 808 | loader_platform_thread_lock_mutex(&objLock); |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 809 | // VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, gpu); |
| 810 | VkLayerDispatchTable *pDeviceTable = get_dispatch_table(ObjectTracker_device_table_map, *pDevice); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 811 | VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 812 | if (result == VK_SUCCESS) { |
| 813 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 814 | //// VkLayerDispatchTable *pTable = get_dispatch_table(ObjectTracker_device_table_map, *pDevice); |
| 815 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 816 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 817 | create_device(*pDevice, *pDevice, VK_OBJECT_TYPE_DEVICE); |
Jon Ashburn | 8acd233 | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 818 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | loader_platform_thread_unlock_mutex(&objLock); |
| 822 | return result; |
| 823 | } |
| 824 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 825 | VkResult explicit_EnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) |
| 826 | { |
| 827 | VkBool32 skipCall = VK_FALSE; |
| 828 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 829 | skipCall |= validate_instance(instance, instance); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 830 | loader_platform_thread_unlock_mutex(&objLock); |
| 831 | if (skipCall) |
| 832 | return VK_ERROR_VALIDATION_FAILED; |
| 833 | VkResult result = get_dispatch_table(ObjectTracker_instance_table_map, instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
| 834 | loader_platform_thread_lock_mutex(&objLock); |
| 835 | if (result == VK_SUCCESS) { |
| 836 | if (pPhysicalDevices) { |
| 837 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 838 | create_physical_device(instance, pPhysicalDevices[i], VK_OBJECT_TYPE_PHYSICAL_DEVICE); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 839 | } |
| 840 | } |
| 841 | } |
| 842 | loader_platform_thread_unlock_mutex(&objLock); |
| 843 | return result; |
| 844 | } |
| 845 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 846 | void |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 847 | explicit_GetDeviceQueue( |
| 848 | VkDevice device, |
| 849 | uint32_t queueNodeIndex, |
| 850 | uint32_t queueIndex, |
| 851 | VkQueue *pQueue) |
| 852 | { |
| 853 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 854 | validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 855 | loader_platform_thread_unlock_mutex(&objLock); |
| 856 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 857 | get_dispatch_table(ObjectTracker_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 858 | |
| 859 | loader_platform_thread_lock_mutex(&objLock); |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 860 | addQueueInfo(queueNodeIndex, *pQueue); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 861 | create_queue(device, *pQueue, VK_OBJECT_TYPE_QUEUE); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 862 | loader_platform_thread_unlock_mutex(&objLock); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | VkResult |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 866 | explicit_MapMemory( |
| 867 | VkDevice device, |
| 868 | VkDeviceMemory mem, |
| 869 | VkDeviceSize offset, |
| 870 | VkDeviceSize size, |
| 871 | VkFlags flags, |
| 872 | void **ppData) |
| 873 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 874 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 875 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 876 | skipCall |= set_device_memory_status(device, mem, VK_OBJECT_TYPE_DEVICE_MEMORY, OBJSTATUS_GPU_MEM_MAPPED); |
| 877 | skipCall |= validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 878 | loader_platform_thread_unlock_mutex(&objLock); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 879 | if (skipCall == VK_TRUE) |
| 880 | return VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 881 | |
| 882 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData); |
| 883 | |
| 884 | return result; |
| 885 | } |
| 886 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 887 | void |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 888 | explicit_UnmapMemory( |
| 889 | VkDevice device, |
| 890 | VkDeviceMemory mem) |
| 891 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 892 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 893 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 894 | skipCall |= reset_device_memory_status(device, mem, VK_OBJECT_TYPE_DEVICE_MEMORY, OBJSTATUS_GPU_MEM_MAPPED); |
| 895 | skipCall |= validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 896 | loader_platform_thread_unlock_mutex(&objLock); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 897 | if (skipCall == VK_TRUE) |
| 898 | return; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 899 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 900 | get_dispatch_table(ObjectTracker_device_table_map, device)->UnmapMemory(device, mem); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 901 | } |
| 902 | |
| 903 | VkResult |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 904 | explicit_QueueBindSparse( |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 905 | VkQueue queue, |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 906 | uint32_t bindInfoCount, |
| 907 | const VkBindSparseInfo* pBindInfo, |
| 908 | VkFence fence) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 909 | { |
| 910 | loader_platform_thread_lock_mutex(&objLock); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 911 | validateQueueFlags(queue, "QueueBindSparse"); |
| 912 | |
| 913 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 914 | for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++) |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 915 | validate_buffer(queue, pBindInfo[i].pBufferBinds[j].buffer); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 916 | for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++) |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 917 | validate_image(queue, pBindInfo[i].pImageOpaqueBinds[j].image); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 918 | for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++) |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 919 | validate_image(queue, pBindInfo[i].pImageBinds[j].image); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 920 | } |
| 921 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 922 | loader_platform_thread_unlock_mutex(&objLock); |
| 923 | |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 924 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 925 | return result; |
| 926 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 927 | |
| 928 | VkResult |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 929 | explicit_AllocateCommandBuffers( |
| 930 | VkDevice device, |
| 931 | const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 932 | VkCommandBuffer* pCommandBuffers) |
| 933 | { |
| 934 | VkBool32 skipCall = VK_FALSE; |
| 935 | loader_platform_thread_lock_mutex(&objLock); |
| 936 | skipCall |= validate_device(device, device); |
| 937 | skipCall |= validate_command_pool(device, pAllocateInfo->commandPool); |
| 938 | loader_platform_thread_unlock_mutex(&objLock); |
| 939 | |
| 940 | if (skipCall) { |
| 941 | return VK_ERROR_VALIDATION_FAILED; |
| 942 | } |
| 943 | |
| 944 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->AllocateCommandBuffers( |
| 945 | device, pAllocateInfo, pCommandBuffers); |
| 946 | |
| 947 | loader_platform_thread_lock_mutex(&objLock); |
| 948 | for (uint32_t i = 0; i < pAllocateInfo->bufferCount; i++) { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 949 | alloc_command_buffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], VK_OBJECT_TYPE_COMMAND_BUFFER); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 950 | } |
| 951 | loader_platform_thread_unlock_mutex(&objLock); |
| 952 | |
| 953 | return result; |
| 954 | } |
| 955 | |
| 956 | VkResult |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 957 | explicit_AllocateDescriptorSets( |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 958 | VkDevice device, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 959 | const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 960 | VkDescriptorSet *pDescriptorSets) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 961 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 962 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 963 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 964 | skipCall |= validate_device(device, device); |
| 965 | skipCall |= validate_descriptor_pool(device, pAllocateInfo->descriptorPool); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 966 | for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 967 | skipCall |= validate_descriptor_set_layout(device, pAllocateInfo->pSetLayouts[i]); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 968 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 969 | loader_platform_thread_unlock_mutex(&objLock); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 970 | if (skipCall) |
| 971 | return VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 972 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 973 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->AllocateDescriptorSets( |
| 974 | device, pAllocateInfo, pDescriptorSets); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 975 | |
| 976 | loader_platform_thread_lock_mutex(&objLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 977 | for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 978 | alloc_descriptor_set(device, pAllocateInfo->descriptorPool, pDescriptorSets[i], VK_OBJECT_TYPE_DESCRIPTOR_SET); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 979 | } |
| 980 | loader_platform_thread_unlock_mutex(&objLock); |
| 981 | |
| 982 | return result; |
| 983 | } |
| 984 | |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 985 | void |
| 986 | explicit_FreeCommandBuffers( |
| 987 | VkDevice device, |
| 988 | VkCommandPool commandPool, |
| 989 | uint32_t commandBufferCount, |
| 990 | const VkCommandBuffer *pCommandBuffers) |
| 991 | { |
| 992 | loader_platform_thread_lock_mutex(&objLock); |
| 993 | validate_command_pool(device, commandPool); |
| 994 | validate_device(device, device); |
| 995 | loader_platform_thread_unlock_mutex(&objLock); |
| 996 | |
| 997 | get_dispatch_table(ObjectTracker_device_table_map, device)->FreeCommandBuffers(device, |
| 998 | commandPool, commandBufferCount, pCommandBuffers); |
| 999 | |
| 1000 | loader_platform_thread_lock_mutex(&objLock); |
| 1001 | for (uint32_t i = 0; i < commandBufferCount; i++) |
| 1002 | { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 1003 | free_command_buffer(device, commandPool, *pCommandBuffers); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1004 | pCommandBuffers++; |
| 1005 | } |
| 1006 | loader_platform_thread_unlock_mutex(&objLock); |
| 1007 | } |
| 1008 | |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 1009 | void |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 1010 | explicit_DestroySwapchainKHR( |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 1011 | VkDevice device, |
| 1012 | VkSwapchainKHR swapchain, |
| 1013 | const VkAllocationCallbacks *pAllocator) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1014 | { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1015 | loader_platform_thread_lock_mutex(&objLock); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1016 | // A swapchain's images are implicitly deleted when the swapchain is deleted. |
| 1017 | // Remove this swapchain's images from our map of such images. |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1018 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = swapchainImageMap.begin(); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1019 | while (itr != swapchainImageMap.end()) { |
| 1020 | OBJTRACK_NODE* pNode = (*itr).second; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1021 | if (pNode->parentObj == reinterpret_cast<uint64_t>(swapchain)) { |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1022 | swapchainImageMap.erase(itr++); |
| 1023 | } else { |
| 1024 | ++itr; |
| 1025 | } |
| 1026 | } |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1027 | destroy_swapchain(device, swapchain); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1028 | loader_platform_thread_unlock_mutex(&objLock); |
| 1029 | |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 1030 | get_dispatch_table(ObjectTracker_device_table_map, device)->DestroySwapchainKHR(device, swapchain, pAllocator); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1031 | } |
| 1032 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 1033 | void |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1034 | explicit_FreeMemory( |
| 1035 | VkDevice device, |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1036 | VkDeviceMemory mem, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1037 | const VkAllocationCallbacks* pAllocator) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1038 | { |
| 1039 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1040 | validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1041 | loader_platform_thread_unlock_mutex(&objLock); |
| 1042 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1043 | get_dispatch_table(ObjectTracker_device_table_map, device)->FreeMemory(device, mem, pAllocator); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1044 | |
| 1045 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1046 | destroy_device_memory(device, mem); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1047 | loader_platform_thread_unlock_mutex(&objLock); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1048 | } |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 1049 | |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1050 | VkResult |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1051 | explicit_FreeDescriptorSets( |
| 1052 | VkDevice device, |
| 1053 | VkDescriptorPool descriptorPool, |
| 1054 | uint32_t count, |
| 1055 | const VkDescriptorSet *pDescriptorSets) |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1056 | { |
| 1057 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1058 | validate_descriptor_pool(device, descriptorPool); |
| 1059 | validate_device(device, device); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1060 | loader_platform_thread_unlock_mutex(&objLock); |
| 1061 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets); |
| 1062 | |
| 1063 | loader_platform_thread_lock_mutex(&objLock); |
Courtney Goeltzenleuchter | 7ebf121 | 2015-07-23 11:25:17 -0600 | [diff] [blame] | 1064 | for (uint32_t i=0; i<count; i++) |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1065 | { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 1066 | free_descriptor_set(device, descriptorPool, *pDescriptorSets++); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1067 | } |
| 1068 | loader_platform_thread_unlock_mutex(&objLock); |
| 1069 | return result; |
| 1070 | } |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1071 | |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1072 | void |
| 1073 | explicit_DestroyDescriptorPool( |
| 1074 | VkDevice device, |
| 1075 | VkDescriptorPool descriptorPool, |
| 1076 | const VkAllocationCallbacks *pAllocator) |
| 1077 | { |
| 1078 | VkBool32 skipCall = VK_FALSE; |
| 1079 | loader_platform_thread_lock_mutex(&objLock); |
| 1080 | skipCall |= validate_device(device, device); |
| 1081 | skipCall |= validate_descriptor_pool(device, descriptorPool); |
| 1082 | loader_platform_thread_unlock_mutex(&objLock); |
| 1083 | if (skipCall) { |
| 1084 | return; |
| 1085 | } |
| 1086 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. |
| 1087 | // Remove this pool's descriptor sets from our descriptorSet map. |
| 1088 | loader_platform_thread_lock_mutex(&objLock); |
| 1089 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkDescriptorSetMap.begin(); |
| 1090 | while (itr != VkDescriptorSetMap.end()) { |
| 1091 | OBJTRACK_NODE* pNode = (*itr).second; |
Mark Lobodzinski | b29731a | 2015-11-18 11:01:02 -0700 | [diff] [blame] | 1092 | auto del_itr = itr++; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1093 | if (pNode->parentObj == reinterpret_cast<uint64_t>(descriptorPool)) { |
Mark Lobodzinski | b29731a | 2015-11-18 11:01:02 -0700 | [diff] [blame] | 1094 | destroy_descriptor_set(device, reinterpret_cast<VkDescriptorSet>((*del_itr).first)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1095 | } |
| 1096 | } |
| 1097 | destroy_descriptor_pool(device, descriptorPool); |
| 1098 | loader_platform_thread_unlock_mutex(&objLock); |
| 1099 | get_dispatch_table(ObjectTracker_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool, pAllocator); |
| 1100 | } |
| 1101 | |
| 1102 | void |
| 1103 | explicit_DestroyCommandPool( |
| 1104 | VkDevice device, |
| 1105 | VkCommandPool commandPool, |
| 1106 | const VkAllocationCallbacks *pAllocator) |
| 1107 | { |
| 1108 | VkBool32 skipCall = VK_FALSE; |
| 1109 | loader_platform_thread_lock_mutex(&objLock); |
| 1110 | skipCall |= validate_device(device, device); |
| 1111 | skipCall |= validate_command_pool(device, commandPool); |
| 1112 | loader_platform_thread_unlock_mutex(&objLock); |
| 1113 | if (skipCall) { |
| 1114 | return; |
| 1115 | } |
| 1116 | loader_platform_thread_lock_mutex(&objLock); |
| 1117 | // A CommandPool's command buffers are implicitly deleted when the pool is deleted. |
| 1118 | // Remove this pool's cmdBuffers from our cmd buffer map. |
| 1119 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkCommandBufferMap.begin(); |
| 1120 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator del_itr; |
| 1121 | while (itr != VkCommandBufferMap.end()) { |
| 1122 | OBJTRACK_NODE* pNode = (*itr).second; |
| 1123 | del_itr = itr++; |
| 1124 | if (pNode->parentObj == reinterpret_cast<uint64_t>(commandPool)) { |
| 1125 | destroy_command_buffer(reinterpret_cast<VkCommandBuffer>((*del_itr).first), |
| 1126 | reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
| 1127 | } |
| 1128 | } |
| 1129 | destroy_command_pool(device, commandPool); |
| 1130 | loader_platform_thread_unlock_mutex(&objLock); |
| 1131 | get_dispatch_table(ObjectTracker_device_table_map, device)->DestroyCommandPool(device, commandPool, pAllocator); |
| 1132 | } |
| 1133 | |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1134 | VkResult |
| 1135 | explicit_GetSwapchainImagesKHR( |
| 1136 | VkDevice device, |
| 1137 | VkSwapchainKHR swapchain, |
| 1138 | uint32_t *pCount, |
| 1139 | VkImage *pSwapchainImages) |
| 1140 | { |
| 1141 | VkBool32 skipCall = VK_FALSE; |
| 1142 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1143 | skipCall |= validate_device(device, device); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1144 | loader_platform_thread_unlock_mutex(&objLock); |
| 1145 | if (skipCall) |
| 1146 | return VK_ERROR_VALIDATION_FAILED; |
| 1147 | |
| 1148 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages); |
| 1149 | |
| 1150 | if (pSwapchainImages != NULL) { |
| 1151 | loader_platform_thread_lock_mutex(&objLock); |
| 1152 | for (uint32_t i = 0; i < *pCount; i++) { |
| 1153 | create_swapchain_image_obj(device, pSwapchainImages[i], swapchain); |
| 1154 | } |
| 1155 | loader_platform_thread_unlock_mutex(&objLock); |
| 1156 | } |
| 1157 | return result; |
| 1158 | } |
| 1159 | |