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 |
| 78 | VkDbgMsgCallback 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( |
| 413 | layer_data *my_data) |
| 414 | { |
| 415 | uint32_t report_flags = 0; |
| 416 | uint32_t debug_action = 0; |
| 417 | FILE *log_output = NULL; |
| 418 | const char *option_str; |
| 419 | // initialize ObjectTracker options |
| 420 | report_flags = getLayerOptionFlags("ObjectTrackerReportFlags", 0); |
| 421 | getLayerOptionEnum("ObjectTrackerDebugAction", (uint32_t *) &debug_action); |
| 422 | |
| 423 | if (debug_action & VK_DBG_LAYER_ACTION_LOG_MSG) |
| 424 | { |
| 425 | option_str = getLayerOption("ObjectTrackerLogFilename"); |
Tobin Ehlis | b1df55e | 2015-09-15 09:55:54 -0600 | [diff] [blame] | 426 | log_output = getLayerLogOutput(option_str, "ObjectTracker"); |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 427 | layer_create_msg_callback(my_data->report_data, report_flags, log_callback, (void *) log_output, &(my_data->logging_callback)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | if (!objLockInitialized) |
| 431 | { |
| 432 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
| 433 | // suggestion is to call this during vkCreateInstance(), and then we |
| 434 | // can clean it up during vkDestroyInstance(). However, that requires |
| 435 | // that the layer have per-instance locks. We need to come back and |
| 436 | // address this soon. |
| 437 | loader_platform_thread_create_mutex(&objLock); |
| 438 | objLockInitialized = 1; |
| 439 | } |
| 440 | } |
| 441 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 442 | // |
| 443 | // Forward declares of generated routines |
| 444 | // |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 445 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 446 | static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeLUNARG objType); |
| 447 | static void create_instance(VkInstance dispatchable_object, VkInstance object, VkDebugReportObjectTypeLUNARG objType); |
| 448 | static void create_device(VkDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeLUNARG objType); |
| 449 | static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeLUNARG objType); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 450 | static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object); |
| 451 | static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object); |
| 452 | static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object); |
| 453 | static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object); |
| 454 | static VkBool32 validate_instance(VkInstance dispatchable_object, VkInstance object); |
| 455 | static VkBool32 validate_device(VkDevice dispatchable_object, VkDevice object); |
| 456 | static VkBool32 validate_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object); |
| 457 | static VkBool32 validate_descriptor_set_layout(VkDevice dispatchable_object, VkDescriptorSetLayout object); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 458 | static VkBool32 validate_command_pool(VkDevice dispatchable_object, VkCommandPool object); |
| 459 | static void destroy_command_pool(VkDevice dispatchable_object, VkCommandPool object); |
| 460 | static void destroy_command_buffer(VkCommandBuffer dispatchable_object, VkCommandBuffer object); |
| 461 | static void destroy_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object); |
| 462 | static void destroy_descriptor_set(VkDevice dispatchable_object, VkDescriptorSet object); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 463 | static void destroy_instance(VkInstance dispatchable_object, VkInstance object); |
| 464 | static void destroy_device_memory(VkDevice dispatchable_object, VkDeviceMemory object); |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 465 | static VkBool32 set_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeLUNARG objType, ObjectStatusFlags status_flag); |
| 466 | 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] | 467 | #if 0 |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 468 | static VkBool32 validate_status(VkDevice dispatchable_object, VkFence object, VkDebugReportObjectTypeLUNARG objType, |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 469 | ObjectStatusFlags status_mask, ObjectStatusFlags status_flag, VkFlags msg_flags, OBJECT_TRACK_ERROR error_code, |
| 470 | const char *fail_msg); |
| 471 | #endif |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 472 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkPhysicalDeviceMap; |
| 473 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkImageMap; |
| 474 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkQueueMap; |
| 475 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkDescriptorSetMap; |
| 476 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkBufferMap; |
| 477 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkFenceMap; |
| 478 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSemaphoreMap; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 479 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandPoolMap; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 480 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkCommandBufferMap; |
| 481 | extern unordered_map<uint64_t, OBJTRACK_NODE*> VkSwapchainKHRMap; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 482 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 483 | static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 484 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 485 | if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) && |
| 486 | (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 487 | 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] | 488 | "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 489 | } |
| 490 | return VK_FALSE; |
| 491 | } |
| 492 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 493 | static VkBool32 validate_image(VkCommandBuffer dispatchable_object, VkImage object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 494 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 495 | if ((VkImageMap.find(reinterpret_cast<uint64_t>(object)) == VkImageMap.end()) && |
| 496 | (swapchainImageMap.find(reinterpret_cast<uint64_t>(object)) == swapchainImageMap.end())) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 497 | 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] | 498 | "Invalid VkImage Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 499 | } |
| 500 | return VK_FALSE; |
| 501 | } |
| 502 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 503 | static VkBool32 validate_command_buffer(VkQueue dispatchable_object, VkCommandBuffer object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 504 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 505 | if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 506 | 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] | 507 | "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 508 | } |
| 509 | return VK_FALSE; |
| 510 | } |
| 511 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 512 | static VkBool32 validate_descriptor_set(VkCommandBuffer dispatchable_object, VkDescriptorSet object) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 513 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 514 | if (VkDescriptorSetMap.find(reinterpret_cast<uint64_t>(object)) == VkDescriptorSetMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 515 | 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] | 516 | "Invalid VkDescriptorSet Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 517 | } |
| 518 | return VK_FALSE; |
| 519 | } |
| 520 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 521 | static VkBool32 validate_buffer(VkQueue dispatchable_object, VkBuffer object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 522 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 523 | if (VkBufferMap.find(reinterpret_cast<uint64_t>(object)) != VkBufferMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 524 | 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] | 525 | "Invalid VkBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 526 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 527 | return VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 528 | } |
| 529 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 530 | 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] | 531 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 532 | VkBool32 skipCall = VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 533 | if (object != VK_NULL_HANDLE) { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 534 | if (VkFenceMap.find(reinterpret_cast<uint64_t>(object)) != VkFenceMap.end()) { |
| 535 | OBJTRACK_NODE* pNode = VkFenceMap[reinterpret_cast<uint64_t>(object)]; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 536 | pNode->status |= status_flag; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 537 | } |
| 538 | else { |
| 539 | // If we do not find it print an error |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 540 | 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] | 541 | "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^] | 542 | reinterpret_cast<uint64_t>(object), string_VkDebugReportObjectTypeLUNARG(objType)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 543 | } |
| 544 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 545 | return skipCall; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 546 | } |
| 547 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 548 | static VkBool32 validate_semaphore(VkQueue dispatchable_object, VkSemaphore object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 549 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 550 | if (VkSemaphoreMap.find(reinterpret_cast<uint64_t>(object)) == VkSemaphoreMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 551 | 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] | 552 | "Invalid VkSemaphore Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 553 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 554 | return VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 555 | } |
| 556 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 557 | static VkBool32 validate_command_buffer(VkDevice dispatchable_object, VkCommandBuffer object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 558 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 559 | if (VkCommandBufferMap.find(reinterpret_cast<uint64_t>(object)) == VkCommandBufferMap.end()) { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 560 | 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] | 561 | "Invalid VkCommandBuffer Object %" PRIu64, reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 562 | } |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 563 | return VK_FALSE; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 564 | } |
| 565 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 566 | static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 567 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 568 | 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^] | 569 | "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] | 570 | reinterpret_cast<uint64_t>(vkObj)); |
| 571 | |
| 572 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 573 | pNewObjNode->objType = objType; |
| 574 | pNewObjNode->status = OBJSTATUS_NONE; |
| 575 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 576 | VkPhysicalDeviceMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 577 | uint32_t objIndex = objTypeToIndex(objType); |
| 578 | numObjs[objIndex]++; |
| 579 | numTotalObjs++; |
| 580 | } |
| 581 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 582 | static void create_surface_khr(VkInstance instance, VkSurfaceKHR surface, VkDebugReportObjectTypeLUNARG objType) |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 583 | { |
| 584 | // TODO: Add tracking of surface objects |
| 585 | } |
| 586 | |
| 587 | static void destroy_surface_khr(VkInstance instance, VkSurfaceKHR surface) |
| 588 | { |
| 589 | // TODO: Add tracking of surface objects |
| 590 | } |
| 591 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 592 | 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] | 593 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 594 | 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^] | 595 | "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] | 596 | reinterpret_cast<uint64_t>(vkObj)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 597 | |
| 598 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 599 | pNewObjNode->objType = objType; |
| 600 | pNewObjNode->status = OBJSTATUS_NONE; |
| 601 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
| 602 | pNewObjNode->parentObj = (uint64_t) commandPool; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 603 | VkCommandBufferMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 604 | uint32_t objIndex = objTypeToIndex(objType); |
| 605 | numObjs[objIndex]++; |
| 606 | numTotalObjs++; |
| 607 | } |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 608 | |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 609 | static void free_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer) |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 610 | { |
| 611 | uint64_t object_handle = reinterpret_cast<uint64_t>(commandBuffer); |
| 612 | if (VkCommandBufferMap.find(object_handle) != VkCommandBufferMap.end()) { |
| 613 | OBJTRACK_NODE* pNode = VkCommandBufferMap[(uint64_t)commandBuffer]; |
| 614 | |
| 615 | if (pNode->parentObj != reinterpret_cast<uint64_t>(commandPool)) { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 616 | 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] | 617 | "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 618 | reinterpret_cast<uint64_t>(commandBuffer), pNode->parentObj, reinterpret_cast<uint64_t>(commandPool)); |
| 619 | } else { |
| 620 | |
| 621 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 622 | assert(numTotalObjs > 0); |
| 623 | numTotalObjs--; |
| 624 | assert(numObjs[objIndex] > 0); |
| 625 | numObjs[objIndex]--; |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 626 | 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] | 627 | "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^] | 628 | string_VkDebugReportObjectTypeLUNARG(pNode->objType), reinterpret_cast<uint64_t>(commandBuffer), numTotalObjs, numObjs[objIndex], |
| 629 | string_VkDebugReportObjectTypeLUNARG(pNode->objType)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 630 | delete pNode; |
| 631 | VkCommandBufferMap.erase(object_handle); |
| 632 | } |
| 633 | } else { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 634 | 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] | 635 | "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
| 636 | object_handle); |
| 637 | } |
| 638 | } |
| 639 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 640 | 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] | 641 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 642 | 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^] | 643 | "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] | 644 | reinterpret_cast<uint64_t>(vkObj)); |
| 645 | |
| 646 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 647 | pNewObjNode->objType = objType; |
| 648 | pNewObjNode->status = OBJSTATUS_NONE; |
| 649 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
| 650 | pNewObjNode->parentObj = (uint64_t) descriptorPool; |
| 651 | VkDescriptorSetMap[(uint64_t)vkObj] = pNewObjNode; |
| 652 | uint32_t objIndex = objTypeToIndex(objType); |
| 653 | numObjs[objIndex]++; |
| 654 | numTotalObjs++; |
| 655 | } |
| 656 | |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 657 | static void free_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet descriptorSet) |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 658 | { |
| 659 | uint64_t object_handle = reinterpret_cast<uint64_t>(descriptorSet); |
| 660 | if (VkDescriptorSetMap.find(object_handle) != VkDescriptorSetMap.end()) { |
| 661 | OBJTRACK_NODE* pNode = VkDescriptorSetMap[(uint64_t)descriptorSet]; |
| 662 | |
| 663 | if (pNode->parentObj != reinterpret_cast<uint64_t>(descriptorPool)) { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 664 | 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] | 665 | "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 666 | reinterpret_cast<uint64_t>(descriptorSet), pNode->parentObj, reinterpret_cast<uint64_t>(descriptorPool)); |
| 667 | } else { |
| 668 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 669 | assert(numTotalObjs > 0); |
| 670 | numTotalObjs--; |
| 671 | assert(numObjs[objIndex] > 0); |
| 672 | numObjs[objIndex]--; |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 673 | 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] | 674 | "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^] | 675 | string_VkDebugReportObjectTypeLUNARG(pNode->objType), reinterpret_cast<uint64_t>(descriptorSet), numTotalObjs, numObjs[objIndex], |
| 676 | string_VkDebugReportObjectTypeLUNARG(pNode->objType)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 677 | delete pNode; |
| 678 | VkDescriptorSetMap.erase(object_handle); |
| 679 | } |
| 680 | } else { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 681 | 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] | 682 | "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
| 683 | object_handle); |
| 684 | } |
| 685 | } |
| 686 | |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 687 | static void create_swapchain_khr(VkDevice dispatchable_object, VkSwapchainKHR vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 688 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 689 | 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^] | 690 | "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] | 691 | reinterpret_cast<uint64_t>(vkObj)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 692 | |
| 693 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 694 | pNewObjNode->objType = objType; |
| 695 | pNewObjNode->status = OBJSTATUS_NONE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 696 | pNewObjNode->vkObj = (uint64_t) vkObj; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 697 | VkSwapchainKHRMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 698 | uint32_t objIndex = objTypeToIndex(objType); |
| 699 | numObjs[objIndex]++; |
| 700 | numTotalObjs++; |
| 701 | } |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 702 | static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeLUNARG objType) |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 703 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 704 | 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^] | 705 | "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] | 706 | reinterpret_cast<uint64_t>(vkObj)); |
| 707 | |
| 708 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 709 | pNewObjNode->objType = objType; |
| 710 | pNewObjNode->status = OBJSTATUS_NONE; |
| 711 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 712 | VkQueueMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 713 | uint32_t objIndex = objTypeToIndex(objType); |
| 714 | numObjs[objIndex]++; |
| 715 | numTotalObjs++; |
| 716 | } |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 717 | static void create_swapchain_image_obj(VkDevice dispatchable_object, VkImage vkObj, VkSwapchainKHR swapchain) |
| 718 | { |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 719 | 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] | 720 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64 , object_track_index++, "SwapchainImage", |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 721 | reinterpret_cast<uint64_t>(vkObj)); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 722 | |
| 723 | OBJTRACK_NODE* pNewObjNode = new OBJTRACK_NODE; |
| 724 | pNewObjNode->objType = VK_OBJECT_TYPE_IMAGE; |
| 725 | pNewObjNode->status = OBJSTATUS_NONE; |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 726 | pNewObjNode->vkObj = (uint64_t) vkObj; |
| 727 | pNewObjNode->parentObj = (uint64_t) swapchain; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 728 | swapchainImageMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 729 | } |
| 730 | |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 731 | static void destroy_swapchain(VkDevice dispatchable_object, VkSwapchainKHR object) |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 732 | { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 733 | if (VkSwapchainKHRMap.find(reinterpret_cast<uint64_t>(object)) != VkSwapchainKHRMap.end()) { |
| 734 | OBJTRACK_NODE* pNode = VkSwapchainKHRMap[reinterpret_cast<uint64_t>(object)]; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 735 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 736 | assert(numTotalObjs > 0); |
| 737 | numTotalObjs--; |
| 738 | assert(numObjs[objIndex] > 0); |
| 739 | numObjs[objIndex]--; |
Courtney Goeltzenleuchter | fd4830c | 2015-11-25 10:30:56 -0700 | [diff] [blame] | 740 | 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] | 741 | "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^] | 742 | string_VkDebugReportObjectTypeLUNARG(pNode->objType), (uint64_t) object, numTotalObjs, numObjs[objIndex], |
| 743 | string_VkDebugReportObjectTypeLUNARG(pNode->objType)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 744 | delete pNode; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 745 | VkSwapchainKHRMap.erase(reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 746 | } else { |
Courtney Goeltzenleuchter | b19042e | 2015-11-25 11:38:54 -0700 | [diff] [blame^] | 747 | 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] | 748 | "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] | 749 | reinterpret_cast<uint64_t>(object)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 750 | } |
| 751 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 752 | // |
| 753 | // Non-auto-generated API functions called by generated code |
| 754 | // |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 755 | VkResult |
| 756 | explicit_CreateInstance( |
| 757 | const VkInstanceCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 758 | const VkAllocationCallbacks * pAllocator, |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 759 | VkInstance * pInstance) |
| 760 | { |
David Pinedo | c0fa1ab | 2015-07-31 10:46:25 -0600 | [diff] [blame] | 761 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 762 | VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, *pInstance); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 763 | VkResult result = pInstanceTable->CreateInstance(pCreateInfo, pAllocator, pInstance); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 764 | |
| 765 | if (result == VK_SUCCESS) { |
| 766 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 767 | my_data->report_data = debug_report_create_instance( |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 768 | pInstanceTable, |
| 769 | *pInstance, |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 770 | pCreateInfo->enabledExtensionNameCount, |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 771 | pCreateInfo->ppEnabledExtensionNames); |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 772 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 773 | |
| 774 | initObjectTracker(my_data); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 775 | create_instance(*pInstance, *pInstance, VK_OBJECT_TYPE_INSTANCE); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 776 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 777 | return result; |
| 778 | } |
| 779 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 780 | void |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 781 | explicit_GetPhysicalDeviceQueueFamilyProperties( |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 782 | VkPhysicalDevice gpu, |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 783 | uint32_t* pCount, |
| 784 | VkQueueFamilyProperties* pProperties) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 785 | { |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 786 | get_dispatch_table(ObjectTracker_instance_table_map, gpu)->GetPhysicalDeviceQueueFamilyProperties(gpu, pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 787 | |
| 788 | loader_platform_thread_lock_mutex(&objLock); |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 789 | if (pProperties != NULL) |
| 790 | setGpuQueueInfoState(*pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 791 | loader_platform_thread_unlock_mutex(&objLock); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | VkResult |
| 795 | explicit_CreateDevice( |
| 796 | VkPhysicalDevice gpu, |
| 797 | const VkDeviceCreateInfo *pCreateInfo, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 798 | const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 799 | VkDevice *pDevice) |
| 800 | { |
| 801 | loader_platform_thread_lock_mutex(&objLock); |
Courtney Goeltzenleuchter | ca173b8 | 2015-06-25 18:01:43 -0600 | [diff] [blame] | 802 | // VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ObjectTracker_instance_table_map, gpu); |
| 803 | VkLayerDispatchTable *pDeviceTable = get_dispatch_table(ObjectTracker_device_table_map, *pDevice); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 804 | VkResult result = pDeviceTable->CreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 805 | if (result == VK_SUCCESS) { |
| 806 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 807 | //// VkLayerDispatchTable *pTable = get_dispatch_table(ObjectTracker_device_table_map, *pDevice); |
| 808 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 809 | 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] | 810 | create_device(*pDevice, *pDevice, VK_OBJECT_TYPE_DEVICE); |
Jon Ashburn | 8acd233 | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 811 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | loader_platform_thread_unlock_mutex(&objLock); |
| 815 | return result; |
| 816 | } |
| 817 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 818 | VkResult explicit_EnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices) |
| 819 | { |
| 820 | VkBool32 skipCall = VK_FALSE; |
| 821 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 822 | skipCall |= validate_instance(instance, instance); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 823 | loader_platform_thread_unlock_mutex(&objLock); |
| 824 | if (skipCall) |
| 825 | return VK_ERROR_VALIDATION_FAILED; |
| 826 | VkResult result = get_dispatch_table(ObjectTracker_instance_table_map, instance)->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
| 827 | loader_platform_thread_lock_mutex(&objLock); |
| 828 | if (result == VK_SUCCESS) { |
| 829 | if (pPhysicalDevices) { |
| 830 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 831 | create_physical_device(instance, pPhysicalDevices[i], VK_OBJECT_TYPE_PHYSICAL_DEVICE); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 832 | } |
| 833 | } |
| 834 | } |
| 835 | loader_platform_thread_unlock_mutex(&objLock); |
| 836 | return result; |
| 837 | } |
| 838 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 839 | void |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 840 | explicit_GetDeviceQueue( |
| 841 | VkDevice device, |
| 842 | uint32_t queueNodeIndex, |
| 843 | uint32_t queueIndex, |
| 844 | VkQueue *pQueue) |
| 845 | { |
| 846 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 847 | validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 848 | loader_platform_thread_unlock_mutex(&objLock); |
| 849 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 850 | 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] | 851 | |
| 852 | loader_platform_thread_lock_mutex(&objLock); |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 853 | addQueueInfo(queueNodeIndex, *pQueue); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 854 | create_queue(device, *pQueue, VK_OBJECT_TYPE_QUEUE); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 855 | loader_platform_thread_unlock_mutex(&objLock); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | VkResult |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 859 | explicit_MapMemory( |
| 860 | VkDevice device, |
| 861 | VkDeviceMemory mem, |
| 862 | VkDeviceSize offset, |
| 863 | VkDeviceSize size, |
| 864 | VkFlags flags, |
| 865 | void **ppData) |
| 866 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 867 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 868 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 869 | skipCall |= set_device_memory_status(device, mem, VK_OBJECT_TYPE_DEVICE_MEMORY, OBJSTATUS_GPU_MEM_MAPPED); |
| 870 | skipCall |= validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 871 | loader_platform_thread_unlock_mutex(&objLock); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 872 | if (skipCall == VK_TRUE) |
| 873 | return VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 874 | |
| 875 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData); |
| 876 | |
| 877 | return result; |
| 878 | } |
| 879 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 880 | void |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 881 | explicit_UnmapMemory( |
| 882 | VkDevice device, |
| 883 | VkDeviceMemory mem) |
| 884 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 885 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 886 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 887 | skipCall |= reset_device_memory_status(device, mem, VK_OBJECT_TYPE_DEVICE_MEMORY, OBJSTATUS_GPU_MEM_MAPPED); |
| 888 | skipCall |= validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 889 | loader_platform_thread_unlock_mutex(&objLock); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 890 | if (skipCall == VK_TRUE) |
| 891 | return; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 892 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 893 | get_dispatch_table(ObjectTracker_device_table_map, device)->UnmapMemory(device, mem); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | VkResult |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 897 | explicit_QueueBindSparse( |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 898 | VkQueue queue, |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 899 | uint32_t bindInfoCount, |
| 900 | const VkBindSparseInfo* pBindInfo, |
| 901 | VkFence fence) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 902 | { |
| 903 | loader_platform_thread_lock_mutex(&objLock); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 904 | validateQueueFlags(queue, "QueueBindSparse"); |
| 905 | |
| 906 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 907 | for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++) |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 908 | validate_buffer(queue, pBindInfo[i].pBufferBinds[j].buffer); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 909 | for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++) |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 910 | validate_image(queue, pBindInfo[i].pImageOpaqueBinds[j].image); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 911 | for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++) |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 912 | validate_image(queue, pBindInfo[i].pImageBinds[j].image); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 913 | } |
| 914 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 915 | loader_platform_thread_unlock_mutex(&objLock); |
| 916 | |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 917 | 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] | 918 | return result; |
| 919 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 920 | |
| 921 | VkResult |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 922 | explicit_AllocateCommandBuffers( |
| 923 | VkDevice device, |
| 924 | const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 925 | VkCommandBuffer* pCommandBuffers) |
| 926 | { |
| 927 | VkBool32 skipCall = VK_FALSE; |
| 928 | loader_platform_thread_lock_mutex(&objLock); |
| 929 | skipCall |= validate_device(device, device); |
| 930 | skipCall |= validate_command_pool(device, pAllocateInfo->commandPool); |
| 931 | loader_platform_thread_unlock_mutex(&objLock); |
| 932 | |
| 933 | if (skipCall) { |
| 934 | return VK_ERROR_VALIDATION_FAILED; |
| 935 | } |
| 936 | |
| 937 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->AllocateCommandBuffers( |
| 938 | device, pAllocateInfo, pCommandBuffers); |
| 939 | |
| 940 | loader_platform_thread_lock_mutex(&objLock); |
| 941 | for (uint32_t i = 0; i < pAllocateInfo->bufferCount; i++) { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 942 | 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] | 943 | } |
| 944 | loader_platform_thread_unlock_mutex(&objLock); |
| 945 | |
| 946 | return result; |
| 947 | } |
| 948 | |
| 949 | VkResult |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 950 | explicit_AllocateDescriptorSets( |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 951 | VkDevice device, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 952 | const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 953 | VkDescriptorSet *pDescriptorSets) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 954 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 955 | VkBool32 skipCall = VK_FALSE; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 956 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 957 | skipCall |= validate_device(device, device); |
| 958 | skipCall |= validate_descriptor_pool(device, pAllocateInfo->descriptorPool); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 959 | for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) { |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 960 | skipCall |= validate_descriptor_set_layout(device, pAllocateInfo->pSetLayouts[i]); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 961 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 962 | loader_platform_thread_unlock_mutex(&objLock); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 963 | if (skipCall) |
| 964 | return VK_ERROR_VALIDATION_FAILED; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 965 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 966 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->AllocateDescriptorSets( |
| 967 | device, pAllocateInfo, pDescriptorSets); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 968 | |
| 969 | loader_platform_thread_lock_mutex(&objLock); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 970 | for (uint32_t i = 0; i < pAllocateInfo->setLayoutCount; i++) { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 971 | 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] | 972 | } |
| 973 | loader_platform_thread_unlock_mutex(&objLock); |
| 974 | |
| 975 | return result; |
| 976 | } |
| 977 | |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 978 | void |
| 979 | explicit_FreeCommandBuffers( |
| 980 | VkDevice device, |
| 981 | VkCommandPool commandPool, |
| 982 | uint32_t commandBufferCount, |
| 983 | const VkCommandBuffer *pCommandBuffers) |
| 984 | { |
| 985 | loader_platform_thread_lock_mutex(&objLock); |
| 986 | validate_command_pool(device, commandPool); |
| 987 | validate_device(device, device); |
| 988 | loader_platform_thread_unlock_mutex(&objLock); |
| 989 | |
| 990 | get_dispatch_table(ObjectTracker_device_table_map, device)->FreeCommandBuffers(device, |
| 991 | commandPool, commandBufferCount, pCommandBuffers); |
| 992 | |
| 993 | loader_platform_thread_lock_mutex(&objLock); |
| 994 | for (uint32_t i = 0; i < commandBufferCount; i++) |
| 995 | { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 996 | free_command_buffer(device, commandPool, *pCommandBuffers); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 997 | pCommandBuffers++; |
| 998 | } |
| 999 | loader_platform_thread_unlock_mutex(&objLock); |
| 1000 | } |
| 1001 | |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 1002 | void |
Ian Elliott | 7e40db9 | 2015-08-21 15:09:33 -0600 | [diff] [blame] | 1003 | explicit_DestroySwapchainKHR( |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 1004 | VkDevice device, |
| 1005 | VkSwapchainKHR swapchain, |
| 1006 | const VkAllocationCallbacks *pAllocator) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1007 | { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1008 | loader_platform_thread_lock_mutex(&objLock); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1009 | // A swapchain's images are implicitly deleted when the swapchain is deleted. |
| 1010 | // Remove this swapchain's images from our map of such images. |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1011 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = swapchainImageMap.begin(); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1012 | while (itr != swapchainImageMap.end()) { |
| 1013 | OBJTRACK_NODE* pNode = (*itr).second; |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1014 | if (pNode->parentObj == reinterpret_cast<uint64_t>(swapchain)) { |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1015 | swapchainImageMap.erase(itr++); |
| 1016 | } else { |
| 1017 | ++itr; |
| 1018 | } |
| 1019 | } |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1020 | destroy_swapchain(device, swapchain); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1021 | loader_platform_thread_unlock_mutex(&objLock); |
| 1022 | |
Ian Elliott | 0584606 | 2015-11-20 14:13:17 -0700 | [diff] [blame] | 1023 | get_dispatch_table(ObjectTracker_device_table_map, device)->DestroySwapchainKHR(device, swapchain, pAllocator); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1024 | } |
| 1025 | |
Mark Lobodzinski | 2141f65 | 2015-09-07 13:59:43 -0600 | [diff] [blame] | 1026 | void |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1027 | explicit_FreeMemory( |
| 1028 | VkDevice device, |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1029 | VkDeviceMemory mem, |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1030 | const VkAllocationCallbacks* pAllocator) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1031 | { |
| 1032 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1033 | validate_device(device, device); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1034 | loader_platform_thread_unlock_mutex(&objLock); |
| 1035 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1036 | get_dispatch_table(ObjectTracker_device_table_map, device)->FreeMemory(device, mem, pAllocator); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1037 | |
| 1038 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1039 | destroy_device_memory(device, mem); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1040 | loader_platform_thread_unlock_mutex(&objLock); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 1041 | } |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 1042 | |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1043 | VkResult |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1044 | explicit_FreeDescriptorSets( |
| 1045 | VkDevice device, |
| 1046 | VkDescriptorPool descriptorPool, |
| 1047 | uint32_t count, |
| 1048 | const VkDescriptorSet *pDescriptorSets) |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1049 | { |
| 1050 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1051 | validate_descriptor_pool(device, descriptorPool); |
| 1052 | validate_device(device, device); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1053 | loader_platform_thread_unlock_mutex(&objLock); |
| 1054 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets); |
| 1055 | |
| 1056 | loader_platform_thread_lock_mutex(&objLock); |
Courtney Goeltzenleuchter | 7ebf121 | 2015-07-23 11:25:17 -0600 | [diff] [blame] | 1057 | for (uint32_t i=0; i<count; i++) |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1058 | { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 1059 | free_descriptor_set(device, descriptorPool, *pDescriptorSets++); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 1060 | } |
| 1061 | loader_platform_thread_unlock_mutex(&objLock); |
| 1062 | return result; |
| 1063 | } |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1064 | |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1065 | void |
| 1066 | explicit_DestroyDescriptorPool( |
| 1067 | VkDevice device, |
| 1068 | VkDescriptorPool descriptorPool, |
| 1069 | const VkAllocationCallbacks *pAllocator) |
| 1070 | { |
| 1071 | VkBool32 skipCall = VK_FALSE; |
| 1072 | loader_platform_thread_lock_mutex(&objLock); |
| 1073 | skipCall |= validate_device(device, device); |
| 1074 | skipCall |= validate_descriptor_pool(device, descriptorPool); |
| 1075 | loader_platform_thread_unlock_mutex(&objLock); |
| 1076 | if (skipCall) { |
| 1077 | return; |
| 1078 | } |
| 1079 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. |
| 1080 | // Remove this pool's descriptor sets from our descriptorSet map. |
| 1081 | loader_platform_thread_lock_mutex(&objLock); |
| 1082 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkDescriptorSetMap.begin(); |
| 1083 | while (itr != VkDescriptorSetMap.end()) { |
| 1084 | OBJTRACK_NODE* pNode = (*itr).second; |
Mark Lobodzinski | b29731a | 2015-11-18 11:01:02 -0700 | [diff] [blame] | 1085 | auto del_itr = itr++; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1086 | if (pNode->parentObj == reinterpret_cast<uint64_t>(descriptorPool)) { |
Mark Lobodzinski | b29731a | 2015-11-18 11:01:02 -0700 | [diff] [blame] | 1087 | destroy_descriptor_set(device, reinterpret_cast<VkDescriptorSet>((*del_itr).first)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 1088 | } |
| 1089 | } |
| 1090 | destroy_descriptor_pool(device, descriptorPool); |
| 1091 | loader_platform_thread_unlock_mutex(&objLock); |
| 1092 | get_dispatch_table(ObjectTracker_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool, pAllocator); |
| 1093 | } |
| 1094 | |
| 1095 | void |
| 1096 | explicit_DestroyCommandPool( |
| 1097 | VkDevice device, |
| 1098 | VkCommandPool commandPool, |
| 1099 | const VkAllocationCallbacks *pAllocator) |
| 1100 | { |
| 1101 | VkBool32 skipCall = VK_FALSE; |
| 1102 | loader_platform_thread_lock_mutex(&objLock); |
| 1103 | skipCall |= validate_device(device, device); |
| 1104 | skipCall |= validate_command_pool(device, commandPool); |
| 1105 | loader_platform_thread_unlock_mutex(&objLock); |
| 1106 | if (skipCall) { |
| 1107 | return; |
| 1108 | } |
| 1109 | loader_platform_thread_lock_mutex(&objLock); |
| 1110 | // A CommandPool's command buffers are implicitly deleted when the pool is deleted. |
| 1111 | // Remove this pool's cmdBuffers from our cmd buffer map. |
| 1112 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator itr = VkCommandBufferMap.begin(); |
| 1113 | unordered_map<uint64_t, OBJTRACK_NODE*>::iterator del_itr; |
| 1114 | while (itr != VkCommandBufferMap.end()) { |
| 1115 | OBJTRACK_NODE* pNode = (*itr).second; |
| 1116 | del_itr = itr++; |
| 1117 | if (pNode->parentObj == reinterpret_cast<uint64_t>(commandPool)) { |
| 1118 | destroy_command_buffer(reinterpret_cast<VkCommandBuffer>((*del_itr).first), |
| 1119 | reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
| 1120 | } |
| 1121 | } |
| 1122 | destroy_command_pool(device, commandPool); |
| 1123 | loader_platform_thread_unlock_mutex(&objLock); |
| 1124 | get_dispatch_table(ObjectTracker_device_table_map, device)->DestroyCommandPool(device, commandPool, pAllocator); |
| 1125 | } |
| 1126 | |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1127 | VkResult |
| 1128 | explicit_GetSwapchainImagesKHR( |
| 1129 | VkDevice device, |
| 1130 | VkSwapchainKHR swapchain, |
| 1131 | uint32_t *pCount, |
| 1132 | VkImage *pSwapchainImages) |
| 1133 | { |
| 1134 | VkBool32 skipCall = VK_FALSE; |
| 1135 | loader_platform_thread_lock_mutex(&objLock); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 1136 | skipCall |= validate_device(device, device); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 1137 | loader_platform_thread_unlock_mutex(&objLock); |
| 1138 | if (skipCall) |
| 1139 | return VK_ERROR_VALIDATION_FAILED; |
| 1140 | |
| 1141 | VkResult result = get_dispatch_table(ObjectTracker_device_table_map, device)->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages); |
| 1142 | |
| 1143 | if (pSwapchainImages != NULL) { |
| 1144 | loader_platform_thread_lock_mutex(&objLock); |
| 1145 | for (uint32_t i = 0; i < *pCount; i++) { |
| 1146 | create_swapchain_image_obj(device, pSwapchainImages[i], swapchain); |
| 1147 | } |
| 1148 | loader_platform_thread_unlock_mutex(&objLock); |
| 1149 | } |
| 1150 | return result; |
| 1151 | } |
| 1152 | |