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 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 455 | static bool PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 456 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 457 | bool skip = false; |
| 458 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter", kVUIDUndefined); |
| 459 | skip |= ValidateDestroyObject(device_data->instance, device, kVulkanObjectTypeDevice, pAllocator, |
| 460 | "VUID-vkDestroyDevice-device-00379", "VUID-vkDestroyDevice-device-00380"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 461 | // Report any remaining objects associated with this VkDevice object in LL |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 462 | skip |= ReportUndestroyedObjects(device, "VUID-vkDestroyDevice-device-00378"); |
| 463 | |
| 464 | return skip; |
| 465 | } |
| 466 | |
| 467 | static void PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
| 468 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 469 | RecordDestroyObject(device_data->instance, device, kVulkanObjectTypeDevice); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 470 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 471 | |
| 472 | // Clean up Queue's MemRef Linked Lists |
| 473 | DestroyQueueDataStructures(device); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 474 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 475 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 476 | VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
| 477 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 478 | { |
| 479 | bool skip = false; |
| 480 | std::lock_guard<std::mutex> lock(global_lock); |
| 481 | skip = PreCallValidateDestroyDevice(device, pAllocator); |
| 482 | // Skipping down-chain destroydevice calls will hose any upstream validation layers |
| 483 | PreCallRecordDestroyDevice(device, pAllocator); |
| 484 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 485 | dispatch_key key = get_dispatch_key(device); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 486 | device_data->device_dispatch_table.DestroyDevice(device, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 487 | FreeLayerDataPtr(key, layer_data_map); |
| 488 | } |
| 489 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 490 | static bool PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
| 491 | bool skip = false; |
| 492 | skip |= |
| 493 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue-device-parameter", kVUIDUndefined); |
| 494 | return skip; |
| 495 | } |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 496 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 497 | static void PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 498 | CreateQueue(device, *pQueue); |
| 499 | AddQueueInfo(device, queueFamilyIndex, *pQueue); |
| 500 | } |
| 501 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 502 | VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
| 503 | { |
| 504 | std::lock_guard<std::mutex> lock(global_lock); |
| 505 | bool skip = PreCallValidateGetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
| 506 | if (skip) return; |
| 507 | } |
| 508 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 509 | device_data->device_dispatch_table.GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
| 510 | { |
| 511 | if (*pQueue != VK_NULL_HANDLE) { |
| 512 | std::lock_guard<std::mutex> lock(global_lock); |
| 513 | PostCallRecordGetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); |
| 514 | } |
| 515 | } |
| 516 | } |
Yiwei Zhang | 991d88d | 2018-02-14 14:39:46 -0800 | [diff] [blame] | 517 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 518 | static bool PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
| 519 | bool skip = false; |
| 520 | skip |= |
| 521 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter", kVUIDUndefined); |
| 522 | return skip; |
| 523 | } |
| 524 | |
| 525 | static void PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
| 526 | CreateQueue(device, *pQueue); |
| 527 | AddQueueInfo(device, pQueueInfo->queueFamilyIndex, *pQueue); |
| 528 | } |
| 529 | |
| 530 | VKAPI_ATTR void VKAPI_CALL GetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
| 531 | { |
| 532 | std::lock_guard<std::mutex> lock(global_lock); |
| 533 | bool skip = PreCallValidateGetDeviceQueue2(device, pQueueInfo, pQueue); |
| 534 | if (skip) return; |
| 535 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 536 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 537 | device_data->device_dispatch_table.GetDeviceQueue2(device, pQueueInfo, pQueue); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 538 | { |
| 539 | if (*pQueue != VK_NULL_HANDLE) { |
| 540 | std::lock_guard<std::mutex> lock(global_lock); |
| 541 | PostCallRecordGetDeviceQueue2(device, pQueueInfo, pQueue); |
| 542 | } |
Yiwei Zhang | 991d88d | 2018-02-14 14:39:46 -0800 | [diff] [blame] | 543 | } |
| 544 | } |
| 545 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 546 | static bool PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 547 | const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, |
| 548 | const VkCopyDescriptorSet *pDescriptorCopies) { |
| 549 | bool skip = false; |
| 550 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter", |
| 551 | kVUIDUndefined); |
| 552 | if (pDescriptorCopies) { |
| 553 | for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { |
| 554 | if (pDescriptorCopies[idx0].dstSet) { |
| 555 | skip |= ValidateObject(device, pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, |
| 556 | "VUID-VkCopyDescriptorSet-dstSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
| 557 | } |
| 558 | if (pDescriptorCopies[idx0].srcSet) { |
| 559 | skip |= ValidateObject(device, pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, |
| 560 | "VUID-VkCopyDescriptorSet-srcSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | if (pDescriptorWrites) { |
| 565 | for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { |
| 566 | skip |= ValidateDescriptorWrite(device, &pDescriptorWrites[idx1], false); |
| 567 | } |
| 568 | } |
| 569 | return skip; |
| 570 | } |
| 571 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 572 | VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 573 | const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, |
| 574 | const VkCopyDescriptorSet *pDescriptorCopies) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 575 | { |
| 576 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 577 | bool skip = PreCallValidateUpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, |
| 578 | pDescriptorCopies); |
| 579 | if (skip) return; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 580 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 581 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 582 | device_data->device_dispatch_table.UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, |
| 583 | pDescriptorCopies); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 584 | } |
| 585 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 586 | static bool PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 587 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 588 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 589 | bool skip = VK_FALSE; |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 590 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateComputePipelines-device-parameter", |
| 591 | kVUIDUndefined); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 592 | if (pCreateInfos) { |
| 593 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
| 594 | if (pCreateInfos[idx0].basePipelineHandle) { |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 595 | skip |= |
| 596 | ValidateObject(device, pCreateInfos[idx0].basePipelineHandle, kVulkanObjectTypePipeline, true, |
| 597 | "VUID-VkComputePipelineCreateInfo-flags-00697", "VUID-VkComputePipelineCreateInfo-commonparent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 598 | } |
| 599 | if (pCreateInfos[idx0].layout) { |
| 600 | skip |= ValidateObject(device, pCreateInfos[idx0].layout, kVulkanObjectTypePipelineLayout, false, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 601 | "VUID-VkComputePipelineCreateInfo-layout-parameter", |
| 602 | "VUID-VkComputePipelineCreateInfo-commonparent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 603 | } |
| 604 | if (pCreateInfos[idx0].stage.module) { |
| 605 | skip |= ValidateObject(device, pCreateInfos[idx0].stage.module, kVulkanObjectTypeShaderModule, false, |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 606 | "VUID-VkPipelineShaderStageCreateInfo-module-parameter", kVUIDUndefined); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 607 | } |
| 608 | } |
| 609 | } |
| 610 | if (pipelineCache) { |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 611 | skip |= ValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true, |
| 612 | "VUID-vkCreateComputePipelines-pipelineCache-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 613 | "VUID-vkCreateComputePipelines-pipelineCache-parent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 614 | } |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 615 | if (skip) { |
| 616 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 617 | pPipelines[i] = VK_NULL_HANDLE; |
| 618 | } |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 619 | } |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 620 | return skip; |
| 621 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 622 | |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 623 | static void PostCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 624 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 625 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 626 | for (uint32_t idx1 = 0; idx1 < createInfoCount; ++idx1) { |
| 627 | if (pPipelines[idx1] != VK_NULL_HANDLE) { |
| 628 | CreateObject(device, pPipelines[idx1], kVulkanObjectTypePipeline, pAllocator); |
| 629 | } |
| 630 | } |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 634 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 635 | const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { |
| 636 | { |
| 637 | std::lock_guard<std::mutex> lock(global_lock); |
| 638 | bool skip = |
| 639 | PreCallValidateCreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); |
| 640 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 641 | } |
| 642 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 643 | VkResult result = device_data->device_dispatch_table.CreateComputePipelines(device, pipelineCache, createInfoCount, |
| 644 | pCreateInfos, pAllocator, pPipelines); |
| 645 | { |
| 646 | std::lock_guard<std::mutex> lock(global_lock); |
| 647 | PostCallRecordCreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); |
| 648 | } |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 649 | return result; |
| 650 | } |
| 651 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 652 | static bool PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 653 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 654 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 655 | |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 656 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkResetDescriptorPool-device-parameter", |
| 657 | kVUIDUndefined); |
| 658 | skip |= |
| 659 | ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 660 | "VUID-vkResetDescriptorPool-descriptorPool-parameter", "VUID-vkResetDescriptorPool-descriptorPool-parent"); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 661 | for (const auto &itr : device_data->object_map[kVulkanObjectTypeDescriptorSet]) { |
| 662 | if (itr.second->parent_object == HandleToUint64(descriptorPool)) { |
| 663 | skip |= ValidateDestroyObject(device, (VkDescriptorSet)(itr.first), kVulkanObjectTypeDescriptorSet, nullptr, |
| 664 | kVUIDUndefined, kVUIDUndefined); |
| 665 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 666 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 667 | return skip; |
| 668 | } |
| 669 | |
| 670 | static void PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { |
| 671 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 672 | |
| 673 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. Remove this pool's descriptor sets from |
| 674 | // our descriptorSet map. |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 675 | auto itr = device_data->object_map[kVulkanObjectTypeDescriptorSet].begin(); |
| 676 | while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 677 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 678 | auto del_itr = itr++; |
| 679 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 680 | RecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 681 | } |
| 682 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 686 | VkDescriptorPoolResetFlags flags) { |
| 687 | { |
| 688 | std::lock_guard<std::mutex> lock(global_lock); |
| 689 | bool skip = PreCallValidateResetDescriptorPool(device, descriptorPool, flags); |
| 690 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 691 | PreCallRecordResetDescriptorPool(device, descriptorPool, flags); |
| 692 | } |
| 693 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 694 | VkResult result = device_data->device_dispatch_table.ResetDescriptorPool(device, descriptorPool, flags); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 695 | return result; |
| 696 | } |
| 697 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 698 | static bool PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 699 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map); |
| 700 | bool skip = false; |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 701 | skip |= ValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false, |
| 702 | "VUID-vkBeginCommandBuffer-commandBuffer-parameter", kVUIDUndefined); |
| 703 | if (begin_info) { |
| 704 | ObjTrackState *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
| 705 | if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && |
| 706 | (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { |
| 707 | skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, true, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 708 | "VUID-VkCommandBufferBeginInfo-flags-00055", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 709 | skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 710 | "VUID-VkCommandBufferBeginInfo-flags-00053", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 711 | } |
| 712 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 713 | return skip; |
| 714 | } |
| 715 | |
| 716 | VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) { |
| 717 | { |
| 718 | std::lock_guard<std::mutex> lock(global_lock); |
| 719 | bool skip = PreCallValidateBeginCommandBuffer(command_buffer, begin_info); |
| 720 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 721 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 722 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 723 | VkResult result = device_data->device_dispatch_table.BeginCommandBuffer(command_buffer, begin_info); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 724 | return result; |
| 725 | } |
| 726 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 727 | static void PostCallRecordCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 728 | const VkAllocationCallbacks *pAllocator, |
| 729 | VkDebugReportCallbackEXT *pCallback) { |
| 730 | CreateObject(instance, *pCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator); |
| 731 | } |
| 732 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 733 | VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance, |
| 734 | const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 735 | const VkAllocationCallbacks *pAllocator, |
| 736 | VkDebugReportCallbackEXT *pCallback) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 737 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 738 | VkResult result = |
| 739 | instance_data->instance_dispatch_table.CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 740 | if (VK_SUCCESS == result) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 741 | result = layer_create_report_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pCallback); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 742 | PostCallRecordCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 743 | } |
| 744 | return result; |
| 745 | } |
| 746 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 747 | static bool PreCallValidateDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 748 | const VkAllocationCallbacks *pAllocator) { |
| 749 | bool skip = ValidateDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator, |
| 750 | "VUID-vkDestroyDebugReportCallbackEXT-instance-01242", |
| 751 | "VUID-vkDestroyDebugReportCallbackEXT-instance-01243"); |
| 752 | return skip; |
| 753 | } |
| 754 | |
| 755 | static void PreCallRecordDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 756 | const VkAllocationCallbacks *pAllocator) { |
| 757 | RecordDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT); |
| 758 | } |
| 759 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 760 | VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 761 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 762 | { |
| 763 | std::lock_guard<std::mutex> lock(global_lock); |
| 764 | bool skip = PreCallValidateDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
| 765 | if (skip) return; |
| 766 | PreCallRecordDestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
| 767 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 768 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 769 | instance_data->instance_dispatch_table.DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 770 | layer_destroy_report_callback(instance_data->report_data, msgCallback, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, |
| 774 | VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, |
| 775 | int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 776 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 777 | instance_data->instance_dispatch_table.DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, |
| 778 | pMsg); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 779 | } |
| 780 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 781 | // VK_EXT_debug_utils commands |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 782 | |
| 783 | static bool PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) { |
| 784 | return ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkSetDebugUtilsObjectNameEXT-device-parameter", |
| 785 | kVUIDUndefined); |
| 786 | } |
| 787 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 788 | VKAPI_ATTR VkResult VKAPI_CALL SetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 789 | { |
| 790 | std::lock_guard<std::mutex> lock(global_lock); |
| 791 | bool skip = PreCallValidateSetDebugUtilsObjectNameEXT(device, pNameInfo); |
| 792 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 793 | } |
| 794 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 795 | if (pNameInfo->pObjectName) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 796 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 797 | dev_data->report_data->debugUtilsObjectNameMap->insert( |
| 798 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->objectHandle, pNameInfo->pObjectName)); |
| 799 | } else { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 800 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 801 | dev_data->report_data->debugUtilsObjectNameMap->erase(pNameInfo->objectHandle); |
| 802 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 803 | VkResult result = dev_data->device_dispatch_table.SetDebugUtilsObjectNameEXT(device, pNameInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 804 | return result; |
| 805 | } |
| 806 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 807 | static bool PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) { |
| 808 | return ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkSetDebugUtilsObjectTagEXT-device-parameter", |
| 809 | kVUIDUndefined); |
| 810 | } |
| 811 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 812 | VKAPI_ATTR VkResult VKAPI_CALL SetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 813 | { |
| 814 | std::lock_guard<std::mutex> lock(global_lock); |
| 815 | bool skip = PreCallValidateSetDebugUtilsObjectTagEXT(device, pTagInfo); |
| 816 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 817 | } |
| 818 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 819 | VkResult result = dev_data->device_dispatch_table.SetDebugUtilsObjectTagEXT(device, pTagInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 820 | return result; |
| 821 | } |
| 822 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 823 | static bool PreCallValidateQueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 824 | return ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueBeginDebugUtilsLabelEXT-queue-parameter", |
| 825 | kVUIDUndefined); |
| 826 | } |
| 827 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 828 | VKAPI_ATTR void VKAPI_CALL QueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 829 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 830 | { |
| 831 | std::lock_guard<std::mutex> lock(global_lock); |
| 832 | bool skip = PreCallValidateQueueBeginDebugUtilsLabelEXT(queue, pLabelInfo); |
| 833 | if (skip) return; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 834 | BeginQueueDebugUtilsLabel(dev_data->report_data, queue, pLabelInfo); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 835 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 836 | dev_data->device_dispatch_table.QueueBeginDebugUtilsLabelEXT(queue, pLabelInfo); |
| 837 | } |
| 838 | |
| 839 | static bool PreCallValidateQueueEndDebugUtilsLabelEXT(VkQueue queue) { |
| 840 | return ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueEndDebugUtilsLabelEXT-queue-parameter", |
| 841 | kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | VKAPI_ATTR void VKAPI_CALL QueueEndDebugUtilsLabelEXT(VkQueue queue) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 845 | { |
| 846 | std::lock_guard<std::mutex> lock(global_lock); |
| 847 | bool skip = PreCallValidateQueueEndDebugUtilsLabelEXT(queue); |
| 848 | if (skip) return; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 849 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 850 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 851 | dev_data->device_dispatch_table.QueueEndDebugUtilsLabelEXT(queue); |
| 852 | { |
| 853 | std::lock_guard<std::mutex> lock(global_lock); |
| 854 | EndQueueDebugUtilsLabel(dev_data->report_data, queue); |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | static bool PreCallValidateQueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 859 | return ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueInsertDebugUtilsLabelEXT-queue-parameter", |
| 860 | kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | VKAPI_ATTR void VKAPI_CALL QueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 864 | { |
| 865 | std::lock_guard<std::mutex> lock(global_lock); |
| 866 | bool skip = PreCallValidateQueueInsertDebugUtilsLabelEXT(queue, pLabelInfo); |
| 867 | if (skip) return; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 868 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 869 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
| 870 | { |
| 871 | std::lock_guard<std::mutex> lock(global_lock); |
| 872 | InsertQueueDebugUtilsLabel(dev_data->report_data, queue, pLabelInfo); |
| 873 | } |
| 874 | dev_data->device_dispatch_table.QueueInsertDebugUtilsLabelEXT(queue, pLabelInfo); |
| 875 | } |
| 876 | |
| 877 | static bool PreCallValidateCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 878 | return ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 879 | "VUID-vkCmdBeginDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | VKAPI_ATTR void VKAPI_CALL CmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 883 | { |
| 884 | std::lock_guard<std::mutex> lock(global_lock); |
| 885 | bool skip = PreCallValidateCmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo); |
| 886 | if (skip) return; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 887 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 888 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 889 | { |
| 890 | std::lock_guard<std::mutex> lock(global_lock); |
| 891 | BeginCmdDebugUtilsLabel(dev_data->report_data, commandBuffer, pLabelInfo); |
| 892 | } |
| 893 | dev_data->device_dispatch_table.CmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo); |
| 894 | } |
| 895 | |
| 896 | static bool PreCallValidateCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) { |
| 897 | return ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 898 | "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 899 | } |
| 900 | |
| 901 | VKAPI_ATTR void VKAPI_CALL CmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 902 | { |
| 903 | std::lock_guard<std::mutex> lock(global_lock); |
| 904 | bool skip = PreCallValidateCmdEndDebugUtilsLabelEXT(commandBuffer); |
| 905 | if (skip) return; |
| 906 | } |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 907 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 908 | dev_data->device_dispatch_table.CmdEndDebugUtilsLabelEXT(commandBuffer); |
| 909 | { |
| 910 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 911 | EndCmdDebugUtilsLabel(dev_data->report_data, commandBuffer); |
| 912 | } |
| 913 | } |
| 914 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 915 | static bool PreCallValidateCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
| 916 | return ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 917 | "VUID-vkCmdInsertDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined); |
| 918 | } |
| 919 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 920 | VKAPI_ATTR void VKAPI_CALL CmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 921 | { |
| 922 | std::lock_guard<std::mutex> lock(global_lock); |
| 923 | bool skip = PreCallValidateCmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo); |
| 924 | if (skip) return; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 925 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 926 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); |
| 927 | { |
| 928 | std::lock_guard<std::mutex> lock(global_lock); |
| 929 | InsertCmdDebugUtilsLabel(dev_data->report_data, commandBuffer, pLabelInfo); |
| 930 | } |
| 931 | dev_data->device_dispatch_table.CmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo); |
| 932 | } |
| 933 | |
| 934 | static bool PreCallValidateCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 935 | const VkAllocationCallbacks *pAllocator, |
| 936 | VkDebugUtilsMessengerEXT *pMessenger) { |
| 937 | return ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 938 | "VUID-vkCreateDebugUtilsMessengerEXT-instance-parameter", kVUIDUndefined); |
| 939 | } |
| 940 | |
| 941 | static void PostCallRecordCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 942 | const VkAllocationCallbacks *pAllocator, |
| 943 | VkDebugUtilsMessengerEXT *pMessenger) { |
| 944 | CreateObject(instance, *pMessenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | VKAPI_ATTR VkResult VKAPI_CALL CreateDebugUtilsMessengerEXT(VkInstance instance, |
| 948 | const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 949 | const VkAllocationCallbacks *pAllocator, |
| 950 | VkDebugUtilsMessengerEXT *pMessenger) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 951 | { |
| 952 | std::lock_guard<std::mutex> lock(global_lock); |
| 953 | bool skip = PreCallValidateCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); |
| 954 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 955 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 956 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 957 | VkResult result = |
| 958 | instance_data->instance_dispatch_table.CreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 959 | if (VK_SUCCESS == result) { |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 960 | result = layer_create_messenger_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pMessenger); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 961 | PostCallRecordCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 962 | } |
| 963 | return result; |
| 964 | } |
| 965 | |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 966 | static bool PreCallValidateDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 967 | const VkAllocationCallbacks *pAllocator) { |
| 968 | bool skip = false; |
| 969 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 970 | "VUID-vkDestroyDebugUtilsMessengerEXT-instance-parameter", kVUIDUndefined); |
| 971 | skip |= ValidateObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, false, |
| 972 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-parameter", |
| 973 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-parent"); |
| 974 | skip |= ValidateDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator, |
| 975 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01915", |
| 976 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01916"); |
| 977 | return skip; |
| 978 | } |
| 979 | |
| 980 | static void PreCallRecordDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 981 | const VkAllocationCallbacks *pAllocator) { |
| 982 | RecordDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT); |
| 983 | } |
| 984 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 985 | VKAPI_ATTR void VKAPI_CALL DestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 986 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 987 | { |
| 988 | std::lock_guard<std::mutex> lock(global_lock); |
| 989 | bool skip = PreCallValidateDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); |
| 990 | if (skip) return; |
| 991 | PreCallRecordDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); |
| 992 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 993 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 994 | instance_data->instance_dispatch_table.DestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 995 | layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 996 | } |
| 997 | |
| 998 | static bool PreCallValidateSubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, |
| 999 | VkDebugUtilsMessageTypeFlagsEXT messageTypes, |
| 1000 | const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) { |
| 1001 | bool skip = false; |
| 1002 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 1003 | "VUID-vkeSubmitDebugUtilsMessageEXT-instance-parameter", kVUIDUndefined); |
| 1004 | return skip; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1005 | } |
| 1006 | |
| 1007 | VKAPI_ATTR void VKAPI_CALL SubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, |
| 1008 | VkDebugUtilsMessageTypeFlagsEXT messageTypes, |
| 1009 | const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 1010 | { |
| 1011 | std::lock_guard<std::mutex> lock(global_lock); |
| 1012 | bool skip = PreCallValidateSubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData); |
| 1013 | if (skip) return; |
| 1014 | } |
| 1015 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1016 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1017 | instance_data->instance_dispatch_table.SubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}, |
| 1021 | {VK_EXT_DEBUG_UTILS_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_SPEC_VERSION}}; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1022 | |
| 1023 | static const VkLayerProperties globalLayerProps = {"VK_LAYER_LUNARG_object_tracker", |
| 1024 | VK_LAYER_API_VERSION, // specVersion |
| 1025 | 1, // implementationVersion |
| 1026 | "LunarG Validation Layer"}; |
| 1027 | |
| 1028 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { |
| 1029 | return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); |
| 1030 | } |
| 1031 | |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1032 | static bool PreCallValidateEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 1033 | VkLayerProperties *pProperties) { |
| 1034 | // Set null_allowed to true here to cover for the lame loader-layer interface wrapper calls |
| 1035 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, true, |
| 1036 | "VUID-vkEnumerateDeviceLayerProperties-physicalDevice-parameter", kVUIDUndefined); |
| 1037 | } |
| 1038 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1039 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 1040 | VkLayerProperties *pProperties) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1041 | { |
| 1042 | std::lock_guard<std::mutex> lock(global_lock); |
| 1043 | bool skip = PreCallValidateEnumerateDeviceLayerProperties(physicalDevice, pCount, pProperties); |
| 1044 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1045 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1046 | return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); |
| 1047 | } |
| 1048 | |
| 1049 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 1050 | VkExtensionProperties *pProperties) { |
| 1051 | if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) |
| 1052 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 1053 | |
| 1054 | return VK_ERROR_LAYER_NOT_PRESENT; |
| 1055 | } |
| 1056 | |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1057 | static bool PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 1058 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
| 1059 | // Set null_allowed to true here to cover for the lame loader-layer interface wrapper calls |
| 1060 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, true, |
| 1061 | "VUID-vkEnumerateDeviceExtensionProperties-physicalDevice-parameter", kVUIDUndefined); |
| 1062 | } |
| 1063 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1064 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 1065 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1066 | { |
| 1067 | std::lock_guard<std::mutex> lock(global_lock); |
| 1068 | bool skip = PreCallValidateEnumerateDeviceExtensionProperties(physicalDevice, pLayerName, pCount, pProperties); |
| 1069 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1070 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1071 | if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) |
| 1072 | return util_GetExtensionProperties(0, nullptr, pCount, pProperties); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1073 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1074 | return instance_data->instance_dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1075 | } |
| 1076 | |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1077 | static bool PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 1078 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 1079 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1080 | "VUID-vkCreateDevice-physicalDevice-parameter", kVUIDUndefined); |
| 1081 | } |
| 1082 | |
| 1083 | static void PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 1084 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 1085 | layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1086 | CreateObject(phy_dev_data->instance, *pDevice, kVulkanObjectTypeDevice, pAllocator); |
| 1087 | } |
| 1088 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1089 | VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 1090 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 1091 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1092 | bool skip = PreCallValidateCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1093 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1094 | |
| 1095 | layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1096 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1097 | |
| 1098 | assert(chain_info->u.pLayerInfo); |
| 1099 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1100 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 1101 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(phy_dev_data->instance, "vkCreateDevice"); |
| 1102 | if (fpCreateDevice == NULL) { |
| 1103 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1104 | } |
| 1105 | |
| 1106 | // Advance the link info for the next element on the chain |
| 1107 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1108 | |
| 1109 | VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 1110 | if (result != VK_SUCCESS) { |
| 1111 | return result; |
| 1112 | } |
| 1113 | |
| 1114 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1115 | 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] | 1116 | layer_init_device_dispatch_table(*pDevice, &device_data->device_dispatch_table, fpGetDeviceProcAddr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1117 | |
Mark Lobodzinski | f42ced6 | 2018-07-02 12:59:27 -0600 | [diff] [blame] | 1118 | // Save pCreateInfo device extension list for GetDeviceProcAddr() |
| 1119 | for (uint32_t extn = 0; extn < pCreateInfo->enabledExtensionCount; extn++) { |
| 1120 | device_data->device_extension_set.insert(pCreateInfo->ppEnabledExtensionNames[extn]); |
| 1121 | } |
| 1122 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1123 | // Add link back to physDev |
| 1124 | device_data->physical_device = physicalDevice; |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 1125 | device_data->instance = phy_dev_data->instance; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1126 | |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1127 | PostCallRecordCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1128 | |
| 1129 | return result; |
| 1130 | } |
| 1131 | |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1132 | static bool PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 1133 | VkImage *pSwapchainImages) { |
| 1134 | bool skip = false; |
| 1135 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
| 1136 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
| 1137 | skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, |
| 1138 | "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", "VUID-vkGetSwapchainImagesKHR-commonparent"); |
| 1139 | return skip; |
| 1140 | } |
| 1141 | |
| 1142 | static void PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 1143 | VkImage *pSwapchainImages) { |
| 1144 | if (pSwapchainImages != NULL) { |
| 1145 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 1146 | CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); |
| 1147 | } |
| 1148 | } |
| 1149 | } |
| 1150 | |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 1151 | VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 1152 | VkImage *pSwapchainImages) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1153 | { |
| 1154 | std::lock_guard<std::mutex> lock(global_lock); |
| 1155 | bool skip = PreCallValidateGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
| 1156 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1157 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1158 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1159 | VkResult result = |
| 1160 | device_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1161 | { |
| 1162 | std::lock_guard<std::mutex> lock(global_lock); |
| 1163 | PostCallRecordGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 1164 | } |
| 1165 | return result; |
| 1166 | } |
| 1167 | |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1168 | static bool PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1169 | const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1170 | bool skip = false; |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1171 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorSetLayout-device-parameter", |
| 1172 | kVUIDUndefined); |
| 1173 | if (pCreateInfo) { |
| 1174 | if (pCreateInfo->pBindings) { |
| 1175 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 1176 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 1177 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 1178 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 1179 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 1180 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 1181 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
| 1182 | skip |= ValidateObject(device, sampler, kVulkanObjectTypeSampler, false, |
| 1183 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1184 | } |
| 1185 | } |
| 1186 | } |
| 1187 | } |
| 1188 | } |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1189 | return skip; |
| 1190 | } |
| 1191 | |
| 1192 | static void PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1193 | const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { |
| 1194 | CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
| 1195 | } |
| 1196 | |
| 1197 | VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1198 | const VkAllocationCallbacks *pAllocator, |
| 1199 | VkDescriptorSetLayout *pSetLayout) { |
| 1200 | { |
| 1201 | std::lock_guard<std::mutex> lock(global_lock); |
| 1202 | bool skip = PreCallValidateCreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); |
| 1203 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1204 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1205 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1206 | VkResult result = device_data->device_dispatch_table.CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1207 | if (VK_SUCCESS == result) { |
| 1208 | std::lock_guard<std::mutex> lock(global_lock); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame^] | 1209 | PostCallRecordCreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1210 | } |
| 1211 | return result; |
| 1212 | } |
| 1213 | |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1214 | static inline bool ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { |
| 1215 | bool skip = false; |
| 1216 | if (pCreateInfo->pBindings) { |
| 1217 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 1218 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 1219 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
| 1220 | skip |= |
| 1221 | ValidateObject(device, pCreateInfo->pBindings[index1].pImmutableSamplers[index2], kVulkanObjectTypeSampler, |
| 1222 | true, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
| 1223 | } |
| 1224 | } |
| 1225 | } |
| 1226 | } |
| 1227 | return skip; |
| 1228 | } |
| 1229 | |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1230 | VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1231 | VkDescriptorSetLayoutSupport *pSupport) { |
| 1232 | bool skip = false; |
| 1233 | { |
| 1234 | std::lock_guard<std::mutex> lock(global_lock); |
| 1235 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 1236 | "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", kVUIDUndefined); |
| 1237 | if (pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1238 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1239 | } |
| 1240 | } |
| 1241 | if (skip) return; |
| 1242 | GetLayerDataPtr(get_dispatch_key(device), layer_data_map) |
| 1243 | ->device_dispatch_table.GetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport); |
| 1244 | } |
| 1245 | |
| 1246 | VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupportKHR(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1247 | VkDescriptorSetLayoutSupport *pSupport) { |
| 1248 | bool skip = false; |
| 1249 | { |
| 1250 | std::lock_guard<std::mutex> lock(global_lock); |
| 1251 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 1252 | "VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", kVUIDUndefined); |
| 1253 | if (pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1254 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1255 | } |
| 1256 | } |
| 1257 | if (skip) return; |
| 1258 | GetLayerDataPtr(get_dispatch_key(device), layer_data_map) |
| 1259 | ->device_dispatch_table.GetDescriptorSetLayoutSupportKHR(device, pCreateInfo, pSupport); |
| 1260 | } |
| 1261 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1262 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 1263 | uint32_t *pQueueFamilyPropertyCount, |
| 1264 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
| 1265 | bool skip = false; |
| 1266 | { |
| 1267 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1268 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1269 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1270 | } |
| 1271 | if (skip) { |
| 1272 | return; |
| 1273 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1274 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1275 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, |
| 1276 | pQueueFamilyProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1277 | std::lock_guard<std::mutex> lock(global_lock); |
| 1278 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1279 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1280 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1281 | } |
| 1282 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1283 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i]; |
| 1284 | } |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1289 | VkInstance *pInstance) { |
| 1290 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1291 | |
| 1292 | assert(chain_info->u.pLayerInfo); |
| 1293 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1294 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
| 1295 | if (fpCreateInstance == NULL) { |
| 1296 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1297 | } |
| 1298 | |
| 1299 | // Advance the link info for the next element on the chain |
| 1300 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1301 | |
| 1302 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 1303 | if (result != VK_SUCCESS) { |
| 1304 | return result; |
| 1305 | } |
| 1306 | |
| 1307 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 1308 | instance_data->instance = *pInstance; |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1309 | layer_init_instance_dispatch_table(*pInstance, &instance_data->instance_dispatch_table, fpGetInstanceProcAddr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1310 | |
| 1311 | // Look for one or more debug report create info structures, and copy the |
| 1312 | // callback(s) for each one found (for use by vkDestroyInstance) |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1313 | layer_copy_tmp_debug_messengers(pCreateInfo->pNext, &instance_data->num_tmp_debug_messengers, |
| 1314 | &instance_data->tmp_messenger_create_infos, &instance_data->tmp_debug_messengers); |
| 1315 | layer_copy_tmp_report_callbacks(pCreateInfo->pNext, &instance_data->num_tmp_report_callbacks, |
| 1316 | &instance_data->tmp_report_create_infos, &instance_data->tmp_report_callbacks); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1317 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1318 | instance_data->report_data = |
| 1319 | debug_utils_create_instance(&instance_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, |
| 1320 | pCreateInfo->ppEnabledExtensionNames); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1321 | |
| 1322 | InitObjectTracker(instance_data, pAllocator); |
| 1323 | |
| 1324 | CreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); |
| 1325 | |
| 1326 | return result; |
| 1327 | } |
| 1328 | |
| 1329 | VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 1330 | VkPhysicalDevice *pPhysicalDevices) { |
| 1331 | bool skip = VK_FALSE; |
| 1332 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1333 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 1334 | "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1335 | lock.unlock(); |
| 1336 | if (skip) { |
| 1337 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1338 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1339 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1340 | VkResult result = |
| 1341 | instance_data->instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1342 | lock.lock(); |
Tony-LunarG | 2b0915e | 2018-10-31 16:02:40 -0600 | [diff] [blame] | 1343 | if (result == VK_SUCCESS || result == VK_INCOMPLETE) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1344 | if (pPhysicalDevices) { |
| 1345 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
| 1346 | CreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
| 1347 | } |
| 1348 | } |
| 1349 | } |
| 1350 | lock.unlock(); |
| 1351 | return result; |
| 1352 | } |
| 1353 | |
| 1354 | VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 1355 | VkCommandBuffer *pCommandBuffers) { |
| 1356 | bool skip = VK_FALSE; |
| 1357 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1358 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1359 | kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1360 | skip |= ValidateObject(device, pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
| 1361 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1362 | lock.unlock(); |
| 1363 | |
| 1364 | if (skip) { |
| 1365 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1366 | } |
| 1367 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1368 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1369 | VkResult result = device_data->device_dispatch_table.AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1370 | |
| 1371 | lock.lock(); |
| 1372 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
| 1373 | AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
| 1374 | } |
| 1375 | lock.unlock(); |
| 1376 | |
| 1377 | return result; |
| 1378 | } |
| 1379 | |
| 1380 | VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 1381 | VkDescriptorSet *pDescriptorSets) { |
| 1382 | bool skip = VK_FALSE; |
| 1383 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1384 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", |
| 1385 | kVUIDUndefined); |
| 1386 | skip |= ValidateObject(device, pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 1387 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1388 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1389 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 1390 | skip |= ValidateObject(device, pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1391 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 1392 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1393 | } |
| 1394 | lock.unlock(); |
| 1395 | if (skip) { |
| 1396 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1397 | } |
| 1398 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1399 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1400 | VkResult result = device_data->device_dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1401 | |
| 1402 | if (VK_SUCCESS == result) { |
| 1403 | lock.lock(); |
| 1404 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 1405 | AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
| 1406 | } |
| 1407 | lock.unlock(); |
| 1408 | } |
| 1409 | |
| 1410 | return result; |
| 1411 | } |
| 1412 | |
| 1413 | VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 1414 | const VkCommandBuffer *pCommandBuffers) { |
| 1415 | bool skip = false; |
| 1416 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1417 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1418 | ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, "VUID-vkFreeCommandBuffers-commandPool-parameter", |
| 1419 | "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1420 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 1421 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
| 1422 | skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); |
| 1423 | } |
| 1424 | } |
| 1425 | |
| 1426 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1427 | ValidateDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1428 | RecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | lock.unlock(); |
| 1432 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1433 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1434 | device_data->device_dispatch_table.FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1435 | } |
| 1436 | } |
| 1437 | |
| 1438 | VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
| 1439 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1440 | std::unique_lock<std::mutex> lock(global_lock); |
| 1441 | // A swapchain's images are implicitly deleted when the swapchain is deleted. |
| 1442 | // Remove this swapchain's images from our map of such images. |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1443 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = device_data->swapchainImageMap.begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1444 | while (itr != device_data->swapchainImageMap.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1445 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1446 | if (pNode->parent_object == HandleToUint64(swapchain)) { |
| 1447 | delete pNode; |
| 1448 | auto delete_item = itr++; |
| 1449 | device_data->swapchainImageMap.erase(delete_item); |
| 1450 | } else { |
| 1451 | ++itr; |
| 1452 | } |
| 1453 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1454 | ValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, |
| 1455 | "VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
| 1456 | RecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1457 | lock.unlock(); |
| 1458 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1459 | device_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 1463 | const VkDescriptorSet *pDescriptorSets) { |
| 1464 | bool skip = false; |
| 1465 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 1466 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1467 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", |
| 1468 | kVUIDUndefined); |
| 1469 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 1470 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1471 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 1472 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
| 1473 | skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); |
| 1474 | } |
| 1475 | } |
| 1476 | |
| 1477 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1478 | ValidateDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1479 | RecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | lock.unlock(); |
| 1483 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1484 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1485 | result = device_data->device_dispatch_table.FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1486 | } |
| 1487 | return result; |
| 1488 | } |
| 1489 | |
| 1490 | VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 1491 | const VkAllocationCallbacks *pAllocator) { |
| 1492 | bool skip = VK_FALSE; |
| 1493 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1494 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1495 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", |
| 1496 | kVUIDUndefined); |
| 1497 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
| 1498 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1499 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1500 | lock.unlock(); |
| 1501 | if (skip) { |
| 1502 | return; |
| 1503 | } |
| 1504 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. |
| 1505 | // Remove this pool's descriptor sets from our descriptorSet map. |
| 1506 | lock.lock(); |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1507 | 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] | 1508 | while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1509 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1510 | auto del_itr = itr++; |
| 1511 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1512 | ValidateDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, |
| 1513 | kVUIDUndefined, kVUIDUndefined); |
| 1514 | RecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1515 | } |
| 1516 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1517 | ValidateDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
| 1518 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
| 1519 | RecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1520 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1521 | device_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { |
| 1525 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1526 | bool skip = false; |
| 1527 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1528 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", |
| 1529 | kVUIDUndefined); |
| 1530 | skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, true, |
| 1531 | "VUID-vkDestroyCommandPool-commandPool-parameter", "VUID-vkDestroyCommandPool-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1532 | lock.unlock(); |
| 1533 | if (skip) { |
| 1534 | return; |
| 1535 | } |
| 1536 | lock.lock(); |
| 1537 | // A CommandPool's command buffers are implicitly deleted when the pool is deleted. |
| 1538 | // Remove this pool's cmdBuffers from our cmd buffer map. |
| 1539 | auto itr = device_data->object_map[kVulkanObjectTypeCommandBuffer].begin(); |
| 1540 | auto del_itr = itr; |
| 1541 | while (itr != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1542 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1543 | del_itr = itr++; |
| 1544 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
| 1545 | skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1546 | ValidateDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer, |
| 1547 | nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1548 | RecordDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1549 | } |
| 1550 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1551 | ValidateDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
| 1552 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
| 1553 | RecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1554 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1555 | device_data->device_dispatch_table.DestroyCommandPool(device, commandPool, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1556 | } |
| 1557 | |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1558 | // Note: This is the core version of this routine. The extension version is below. |
| 1559 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 1560 | uint32_t *pQueueFamilyPropertyCount, |
| 1561 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
| 1562 | bool skip = false; |
| 1563 | { |
| 1564 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1565 | skip |= |
| 1566 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1567 | } |
| 1568 | if (skip) { |
| 1569 | return; |
| 1570 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1571 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1572 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount, |
| 1573 | pQueueFamilyProperties); |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1574 | std::lock_guard<std::mutex> lock(global_lock); |
| 1575 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1576 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1577 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1578 | } |
| 1579 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1580 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
| 1581 | } |
| 1582 | } |
| 1583 | } |
| 1584 | |
| 1585 | // 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] | 1586 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, |
| 1587 | uint32_t *pQueueFamilyPropertyCount, |
| 1588 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
| 1589 | bool skip = false; |
| 1590 | { |
| 1591 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1592 | skip |= |
| 1593 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1594 | } |
| 1595 | if (skip) { |
| 1596 | return; |
| 1597 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1598 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1599 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, pQueueFamilyPropertyCount, |
| 1600 | pQueueFamilyProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1601 | std::lock_guard<std::mutex> lock(global_lock); |
| 1602 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1603 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1604 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1605 | } |
| 1606 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1607 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
| 1608 | } |
| 1609 | } |
| 1610 | } |
| 1611 | |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1612 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1613 | VkDisplayPropertiesKHR *pProperties) { |
| 1614 | bool skip = false; |
| 1615 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1616 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1617 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1618 | lock.unlock(); |
| 1619 | |
| 1620 | if (skip) { |
| 1621 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1622 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1623 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1624 | VkResult result = |
| 1625 | instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1626 | |
| 1627 | lock.lock(); |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1628 | if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) { |
| 1629 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1630 | CreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1631 | } |
| 1632 | } |
| 1633 | lock.unlock(); |
| 1634 | |
| 1635 | return result; |
| 1636 | } |
| 1637 | |
| 1638 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1639 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { |
| 1640 | bool skip = false; |
| 1641 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1642 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1643 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1644 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 1645 | "VUID-vkGetDisplayModePropertiesKHR-display-parameter", kVUIDUndefined); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1646 | lock.unlock(); |
| 1647 | |
| 1648 | if (skip) { |
| 1649 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1650 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1651 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1652 | VkResult result = |
| 1653 | instance_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1654 | |
| 1655 | lock.lock(); |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1656 | if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) { |
| 1657 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1658 | CreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1659 | } |
| 1660 | } |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1661 | |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1662 | lock.unlock(); |
| 1663 | |
| 1664 | return result; |
| 1665 | } |
| 1666 | |
Mark Lobodzinski | dfe5e17 | 2017-07-19 13:03:22 -0600 | [diff] [blame] | 1667 | VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1668 | bool skip = VK_FALSE; |
| 1669 | std::unique_lock<std::mutex> lock(global_lock); |
| 1670 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1671 | if (pNameInfo->pObjectName) { |
| 1672 | dev_data->report_data->debugObjectNameMap->insert( |
| 1673 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName)); |
| 1674 | } else { |
| 1675 | dev_data->report_data->debugObjectNameMap->erase(pNameInfo->object); |
| 1676 | } |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1677 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDebugMarkerSetObjectNameEXT-device-parameter", |
| 1678 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1679 | lock.unlock(); |
| 1680 | if (skip) { |
| 1681 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1682 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1683 | VkResult result = dev_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1684 | return result; |
| 1685 | } |
| 1686 | |
| 1687 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { |
| 1688 | assert(instance); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1689 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1690 | if (instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr == NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1691 | return NULL; |
| 1692 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1693 | return instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1694 | } |
| 1695 | |
| 1696 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { |
Mark Lobodzinski | f42ced6 | 2018-07-02 12:59:27 -0600 | [diff] [blame] | 1697 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1698 | if (!ApiParentExtensionEnabled(funcName, device_data->device_extension_set)) { |
| 1699 | return nullptr; |
| 1700 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1701 | const auto item = name_to_funcptr_map.find(funcName); |
| 1702 | if (item != name_to_funcptr_map.end()) { |
| 1703 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 1704 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1705 | if (!device_data->device_dispatch_table.GetDeviceProcAddr) return NULL; |
| 1706 | return device_data->device_dispatch_table.GetDeviceProcAddr(device, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1707 | } |
| 1708 | |
| 1709 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 1710 | const auto item = name_to_funcptr_map.find(funcName); |
| 1711 | if (item != name_to_funcptr_map.end()) { |
| 1712 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 1713 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1714 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1715 | if (!instance_data->instance_dispatch_table.GetInstanceProcAddr) return nullptr; |
| 1716 | return instance_data->instance_dispatch_table.GetInstanceProcAddr(instance, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1717 | } |
| 1718 | |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1719 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1720 | VkDisplayProperties2KHR *pProperties) { |
| 1721 | bool skip = false; |
| 1722 | { |
| 1723 | std::lock_guard<std::mutex> lock(global_lock); |
| 1724 | skip |= |
| 1725 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
| 1726 | } |
| 1727 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1728 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1729 | VkResult result = |
| 1730 | instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1731 | if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1732 | std::lock_guard<std::mutex> lock(global_lock); |
| 1733 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 1734 | CreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
| 1735 | } |
| 1736 | } |
| 1737 | |
| 1738 | return result; |
| 1739 | } |
| 1740 | |
| 1741 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1742 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
| 1743 | bool skip = false; |
| 1744 | { |
| 1745 | std::lock_guard<std::mutex> lock(global_lock); |
| 1746 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1747 | "VUID-vkGetDisplayPlaneSupportedDisplaysKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1748 | } |
| 1749 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1750 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1751 | VkResult result = instance_data->instance_dispatch_table.GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, |
| 1752 | pDisplayCount, pDisplays); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1753 | if (pDisplays && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1754 | std::lock_guard<std::mutex> lock(global_lock); |
| 1755 | for (uint32_t index = 0; index < *pDisplayCount; ++index) { |
| 1756 | CreateObject(physicalDevice, pDisplays[index], kVulkanObjectTypeDisplayKHR, nullptr); |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | return result; |
| 1761 | } |
| 1762 | |
| 1763 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1764 | uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties) { |
| 1765 | bool skip = false; |
| 1766 | { |
| 1767 | std::lock_guard<std::mutex> lock(global_lock); |
| 1768 | skip |= |
| 1769 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
| 1770 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, kVUIDUndefined, kVUIDUndefined); |
| 1771 | } |
| 1772 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1773 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1774 | VkResult result = |
| 1775 | instance_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1776 | if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1777 | std::lock_guard<std::mutex> lock(global_lock); |
| 1778 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 1779 | CreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, |
| 1780 | nullptr); |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | return result; |
| 1785 | } |
| 1786 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1787 | } // namespace object_tracker |
| 1788 | |
| 1789 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 1790 | VkExtensionProperties *pProperties) { |
| 1791 | return object_tracker::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); |
| 1792 | } |
| 1793 | |
| 1794 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 1795 | VkLayerProperties *pProperties) { |
| 1796 | return object_tracker::EnumerateInstanceLayerProperties(pCount, pProperties); |
| 1797 | } |
| 1798 | |
| 1799 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 1800 | VkLayerProperties *pProperties) { |
| 1801 | // The layer command handles VK_NULL_HANDLE just fine internally |
| 1802 | assert(physicalDevice == VK_NULL_HANDLE); |
| 1803 | return object_tracker::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); |
| 1804 | } |
| 1805 | |
| 1806 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
| 1807 | return object_tracker::GetDeviceProcAddr(dev, funcName); |
| 1808 | } |
| 1809 | |
| 1810 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 1811 | return object_tracker::GetInstanceProcAddr(instance, funcName); |
| 1812 | } |
| 1813 | |
| 1814 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 1815 | const char *pLayerName, uint32_t *pCount, |
| 1816 | VkExtensionProperties *pProperties) { |
| 1817 | // The layer command handles VK_NULL_HANDLE just fine internally |
| 1818 | assert(physicalDevice == VK_NULL_HANDLE); |
| 1819 | return object_tracker::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); |
| 1820 | } |
| 1821 | |
| 1822 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, |
| 1823 | const char *funcName) { |
| 1824 | return object_tracker::GetPhysicalDeviceProcAddr(instance, funcName); |
| 1825 | } |
| 1826 | |
| 1827 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { |
| 1828 | assert(pVersionStruct != NULL); |
| 1829 | assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); |
| 1830 | |
| 1831 | // Fill in the function pointers if our version is at least capable of having the structure contain them. |
| 1832 | if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { |
| 1833 | pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; |
| 1834 | pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; |
| 1835 | pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; |
| 1836 | } |
| 1837 | |
| 1838 | if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 1839 | object_tracker::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; |
| 1840 | } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 1841 | pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 1842 | } |
| 1843 | |
| 1844 | return VK_SUCCESS; |
| 1845 | } |