Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2016 Google Inc. |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 5 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 9 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 11 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 17 | * |
| 18 | * Author: Jon Ashburn <jon@lunarg.com> |
| 19 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 20 | * Author: Tobin Ehlis <tobin@lunarg.com> |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 23 | #include <mutex> |
| 24 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include "vulkan/vk_layer.h" |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 26 | #include "vk_layer_extension_utils.h" |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 27 | #include "vk_enum_string_helper.h" |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 28 | #include "vk_layer_table.h" |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 29 | #include "vk_layer_utils.h" |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 30 | |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 31 | // Object Tracker ERROR codes |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 32 | typedef enum _OBJECT_TRACK_ERROR { |
| 33 | OBJTRACK_NONE, // Used for INFO & other non-error messages |
| 34 | OBJTRACK_UNKNOWN_OBJECT, // Updating uses of object that's not in global object list |
| 35 | OBJTRACK_INTERNAL_ERROR, // Bug with data tracking within the layer |
| 36 | OBJTRACK_DESTROY_OBJECT_FAILED, // Couldn't find object to be destroyed |
| 37 | OBJTRACK_OBJECT_LEAK, // OBJECT was not correctly freed/destroyed |
| 38 | OBJTRACK_OBJCOUNT_MAX_EXCEEDED, // Request for Object data in excess of max obj count |
| 39 | OBJTRACK_INVALID_OBJECT, // Object used that has never been created |
| 40 | OBJTRACK_DESCRIPTOR_POOL_MISMATCH, // Descriptor Pools specified incorrectly |
| 41 | OBJTRACK_COMMAND_POOL_MISMATCH, // Command Pools specified incorrectly |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 42 | } OBJECT_TRACK_ERROR; |
| 43 | |
Tobin Ehlis | 91ce77e | 2015-01-16 08:56:30 -0700 | [diff] [blame] | 44 | // Object Status -- used to track state of individual objects |
Mark Lobodzinski | 38f0db2 | 2015-05-20 17:33:47 -0500 | [diff] [blame] | 45 | typedef VkFlags ObjectStatusFlags; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 46 | typedef enum _ObjectStatusFlagBits { |
| 47 | OBJSTATUS_NONE = 0x00000000, // No status is set |
| 48 | OBJSTATUS_FENCE_IS_SUBMITTED = 0x00000001, // Fence has been submitted |
| 49 | OBJSTATUS_VIEWPORT_BOUND = 0x00000002, // Viewport state object has been bound |
| 50 | OBJSTATUS_RASTER_BOUND = 0x00000004, // Viewport state object has been bound |
| 51 | OBJSTATUS_COLOR_BLEND_BOUND = 0x00000008, // Viewport state object has been bound |
| 52 | OBJSTATUS_DEPTH_STENCIL_BOUND = 0x00000010, // Viewport state object has been bound |
| 53 | OBJSTATUS_GPU_MEM_MAPPED = 0x00000020, // Memory object is currently mapped |
| 54 | OBJSTATUS_COMMAND_BUFFER_SECONDARY = 0x00000040, // Command Buffer is of type SECONDARY |
Mark Lobodzinski | 38f0db2 | 2015-05-20 17:33:47 -0500 | [diff] [blame] | 55 | } ObjectStatusFlagBits; |
Chia-I Wu | f869338 | 2015-04-16 22:02:10 +0800 | [diff] [blame] | 56 | |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 57 | typedef struct _OBJTRACK_NODE { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 58 | uint64_t vkObj; // Object handle |
| 59 | VkDebugReportObjectTypeEXT objType; // Object type identifier |
| 60 | ObjectStatusFlags status; // Object state |
| 61 | uint64_t parentObj; // Parent object |
| 62 | uint64_t belongsTo; // Object Scope -- owning device/instance |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 63 | } OBJTRACK_NODE; |
Mark Lobodzinski | aae93e5 | 2015-02-09 10:20:53 -0600 | [diff] [blame] | 64 | |
Tobin Ehlis | 4258653 | 2014-11-14 13:01:02 -0700 | [diff] [blame] | 65 | // prototype for extension functions |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 66 | uint64_t objTrackGetObjectCount(VkDevice device); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 67 | uint64_t objTrackGetObjectsOfTypeCount(VkDevice, VkDebugReportObjectTypeEXT type); |
Mark Lobodzinski | aae93e5 | 2015-02-09 10:20:53 -0600 | [diff] [blame] | 68 | |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 69 | // Func ptr typedefs |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 70 | typedef uint64_t (*OBJ_TRACK_GET_OBJECT_COUNT)(VkDevice); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 71 | typedef uint64_t (*OBJ_TRACK_GET_OBJECTS_OF_TYPE_COUNT)(VkDevice, VkDebugReportObjectTypeEXT); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 72 | |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 73 | struct layer_data { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 74 | debug_report_data *report_data; |
Cody Northrop | 9c93ec5 | 2016-04-28 09:55:08 -0600 | [diff] [blame] | 75 | // TODO: put instance data here |
| 76 | std::vector<VkDebugReportCallbackEXT> logging_callback; |
| 77 | bool wsi_enabled; |
| 78 | bool objtrack_extensions_enabled; |
Ian Elliott | ed6b5ac | 2016-04-28 09:08:13 -0600 | [diff] [blame] | 79 | // The following are for keeping track of the temporary callbacks that can |
| 80 | // be used in vkCreateInstance and vkDestroyInstance: |
| 81 | uint32_t num_tmp_callbacks; |
| 82 | VkDebugReportCallbackCreateInfoEXT *tmp_dbg_create_infos; |
| 83 | VkDebugReportCallbackEXT *tmp_callbacks; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 84 | |
Ian Elliott | ed6b5ac | 2016-04-28 09:08:13 -0600 | [diff] [blame] | 85 | layer_data() |
| 86 | : report_data(nullptr), wsi_enabled(false), objtrack_extensions_enabled(false), num_tmp_callbacks(0), |
| 87 | tmp_dbg_create_infos(nullptr), tmp_callbacks(nullptr){}; |
Cody Northrop | 55443ef | 2015-09-28 15:09:32 -0600 | [diff] [blame] | 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; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 95 | static std::unordered_map<void *, layer_data *> layer_data_map; |
| 96 | static device_table_map object_tracker_device_table_map; |
| 97 | static instance_table_map object_tracker_instance_table_map; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 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 |
Mark Lobodzinski | f93272b | 2016-05-02 12:08:24 -0600 | [diff] [blame^] | 101 | static std::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; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 104 | static std::mutex global_lock; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 105 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 106 | #define NUM_OBJECT_TYPES (VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT + 1) |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 107 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 108 | static uint64_t numObjs[NUM_OBJECT_TYPES] = {0}; |
| 109 | static uint64_t numTotalObjs = 0; |
| 110 | static VkQueueFamilyProperties *queueInfo = NULL; |
| 111 | static uint32_t queueCount = 0; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 112 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 113 | template layer_data *get_my_data_ptr<layer_data>(void *data_key, std::unordered_map<void *, layer_data *> &data_map); |
Mark Lobodzinski | 2eeb3c6 | 2015-09-01 08:52:55 -0600 | [diff] [blame] | 114 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 115 | // |
| 116 | // Internal Object Tracker Functions |
| 117 | // |
| 118 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 119 | static void createDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 120 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); |
| 121 | VkLayerDispatchTable *pDisp = get_dispatch_table(object_tracker_device_table_map, device); |
Jon Ashburn | 8acd233 | 2015-09-16 18:08:32 -0600 | [diff] [blame] | 122 | PFN_vkGetDeviceProcAddr gpa = pDisp->GetDeviceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 123 | pDisp->CreateSwapchainKHR = (PFN_vkCreateSwapchainKHR)gpa(device, "vkCreateSwapchainKHR"); |
| 124 | pDisp->DestroySwapchainKHR = (PFN_vkDestroySwapchainKHR)gpa(device, "vkDestroySwapchainKHR"); |
| 125 | pDisp->GetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR)gpa(device, "vkGetSwapchainImagesKHR"); |
| 126 | pDisp->AcquireNextImageKHR = (PFN_vkAcquireNextImageKHR)gpa(device, "vkAcquireNextImageKHR"); |
| 127 | pDisp->QueuePresentKHR = (PFN_vkQueuePresentKHR)gpa(device, "vkQueuePresentKHR"); |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 128 | my_device_data->wsi_enabled = false; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 129 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 130 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) |
Ian Elliott | 1064fe3 | 2015-07-06 14:31:32 -0600 | [diff] [blame] | 131 | my_device_data->wsi_enabled = true; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 132 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 133 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], "OBJTRACK_EXTENSIONS") == 0) |
Courtney Goeltzenleuchter | fce8cd2 | 2015-07-05 22:13:43 -0600 | [diff] [blame] | 134 | my_device_data->objtrack_extensions_enabled = true; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 138 | static void createInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) { |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 139 | uint32_t i; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 140 | VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(object_tracker_instance_table_map, instance); |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 141 | PFN_vkGetInstanceProcAddr gpa = pDisp->GetInstanceProcAddr; |
Michael Lentine | 56512bb | 2016-03-02 17:28:55 -0600 | [diff] [blame] | 142 | |
| 143 | pDisp->DestroySurfaceKHR = (PFN_vkDestroySurfaceKHR)gpa(instance, "vkDestroySurfaceKHR"); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 144 | pDisp->GetPhysicalDeviceSurfaceSupportKHR = |
| 145 | (PFN_vkGetPhysicalDeviceSurfaceSupportKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceSupportKHR"); |
| 146 | pDisp->GetPhysicalDeviceSurfaceCapabilitiesKHR = |
| 147 | (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR"); |
| 148 | pDisp->GetPhysicalDeviceSurfaceFormatsKHR = |
| 149 | (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)gpa(instance, "vkGetPhysicalDeviceSurfaceFormatsKHR"); |
| 150 | pDisp->GetPhysicalDeviceSurfacePresentModesKHR = |
| 151 | (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)gpa(instance, "vkGetPhysicalDeviceSurfacePresentModesKHR"); |
Mark Lobodzinski | e86e138 | 2015-11-24 15:50:44 -0700 | [diff] [blame] | 152 | |
| 153 | #if VK_USE_PLATFORM_WIN32_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 154 | pDisp->CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)gpa(instance, "vkCreateWin32SurfaceKHR"); |
| 155 | pDisp->GetPhysicalDeviceWin32PresentationSupportKHR = |
| 156 | (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 157 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 158 | #ifdef VK_USE_PLATFORM_XCB_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 159 | pDisp->CreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)gpa(instance, "vkCreateXcbSurfaceKHR"); |
| 160 | pDisp->GetPhysicalDeviceXcbPresentationSupportKHR = |
| 161 | (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 162 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 163 | #ifdef VK_USE_PLATFORM_XLIB_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 164 | pDisp->CreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)gpa(instance, "vkCreateXlibSurfaceKHR"); |
| 165 | pDisp->GetPhysicalDeviceXlibPresentationSupportKHR = |
| 166 | (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 167 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 168 | #ifdef VK_USE_PLATFORM_MIR_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 169 | pDisp->CreateMirSurfaceKHR = (PFN_vkCreateMirSurfaceKHR)gpa(instance, "vkCreateMirSurfaceKHR"); |
| 170 | pDisp->GetPhysicalDeviceMirPresentationSupportKHR = |
| 171 | (PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceMirPresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 172 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 173 | #ifdef VK_USE_PLATFORM_WAYLAND_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 174 | pDisp->CreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)gpa(instance, "vkCreateWaylandSurfaceKHR"); |
| 175 | pDisp->GetPhysicalDeviceWaylandPresentationSupportKHR = |
| 176 | (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)gpa(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 177 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 178 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 179 | pDisp->CreateAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)gpa(instance, "vkCreateAndroidSurfaceKHR"); |
Mark Lobodzinski | a8a5f85 | 2015-12-10 16:25:21 -0700 | [diff] [blame] | 180 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
Mark Lobodzinski | e86e138 | 2015-11-24 15:50:44 -0700 | [diff] [blame] | 181 | |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 182 | instanceExtMap[pDisp].wsi_enabled = false; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 183 | for (i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 184 | if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 185 | instanceExtMap[pDisp].wsi_enabled = true; |
Jon Ashburn | 3dc3938 | 2015-09-17 10:00:32 -0600 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 189 | // Indicate device or instance dispatch table type |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 190 | typedef enum _DispTableType { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 191 | DISP_TBL_TYPE_INSTANCE, |
| 192 | DISP_TBL_TYPE_DEVICE, |
| 193 | } DispTableType; |
| 194 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 195 | debug_report_data *mdd(const void *object) { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 196 | dispatch_key key = get_dispatch_key(object); |
| 197 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 198 | return my_data->report_data; |
| 199 | } |
| 200 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 201 | debug_report_data *mid(VkInstance object) { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 202 | dispatch_key key = get_dispatch_key(object); |
| 203 | layer_data *my_data = get_my_data_ptr(key, layer_data_map); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 204 | return my_data->report_data; |
| 205 | } |
| 206 | |
| 207 | // For each Queue's doubly linked-list of mem refs |
| 208 | typedef struct _OT_MEM_INFO { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 209 | VkDeviceMemory mem; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 210 | struct _OT_MEM_INFO *pNextMI; |
| 211 | struct _OT_MEM_INFO *pPrevMI; |
| 212 | |
| 213 | } OT_MEM_INFO; |
| 214 | |
| 215 | // Track Queue information |
| 216 | typedef struct _OT_QUEUE_INFO { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 217 | OT_MEM_INFO *pMemRefList; |
| 218 | struct _OT_QUEUE_INFO *pNextQI; |
| 219 | uint32_t queueNodeIndex; |
| 220 | VkQueue queue; |
| 221 | uint32_t refCount; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 222 | } OT_QUEUE_INFO; |
| 223 | |
| 224 | // Global list of QueueInfo structures, one per queue |
| 225 | static OT_QUEUE_INFO *g_pQueueInfo = NULL; |
| 226 | |
| 227 | // Convert an object type enum to an object type array index |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 228 | static uint32_t objTypeToIndex(uint32_t objType) { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 229 | uint32_t index = objType; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 230 | return index; |
| 231 | } |
| 232 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 233 | // Add new queue to head of global queue list |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 234 | static void addQueueInfo(uint32_t queueNodeIndex, VkQueue queue) { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 235 | OT_QUEUE_INFO *pQueueInfo = new OT_QUEUE_INFO; |
| 236 | |
| 237 | if (pQueueInfo != NULL) { |
| 238 | memset(pQueueInfo, 0, sizeof(OT_QUEUE_INFO)); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 239 | pQueueInfo->queue = queue; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 240 | pQueueInfo->queueNodeIndex = queueNodeIndex; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 241 | pQueueInfo->pNextQI = g_pQueueInfo; |
| 242 | g_pQueueInfo = pQueueInfo; |
| 243 | } else { |
| 244 | log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast<uint64_t>(queue), |
| 245 | __LINE__, OBJTRACK_INTERNAL_ERROR, "OBJTRACK", |
| 246 | "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information"); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
| 250 | // Destroy memRef lists and free all memory |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 251 | static void destroyQueueMemRefLists(void) { |
| 252 | OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 253 | OT_QUEUE_INFO *pDelQueueInfo = NULL; |
| 254 | while (pQueueInfo != NULL) { |
| 255 | OT_MEM_INFO *pMemInfo = pQueueInfo->pMemRefList; |
| 256 | while (pMemInfo != NULL) { |
| 257 | OT_MEM_INFO *pDelMemInfo = pMemInfo; |
| 258 | pMemInfo = pMemInfo->pNextMI; |
| 259 | delete pDelMemInfo; |
| 260 | } |
| 261 | pDelQueueInfo = pQueueInfo; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 262 | pQueueInfo = pQueueInfo->pNextQI; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 263 | delete pDelQueueInfo; |
| 264 | } |
| 265 | g_pQueueInfo = pQueueInfo; |
| 266 | } |
| 267 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 268 | static void setGpuQueueInfoState(uint32_t count, void *pData) { |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 269 | queueCount = count; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 270 | queueInfo = (VkQueueFamilyProperties *)realloc((void *)queueInfo, count * sizeof(VkQueueFamilyProperties)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 271 | if (queueInfo != NULL) { |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 272 | memcpy(queueInfo, pData, count * sizeof(VkQueueFamilyProperties)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 273 | } |
| 274 | } |
| 275 | |
| 276 | // Check Queue type flags for selected queue operations |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 277 | static void validateQueueFlags(VkQueue queue, const char *function) { |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 278 | OT_QUEUE_INFO *pQueueInfo = g_pQueueInfo; |
| 279 | while ((pQueueInfo != NULL) && (pQueueInfo->queue != queue)) { |
| 280 | pQueueInfo = pQueueInfo->pNextQI; |
| 281 | } |
| 282 | if (pQueueInfo != NULL) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 283 | if ((queueInfo != NULL) && (queueInfo[pQueueInfo->queueNodeIndex].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == 0) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 284 | log_msg(mdd(queue), VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, |
| 285 | reinterpret_cast<uint64_t>(queue), __LINE__, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
| 286 | "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] | 287 | } |
| 288 | } |
| 289 | } |
| 290 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 291 | /* TODO: Port to new type safety */ |
| 292 | #if 0 |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 293 | // Check object status for selected flag state |
Courtney Goeltzenleuchter | cd2a099 | 2015-07-09 11:44:38 -0600 | [diff] [blame] | 294 | static VkBool32 |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 295 | validate_status( |
| 296 | VkObject dispatchable_object, |
| 297 | VkObject vkObj, |
| 298 | VkObjectType objType, |
| 299 | ObjectStatusFlags status_mask, |
| 300 | ObjectStatusFlags status_flag, |
| 301 | VkFlags msg_flags, |
| 302 | OBJECT_TRACK_ERROR error_code, |
| 303 | const char *fail_msg) |
| 304 | { |
| 305 | if (objMap.find(vkObj) != objMap.end()) { |
| 306 | OBJTRACK_NODE* pNode = objMap[vkObj]; |
| 307 | if ((pNode->status & status_mask) != status_flag) { |
| 308 | char str[1024]; |
Mark Lobodzinski | 6085c2b | 2016-01-04 15:48:11 -0700 | [diff] [blame] | 309 | log_msg(mdd(dispatchable_object), msg_flags, pNode->objType, vkObj, __LINE__, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 310 | "OBJECT VALIDATION WARNING: %s object 0x%" PRIxLEAST64 ": %s", string_VkObjectType(objType), |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 311 | static_cast<uint64_t>(vkObj), fail_msg); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 312 | return VK_FALSE; |
| 313 | } |
| 314 | return VK_TRUE; |
| 315 | } |
| 316 | else { |
| 317 | // If we do not find it print an error |
Mark Lobodzinski | 6085c2b | 2016-01-04 15:48:11 -0700 | [diff] [blame] | 318 | log_msg(mdd(dispatchable_object), msg_flags, (VkObjectType) 0, vkObj, __LINE__, OBJTRACK_UNKNOWN_OBJECT, "OBJTRACK", |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 319 | "Unable to obtain status for non-existent object 0x%" PRIxLEAST64 " of %s type", |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 320 | static_cast<uint64_t>(vkObj), string_VkObjectType(objType)); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 321 | return VK_FALSE; |
| 322 | } |
| 323 | } |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 324 | #endif |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 325 | |
| 326 | #include "vk_dispatch_table_helper.h" |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 327 | |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 328 | static void init_object_tracker(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { |
| 329 | |
| 330 | layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_object_tracker"); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 331 | } |
| 332 | |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 333 | // |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 334 | // Forward declarations |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 335 | // |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 336 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 337 | static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeEXT objType); |
| 338 | static void create_instance(VkInstance dispatchable_object, VkInstance object, VkDebugReportObjectTypeEXT objType); |
| 339 | static void create_device(VkDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeEXT objType); |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 340 | static void create_device(VkPhysicalDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeEXT objType); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 341 | static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeEXT objType); |
| 342 | static VkBool32 validate_image(VkQueue dispatchable_object, VkImage object, VkDebugReportObjectTypeEXT objType, bool null_allowed); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 343 | static VkBool32 validate_instance(VkInstance dispatchable_object, VkInstance object, VkDebugReportObjectTypeEXT objType, |
| 344 | bool null_allowed); |
| 345 | static VkBool32 validate_device(VkDevice dispatchable_object, VkDevice object, VkDebugReportObjectTypeEXT objType, |
| 346 | bool null_allowed); |
| 347 | static VkBool32 validate_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object, VkDebugReportObjectTypeEXT objType, |
| 348 | bool null_allowed); |
| 349 | static VkBool32 validate_descriptor_set_layout(VkDevice dispatchable_object, VkDescriptorSetLayout object, |
| 350 | VkDebugReportObjectTypeEXT objType, bool null_allowed); |
| 351 | static VkBool32 validate_command_pool(VkDevice dispatchable_object, VkCommandPool object, VkDebugReportObjectTypeEXT objType, |
| 352 | bool null_allowed); |
| 353 | static VkBool32 validate_buffer(VkQueue dispatchable_object, VkBuffer object, VkDebugReportObjectTypeEXT objType, |
| 354 | bool null_allowed); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 355 | static void create_pipeline(VkDevice dispatchable_object, VkPipeline vkObj, VkDebugReportObjectTypeEXT objType); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 356 | static VkBool32 validate_pipeline_cache(VkDevice dispatchable_object, VkPipelineCache object, VkDebugReportObjectTypeEXT objType, |
| 357 | bool null_allowed); |
| 358 | static VkBool32 validate_render_pass(VkDevice dispatchable_object, VkRenderPass object, VkDebugReportObjectTypeEXT objType, |
| 359 | bool null_allowed); |
| 360 | static VkBool32 validate_shader_module(VkDevice dispatchable_object, VkShaderModule object, VkDebugReportObjectTypeEXT objType, |
| 361 | bool null_allowed); |
| 362 | static VkBool32 validate_pipeline_layout(VkDevice dispatchable_object, VkPipelineLayout object, VkDebugReportObjectTypeEXT objType, |
| 363 | bool null_allowed); |
| 364 | static VkBool32 validate_pipeline(VkDevice dispatchable_object, VkPipeline object, VkDebugReportObjectTypeEXT objType, |
| 365 | bool null_allowed); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 366 | static void destroy_command_pool(VkDevice dispatchable_object, VkCommandPool object); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 367 | static void destroy_descriptor_pool(VkDevice dispatchable_object, VkDescriptorPool object); |
| 368 | static void destroy_descriptor_set(VkDevice dispatchable_object, VkDescriptorSet object); |
| 369 | static void destroy_device_memory(VkDevice dispatchable_object, VkDeviceMemory object); |
| 370 | static void destroy_swapchain_khr(VkDevice dispatchable_object, VkSwapchainKHR object); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 371 | static VkBool32 set_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeEXT objType, |
| 372 | ObjectStatusFlags status_flag); |
| 373 | static VkBool32 reset_device_memory_status(VkDevice dispatchable_object, VkDeviceMemory object, VkDebugReportObjectTypeEXT objType, |
| 374 | ObjectStatusFlags status_flag); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 375 | #if 0 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 376 | static VkBool32 validate_status(VkDevice dispatchable_object, VkFence object, VkDebugReportObjectTypeEXT objType, |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 377 | ObjectStatusFlags status_mask, ObjectStatusFlags status_flag, VkFlags msg_flags, OBJECT_TRACK_ERROR error_code, |
| 378 | const char *fail_msg); |
| 379 | #endif |
Mark Lobodzinski | f93272b | 2016-05-02 12:08:24 -0600 | [diff] [blame^] | 380 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkPhysicalDeviceMap; |
| 381 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkDeviceMap; |
| 382 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkImageMap; |
| 383 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkQueueMap; |
| 384 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkDescriptorSetMap; |
| 385 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkBufferMap; |
| 386 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkFenceMap; |
| 387 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkSemaphoreMap; |
| 388 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkCommandPoolMap; |
| 389 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkCommandBufferMap; |
| 390 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkSwapchainKHRMap; |
| 391 | extern std::unordered_map<uint64_t, OBJTRACK_NODE *> VkSurfaceKHRMap; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 392 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 393 | static void create_physical_device(VkInstance dispatchable_object, VkPhysicalDevice vkObj, VkDebugReportObjectTypeEXT objType) { |
| 394 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), __LINE__, |
| 395 | OBJTRACK_NONE, "OBJTRACK", "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, |
| 396 | string_VkDebugReportObjectTypeEXT(objType), reinterpret_cast<uint64_t>(vkObj)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 397 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 398 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 399 | pNewObjNode->objType = objType; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 400 | pNewObjNode->belongsTo = (uint64_t)dispatchable_object; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 401 | pNewObjNode->status = OBJSTATUS_NONE; |
| 402 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 403 | VkPhysicalDeviceMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 404 | uint32_t objIndex = objTypeToIndex(objType); |
| 405 | numObjs[objIndex]++; |
| 406 | numTotalObjs++; |
| 407 | } |
| 408 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 409 | static void create_surface_khr(VkInstance dispatchable_object, VkSurfaceKHR vkObj, VkDebugReportObjectTypeEXT objType) { |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 410 | // TODO: Add tracking of surface objects |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 411 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, objType, (uint64_t)(vkObj), __LINE__, OBJTRACK_NONE, |
| 412 | "OBJTRACK", "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, |
| 413 | string_VkDebugReportObjectTypeEXT(objType), (uint64_t)(vkObj)); |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 414 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 415 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 416 | pNewObjNode->objType = objType; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 417 | pNewObjNode->belongsTo = (uint64_t)dispatchable_object; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 418 | pNewObjNode->status = OBJSTATUS_NONE; |
| 419 | pNewObjNode->vkObj = (uint64_t)(vkObj); |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 420 | VkSurfaceKHRMap[(uint64_t)vkObj] = pNewObjNode; |
| 421 | uint32_t objIndex = objTypeToIndex(objType); |
| 422 | numObjs[objIndex]++; |
| 423 | numTotalObjs++; |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 424 | } |
| 425 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 426 | static void destroy_surface_khr(VkInstance dispatchable_object, VkSurfaceKHR object) { |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 427 | uint64_t object_handle = (uint64_t)(object); |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 428 | if (VkSurfaceKHRMap.find(object_handle) != VkSurfaceKHRMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 429 | OBJTRACK_NODE *pNode = VkSurfaceKHRMap[(uint64_t)object]; |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 430 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 431 | assert(numTotalObjs > 0); |
| 432 | numTotalObjs--; |
| 433 | assert(numObjs[objIndex] > 0); |
| 434 | numObjs[objIndex]--; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 435 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, pNode->objType, object_handle, __LINE__, |
| 436 | OBJTRACK_NONE, "OBJTRACK", |
| 437 | "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", |
| 438 | string_VkDebugReportObjectTypeEXT(pNode->objType), (uint64_t)(object), numTotalObjs, numObjs[objIndex], |
| 439 | string_VkDebugReportObjectTypeEXT(pNode->objType)); |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 440 | delete pNode; |
| 441 | VkSurfaceKHRMap.erase(object_handle); |
| 442 | } else { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 443 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, object_handle, __LINE__, |
| 444 | OBJTRACK_NONE, "OBJTRACK", |
| 445 | "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", object_handle); |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 446 | } |
Mark Lobodzinski | b49b6e5 | 2015-11-26 10:59:58 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 449 | static void alloc_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer vkObj, |
| 450 | VkDebugReportObjectTypeEXT objType, VkCommandBufferLevel level) { |
| 451 | log_msg(mdd(device), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), __LINE__, OBJTRACK_NONE, |
| 452 | "OBJTRACK", "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, |
| 453 | string_VkDebugReportObjectTypeEXT(objType), reinterpret_cast<uint64_t>(vkObj)); |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 454 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 455 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
| 456 | pNewObjNode->objType = objType; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 457 | pNewObjNode->belongsTo = (uint64_t)device; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 458 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
| 459 | pNewObjNode->parentObj = (uint64_t)commandPool; |
Mark Lobodzinski | 2fba032 | 2016-01-23 18:31:23 -0700 | [diff] [blame] | 460 | if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { |
| 461 | pNewObjNode->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; |
| 462 | } else { |
| 463 | pNewObjNode->status = OBJSTATUS_NONE; |
| 464 | } |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 465 | VkCommandBufferMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 466 | uint32_t objIndex = objTypeToIndex(objType); |
| 467 | numObjs[objIndex]++; |
| 468 | numTotalObjs++; |
| 469 | } |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 470 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 471 | static void free_command_buffer(VkDevice device, VkCommandPool commandPool, VkCommandBuffer commandBuffer) { |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 472 | uint64_t object_handle = reinterpret_cast<uint64_t>(commandBuffer); |
| 473 | if (VkCommandBufferMap.find(object_handle) != VkCommandBufferMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 474 | OBJTRACK_NODE *pNode = VkCommandBufferMap[(uint64_t)commandBuffer]; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 475 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 476 | if (pNode->parentObj != (uint64_t)(commandPool)) { |
| 477 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, pNode->objType, object_handle, __LINE__, |
| 478 | OBJTRACK_COMMAND_POOL_MISMATCH, "OBJTRACK", |
| 479 | "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 |
| 480 | " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 481 | reinterpret_cast<uint64_t>(commandBuffer), pNode->parentObj, (uint64_t)(commandPool)); |
| 482 | } else { |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 483 | |
| 484 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 485 | assert(numTotalObjs > 0); |
| 486 | numTotalObjs--; |
| 487 | assert(numObjs[objIndex] > 0); |
| 488 | numObjs[objIndex]--; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 489 | log_msg(mdd(device), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, pNode->objType, object_handle, __LINE__, OBJTRACK_NONE, |
| 490 | "OBJTRACK", "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", |
| 491 | string_VkDebugReportObjectTypeEXT(pNode->objType), reinterpret_cast<uint64_t>(commandBuffer), numTotalObjs, |
| 492 | numObjs[objIndex], string_VkDebugReportObjectTypeEXT(pNode->objType)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 493 | delete pNode; |
| 494 | VkCommandBufferMap.erase(object_handle); |
| 495 | } |
| 496 | } else { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 497 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, object_handle, __LINE__, OBJTRACK_NONE, |
| 498 | "OBJTRACK", "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
| 499 | object_handle); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 500 | } |
| 501 | } |
| 502 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 503 | static void alloc_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet vkObj, |
| 504 | VkDebugReportObjectTypeEXT objType) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 505 | log_msg(mdd(device), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, objType, (uint64_t)(vkObj), __LINE__, OBJTRACK_NONE, "OBJTRACK", |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 506 | "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, string_VkDebugReportObjectTypeEXT(objType), |
| 507 | (uint64_t)(vkObj)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 508 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 509 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
| 510 | pNewObjNode->objType = objType; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 511 | pNewObjNode->belongsTo = (uint64_t)device; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 512 | pNewObjNode->status = OBJSTATUS_NONE; |
| 513 | pNewObjNode->vkObj = (uint64_t)(vkObj); |
| 514 | pNewObjNode->parentObj = (uint64_t)descriptorPool; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 515 | VkDescriptorSetMap[(uint64_t)vkObj] = pNewObjNode; |
| 516 | uint32_t objIndex = objTypeToIndex(objType); |
| 517 | numObjs[objIndex]++; |
| 518 | numTotalObjs++; |
| 519 | } |
| 520 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 521 | static void free_descriptor_set(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorSet descriptorSet) { |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 522 | uint64_t object_handle = (uint64_t)(descriptorSet); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 523 | if (VkDescriptorSetMap.find(object_handle) != VkDescriptorSetMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 524 | OBJTRACK_NODE *pNode = VkDescriptorSetMap[(uint64_t)descriptorSet]; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 525 | |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 526 | if (pNode->parentObj != (uint64_t)(descriptorPool)) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 527 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, pNode->objType, object_handle, __LINE__, |
| 528 | OBJTRACK_DESCRIPTOR_POOL_MISMATCH, "OBJTRACK", |
| 529 | "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 |
| 530 | " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 531 | (uint64_t)(descriptorSet), pNode->parentObj, (uint64_t)(descriptorPool)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 532 | } else { |
| 533 | uint32_t objIndex = objTypeToIndex(pNode->objType); |
| 534 | assert(numTotalObjs > 0); |
| 535 | numTotalObjs--; |
| 536 | assert(numObjs[objIndex] > 0); |
| 537 | numObjs[objIndex]--; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 538 | log_msg(mdd(device), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, pNode->objType, object_handle, __LINE__, OBJTRACK_NONE, |
| 539 | "OBJTRACK", "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", |
| 540 | string_VkDebugReportObjectTypeEXT(pNode->objType), (uint64_t)(descriptorSet), numTotalObjs, numObjs[objIndex], |
| 541 | string_VkDebugReportObjectTypeEXT(pNode->objType)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 542 | delete pNode; |
| 543 | VkDescriptorSetMap.erase(object_handle); |
| 544 | } |
| 545 | } else { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 546 | log_msg(mdd(device), VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0, object_handle, __LINE__, OBJTRACK_NONE, |
| 547 | "OBJTRACK", "Unable to remove obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", |
| 548 | object_handle); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 549 | } |
| 550 | } |
| 551 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 552 | static void create_queue(VkDevice dispatchable_object, VkQueue vkObj, VkDebugReportObjectTypeEXT objType) { |
| 553 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, objType, reinterpret_cast<uint64_t>(vkObj), __LINE__, |
| 554 | OBJTRACK_NONE, "OBJTRACK", "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, |
| 555 | string_VkDebugReportObjectTypeEXT(objType), reinterpret_cast<uint64_t>(vkObj)); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 556 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 557 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 558 | pNewObjNode->objType = objType; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 559 | pNewObjNode->belongsTo = (uint64_t)dispatchable_object; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 560 | pNewObjNode->status = OBJSTATUS_NONE; |
| 561 | pNewObjNode->vkObj = reinterpret_cast<uint64_t>(vkObj); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 562 | VkQueueMap[reinterpret_cast<uint64_t>(vkObj)] = pNewObjNode; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 563 | uint32_t objIndex = objTypeToIndex(objType); |
| 564 | numObjs[objIndex]++; |
| 565 | numTotalObjs++; |
| 566 | } |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 567 | static void create_swapchain_image_obj(VkDevice dispatchable_object, VkImage vkObj, VkSwapchainKHR swapchain) { |
| 568 | log_msg(mdd(dispatchable_object), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, (uint64_t)vkObj, |
| 569 | __LINE__, OBJTRACK_NONE, "OBJTRACK", "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, |
| 570 | "SwapchainImage", (uint64_t)(vkObj)); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 571 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 572 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
| 573 | pNewObjNode->belongsTo = (uint64_t)dispatchable_object; |
| 574 | pNewObjNode->objType = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT; |
| 575 | pNewObjNode->status = OBJSTATUS_NONE; |
| 576 | pNewObjNode->vkObj = (uint64_t)vkObj; |
| 577 | pNewObjNode->parentObj = (uint64_t)swapchain; |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 578 | swapchainImageMap[(uint64_t)(vkObj)] = pNewObjNode; |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 579 | } |
| 580 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 581 | static void create_device(VkInstance dispatchable_object, VkDevice vkObj, VkDebugReportObjectTypeEXT objType) { |
| 582 | log_msg(mid(dispatchable_object), VK_DEBUG_REPORT_INFORMATION_BIT_EXT, objType, (uint64_t)(vkObj), __LINE__, OBJTRACK_NONE, |
| 583 | "OBJTRACK", "OBJ[%llu] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, |
| 584 | string_VkDebugReportObjectTypeEXT(objType), (uint64_t)(vkObj)); |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 585 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 586 | OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 587 | pNewObjNode->belongsTo = (uint64_t)dispatchable_object; |
| 588 | pNewObjNode->objType = objType; |
| 589 | pNewObjNode->status = OBJSTATUS_NONE; |
| 590 | pNewObjNode->vkObj = (uint64_t)(vkObj); |
| 591 | VkDeviceMap[(uint64_t)vkObj] = pNewObjNode; |
| 592 | uint32_t objIndex = objTypeToIndex(objType); |
| 593 | numObjs[objIndex]++; |
| 594 | numTotalObjs++; |
| 595 | } |
| 596 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 597 | // |
| 598 | // Non-auto-generated API functions called by generated code |
| 599 | // |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 600 | VkResult explicit_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 601 | VkInstance *pInstance) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 602 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
David Pinedo | c0fa1ab | 2015-07-31 10:46:25 -0600 | [diff] [blame] | 603 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 604 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 605 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 606 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 607 | if (fpCreateInstance == NULL) { |
| 608 | return VK_ERROR_INITIALIZATION_FAILED; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 609 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 610 | |
| 611 | // Advance the link info for the next element on the chain |
| 612 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 613 | |
| 614 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 615 | if (result != VK_SUCCESS) { |
| 616 | return result; |
| 617 | } |
| 618 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 619 | layer_data *my_data = get_my_data_ptr(get_dispatch_key(*pInstance), layer_data_map); |
| 620 | initInstanceTable(*pInstance, fpGetInstanceProcAddr, object_tracker_instance_table_map); |
| 621 | VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(object_tracker_instance_table_map, *pInstance); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 622 | |
Ian Elliott | ed6b5ac | 2016-04-28 09:08:13 -0600 | [diff] [blame] | 623 | // Look for one or more debug report create info structures, and copy the |
| 624 | // callback(s) for each one found (for use by vkDestroyInstance) |
| 625 | layer_copy_tmp_callbacks(pCreateInfo->pNext, &my_data->num_tmp_callbacks, &my_data->tmp_dbg_create_infos, |
| 626 | &my_data->tmp_callbacks); |
| 627 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 628 | my_data->report_data = debug_report_create_instance(pInstanceTable, *pInstance, pCreateInfo->enabledExtensionCount, |
| 629 | pCreateInfo->ppEnabledExtensionNames); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 630 | |
Mark Lobodzinski | 1079e1b | 2016-03-15 14:21:59 -0600 | [diff] [blame] | 631 | init_object_tracker(my_data, pAllocator); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 632 | createInstanceRegisterExtensions(pCreateInfo, *pInstance); |
| 633 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 634 | create_instance(*pInstance, *pInstance, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 635 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 636 | return result; |
| 637 | } |
| 638 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 639 | void explicit_GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice gpu, uint32_t *pCount, VkQueueFamilyProperties *pProperties) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 640 | get_dispatch_table(object_tracker_instance_table_map, gpu)->GetPhysicalDeviceQueueFamilyProperties(gpu, pCount, pProperties); |
Tony Barbour | 59a4732 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 641 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 642 | std::lock_guard<std::mutex> lock(global_lock); |
| 643 | if (pProperties != NULL) { |
Cody Northrop | d080288 | 2015-08-03 17:04:53 -0600 | [diff] [blame] | 644 | setGpuQueueInfoState(*pCount, pProperties); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 645 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 646 | } |
| 647 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 648 | VkResult explicit_CreateDevice(VkPhysicalDevice gpu, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 649 | VkDevice *pDevice) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 650 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 651 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 652 | |
| 653 | assert(chain_info->u.pLayerInfo); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 654 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 655 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 656 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(NULL, "vkCreateDevice"); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 657 | if (fpCreateDevice == NULL) { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 658 | return VK_ERROR_INITIALIZATION_FAILED; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 659 | } |
| 660 | |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 661 | // Advance the link info for the next element on the chain |
| 662 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 663 | |
| 664 | VkResult result = fpCreateDevice(gpu, pCreateInfo, pAllocator, pDevice); |
| 665 | if (result != VK_SUCCESS) { |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 666 | return result; |
| 667 | } |
| 668 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 669 | layer_data *my_instance_data = get_my_data_ptr(get_dispatch_key(gpu), layer_data_map); |
| 670 | layer_data *my_device_data = get_my_data_ptr(get_dispatch_key(*pDevice), layer_data_map); |
| 671 | my_device_data->report_data = layer_debug_report_create_device(my_instance_data->report_data, *pDevice); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 672 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 673 | initDeviceTable(*pDevice, fpGetDeviceProcAddr, object_tracker_device_table_map); |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 674 | |
| 675 | createDeviceRegisterExtensions(pCreateInfo, *pDevice); |
| 676 | |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 677 | if (VkPhysicalDeviceMap.find((uint64_t)gpu) != VkPhysicalDeviceMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 678 | OBJTRACK_NODE *pNewObjNode = VkPhysicalDeviceMap[(uint64_t)gpu]; |
Mark Lobodzinski | c857fb3 | 2016-03-08 15:10:00 -0700 | [diff] [blame] | 679 | create_device((VkInstance)pNewObjNode->belongsTo, *pDevice, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT); |
| 680 | } |
Courtney Goeltzenleuchter | 00150eb | 2016-01-08 12:18:43 -0700 | [diff] [blame] | 681 | |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 682 | return result; |
| 683 | } |
| 684 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 685 | VkResult explicit_EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 686 | VkPhysicalDevice *pPhysicalDevices) { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 687 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 688 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 689 | skipCall |= validate_instance(instance, instance, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 690 | lock.unlock(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 691 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 692 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 693 | VkResult result = get_dispatch_table(object_tracker_instance_table_map, instance) |
| 694 | ->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 695 | lock.lock(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 696 | if (result == VK_SUCCESS) { |
| 697 | if (pPhysicalDevices) { |
| 698 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 699 | create_physical_device(instance, pPhysicalDevices[i], VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 703 | lock.unlock(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 704 | return result; |
| 705 | } |
| 706 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 707 | void explicit_GetDeviceQueue(VkDevice device, uint32_t queueNodeIndex, uint32_t queueIndex, VkQueue *pQueue) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 708 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 709 | validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 710 | lock.unlock(); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 711 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 712 | get_dispatch_table(object_tracker_device_table_map, device)->GetDeviceQueue(device, queueNodeIndex, queueIndex, pQueue); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 713 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 714 | lock.lock(); |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 715 | addQueueInfo(queueNodeIndex, *pQueue); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 716 | create_queue(device, *pQueue, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 717 | } |
| 718 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 719 | VkResult explicit_MapMemory(VkDevice device, VkDeviceMemory mem, VkDeviceSize offset, VkDeviceSize size, VkFlags flags, |
| 720 | void **ppData) { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 721 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 722 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 723 | skipCall |= set_device_memory_status(device, mem, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, OBJSTATUS_GPU_MEM_MAPPED); |
| 724 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 725 | lock.unlock(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 726 | if (skipCall == VK_TRUE) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 727 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 728 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 729 | VkResult result = |
| 730 | get_dispatch_table(object_tracker_device_table_map, device)->MapMemory(device, mem, offset, size, flags, ppData); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 731 | |
| 732 | return result; |
| 733 | } |
| 734 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 735 | void explicit_UnmapMemory(VkDevice device, VkDeviceMemory mem) { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 736 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 737 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 738 | skipCall |= reset_device_memory_status(device, mem, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, OBJSTATUS_GPU_MEM_MAPPED); |
| 739 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 740 | lock.unlock(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 741 | if (skipCall == VK_TRUE) |
| 742 | return; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 743 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 744 | get_dispatch_table(object_tracker_device_table_map, device)->UnmapMemory(device, mem); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 745 | } |
| 746 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 747 | VkResult explicit_QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, VkFence fence) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 748 | std::unique_lock<std::mutex> lock(global_lock); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 749 | validateQueueFlags(queue, "QueueBindSparse"); |
| 750 | |
| 751 | for (uint32_t i = 0; i < bindInfoCount; i++) { |
| 752 | for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 753 | validate_buffer(queue, pBindInfo[i].pBufferBinds[j].buffer, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, false); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 754 | for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 755 | validate_image(queue, pBindInfo[i].pImageOpaqueBinds[j].image, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, false); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 756 | for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++) |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 757 | validate_image(queue, pBindInfo[i].pImageBinds[j].image, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, false); |
Chia-I Wu | 1ff4c3d | 2015-10-26 16:55:27 +0800 | [diff] [blame] | 758 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 759 | lock.unlock(); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 760 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 761 | VkResult result = |
| 762 | get_dispatch_table(object_tracker_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); |
Mark Lobodzinski | 16e8bef | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 763 | return result; |
| 764 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 765 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 766 | VkResult explicit_AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 767 | VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 768 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 769 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 770 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
| 771 | skipCall |= validate_command_pool(device, pAllocateInfo->commandPool, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 772 | lock.unlock(); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 773 | |
| 774 | if (skipCall) { |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 775 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 776 | } |
| 777 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 778 | VkResult result = |
| 779 | get_dispatch_table(object_tracker_device_table_map, device)->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 780 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 781 | lock.lock(); |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 782 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 783 | alloc_command_buffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 784 | pAllocateInfo->level); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 785 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 786 | lock.unlock(); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 787 | |
| 788 | return result; |
| 789 | } |
| 790 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 791 | VkResult explicit_AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 792 | VkDescriptorSet *pDescriptorSets) { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 793 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 794 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 795 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 796 | skipCall |= |
| 797 | validate_descriptor_pool(device, pAllocateInfo->descriptorPool, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, false); |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 798 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 799 | skipCall |= validate_descriptor_set_layout(device, pAllocateInfo->pSetLayouts[i], |
| 800 | VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT, false); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 801 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 802 | lock.unlock(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 803 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 804 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 805 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 806 | VkResult result = |
| 807 | get_dispatch_table(object_tracker_device_table_map, device)->AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 808 | |
Chris Forbes | 539a87c | 2016-01-22 15:44:40 +1300 | [diff] [blame] | 809 | if (VK_SUCCESS == result) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 810 | lock.lock(); |
Chris Forbes | 539a87c | 2016-01-22 15:44:40 +1300 | [diff] [blame] | 811 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 812 | alloc_descriptor_set(device, pAllocateInfo->descriptorPool, pDescriptorSets[i], |
| 813 | VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT); |
Chris Forbes | 539a87c | 2016-01-22 15:44:40 +1300 | [diff] [blame] | 814 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 815 | lock.unlock(); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 816 | } |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 817 | |
| 818 | return result; |
| 819 | } |
| 820 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 821 | void explicit_FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 822 | const VkCommandBuffer *pCommandBuffers) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 823 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 824 | validate_command_pool(device, commandPool, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, false); |
| 825 | validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 826 | lock.unlock(); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 827 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 828 | get_dispatch_table(object_tracker_device_table_map, device) |
| 829 | ->FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 830 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 831 | lock.lock(); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 832 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 833 | free_command_buffer(device, commandPool, *pCommandBuffers); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 834 | pCommandBuffers++; |
| 835 | } |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 836 | } |
| 837 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 838 | void explicit_DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 839 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 840 | // A swapchain's images are implicitly deleted when the swapchain is deleted. |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 841 | // Remove this swapchain's images from our map of such images. |
Mark Lobodzinski | f93272b | 2016-05-02 12:08:24 -0600 | [diff] [blame^] | 842 | std::unordered_map<uint64_t, OBJTRACK_NODE *>::iterator itr = swapchainImageMap.begin(); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 843 | while (itr != swapchainImageMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 844 | OBJTRACK_NODE *pNode = (*itr).second; |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 845 | if (pNode->parentObj == (uint64_t)(swapchain)) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 846 | swapchainImageMap.erase(itr++); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 847 | } else { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 848 | ++itr; |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 849 | } |
| 850 | } |
Tobin Ehlis | 86684f9 | 2016-01-05 10:33:58 -0700 | [diff] [blame] | 851 | destroy_swapchain_khr(device, swapchain); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 852 | lock.unlock(); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 853 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 854 | get_dispatch_table(object_tracker_device_table_map, device)->DestroySwapchainKHR(device, swapchain, pAllocator); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 855 | } |
| 856 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 857 | void explicit_FreeMemory(VkDevice device, VkDeviceMemory mem, const VkAllocationCallbacks *pAllocator) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 858 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 859 | validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 860 | lock.unlock(); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 861 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 862 | get_dispatch_table(object_tracker_device_table_map, device)->FreeMemory(device, mem, pAllocator); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 863 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 864 | lock.lock(); |
Michael Lentine | 13803dc | 2015-11-04 14:35:12 -0800 | [diff] [blame] | 865 | destroy_device_memory(device, mem); |
Mark Lobodzinski | fae7885 | 2015-06-23 11:35:12 -0600 | [diff] [blame] | 866 | } |
Tony Barbour | a05dbaa | 2015-07-09 17:31:46 -0600 | [diff] [blame] | 867 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 868 | VkResult explicit_FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t count, |
| 869 | const VkDescriptorSet *pDescriptorSets) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 870 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 871 | validate_descriptor_pool(device, descriptorPool, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, false); |
| 872 | validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 873 | lock.unlock(); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 874 | VkResult result = get_dispatch_table(object_tracker_device_table_map, device) |
| 875 | ->FreeDescriptorSets(device, descriptorPool, count, pDescriptorSets); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 876 | |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 877 | lock.lock(); |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 878 | for (uint32_t i = 0; i < count; i++) { |
Michael Lentine | fc6aa76 | 2015-11-20 12:11:42 -0800 | [diff] [blame] | 879 | free_descriptor_set(device, descriptorPool, *pDescriptorSets++); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 880 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 881 | lock.unlock(); |
Tony Barbour | 770f80d | 2015-07-20 10:52:13 -0600 | [diff] [blame] | 882 | return result; |
| 883 | } |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 884 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 885 | void explicit_DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 886 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 887 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 888 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
| 889 | skipCall |= validate_descriptor_pool(device, descriptorPool, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 890 | lock.unlock(); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 891 | if (skipCall) { |
| 892 | return; |
| 893 | } |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 894 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 895 | // Remove this pool's descriptor sets from our descriptorSet map. |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 896 | lock.lock(); |
Mark Lobodzinski | f93272b | 2016-05-02 12:08:24 -0600 | [diff] [blame^] | 897 | std::unordered_map<uint64_t, OBJTRACK_NODE *>::iterator itr = VkDescriptorSetMap.begin(); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 898 | while (itr != VkDescriptorSetMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 899 | OBJTRACK_NODE *pNode = (*itr).second; |
Mark Lobodzinski | b29731a | 2015-11-18 11:01:02 -0700 | [diff] [blame] | 900 | auto del_itr = itr++; |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 901 | if (pNode->parentObj == (uint64_t)(descriptorPool)) { |
| 902 | destroy_descriptor_set(device, (VkDescriptorSet)((*del_itr).first)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 903 | } |
| 904 | } |
| 905 | destroy_descriptor_pool(device, descriptorPool); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 906 | lock.unlock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 907 | get_dispatch_table(object_tracker_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool, pAllocator); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 908 | } |
| 909 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 910 | void explicit_DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 911 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 912 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 913 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
| 914 | skipCall |= validate_command_pool(device, commandPool, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 915 | lock.unlock(); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 916 | if (skipCall) { |
| 917 | return; |
| 918 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 919 | lock.lock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 920 | // A CommandPool's command buffers are implicitly deleted when the pool is deleted. |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 921 | // Remove this pool's cmdBuffers from our cmd buffer map. |
Mark Lobodzinski | f93272b | 2016-05-02 12:08:24 -0600 | [diff] [blame^] | 922 | std::unordered_map<uint64_t, OBJTRACK_NODE *>::iterator itr = VkCommandBufferMap.begin(); |
| 923 | std::unordered_map<uint64_t, OBJTRACK_NODE *>::iterator del_itr; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 924 | while (itr != VkCommandBufferMap.end()) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 925 | OBJTRACK_NODE *pNode = (*itr).second; |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 926 | del_itr = itr++; |
Mark Young | 93ecb1d | 2016-01-13 13:47:16 -0700 | [diff] [blame] | 927 | if (pNode->parentObj == (uint64_t)(commandPool)) { |
Tobin Ehlis | 4192fdf | 2016-04-18 15:40:59 -0600 | [diff] [blame] | 928 | free_command_buffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 929 | } |
| 930 | } |
| 931 | destroy_command_pool(device, commandPool); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 932 | lock.unlock(); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 933 | get_dispatch_table(object_tracker_device_table_map, device)->DestroyCommandPool(device, commandPool, pAllocator); |
Mark Lobodzinski | 5f5c0e1 | 2015-11-12 16:02:35 -0700 | [diff] [blame] | 934 | } |
| 935 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 936 | VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pCount, VkImage *pSwapchainImages) { |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 937 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 938 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 939 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 940 | lock.unlock(); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 941 | if (skipCall) |
Courtney Goeltzenleuchter | 52fee65 | 2015-12-10 16:41:22 -0700 | [diff] [blame] | 942 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 943 | |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 944 | VkResult result = get_dispatch_table(object_tracker_device_table_map, device) |
| 945 | ->GetSwapchainImagesKHR(device, swapchain, pCount, pSwapchainImages); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 946 | |
| 947 | if (pSwapchainImages != NULL) { |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 948 | lock.lock(); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 949 | for (uint32_t i = 0; i < *pCount; i++) { |
| 950 | create_swapchain_image_obj(device, pSwapchainImages[i], swapchain); |
| 951 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 952 | lock.unlock(); |
Mark Lobodzinski | e6d3f2c | 2015-10-14 13:16:33 -0600 | [diff] [blame] | 953 | } |
| 954 | return result; |
| 955 | } |
| 956 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 957 | // TODO: Add special case to codegen to cover validating all the pipelines instead of just the first |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 958 | VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 959 | const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 960 | VkPipeline *pPipelines) { |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 961 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 962 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 963 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 964 | if (pCreateInfos) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 965 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 966 | if (pCreateInfos[idx0].basePipelineHandle) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 967 | skipCall |= validate_pipeline(device, pCreateInfos[idx0].basePipelineHandle, |
| 968 | VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, true); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 969 | } |
| 970 | if (pCreateInfos[idx0].layout) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 971 | skipCall |= validate_pipeline_layout(device, pCreateInfos[idx0].layout, |
| 972 | VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 973 | } |
| 974 | if (pCreateInfos[idx0].pStages) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 975 | for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) { |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 976 | if (pCreateInfos[idx0].pStages[idx1].module) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 977 | skipCall |= validate_shader_module(device, pCreateInfos[idx0].pStages[idx1].module, |
| 978 | VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 979 | } |
| 980 | } |
| 981 | } |
| 982 | if (pCreateInfos[idx0].renderPass) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 983 | skipCall |= |
| 984 | validate_render_pass(device, pCreateInfos[idx0].renderPass, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 985 | } |
| 986 | } |
| 987 | } |
| 988 | if (pipelineCache) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 989 | skipCall |= validate_pipeline_cache(device, pipelineCache, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 990 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 991 | lock.unlock(); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 992 | if (skipCall) |
| 993 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 994 | VkResult result = get_dispatch_table(object_tracker_device_table_map, device) |
| 995 | ->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 996 | lock.lock(); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 997 | if (result == VK_SUCCESS) { |
| 998 | for (uint32_t idx2 = 0; idx2 < createInfoCount; ++idx2) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 999 | create_pipeline(device, pPipelines[idx2], VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1000 | } |
| 1001 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 1002 | lock.unlock(); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1003 | return result; |
| 1004 | } |
| 1005 | |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1006 | // TODO: Add special case to codegen to cover validating all the pipelines instead of just the first |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1007 | VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 1008 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 1009 | VkPipeline *pPipelines) { |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1010 | VkBool32 skipCall = VK_FALSE; |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 1011 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1012 | skipCall |= validate_device(device, device, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1013 | if (pCreateInfos) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1014 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1015 | if (pCreateInfos[idx0].basePipelineHandle) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1016 | skipCall |= validate_pipeline(device, pCreateInfos[idx0].basePipelineHandle, |
| 1017 | VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, true); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1018 | } |
| 1019 | if (pCreateInfos[idx0].layout) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1020 | skipCall |= validate_pipeline_layout(device, pCreateInfos[idx0].layout, |
| 1021 | VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1022 | } |
| 1023 | if (pCreateInfos[idx0].stage.module) { |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1024 | skipCall |= validate_shader_module(device, pCreateInfos[idx0].stage.module, |
| 1025 | VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1026 | } |
| 1027 | } |
| 1028 | } |
| 1029 | if (pipelineCache) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1030 | skipCall |= validate_pipeline_cache(device, pipelineCache, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT, false); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1031 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 1032 | lock.unlock(); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1033 | if (skipCall) |
| 1034 | return VK_ERROR_VALIDATION_FAILED_EXT; |
Jon Ashburn | 5484e0c | 2016-03-08 17:48:44 -0700 | [diff] [blame] | 1035 | VkResult result = get_dispatch_table(object_tracker_device_table_map, device) |
| 1036 | ->CreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 1037 | lock.lock(); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1038 | if (result == VK_SUCCESS) { |
| 1039 | for (uint32_t idx1 = 0; idx1 < createInfoCount; ++idx1) { |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 1040 | create_pipeline(device, pPipelines[idx1], VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1041 | } |
| 1042 | } |
Jeremy Hayes | 2f065b1 | 2016-04-13 10:54:17 -0600 | [diff] [blame] | 1043 | lock.unlock(); |
Mark Lobodzinski | 154329b | 2016-01-26 09:55:28 -0700 | [diff] [blame] | 1044 | return result; |
| 1045 | } |