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