Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 1 | /* Copyright (c) 2015-2018 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2018 Valve Corporation |
| 3 | * Copyright (c) 2015-2018 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2018 Google Inc. |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 19 | * Author: Jon Ashburn <jon@lunarg.com> |
| 20 | * Author: Tobin Ehlis <tobin@lunarg.com> |
| 21 | */ |
| 22 | |
| 23 | #include "object_tracker.h" |
| 24 | |
| 25 | namespace object_tracker { |
| 26 | |
| 27 | std::unordered_map<void *, layer_data *> layer_data_map; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 28 | std::mutex global_lock; |
| 29 | uint64_t object_track_index = 0; |
| 30 | uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 31 | |
| 32 | void InitObjectTracker(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 33 | layer_debug_messenger_actions(my_data->report_data, my_data->logging_messenger, pAllocator, "lunarg_object_tracker"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | // Add new queue to head of global queue list |
| 37 | void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue) { |
| 38 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 39 | auto queueItem = device_data->queue_info_map.find(queue); |
| 40 | if (queueItem == device_data->queue_info_map.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 41 | ObjTrackQueueInfo *p_queue_info = new ObjTrackQueueInfo; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 42 | if (p_queue_info != NULL) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 43 | memset(p_queue_info, 0, sizeof(ObjTrackQueueInfo)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 44 | p_queue_info->queue = queue; |
| 45 | p_queue_info->queue_node_index = queue_node_index; |
| 46 | device_data->queue_info_map[queue] = p_queue_info; |
| 47 | } else { |
| 48 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, |
Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 49 | HandleToUint64(queue), kVUID_ObjectTracker_InternalError, |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 50 | "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information"); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // Destroy memRef lists and free all memory |
| 56 | void DestroyQueueDataStructures(VkDevice device) { |
| 57 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 58 | |
| 59 | for (auto queue_item : device_data->queue_info_map) { |
| 60 | delete queue_item.second; |
| 61 | } |
| 62 | device_data->queue_info_map.clear(); |
| 63 | |
| 64 | // Destroy the items in the queue map |
| 65 | auto queue = device_data->object_map[kVulkanObjectTypeQueue].begin(); |
| 66 | while (queue != device_data->object_map[kVulkanObjectTypeQueue].end()) { |
| 67 | uint32_t obj_index = queue->second->object_type; |
| 68 | assert(device_data->num_total_objects > 0); |
| 69 | device_data->num_total_objects--; |
| 70 | assert(device_data->num_objects[obj_index] > 0); |
| 71 | device_data->num_objects[obj_index]--; |
| 72 | log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, |
Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 73 | queue->second->handle, kVUID_ObjectTracker_Info, |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 74 | "OBJ_STAT Destroy Queue obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " Queue objs).", |
| 75 | queue->second->handle, device_data->num_total_objects, device_data->num_objects[obj_index]); |
| 76 | delete queue->second; |
| 77 | queue = device_data->object_map[kVulkanObjectTypeQueue].erase(queue); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // Check Queue type flags for selected queue operations |
| 82 | void ValidateQueueFlags(VkQueue queue, const char *function) { |
| 83 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 84 | auto queue_item = device_data->queue_info_map.find(queue); |
| 85 | if (queue_item != device_data->queue_info_map.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 86 | ObjTrackQueueInfo *pQueueInfo = queue_item->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 87 | if (pQueueInfo != NULL) { |
| 88 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(device_data->physical_device), layer_data_map); |
| 89 | if ((instance_data->queue_family_properties[pQueueInfo->queue_node_index].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == |
| 90 | 0) { |
| 91 | log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 92 | HandleToUint64(queue), "VUID-vkQueueBindSparse-queuetype", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 93 | "Attempting %s on a non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not set.", function); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 99 | // Look for this device object in any of the instance child devices lists. |
| 100 | // NOTE: This is of dubious value. In most circumstances Vulkan will die a flaming death if a dispatchable object is invalid. |
| 101 | // However, if this layer is loaded first and GetProcAddress is used to make API calls, it will detect bad DOs. |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 102 | bool ValidateDeviceObject(uint64_t device_handle, const std::string &invalid_handle_code, const std::string &wrong_device_code) { |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 103 | VkInstance last_instance = nullptr; |
| 104 | for (auto layer_data : layer_data_map) { |
| 105 | for (auto object : layer_data.second->object_map[kVulkanObjectTypeDevice]) { |
| 106 | // Grab last instance to use for possible error message |
| 107 | last_instance = layer_data.second->instance; |
| 108 | if (object.second->handle == device_handle) return false; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(last_instance), layer_data_map); |
| 113 | return log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device_handle, |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 114 | invalid_handle_code, "Invalid Device Object 0x%" PRIxLEAST64 ".", device_handle); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 117 | void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer, |
| 118 | VkCommandBufferLevel level) { |
| 119 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 120 | |
| 121 | log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 122 | HandleToUint64(command_buffer), kVUID_ObjectTracker_Info, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 123 | object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT", HandleToUint64(command_buffer)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 124 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 125 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 126 | pNewObjNode->object_type = kVulkanObjectTypeCommandBuffer; |
| 127 | pNewObjNode->handle = HandleToUint64(command_buffer); |
| 128 | pNewObjNode->parent_object = HandleToUint64(command_pool); |
| 129 | if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { |
| 130 | pNewObjNode->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; |
| 131 | } else { |
| 132 | pNewObjNode->status = OBJSTATUS_NONE; |
| 133 | } |
| 134 | device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)] = pNewObjNode; |
| 135 | device_data->num_objects[kVulkanObjectTypeCommandBuffer]++; |
| 136 | device_data->num_total_objects++; |
| 137 | } |
| 138 | |
| 139 | bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) { |
| 140 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 141 | bool skip = false; |
| 142 | uint64_t object_handle = HandleToUint64(command_buffer); |
| 143 | if (device_data->object_map[kVulkanObjectTypeCommandBuffer].find(object_handle) != |
| 144 | device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 145 | ObjTrackState *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 146 | |
| 147 | if (pNode->parent_object != HandleToUint64(command_pool)) { |
| 148 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 149 | object_handle, "VUID-vkFreeCommandBuffers-pCommandBuffers-parent", |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 150 | "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 151 | " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 152 | HandleToUint64(command_buffer), pNode->parent_object, HandleToUint64(command_pool)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 153 | } |
| 154 | } else { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 155 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 156 | object_handle, "VUID-vkFreeCommandBuffers-pCommandBuffers-00048", "Invalid %s Object 0x%" PRIxLEAST64 ".", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 157 | object_string[kVulkanObjectTypeCommandBuffer], object_handle); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 158 | } |
| 159 | return skip; |
| 160 | } |
| 161 | |
| 162 | void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
| 163 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 164 | |
| 165 | log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, |
Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 166 | HandleToUint64(descriptor_set), kVUID_ObjectTracker_Info, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 167 | object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT", HandleToUint64(descriptor_set)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 168 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 169 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 170 | pNewObjNode->object_type = kVulkanObjectTypeDescriptorSet; |
| 171 | pNewObjNode->status = OBJSTATUS_NONE; |
| 172 | pNewObjNode->handle = HandleToUint64(descriptor_set); |
| 173 | pNewObjNode->parent_object = HandleToUint64(descriptor_pool); |
| 174 | device_data->object_map[kVulkanObjectTypeDescriptorSet][HandleToUint64(descriptor_set)] = pNewObjNode; |
| 175 | device_data->num_objects[kVulkanObjectTypeDescriptorSet]++; |
| 176 | device_data->num_total_objects++; |
| 177 | } |
| 178 | |
| 179 | bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
| 180 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 181 | bool skip = false; |
| 182 | uint64_t object_handle = HandleToUint64(descriptor_set); |
| 183 | auto dsItem = device_data->object_map[kVulkanObjectTypeDescriptorSet].find(object_handle); |
| 184 | if (dsItem != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 185 | ObjTrackState *pNode = dsItem->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 186 | |
| 187 | if (pNode->parent_object != HandleToUint64(descriptor_pool)) { |
| 188 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 189 | object_handle, "VUID-vkFreeDescriptorSets-pDescriptorSets-parent", |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 190 | "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 191 | " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 192 | HandleToUint64(descriptor_set), pNode->parent_object, HandleToUint64(descriptor_pool)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 193 | } |
| 194 | } else { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 195 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 196 | object_handle, "VUID-vkFreeDescriptorSets-pDescriptorSets-00310", "Invalid %s Object 0x%" PRIxLEAST64 ".", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 197 | object_string[kVulkanObjectTypeDescriptorSet], object_handle); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 198 | } |
| 199 | return skip; |
| 200 | } |
| 201 | |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 202 | template <typename DispObj> |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 203 | static bool ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush) { |
| 204 | bool skip = false; |
| 205 | |
| 206 | if (!isPush && desc->dstSet) { |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 207 | skip |= ValidateObject(disp, desc->dstSet, kVulkanObjectTypeDescriptorSet, false, "VUID-VkWriteDescriptorSet-dstSet-00320", |
| 208 | "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 212 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 213 | for (uint32_t idx2 = 0; idx2 < desc->descriptorCount; ++idx2) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 214 | skip |= ValidateObject(disp, desc->pTexelBufferView[idx2], kVulkanObjectTypeBufferView, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 215 | "VUID-VkWriteDescriptorSet-descriptorType-00323", "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
| 219 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 220 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 221 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 222 | for (uint32_t idx3 = 0; idx3 < desc->descriptorCount; ++idx3) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 223 | skip |= ValidateObject(disp, desc->pImageInfo[idx3].imageView, kVulkanObjectTypeImageView, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 224 | "VUID-VkWriteDescriptorSet-descriptorType-00326", "VUID-VkDescriptorImageInfo-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 225 | } |
| 226 | } |
| 227 | |
| 228 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 229 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 230 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 231 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 232 | for (uint32_t idx4 = 0; idx4 < desc->descriptorCount; ++idx4) { |
| 233 | if (desc->pBufferInfo[idx4].buffer) { |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 234 | skip |= ValidateObject(disp, desc->pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 235 | "VUID-VkDescriptorBufferInfo-buffer-parameter", kVUIDUndefined); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | return skip; |
| 241 | } |
| 242 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 243 | static bool PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, |
| 244 | VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, |
| 245 | const VkWriteDescriptorSet *pDescriptorWrites) { |
| 246 | bool skip = false; |
| 247 | skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 248 | "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
| 249 | skip |= ValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, |
| 250 | "VUID-vkCmdPushDescriptorSetKHR-layout-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
| 251 | if (pDescriptorWrites) { |
| 252 | for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) { |
| 253 | skip |= ValidateDescriptorWrite(commandBuffer, &pDescriptorWrites[index0], true); |
| 254 | } |
| 255 | } |
| 256 | return skip; |
| 257 | } |
| 258 | |
Tony Barbour | 2fd0c2c | 2017-08-08 12:51:33 -0600 | [diff] [blame] | 259 | VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, |
| 260 | VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, |
| 261 | const VkWriteDescriptorSet *pDescriptorWrites) { |
| 262 | bool skip = false; |
| 263 | { |
| 264 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 265 | skip |= PreCallValidateCmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, |
| 266 | pDescriptorWrites); |
| 267 | if (skip) return; |
Tony Barbour | 2fd0c2c | 2017-08-08 12:51:33 -0600 | [diff] [blame] | 268 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 269 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 270 | device_data->device_dispatch_table.CmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, |
| 271 | pDescriptorWrites); |
Tony Barbour | 2fd0c2c | 2017-08-08 12:51:33 -0600 | [diff] [blame] | 272 | } |
| 273 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 274 | void CreateQueue(VkDevice device, VkQueue vkObj) { |
| 275 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 276 | |
| 277 | log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, |
Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 278 | HandleToUint64(vkObj), kVUID_ObjectTracker_Info, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 279 | object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT", HandleToUint64(vkObj)); |
| 280 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 281 | ObjTrackState *p_obj_node = NULL; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 282 | auto queue_item = device_data->object_map[kVulkanObjectTypeQueue].find(HandleToUint64(vkObj)); |
| 283 | if (queue_item == device_data->object_map[kVulkanObjectTypeQueue].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 284 | p_obj_node = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 285 | device_data->object_map[kVulkanObjectTypeQueue][HandleToUint64(vkObj)] = p_obj_node; |
| 286 | device_data->num_objects[kVulkanObjectTypeQueue]++; |
| 287 | device_data->num_total_objects++; |
| 288 | } else { |
| 289 | p_obj_node = queue_item->second; |
| 290 | } |
| 291 | p_obj_node->object_type = kVulkanObjectTypeQueue; |
| 292 | p_obj_node->status = OBJSTATUS_NONE; |
| 293 | p_obj_node->handle = HandleToUint64(vkObj); |
| 294 | } |
| 295 | |
| 296 | void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) { |
| 297 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); |
| 298 | log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, |
Dave Houlton | b817a87 | 2018-06-26 13:22:01 -0600 | [diff] [blame] | 299 | HandleToUint64(swapchain_image), kVUID_ObjectTracker_Info, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, |
Mark Lobodzinski | b1fd9d1 | 2018-03-30 14:26:00 -0600 | [diff] [blame] | 300 | object_track_index++, "SwapchainImage", HandleToUint64(swapchain_image)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 301 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 302 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 303 | pNewObjNode->object_type = kVulkanObjectTypeImage; |
| 304 | pNewObjNode->status = OBJSTATUS_NONE; |
| 305 | pNewObjNode->handle = HandleToUint64(swapchain_image); |
| 306 | pNewObjNode->parent_object = HandleToUint64(swapchain); |
| 307 | device_data->swapchainImageMap[HandleToUint64(swapchain_image)] = pNewObjNode; |
| 308 | } |
| 309 | |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 310 | bool DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code) { |
| 311 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 312 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 313 | for (const auto &item : device_data->object_map[object_type]) { |
| 314 | const ObjTrackState *object_info = item.second; |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 315 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], |
| 316 | object_info->handle, error_code, |
| 317 | "OBJ ERROR : For device 0x%" PRIxLEAST64 ", %s object 0x%" PRIxLEAST64 " has not been destroyed.", |
| 318 | HandleToUint64(device), object_string[object_type], object_info->handle); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 319 | } |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 320 | return skip; |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | void DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type) { |
| 324 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 325 | while (!device_data->object_map[object_type].empty()) { |
| 326 | auto item = device_data->object_map[object_type].begin(); |
| 327 | |
| 328 | ObjTrackState *object_info = item->second; |
| 329 | DestroyObjectSilently(device, object_info->handle, object_type); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 330 | } |
| 331 | } |
| 332 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 333 | static bool PreCallValidateDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 334 | dispatch_key key = get_dispatch_key(instance); |
| 335 | layer_data *instance_data = GetLayerDataPtr(key, layer_data_map); |
| 336 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 337 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 338 | // We validate here for coverage, though we'd not have made it this for with a bad instance. |
| 339 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, true, "VUID-vkDestroyInstance-instance-parameter", |
| 340 | kVUIDUndefined); |
| 341 | |
| 342 | // Validate that child devices have been destroyed |
| 343 | for (const auto &iit : instance_data->object_map[kVulkanObjectTypeDevice]) { |
| 344 | ObjTrackState *pNode = iit.second; |
| 345 | |
| 346 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
| 347 | VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[pNode->object_type]; |
| 348 | |
| 349 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, pNode->handle, |
| 350 | kVUID_ObjectTracker_ObjectLeak, "OBJ ERROR : %s object 0x%" PRIxLEAST64 " has not been destroyed.", |
| 351 | string_VkDebugReportObjectTypeEXT(debug_object_type), pNode->handle); |
| 352 | |
| 353 | // Report any remaining objects in LL |
| 354 | skip |= ReportUndestroyedObjects(device, "VUID-vkDestroyInstance-instance-00629"); |
| 355 | |
| 356 | skip |= ValidateDestroyObject(instance, device, kVulkanObjectTypeDevice, pAllocator, |
| 357 | "VUID-vkDestroyInstance-instance-00630", "VUID-vkDestroyInstance-instance-00631"); |
| 358 | } |
| 359 | |
| 360 | ValidateDestroyObject(instance, instance, kVulkanObjectTypeInstance, pAllocator, "VUID-vkDestroyInstance-instance-00630", |
| 361 | "VUID-vkDestroyInstance-instance-00631"); |
| 362 | |
| 363 | return skip; |
| 364 | } |
| 365 | |
| 366 | static void PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 367 | dispatch_key key = get_dispatch_key(instance); |
| 368 | layer_data *instance_data = GetLayerDataPtr(key, layer_data_map); |
| 369 | |
| 370 | // Enable the temporary callback(s) here to catch cleanup issues: |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 371 | if (instance_data->num_tmp_debug_messengers > 0) { |
| 372 | layer_enable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers, |
| 373 | instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers); |
| 374 | } |
| 375 | if (instance_data->num_tmp_report_callbacks > 0) { |
| 376 | layer_enable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks, |
| 377 | instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 378 | } |
| 379 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 380 | // Destroy physical devices |
| 381 | for (auto iit = instance_data->object_map[kVulkanObjectTypePhysicalDevice].begin(); |
| 382 | iit != instance_data->object_map[kVulkanObjectTypePhysicalDevice].end();) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 383 | ObjTrackState *pNode = iit->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 384 | VkPhysicalDevice physical_device = reinterpret_cast<VkPhysicalDevice>(pNode->handle); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 385 | RecordDestroyObject(instance, physical_device, kVulkanObjectTypePhysicalDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 386 | iit = instance_data->object_map[kVulkanObjectTypePhysicalDevice].begin(); |
| 387 | } |
| 388 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 389 | // Destroy child devices |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 390 | for (auto iit = instance_data->object_map[kVulkanObjectTypeDevice].begin(); |
| 391 | iit != instance_data->object_map[kVulkanObjectTypeDevice].end();) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 392 | ObjTrackState *pNode = iit->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 393 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 394 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 395 | |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 396 | RecordDestroyObject(instance, device, kVulkanObjectTypeDevice); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 397 | iit = instance_data->object_map[kVulkanObjectTypeDevice].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 398 | } |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 399 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 400 | instance_data->object_map[kVulkanObjectTypeDevice].clear(); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 401 | } |
| 402 | |
| 403 | static void PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 404 | dispatch_key key = get_dispatch_key(instance); |
| 405 | layer_data *instance_data = GetLayerDataPtr(key, layer_data_map); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 406 | |
| 407 | // Disable and cleanup the temporary callback(s): |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 408 | layer_disable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers, |
| 409 | instance_data->tmp_debug_messengers); |
| 410 | layer_disable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks, |
| 411 | instance_data->tmp_report_callbacks); |
| 412 | if (instance_data->num_tmp_debug_messengers > 0) { |
| 413 | layer_free_tmp_debug_messengers(instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers); |
| 414 | instance_data->num_tmp_debug_messengers = 0; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 415 | } |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 416 | if (instance_data->num_tmp_report_callbacks > 0) { |
| 417 | layer_free_tmp_report_callbacks(instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks); |
| 418 | instance_data->num_tmp_report_callbacks = 0; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | // Clean up logging callback, if any |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 422 | while (instance_data->logging_messenger.size() > 0) { |
| 423 | VkDebugUtilsMessengerEXT messenger = instance_data->logging_messenger.back(); |
| 424 | layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator); |
| 425 | instance_data->logging_messenger.pop_back(); |
| 426 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 427 | while (instance_data->logging_callback.size() > 0) { |
| 428 | VkDebugReportCallbackEXT callback = instance_data->logging_callback.back(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 429 | layer_destroy_report_callback(instance_data->report_data, callback, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 430 | instance_data->logging_callback.pop_back(); |
| 431 | } |
| 432 | |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 433 | RecordDestroyObject(instance, instance, kVulkanObjectTypeInstance); |
GabrÃel Arthúr Pétursson | 3de74ca | 2018-03-18 01:50:54 +0000 | [diff] [blame] | 434 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 435 | layer_debug_utils_destroy_instance(instance_data->report_data); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 436 | FreeLayerDataPtr(key, layer_data_map); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 437 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 438 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame^] | 439 | VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 440 | dispatch_key key = get_dispatch_key(instance); |
| 441 | layer_data *instance_data = GetLayerDataPtr(key, layer_data_map); |
| 442 | { |
| 443 | std::lock_guard<std::mutex> lock(global_lock); |
| 444 | bool skip = PreCallValidateDestroyInstance(instance, pAllocator); |
| 445 | if (skip) return; |
| 446 | PreCallRecordDestroyInstance(instance, pAllocator); |
| 447 | } |
| 448 | instance_data->instance_dispatch_table.DestroyInstance(instance, pAllocator); |
| 449 | { |
| 450 | std::lock_guard<std::mutex> lock(global_lock); |
| 451 | PostCallRecordDestroyInstance(instance, pAllocator); |
| 452 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
| 456 | std::unique_lock<std::mutex> lock(global_lock); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 457 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 458 | ValidateObject(device, device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 459 | ValidateDestroyObject(device_data->instance, device, kVulkanObjectTypeDevice, pAllocator, "VUID-vkDestroyDevice-device-00379", |
| 460 | "VUID-vkDestroyDevice-device-00380"); |
| 461 | RecordDestroyObject(device_data->instance, device, kVulkanObjectTypeDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 462 | |
| 463 | // Report any remaining objects associated with this VkDevice object in LL |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 464 | ReportUndestroyedObjects(device, "VUID-vkDestroyDevice-device-00378"); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 465 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 466 | |
| 467 | // Clean up Queue's MemRef Linked Lists |
| 468 | DestroyQueueDataStructures(device); |
| 469 | |
| 470 | lock.unlock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 471 | dispatch_key key = get_dispatch_key(device); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 472 | device_data->device_dispatch_table.DestroyDevice(device, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 473 | FreeLayerDataPtr(key, layer_data_map); |
| 474 | } |
| 475 | |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 476 | VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
| 477 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 478 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 479 | lock.unlock(); |
| 480 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 481 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 482 | device_data->device_dispatch_table.GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 483 | |
| 484 | lock.lock(); |
| 485 | CreateQueue(device, *pQueue); |
| 486 | AddQueueInfo(device, queueFamilyIndex, *pQueue); |
| 487 | } |
| 488 | |
Yiwei Zhang | 991d88d | 2018-02-14 14:39:46 -0800 | [diff] [blame] | 489 | VKAPI_ATTR void VKAPI_CALL GetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
| 490 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 491 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter", kVUIDUndefined); |
Yiwei Zhang | 991d88d | 2018-02-14 14:39:46 -0800 | [diff] [blame] | 492 | lock.unlock(); |
| 493 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 494 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 495 | device_data->device_dispatch_table.GetDeviceQueue2(device, pQueueInfo, pQueue); |
Yiwei Zhang | 991d88d | 2018-02-14 14:39:46 -0800 | [diff] [blame] | 496 | |
| 497 | lock.lock(); |
| 498 | if (*pQueue != VK_NULL_HANDLE) { |
| 499 | CreateQueue(device, *pQueue); |
| 500 | AddQueueInfo(device, pQueueInfo->queueFamilyIndex, *pQueue); |
| 501 | } |
| 502 | } |
| 503 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 504 | VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 505 | const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, |
| 506 | const VkCopyDescriptorSet *pDescriptorCopies) { |
| 507 | bool skip = false; |
| 508 | { |
| 509 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 510 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter", |
| 511 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 512 | if (pDescriptorCopies) { |
| 513 | for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { |
| 514 | if (pDescriptorCopies[idx0].dstSet) { |
| 515 | skip |= ValidateObject(device, pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 516 | "VUID-VkCopyDescriptorSet-dstSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 517 | } |
| 518 | if (pDescriptorCopies[idx0].srcSet) { |
| 519 | skip |= ValidateObject(device, pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 520 | "VUID-VkCopyDescriptorSet-srcSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 521 | } |
| 522 | } |
| 523 | } |
| 524 | if (pDescriptorWrites) { |
| 525 | for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 526 | skip |= ValidateDescriptorWrite(device, &pDescriptorWrites[idx1], false); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | } |
| 530 | if (skip) { |
| 531 | return; |
| 532 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 533 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 534 | device_data->device_dispatch_table.UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, |
| 535 | pDescriptorCopies); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 536 | } |
| 537 | |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 538 | VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 539 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 540 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { |
| 541 | bool skip = VK_FALSE; |
| 542 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 543 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateComputePipelines-device-parameter", |
| 544 | kVUIDUndefined); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 545 | if (pCreateInfos) { |
| 546 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
| 547 | if (pCreateInfos[idx0].basePipelineHandle) { |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 548 | skip |= |
| 549 | ValidateObject(device, pCreateInfos[idx0].basePipelineHandle, kVulkanObjectTypePipeline, true, |
| 550 | "VUID-VkComputePipelineCreateInfo-flags-00697", "VUID-VkComputePipelineCreateInfo-commonparent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 551 | } |
| 552 | if (pCreateInfos[idx0].layout) { |
| 553 | skip |= ValidateObject(device, pCreateInfos[idx0].layout, kVulkanObjectTypePipelineLayout, false, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 554 | "VUID-VkComputePipelineCreateInfo-layout-parameter", |
| 555 | "VUID-VkComputePipelineCreateInfo-commonparent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 556 | } |
| 557 | if (pCreateInfos[idx0].stage.module) { |
| 558 | skip |= ValidateObject(device, pCreateInfos[idx0].stage.module, kVulkanObjectTypeShaderModule, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 559 | "VUID-VkPipelineShaderStageCreateInfo-module-parameter", kVUIDUndefined); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 560 | } |
| 561 | } |
| 562 | } |
| 563 | if (pipelineCache) { |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 564 | skip |= ValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true, |
| 565 | "VUID-vkCreateComputePipelines-pipelineCache-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 566 | "VUID-vkCreateComputePipelines-pipelineCache-parent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 567 | } |
| 568 | lock.unlock(); |
| 569 | if (skip) { |
| 570 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 571 | pPipelines[i] = VK_NULL_HANDLE; |
| 572 | } |
| 573 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 574 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 575 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 576 | VkResult result = device_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount, |
| 577 | pCreateInfos, pAllocator, pPipelines); |
| 578 | |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 579 | lock.lock(); |
| 580 | for (uint32_t idx1 = 0; idx1 < createInfoCount; ++idx1) { |
| 581 | if (pPipelines[idx1] != VK_NULL_HANDLE) { |
| 582 | CreateObject(device, pPipelines[idx1], kVulkanObjectTypePipeline, pAllocator); |
| 583 | } |
| 584 | } |
| 585 | lock.unlock(); |
| 586 | return result; |
| 587 | } |
| 588 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 589 | VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 590 | VkDescriptorPoolResetFlags flags) { |
| 591 | bool skip = false; |
| 592 | std::unique_lock<std::mutex> lock(global_lock); |
| 593 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 594 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkResetDescriptorPool-device-parameter", |
| 595 | kVUIDUndefined); |
| 596 | skip |= |
| 597 | ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 598 | "VUID-vkResetDescriptorPool-descriptorPool-parameter", "VUID-vkResetDescriptorPool-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 599 | if (skip) { |
| 600 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 601 | } |
| 602 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. |
| 603 | // Remove this pool's descriptor sets from our descriptorSet map. |
| 604 | auto itr = device_data->object_map[kVulkanObjectTypeDescriptorSet].begin(); |
| 605 | while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 606 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 607 | auto del_itr = itr++; |
| 608 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 609 | ValidateDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, |
| 610 | kVUIDUndefined, kVUIDUndefined); |
| 611 | RecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 612 | } |
| 613 | } |
| 614 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 615 | VkResult result = device_data->device_dispatch_table.ResetDescriptorPool(device, descriptorPool, flags); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 616 | return result; |
| 617 | } |
| 618 | |
| 619 | VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) { |
| 620 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map); |
| 621 | bool skip = false; |
| 622 | { |
| 623 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 624 | skip |= ValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false, |
| 625 | "VUID-vkBeginCommandBuffer-commandBuffer-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 626 | if (begin_info) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 627 | ObjTrackState *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 628 | if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && |
| 629 | (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 630 | skip |= |
| 631 | ValidateObject(command_buffer, begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, true, |
| 632 | "VUID-VkCommandBufferBeginInfo-flags-00055", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
| 633 | skip |= |
| 634 | ValidateObject(command_buffer, begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
| 635 | "VUID-VkCommandBufferBeginInfo-flags-00053", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 636 | } |
| 637 | } |
| 638 | } |
| 639 | if (skip) { |
| 640 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 641 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 642 | VkResult result = device_data->device_dispatch_table.BeginCommandBuffer(command_buffer, begin_info); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 643 | return result; |
| 644 | } |
| 645 | |
| 646 | VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance, |
| 647 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 648 | const VkAllocationCallbacks *pAllocator, |
| 649 | VkDebugReportCallbackEXT *pCallback) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 650 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 651 | VkResult result = |
| 652 | instance_data->instance_dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 653 | if (VK_SUCCESS == result) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 654 | result = layer_create_report_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pCallback); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 655 | CreateObject(instance, *pCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator); |
| 656 | } |
| 657 | return result; |
| 658 | } |
| 659 | |
| 660 | VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 661 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 662 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 663 | instance_data->instance_dispatch_table.DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 664 | layer_destroy_report_callback(instance_data->report_data, msgCallback, pAllocator); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 665 | ValidateDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator, |
| 666 | "VUID-vkDestroyDebugReportCallbackEXT-instance-01242", |
| 667 | "VUID-vkDestroyDebugReportCallbackEXT-instance-01243"); |
| 668 | RecordDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, |
| 672 | VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, |
| 673 | int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 674 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 675 | instance_data->instance_dispatch_table.DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, |
| 676 | pMsg); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 677 | } |
| 678 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 679 | // VK_EXT_debug_utils commands |
| 680 | VKAPI_ATTR VkResult VKAPI_CALL SetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) { |
| 681 | bool skip = VK_FALSE; |
| 682 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 683 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 684 | lock.unlock(); |
| 685 | if (skip) { |
| 686 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 687 | } |
| 688 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 689 | if (pNameInfo->pObjectName) { |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 690 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 691 | dev_data->report_data->debugUtilsObjectNameMap->insert( |
| 692 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->objectHandle, pNameInfo->pObjectName)); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 693 | lock.unlock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 694 | } else { |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 695 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 696 | dev_data->report_data->debugUtilsObjectNameMap->erase(pNameInfo->objectHandle); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 697 | lock.unlock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 698 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 699 | VkResult result = dev_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(device, pNameInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 700 | return result; |
| 701 | } |
| 702 | |
| 703 | VKAPI_ATTR VkResult VKAPI_CALL SetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) { |
| 704 | bool skip = VK_FALSE; |
| 705 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 706 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 707 | lock.unlock(); |
| 708 | if (skip) { |
| 709 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 710 | } |
| 711 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 712 | VkResult result = dev_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(device, pTagInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 713 | return result; |
| 714 | } |
| 715 | |
| 716 | VKAPI_ATTR void VKAPI_CALL QueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 717 | bool skip = VK_FALSE; |
| 718 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 719 | skip |= ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 720 | lock.unlock(); |
| 721 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 722 | if (!skip) { |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 723 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 724 | BeginQueueDebugUtilsLabel(dev_data->report_data, queue, pLabelInfo); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 725 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 726 | dev_data->device_dispatch_table.QueueBeginDebugUtilsLabelEXT(queue, pLabelInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 727 | } |
| 728 | } |
| 729 | |
| 730 | VKAPI_ATTR void VKAPI_CALL QueueEndDebugUtilsLabelEXT(VkQueue queue) { |
| 731 | bool skip = VK_FALSE; |
| 732 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 733 | skip |= ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 734 | lock.unlock(); |
| 735 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 736 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 737 | dev_data->device_dispatch_table.QueueEndDebugUtilsLabelEXT(queue); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 738 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 739 | EndQueueDebugUtilsLabel(dev_data->report_data, queue); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 740 | lock.unlock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 741 | } |
| 742 | } |
| 743 | |
| 744 | VKAPI_ATTR void VKAPI_CALL QueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 745 | bool skip = VK_FALSE; |
| 746 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 747 | skip |= ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 748 | lock.unlock(); |
| 749 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 750 | if (!skip) { |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 751 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 752 | InsertQueueDebugUtilsLabel(dev_data->report_data, queue, pLabelInfo); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 753 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 754 | dev_data->device_dispatch_table.QueueInsertDebugUtilsLabelEXT(queue, pLabelInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 755 | } |
| 756 | } |
| 757 | |
| 758 | VKAPI_ATTR void VKAPI_CALL CmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 759 | bool skip = VK_FALSE; |
| 760 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 761 | skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 762 | lock.unlock(); |
| 763 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 764 | if (!skip) { |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 765 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 766 | BeginCmdDebugUtilsLabel(dev_data->report_data, commandBuffer, pLabelInfo); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 767 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 768 | dev_data->device_dispatch_table.CmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | |
| 772 | VKAPI_ATTR void VKAPI_CALL CmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) { |
| 773 | bool skip = VK_FALSE; |
| 774 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 775 | skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 776 | lock.unlock(); |
| 777 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 778 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 779 | dev_data->device_dispatch_table.CmdEndDebugUtilsLabelEXT(commandBuffer); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 780 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 781 | EndCmdDebugUtilsLabel(dev_data->report_data, commandBuffer); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 782 | lock.unlock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 783 | } |
| 784 | } |
| 785 | |
| 786 | VKAPI_ATTR void VKAPI_CALL CmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 787 | bool skip = VK_FALSE; |
| 788 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 789 | skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, kVUIDUndefined, kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 790 | lock.unlock(); |
| 791 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 792 | if (!skip) { |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 793 | lock.lock(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 794 | InsertCmdDebugUtilsLabel(dev_data->report_data, commandBuffer, pLabelInfo); |
Jeremy Hayes | 87648ef | 2018-05-16 12:09:46 -0600 | [diff] [blame] | 795 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 796 | dev_data->device_dispatch_table.CmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 797 | } |
| 798 | } |
| 799 | |
| 800 | VKAPI_ATTR VkResult VKAPI_CALL CreateDebugUtilsMessengerEXT(VkInstance instance, |
| 801 | const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 802 | const VkAllocationCallbacks *pAllocator, |
| 803 | VkDebugUtilsMessengerEXT *pMessenger) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 804 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 805 | VkResult result = |
| 806 | instance_data->instance_dispatch_table.CreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 807 | if (VK_SUCCESS == result) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 808 | result = layer_create_messenger_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMessenger); |
| 809 | CreateObject(instance, *pMessenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator); |
| 810 | } |
| 811 | return result; |
| 812 | } |
| 813 | |
| 814 | VKAPI_ATTR void VKAPI_CALL DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 815 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 816 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 817 | instance_data->instance_dispatch_table.DestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 818 | layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 819 | ValidateDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator, kVUIDUndefined, kVUIDUndefined); |
| 820 | RecordDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | VKAPI_ATTR void VKAPI_CALL SubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, |
| 824 | VkDebugUtilsMessageTypeFlagsEXT messageTypes, |
| 825 | const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 826 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 827 | instance_data->instance_dispatch_table.SubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 828 | } |
| 829 | |
| 830 | static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}, |
| 831 | {VK_EXT_DEBUG_UTILS_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_SPEC_VERSION}}; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 832 | |
| 833 | static const VkLayerProperties globalLayerProps = {"VK_LAYER_LUNARG_object_tracker", |
| 834 | VK_LAYER_API_VERSION, // specVersion |
| 835 | 1, // implementationVersion |
| 836 | "LunarG Validation Layer"}; |
| 837 | |
| 838 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { |
| 839 | return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); |
| 840 | } |
| 841 | |
| 842 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 843 | VkLayerProperties *pProperties) { |
| 844 | return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); |
| 845 | } |
| 846 | |
| 847 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 848 | VkExtensionProperties *pProperties) { |
| 849 | if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) |
| 850 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 851 | |
| 852 | return VK_ERROR_LAYER_NOT_PRESENT; |
| 853 | } |
| 854 | |
| 855 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 856 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
| 857 | if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) |
| 858 | return util_GetExtensionProperties(0, nullptr, pCount, pProperties); |
| 859 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 860 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 861 | return instance_data->instance_dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 865 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 866 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 867 | bool skip = ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 868 | "VUID-vkCreateDevice-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 869 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 870 | |
| 871 | layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 872 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 873 | |
| 874 | assert(chain_info->u.pLayerInfo); |
| 875 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 876 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 877 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(phy_dev_data->instance, "vkCreateDevice"); |
| 878 | if (fpCreateDevice == NULL) { |
| 879 | return VK_ERROR_INITIALIZATION_FAILED; |
| 880 | } |
| 881 | |
| 882 | // Advance the link info for the next element on the chain |
| 883 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 884 | |
| 885 | VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 886 | if (result != VK_SUCCESS) { |
| 887 | return result; |
| 888 | } |
| 889 | |
| 890 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 891 | device_data->report_data = layer_debug_utils_create_device(phy_dev_data->report_data, *pDevice); |
John Zulauf | 9b77730 | 2018-10-08 11:15:51 -0600 | [diff] [blame] | 892 | layer_init_device_dispatch_table(*pDevice, &device_data->device_dispatch_table, fpGetDeviceProcAddr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 893 | |
Mark Lobodzinski | f42ced6 | 2018-07-02 12:59:27 -0600 | [diff] [blame] | 894 | // Save pCreateInfo device extension list for GetDeviceProcAddr() |
| 895 | for (uint32_t extn = 0; extn < pCreateInfo->enabledExtensionCount; extn++) { |
| 896 | device_data->device_extension_set.insert(pCreateInfo->ppEnabledExtensionNames[extn]); |
| 897 | } |
| 898 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 899 | // Add link back to physDev |
| 900 | device_data->physical_device = physicalDevice; |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 901 | device_data->instance = phy_dev_data->instance; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 902 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 903 | CreateObject(phy_dev_data->instance, *pDevice, kVulkanObjectTypeDevice, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 904 | |
| 905 | return result; |
| 906 | } |
| 907 | |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 908 | VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 909 | VkImage *pSwapchainImages) { |
Mark Lobodzinski | 09fa2d4 | 2017-07-21 10:16:53 -0600 | [diff] [blame] | 910 | bool skip = false; |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 911 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 912 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 913 | kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 914 | skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, |
| 915 | "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", kVUIDUndefined); |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 916 | lock.unlock(); |
Mark Lobodzinski | 09fa2d4 | 2017-07-21 10:16:53 -0600 | [diff] [blame] | 917 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 918 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 919 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 920 | VkResult result = |
| 921 | device_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 922 | if (pSwapchainImages != NULL) { |
| 923 | lock.lock(); |
| 924 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 925 | CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); |
| 926 | } |
| 927 | lock.unlock(); |
| 928 | } |
| 929 | return result; |
| 930 | } |
| 931 | |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 932 | VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 933 | const VkAllocationCallbacks *pAllocator, |
| 934 | VkDescriptorSetLayout *pSetLayout) { |
| 935 | bool skip = false; |
| 936 | { |
| 937 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 938 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorSetLayout-device-parameter", |
| 939 | kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 940 | if (pCreateInfo) { |
| 941 | if (pCreateInfo->pBindings) { |
| 942 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 943 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 944 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 945 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 946 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 947 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 948 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 949 | skip |= ValidateObject(device, sampler, kVulkanObjectTypeSampler, false, |
| 950 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | } |
| 954 | } |
| 955 | } |
| 956 | } |
| 957 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 958 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 959 | VkResult result = device_data->device_dispatch_table.CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 960 | if (VK_SUCCESS == result) { |
| 961 | std::lock_guard<std::mutex> lock(global_lock); |
| 962 | CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
| 963 | } |
| 964 | return result; |
| 965 | } |
| 966 | |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 967 | static inline bool ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { |
| 968 | bool skip = false; |
| 969 | if (pCreateInfo->pBindings) { |
| 970 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 971 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 972 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
| 973 | skip |= |
| 974 | ValidateObject(device, pCreateInfo->pBindings[index1].pImmutableSamplers[index2], kVulkanObjectTypeSampler, |
| 975 | true, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
| 976 | } |
| 977 | } |
| 978 | } |
| 979 | } |
| 980 | return skip; |
| 981 | } |
| 982 | |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 983 | VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 984 | VkDescriptorSetLayoutSupport *pSupport) { |
| 985 | bool skip = false; |
| 986 | { |
| 987 | std::lock_guard<std::mutex> lock(global_lock); |
| 988 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 989 | "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", kVUIDUndefined); |
| 990 | if (pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 991 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 992 | } |
| 993 | } |
| 994 | if (skip) return; |
| 995 | GetLayerDataPtr(get_dispatch_key(device), layer_data_map) |
| 996 | ->device_dispatch_table.GetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport); |
| 997 | } |
| 998 | |
| 999 | VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupportKHR(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1000 | VkDescriptorSetLayoutSupport *pSupport) { |
| 1001 | bool skip = false; |
| 1002 | { |
| 1003 | std::lock_guard<std::mutex> lock(global_lock); |
| 1004 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 1005 | "VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", kVUIDUndefined); |
| 1006 | if (pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1007 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1008 | } |
| 1009 | } |
| 1010 | if (skip) return; |
| 1011 | GetLayerDataPtr(get_dispatch_key(device), layer_data_map) |
| 1012 | ->device_dispatch_table.GetDescriptorSetLayoutSupportKHR(device, pCreateInfo, pSupport); |
| 1013 | } |
| 1014 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1015 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 1016 | uint32_t *pQueueFamilyPropertyCount, |
| 1017 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
| 1018 | bool skip = false; |
| 1019 | { |
| 1020 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1021 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1022 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1023 | } |
| 1024 | if (skip) { |
| 1025 | return; |
| 1026 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1027 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1028 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, |
| 1029 | pQueueFamilyProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1030 | std::lock_guard<std::mutex> lock(global_lock); |
| 1031 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1032 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1033 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1034 | } |
| 1035 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1036 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i]; |
| 1037 | } |
| 1038 | } |
| 1039 | } |
| 1040 | |
| 1041 | VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1042 | VkInstance *pInstance) { |
| 1043 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1044 | |
| 1045 | assert(chain_info->u.pLayerInfo); |
| 1046 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1047 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
| 1048 | if (fpCreateInstance == NULL) { |
| 1049 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1050 | } |
| 1051 | |
| 1052 | // Advance the link info for the next element on the chain |
| 1053 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1054 | |
| 1055 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 1056 | if (result != VK_SUCCESS) { |
| 1057 | return result; |
| 1058 | } |
| 1059 | |
| 1060 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 1061 | instance_data->instance = *pInstance; |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1062 | layer_init_instance_dispatch_table(*pInstance, &instance_data->instance_dispatch_table, fpGetInstanceProcAddr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1063 | |
| 1064 | // Look for one or more debug report create info structures, and copy the |
| 1065 | // callback(s) for each one found (for use by vkDestroyInstance) |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1066 | layer_copy_tmp_debug_messengers(pCreateInfo->pNext, &instance_data->num_tmp_debug_messengers, |
| 1067 | &instance_data->tmp_messenger_create_infos, &instance_data->tmp_debug_messengers); |
| 1068 | layer_copy_tmp_report_callbacks(pCreateInfo->pNext, &instance_data->num_tmp_report_callbacks, |
| 1069 | &instance_data->tmp_report_create_infos, &instance_data->tmp_report_callbacks); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1070 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1071 | instance_data->report_data = |
| 1072 | debug_utils_create_instance(&instance_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, |
| 1073 | pCreateInfo->ppEnabledExtensionNames); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1074 | |
| 1075 | InitObjectTracker(instance_data, pAllocator); |
| 1076 | |
| 1077 | CreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); |
| 1078 | |
| 1079 | return result; |
| 1080 | } |
| 1081 | |
| 1082 | VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 1083 | VkPhysicalDevice *pPhysicalDevices) { |
| 1084 | bool skip = VK_FALSE; |
| 1085 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1086 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 1087 | "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1088 | lock.unlock(); |
| 1089 | if (skip) { |
| 1090 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1091 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1092 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1093 | VkResult result = |
| 1094 | instance_data->instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1095 | lock.lock(); |
Tony-LunarG | 2b0915e | 2018-10-31 16:02:40 -0600 | [diff] [blame] | 1096 | if (result == VK_SUCCESS || result == VK_INCOMPLETE) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1097 | if (pPhysicalDevices) { |
| 1098 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
| 1099 | CreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
| 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | lock.unlock(); |
| 1104 | return result; |
| 1105 | } |
| 1106 | |
| 1107 | VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 1108 | VkCommandBuffer *pCommandBuffers) { |
| 1109 | bool skip = VK_FALSE; |
| 1110 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1111 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1112 | kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1113 | skip |= ValidateObject(device, pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
| 1114 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1115 | lock.unlock(); |
| 1116 | |
| 1117 | if (skip) { |
| 1118 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1119 | } |
| 1120 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1121 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1122 | VkResult result = device_data->device_dispatch_table.AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1123 | |
| 1124 | lock.lock(); |
| 1125 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
| 1126 | AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
| 1127 | } |
| 1128 | lock.unlock(); |
| 1129 | |
| 1130 | return result; |
| 1131 | } |
| 1132 | |
| 1133 | VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 1134 | VkDescriptorSet *pDescriptorSets) { |
| 1135 | bool skip = VK_FALSE; |
| 1136 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1137 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", |
| 1138 | kVUIDUndefined); |
| 1139 | skip |= ValidateObject(device, pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 1140 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1141 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1142 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 1143 | skip |= ValidateObject(device, pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1144 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 1145 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1146 | } |
| 1147 | lock.unlock(); |
| 1148 | if (skip) { |
| 1149 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1150 | } |
| 1151 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1152 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1153 | VkResult result = device_data->device_dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1154 | |
| 1155 | if (VK_SUCCESS == result) { |
| 1156 | lock.lock(); |
| 1157 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 1158 | AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
| 1159 | } |
| 1160 | lock.unlock(); |
| 1161 | } |
| 1162 | |
| 1163 | return result; |
| 1164 | } |
| 1165 | |
| 1166 | VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 1167 | const VkCommandBuffer *pCommandBuffers) { |
| 1168 | bool skip = false; |
| 1169 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1170 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1171 | ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, "VUID-vkFreeCommandBuffers-commandPool-parameter", |
| 1172 | "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1173 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 1174 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
| 1175 | skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1180 | ValidateDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1181 | RecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | lock.unlock(); |
| 1185 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1186 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1187 | device_data->device_dispatch_table.FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
| 1192 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1193 | std::unique_lock<std::mutex> lock(global_lock); |
| 1194 | // A swapchain's images are implicitly deleted when the swapchain is deleted. |
| 1195 | // Remove this swapchain's images from our map of such images. |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1196 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = device_data->swapchainImageMap.begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1197 | while (itr != device_data->swapchainImageMap.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1198 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1199 | if (pNode->parent_object == HandleToUint64(swapchain)) { |
| 1200 | delete pNode; |
| 1201 | auto delete_item = itr++; |
| 1202 | device_data->swapchainImageMap.erase(delete_item); |
| 1203 | } else { |
| 1204 | ++itr; |
| 1205 | } |
| 1206 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1207 | ValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, |
| 1208 | "VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
| 1209 | RecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1210 | lock.unlock(); |
| 1211 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1212 | device_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 1216 | const VkDescriptorSet *pDescriptorSets) { |
| 1217 | bool skip = false; |
| 1218 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 1219 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1220 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", |
| 1221 | kVUIDUndefined); |
| 1222 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 1223 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1224 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 1225 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
| 1226 | skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); |
| 1227 | } |
| 1228 | } |
| 1229 | |
| 1230 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1231 | ValidateDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1232 | RecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | lock.unlock(); |
| 1236 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1237 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1238 | result = device_data->device_dispatch_table.FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1239 | } |
| 1240 | return result; |
| 1241 | } |
| 1242 | |
| 1243 | VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 1244 | const VkAllocationCallbacks *pAllocator) { |
| 1245 | bool skip = VK_FALSE; |
| 1246 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1247 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1248 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", |
| 1249 | kVUIDUndefined); |
| 1250 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
| 1251 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1252 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1253 | lock.unlock(); |
| 1254 | if (skip) { |
| 1255 | return; |
| 1256 | } |
| 1257 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. |
| 1258 | // Remove this pool's descriptor sets from our descriptorSet map. |
| 1259 | lock.lock(); |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1260 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = device_data->object_map[kVulkanObjectTypeDescriptorSet].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1261 | while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1262 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1263 | auto del_itr = itr++; |
| 1264 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1265 | ValidateDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, |
| 1266 | kVUIDUndefined, kVUIDUndefined); |
| 1267 | RecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1268 | } |
| 1269 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1270 | ValidateDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
| 1271 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
| 1272 | RecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1273 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1274 | device_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { |
| 1278 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1279 | bool skip = false; |
| 1280 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1281 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", |
| 1282 | kVUIDUndefined); |
| 1283 | skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, true, |
| 1284 | "VUID-vkDestroyCommandPool-commandPool-parameter", "VUID-vkDestroyCommandPool-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1285 | lock.unlock(); |
| 1286 | if (skip) { |
| 1287 | return; |
| 1288 | } |
| 1289 | lock.lock(); |
| 1290 | // A CommandPool's command buffers are implicitly deleted when the pool is deleted. |
| 1291 | // Remove this pool's cmdBuffers from our cmd buffer map. |
| 1292 | auto itr = device_data->object_map[kVulkanObjectTypeCommandBuffer].begin(); |
| 1293 | auto del_itr = itr; |
| 1294 | while (itr != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1295 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1296 | del_itr = itr++; |
| 1297 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
| 1298 | skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1299 | ValidateDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer, |
| 1300 | nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1301 | RecordDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1302 | } |
| 1303 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1304 | ValidateDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
| 1305 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
| 1306 | RecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1307 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1308 | device_data->device_dispatch_table.DestroyCommandPool(device, commandPool, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1309 | } |
| 1310 | |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1311 | // Note: This is the core version of this routine. The extension version is below. |
| 1312 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 1313 | uint32_t *pQueueFamilyPropertyCount, |
| 1314 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
| 1315 | bool skip = false; |
| 1316 | { |
| 1317 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1318 | skip |= |
| 1319 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1320 | } |
| 1321 | if (skip) { |
| 1322 | return; |
| 1323 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1324 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1325 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount, |
| 1326 | pQueueFamilyProperties); |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1327 | std::lock_guard<std::mutex> lock(global_lock); |
| 1328 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1329 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1330 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1331 | } |
| 1332 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1333 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
| 1334 | } |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | // Note: This is the extension version of this routine. The core version is above. |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1339 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, |
| 1340 | uint32_t *pQueueFamilyPropertyCount, |
| 1341 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
| 1342 | bool skip = false; |
| 1343 | { |
| 1344 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1345 | skip |= |
| 1346 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1347 | } |
| 1348 | if (skip) { |
| 1349 | return; |
| 1350 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1351 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1352 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, pQueueFamilyPropertyCount, |
| 1353 | pQueueFamilyProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1354 | std::lock_guard<std::mutex> lock(global_lock); |
| 1355 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1356 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1357 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1358 | } |
| 1359 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1360 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
| 1361 | } |
| 1362 | } |
| 1363 | } |
| 1364 | |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1365 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1366 | VkDisplayPropertiesKHR *pProperties) { |
| 1367 | bool skip = false; |
| 1368 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1369 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1370 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1371 | lock.unlock(); |
| 1372 | |
| 1373 | if (skip) { |
| 1374 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1375 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1376 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1377 | VkResult result = |
| 1378 | instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1379 | |
| 1380 | lock.lock(); |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1381 | if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) { |
| 1382 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1383 | CreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1384 | } |
| 1385 | } |
| 1386 | lock.unlock(); |
| 1387 | |
| 1388 | return result; |
| 1389 | } |
| 1390 | |
| 1391 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1392 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { |
| 1393 | bool skip = false; |
| 1394 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1395 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1396 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1397 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 1398 | "VUID-vkGetDisplayModePropertiesKHR-display-parameter", kVUIDUndefined); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1399 | lock.unlock(); |
| 1400 | |
| 1401 | if (skip) { |
| 1402 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1403 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1404 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1405 | VkResult result = |
| 1406 | instance_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1407 | |
| 1408 | lock.lock(); |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1409 | if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) { |
| 1410 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1411 | CreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1412 | } |
| 1413 | } |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1414 | |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1415 | lock.unlock(); |
| 1416 | |
| 1417 | return result; |
| 1418 | } |
| 1419 | |
Mark Lobodzinski | dfe5e17 | 2017-07-19 13:03:22 -0600 | [diff] [blame] | 1420 | VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1421 | bool skip = VK_FALSE; |
| 1422 | std::unique_lock<std::mutex> lock(global_lock); |
| 1423 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1424 | if (pNameInfo->pObjectName) { |
| 1425 | dev_data->report_data->debugObjectNameMap->insert( |
| 1426 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName)); |
| 1427 | } else { |
| 1428 | dev_data->report_data->debugObjectNameMap->erase(pNameInfo->object); |
| 1429 | } |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1430 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDebugMarkerSetObjectNameEXT-device-parameter", |
| 1431 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1432 | lock.unlock(); |
| 1433 | if (skip) { |
| 1434 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1435 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1436 | VkResult result = dev_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1437 | return result; |
| 1438 | } |
| 1439 | |
| 1440 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { |
| 1441 | assert(instance); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1442 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1443 | if (instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr == NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1444 | return NULL; |
| 1445 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1446 | return instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1447 | } |
| 1448 | |
| 1449 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { |
Mark Lobodzinski | f42ced6 | 2018-07-02 12:59:27 -0600 | [diff] [blame] | 1450 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1451 | if (!ApiParentExtensionEnabled(funcName, device_data->device_extension_set)) { |
| 1452 | return nullptr; |
| 1453 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1454 | const auto item = name_to_funcptr_map.find(funcName); |
| 1455 | if (item != name_to_funcptr_map.end()) { |
| 1456 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 1457 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1458 | if (!device_data->device_dispatch_table.GetDeviceProcAddr) return NULL; |
| 1459 | return device_data->device_dispatch_table.GetDeviceProcAddr(device, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 1463 | const auto item = name_to_funcptr_map.find(funcName); |
| 1464 | if (item != name_to_funcptr_map.end()) { |
| 1465 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 1466 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1467 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1468 | if (!instance_data->instance_dispatch_table.GetInstanceProcAddr) return nullptr; |
| 1469 | return instance_data->instance_dispatch_table.GetInstanceProcAddr(instance, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1470 | } |
| 1471 | |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1472 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1473 | VkDisplayProperties2KHR *pProperties) { |
| 1474 | bool skip = false; |
| 1475 | { |
| 1476 | std::lock_guard<std::mutex> lock(global_lock); |
| 1477 | skip |= |
| 1478 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
| 1479 | } |
| 1480 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1481 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1482 | VkResult result = |
| 1483 | instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1484 | if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1485 | std::lock_guard<std::mutex> lock(global_lock); |
| 1486 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 1487 | CreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | return result; |
| 1492 | } |
| 1493 | |
| 1494 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1495 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
| 1496 | bool skip = false; |
| 1497 | { |
| 1498 | std::lock_guard<std::mutex> lock(global_lock); |
| 1499 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1500 | "VUID-vkGetDisplayPlaneSupportedDisplaysKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1501 | } |
| 1502 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1503 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1504 | VkResult result = instance_data->instance_dispatch_table.GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, |
| 1505 | pDisplayCount, pDisplays); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1506 | if (pDisplays && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1507 | std::lock_guard<std::mutex> lock(global_lock); |
| 1508 | for (uint32_t index = 0; index < *pDisplayCount; ++index) { |
| 1509 | CreateObject(physicalDevice, pDisplays[index], kVulkanObjectTypeDisplayKHR, nullptr); |
| 1510 | } |
| 1511 | } |
| 1512 | |
| 1513 | return result; |
| 1514 | } |
| 1515 | |
| 1516 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1517 | uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties) { |
| 1518 | bool skip = false; |
| 1519 | { |
| 1520 | std::lock_guard<std::mutex> lock(global_lock); |
| 1521 | skip |= |
| 1522 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
| 1523 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, kVUIDUndefined, kVUIDUndefined); |
| 1524 | } |
| 1525 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1526 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1527 | VkResult result = |
| 1528 | instance_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1529 | if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1530 | std::lock_guard<std::mutex> lock(global_lock); |
| 1531 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 1532 | CreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, |
| 1533 | nullptr); |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | return result; |
| 1538 | } |
| 1539 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1540 | } // namespace object_tracker |
| 1541 | |
| 1542 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 1543 | VkExtensionProperties *pProperties) { |
| 1544 | return object_tracker::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); |
| 1545 | } |
| 1546 | |
| 1547 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 1548 | VkLayerProperties *pProperties) { |
| 1549 | return object_tracker::EnumerateInstanceLayerProperties(pCount, pProperties); |
| 1550 | } |
| 1551 | |
| 1552 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 1553 | VkLayerProperties *pProperties) { |
| 1554 | // The layer command handles VK_NULL_HANDLE just fine internally |
| 1555 | assert(physicalDevice == VK_NULL_HANDLE); |
| 1556 | return object_tracker::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); |
| 1557 | } |
| 1558 | |
| 1559 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
| 1560 | return object_tracker::GetDeviceProcAddr(dev, funcName); |
| 1561 | } |
| 1562 | |
| 1563 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 1564 | return object_tracker::GetInstanceProcAddr(instance, funcName); |
| 1565 | } |
| 1566 | |
| 1567 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 1568 | const char *pLayerName, uint32_t *pCount, |
| 1569 | VkExtensionProperties *pProperties) { |
| 1570 | // The layer command handles VK_NULL_HANDLE just fine internally |
| 1571 | assert(physicalDevice == VK_NULL_HANDLE); |
| 1572 | return object_tracker::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); |
| 1573 | } |
| 1574 | |
| 1575 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, |
| 1576 | const char *funcName) { |
| 1577 | return object_tracker::GetPhysicalDeviceProcAddr(instance, funcName); |
| 1578 | } |
| 1579 | |
| 1580 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { |
| 1581 | assert(pVersionStruct != NULL); |
| 1582 | assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); |
| 1583 | |
| 1584 | // Fill in the function pointers if our version is at least capable of having the structure contain them. |
| 1585 | if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { |
| 1586 | pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; |
| 1587 | pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; |
| 1588 | pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; |
| 1589 | } |
| 1590 | |
| 1591 | if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 1592 | object_tracker::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; |
| 1593 | } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 1594 | pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 1595 | } |
| 1596 | |
| 1597 | return VK_SUCCESS; |
| 1598 | } |