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