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 | |
| 1032 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 1033 | VkLayerProperties *pProperties) { |
| 1034 | return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); |
| 1035 | } |
| 1036 | |
| 1037 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 1038 | VkExtensionProperties *pProperties) { |
| 1039 | if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) |
| 1040 | return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); |
| 1041 | |
| 1042 | return VK_ERROR_LAYER_NOT_PRESENT; |
| 1043 | } |
| 1044 | |
| 1045 | VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, |
| 1046 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
| 1047 | if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) |
| 1048 | return util_GetExtensionProperties(0, nullptr, pCount, pProperties); |
| 1049 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1050 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1051 | return instance_data->instance_dispatch_table.EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 1055 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
| 1056 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1057 | bool skip = ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1058 | "VUID-vkCreateDevice-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1059 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1060 | |
| 1061 | layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1062 | VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1063 | |
| 1064 | assert(chain_info->u.pLayerInfo); |
| 1065 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1066 | PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; |
| 1067 | PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(phy_dev_data->instance, "vkCreateDevice"); |
| 1068 | if (fpCreateDevice == NULL) { |
| 1069 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1070 | } |
| 1071 | |
| 1072 | // Advance the link info for the next element on the chain |
| 1073 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1074 | |
| 1075 | VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); |
| 1076 | if (result != VK_SUCCESS) { |
| 1077 | return result; |
| 1078 | } |
| 1079 | |
| 1080 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1081 | 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] | 1082 | layer_init_device_dispatch_table(*pDevice, &device_data->device_dispatch_table, fpGetDeviceProcAddr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1083 | |
Mark Lobodzinski | f42ced6 | 2018-07-02 12:59:27 -0600 | [diff] [blame] | 1084 | // Save pCreateInfo device extension list for GetDeviceProcAddr() |
| 1085 | for (uint32_t extn = 0; extn < pCreateInfo->enabledExtensionCount; extn++) { |
| 1086 | device_data->device_extension_set.insert(pCreateInfo->ppEnabledExtensionNames[extn]); |
| 1087 | } |
| 1088 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1089 | // Add link back to physDev |
| 1090 | device_data->physical_device = physicalDevice; |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 1091 | device_data->instance = phy_dev_data->instance; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1092 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 1093 | CreateObject(phy_dev_data->instance, *pDevice, kVulkanObjectTypeDevice, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1094 | |
| 1095 | return result; |
| 1096 | } |
| 1097 | |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 1098 | VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 1099 | VkImage *pSwapchainImages) { |
Mark Lobodzinski | 09fa2d4 | 2017-07-21 10:16:53 -0600 | [diff] [blame] | 1100 | bool skip = false; |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 1101 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1102 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1103 | kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1104 | skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, |
| 1105 | "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", kVUIDUndefined); |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 1106 | lock.unlock(); |
Mark Lobodzinski | 09fa2d4 | 2017-07-21 10:16:53 -0600 | [diff] [blame] | 1107 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1108 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1109 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1110 | VkResult result = |
| 1111 | device_data->device_dispatch_table.GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); |
Mark Lobodzinski | 216843a | 2017-07-21 13:23:13 -0600 | [diff] [blame] | 1112 | if (pSwapchainImages != NULL) { |
| 1113 | lock.lock(); |
| 1114 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 1115 | CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); |
| 1116 | } |
| 1117 | lock.unlock(); |
| 1118 | } |
| 1119 | return result; |
| 1120 | } |
| 1121 | |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1122 | VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1123 | const VkAllocationCallbacks *pAllocator, |
| 1124 | VkDescriptorSetLayout *pSetLayout) { |
| 1125 | bool skip = false; |
| 1126 | { |
| 1127 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1128 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorSetLayout-device-parameter", |
| 1129 | kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1130 | if (pCreateInfo) { |
| 1131 | if (pCreateInfo->pBindings) { |
| 1132 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 1133 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 1134 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 1135 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 1136 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 1137 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 1138 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1139 | skip |= ValidateObject(device, sampler, kVulkanObjectTypeSampler, false, |
| 1140 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1141 | } |
| 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | } |
| 1147 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1148 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1149 | VkResult result = device_data->device_dispatch_table.CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 1150 | if (VK_SUCCESS == result) { |
| 1151 | std::lock_guard<std::mutex> lock(global_lock); |
| 1152 | CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
| 1153 | } |
| 1154 | return result; |
| 1155 | } |
| 1156 | |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1157 | static inline bool ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { |
| 1158 | bool skip = false; |
| 1159 | if (pCreateInfo->pBindings) { |
| 1160 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 1161 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 1162 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
| 1163 | skip |= |
| 1164 | ValidateObject(device, pCreateInfo->pBindings[index1].pImmutableSamplers[index2], kVulkanObjectTypeSampler, |
| 1165 | true, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
| 1166 | } |
| 1167 | } |
| 1168 | } |
| 1169 | } |
| 1170 | return skip; |
| 1171 | } |
| 1172 | |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1173 | VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1174 | VkDescriptorSetLayoutSupport *pSupport) { |
| 1175 | bool skip = false; |
| 1176 | { |
| 1177 | std::lock_guard<std::mutex> lock(global_lock); |
| 1178 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 1179 | "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", kVUIDUndefined); |
| 1180 | if (pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1181 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1182 | } |
| 1183 | } |
| 1184 | if (skip) return; |
| 1185 | GetLayerDataPtr(get_dispatch_key(device), layer_data_map) |
| 1186 | ->device_dispatch_table.GetDescriptorSetLayoutSupport(device, pCreateInfo, pSupport); |
| 1187 | } |
| 1188 | |
| 1189 | VKAPI_ATTR void VKAPI_CALL GetDescriptorSetLayoutSupportKHR(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 1190 | VkDescriptorSetLayoutSupport *pSupport) { |
| 1191 | bool skip = false; |
| 1192 | { |
| 1193 | std::lock_guard<std::mutex> lock(global_lock); |
| 1194 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 1195 | "VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", kVUIDUndefined); |
| 1196 | if (pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 1197 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
Mark Lobodzinski | 5a1c8d2 | 2018-07-02 10:28:12 -0600 | [diff] [blame] | 1198 | } |
| 1199 | } |
| 1200 | if (skip) return; |
| 1201 | GetLayerDataPtr(get_dispatch_key(device), layer_data_map) |
| 1202 | ->device_dispatch_table.GetDescriptorSetLayoutSupportKHR(device, pCreateInfo, pSupport); |
| 1203 | } |
| 1204 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1205 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 1206 | uint32_t *pQueueFamilyPropertyCount, |
| 1207 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
| 1208 | bool skip = false; |
| 1209 | { |
| 1210 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1211 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1212 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1213 | } |
| 1214 | if (skip) { |
| 1215 | return; |
| 1216 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1217 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1218 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, |
| 1219 | pQueueFamilyProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1220 | std::lock_guard<std::mutex> lock(global_lock); |
| 1221 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1222 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1223 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1224 | } |
| 1225 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1226 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i]; |
| 1227 | } |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1232 | VkInstance *pInstance) { |
| 1233 | VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); |
| 1234 | |
| 1235 | assert(chain_info->u.pLayerInfo); |
| 1236 | PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; |
| 1237 | PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); |
| 1238 | if (fpCreateInstance == NULL) { |
| 1239 | return VK_ERROR_INITIALIZATION_FAILED; |
| 1240 | } |
| 1241 | |
| 1242 | // Advance the link info for the next element on the chain |
| 1243 | chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; |
| 1244 | |
| 1245 | VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); |
| 1246 | if (result != VK_SUCCESS) { |
| 1247 | return result; |
| 1248 | } |
| 1249 | |
| 1250 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 1251 | instance_data->instance = *pInstance; |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1252 | layer_init_instance_dispatch_table(*pInstance, &instance_data->instance_dispatch_table, fpGetInstanceProcAddr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1253 | |
| 1254 | // Look for one or more debug report create info structures, and copy the |
| 1255 | // callback(s) for each one found (for use by vkDestroyInstance) |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 1256 | layer_copy_tmp_debug_messengers(pCreateInfo->pNext, &instance_data->num_tmp_debug_messengers, |
| 1257 | &instance_data->tmp_messenger_create_infos, &instance_data->tmp_debug_messengers); |
| 1258 | layer_copy_tmp_report_callbacks(pCreateInfo->pNext, &instance_data->num_tmp_report_callbacks, |
| 1259 | &instance_data->tmp_report_create_infos, &instance_data->tmp_report_callbacks); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1260 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1261 | instance_data->report_data = |
| 1262 | debug_utils_create_instance(&instance_data->instance_dispatch_table, *pInstance, pCreateInfo->enabledExtensionCount, |
| 1263 | pCreateInfo->ppEnabledExtensionNames); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1264 | |
| 1265 | InitObjectTracker(instance_data, pAllocator); |
| 1266 | |
| 1267 | CreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); |
| 1268 | |
| 1269 | return result; |
| 1270 | } |
| 1271 | |
| 1272 | VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 1273 | VkPhysicalDevice *pPhysicalDevices) { |
| 1274 | bool skip = VK_FALSE; |
| 1275 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1276 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 1277 | "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1278 | lock.unlock(); |
| 1279 | if (skip) { |
| 1280 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1281 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1282 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1283 | VkResult result = |
| 1284 | instance_data->instance_dispatch_table.EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1285 | lock.lock(); |
Tony-LunarG | 2b0915e | 2018-10-31 16:02:40 -0600 | [diff] [blame] | 1286 | if (result == VK_SUCCESS || result == VK_INCOMPLETE) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1287 | if (pPhysicalDevices) { |
| 1288 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
| 1289 | CreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
| 1290 | } |
| 1291 | } |
| 1292 | } |
| 1293 | lock.unlock(); |
| 1294 | return result; |
| 1295 | } |
| 1296 | |
| 1297 | VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 1298 | VkCommandBuffer *pCommandBuffers) { |
| 1299 | bool skip = VK_FALSE; |
| 1300 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1301 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1302 | kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1303 | skip |= ValidateObject(device, pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
| 1304 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1305 | lock.unlock(); |
| 1306 | |
| 1307 | if (skip) { |
| 1308 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1309 | } |
| 1310 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1311 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1312 | VkResult result = device_data->device_dispatch_table.AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1313 | |
| 1314 | lock.lock(); |
| 1315 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
| 1316 | AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
| 1317 | } |
| 1318 | lock.unlock(); |
| 1319 | |
| 1320 | return result; |
| 1321 | } |
| 1322 | |
| 1323 | VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 1324 | VkDescriptorSet *pDescriptorSets) { |
| 1325 | bool skip = VK_FALSE; |
| 1326 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1327 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", |
| 1328 | kVUIDUndefined); |
| 1329 | skip |= ValidateObject(device, pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 1330 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1331 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1332 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 1333 | skip |= ValidateObject(device, pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1334 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 1335 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1336 | } |
| 1337 | lock.unlock(); |
| 1338 | if (skip) { |
| 1339 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1340 | } |
| 1341 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1342 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1343 | VkResult result = device_data->device_dispatch_table.AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1344 | |
| 1345 | if (VK_SUCCESS == result) { |
| 1346 | lock.lock(); |
| 1347 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 1348 | AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
| 1349 | } |
| 1350 | lock.unlock(); |
| 1351 | } |
| 1352 | |
| 1353 | return result; |
| 1354 | } |
| 1355 | |
| 1356 | VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 1357 | const VkCommandBuffer *pCommandBuffers) { |
| 1358 | bool skip = false; |
| 1359 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1360 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", kVUIDUndefined); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1361 | ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, "VUID-vkFreeCommandBuffers-commandPool-parameter", |
| 1362 | "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1363 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 1364 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
| 1365 | skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1370 | ValidateDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1371 | RecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1372 | } |
| 1373 | |
| 1374 | lock.unlock(); |
| 1375 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1376 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1377 | device_data->device_dispatch_table.FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1378 | } |
| 1379 | } |
| 1380 | |
| 1381 | VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
| 1382 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1383 | std::unique_lock<std::mutex> lock(global_lock); |
| 1384 | // A swapchain's images are implicitly deleted when the swapchain is deleted. |
| 1385 | // Remove this swapchain's images from our map of such images. |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1386 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = device_data->swapchainImageMap.begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1387 | while (itr != device_data->swapchainImageMap.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1388 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1389 | if (pNode->parent_object == HandleToUint64(swapchain)) { |
| 1390 | delete pNode; |
| 1391 | auto delete_item = itr++; |
| 1392 | device_data->swapchainImageMap.erase(delete_item); |
| 1393 | } else { |
| 1394 | ++itr; |
| 1395 | } |
| 1396 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1397 | ValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, |
| 1398 | "VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
| 1399 | RecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1400 | lock.unlock(); |
| 1401 | |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1402 | device_data->device_dispatch_table.DestroySwapchainKHR(device, swapchain, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1403 | } |
| 1404 | |
| 1405 | VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 1406 | const VkDescriptorSet *pDescriptorSets) { |
| 1407 | bool skip = false; |
| 1408 | VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; |
| 1409 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1410 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", |
| 1411 | kVUIDUndefined); |
| 1412 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 1413 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1414 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 1415 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
| 1416 | skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1421 | ValidateDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1422 | RecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | lock.unlock(); |
| 1426 | if (!skip) { |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1427 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1428 | result = device_data->device_dispatch_table.FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1429 | } |
| 1430 | return result; |
| 1431 | } |
| 1432 | |
| 1433 | VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 1434 | const VkAllocationCallbacks *pAllocator) { |
| 1435 | bool skip = VK_FALSE; |
| 1436 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1437 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1438 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", |
| 1439 | kVUIDUndefined); |
| 1440 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
| 1441 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
Dave Houlton | 57ae22f | 2018-05-18 16:20:52 -0600 | [diff] [blame] | 1442 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1443 | lock.unlock(); |
| 1444 | if (skip) { |
| 1445 | return; |
| 1446 | } |
| 1447 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. |
| 1448 | // Remove this pool's descriptor sets from our descriptorSet map. |
| 1449 | lock.lock(); |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1450 | 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] | 1451 | while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1452 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1453 | auto del_itr = itr++; |
| 1454 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1455 | ValidateDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, |
| 1456 | kVUIDUndefined, kVUIDUndefined); |
| 1457 | RecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1458 | } |
| 1459 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1460 | ValidateDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
| 1461 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
| 1462 | RecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1463 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1464 | device_data->device_dispatch_table.DestroyDescriptorPool(device, descriptorPool, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1465 | } |
| 1466 | |
| 1467 | VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { |
| 1468 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1469 | bool skip = false; |
| 1470 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1471 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", |
| 1472 | kVUIDUndefined); |
| 1473 | skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, true, |
| 1474 | "VUID-vkDestroyCommandPool-commandPool-parameter", "VUID-vkDestroyCommandPool-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1475 | lock.unlock(); |
| 1476 | if (skip) { |
| 1477 | return; |
| 1478 | } |
| 1479 | lock.lock(); |
| 1480 | // A CommandPool's command buffers are implicitly deleted when the pool is deleted. |
| 1481 | // Remove this pool's cmdBuffers from our cmd buffer map. |
| 1482 | auto itr = device_data->object_map[kVulkanObjectTypeCommandBuffer].begin(); |
| 1483 | auto del_itr = itr; |
| 1484 | while (itr != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 1485 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1486 | del_itr = itr++; |
| 1487 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
| 1488 | skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1489 | ValidateDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer, |
| 1490 | nullptr, kVUIDUndefined, kVUIDUndefined); |
| 1491 | RecordDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1492 | } |
| 1493 | } |
Mark Lobodzinski | eedd767 | 2018-09-12 18:09:49 -0600 | [diff] [blame] | 1494 | ValidateDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
| 1495 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
| 1496 | RecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1497 | lock.unlock(); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1498 | device_data->device_dispatch_table.DestroyCommandPool(device, commandPool, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1499 | } |
| 1500 | |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1501 | // Note: This is the core version of this routine. The extension version is below. |
| 1502 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 1503 | uint32_t *pQueueFamilyPropertyCount, |
| 1504 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
| 1505 | bool skip = false; |
| 1506 | { |
| 1507 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1508 | skip |= |
| 1509 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1510 | } |
| 1511 | if (skip) { |
| 1512 | return; |
| 1513 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1514 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1515 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2(physicalDevice, pQueueFamilyPropertyCount, |
| 1516 | pQueueFamilyProperties); |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1517 | std::lock_guard<std::mutex> lock(global_lock); |
| 1518 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | 14ddc19 | 2017-10-25 16:57:04 -0600 | [diff] [blame] | 1519 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1520 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1521 | } |
| 1522 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1523 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
| 1524 | } |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | // 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] | 1529 | VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, |
| 1530 | uint32_t *pQueueFamilyPropertyCount, |
| 1531 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
| 1532 | bool skip = false; |
| 1533 | { |
| 1534 | std::lock_guard<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1535 | skip |= |
| 1536 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1537 | } |
| 1538 | if (skip) { |
| 1539 | return; |
| 1540 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1541 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1542 | instance_data->instance_dispatch_table.GetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, pQueueFamilyPropertyCount, |
| 1543 | pQueueFamilyProperties); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1544 | std::lock_guard<std::mutex> lock(global_lock); |
| 1545 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1546 | if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1547 | instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); |
| 1548 | } |
| 1549 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
| 1550 | instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
| 1551 | } |
| 1552 | } |
| 1553 | } |
| 1554 | |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1555 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1556 | VkDisplayPropertiesKHR *pProperties) { |
| 1557 | bool skip = false; |
| 1558 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1559 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1560 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1561 | lock.unlock(); |
| 1562 | |
| 1563 | if (skip) { |
| 1564 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1565 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1566 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1567 | VkResult result = |
| 1568 | instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1569 | |
| 1570 | lock.lock(); |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1571 | if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) { |
| 1572 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1573 | CreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1574 | } |
| 1575 | } |
| 1576 | lock.unlock(); |
| 1577 | |
| 1578 | return result; |
| 1579 | } |
| 1580 | |
| 1581 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1582 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { |
| 1583 | bool skip = false; |
| 1584 | std::unique_lock<std::mutex> lock(global_lock); |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1585 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1586 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1587 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 1588 | "VUID-vkGetDisplayModePropertiesKHR-display-parameter", kVUIDUndefined); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1589 | lock.unlock(); |
| 1590 | |
| 1591 | if (skip) { |
| 1592 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1593 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1594 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1595 | VkResult result = |
| 1596 | instance_data->instance_dispatch_table.GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1597 | |
| 1598 | lock.lock(); |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1599 | if ((result == VK_SUCCESS || result == VK_INCOMPLETE) && pProperties) { |
| 1600 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
| 1601 | CreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1602 | } |
| 1603 | } |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1604 | |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1605 | lock.unlock(); |
| 1606 | |
| 1607 | return result; |
| 1608 | } |
| 1609 | |
Mark Lobodzinski | dfe5e17 | 2017-07-19 13:03:22 -0600 | [diff] [blame] | 1610 | VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1611 | bool skip = VK_FALSE; |
| 1612 | std::unique_lock<std::mutex> lock(global_lock); |
| 1613 | layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1614 | if (pNameInfo->pObjectName) { |
| 1615 | dev_data->report_data->debugObjectNameMap->insert( |
| 1616 | std::make_pair<uint64_t, std::string>((uint64_t &&) pNameInfo->object, pNameInfo->pObjectName)); |
| 1617 | } else { |
| 1618 | dev_data->report_data->debugObjectNameMap->erase(pNameInfo->object); |
| 1619 | } |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 1620 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDebugMarkerSetObjectNameEXT-device-parameter", |
| 1621 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1622 | lock.unlock(); |
| 1623 | if (skip) { |
| 1624 | return VK_ERROR_VALIDATION_FAILED_EXT; |
| 1625 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1626 | VkResult result = dev_data->device_dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1627 | return result; |
| 1628 | } |
| 1629 | |
| 1630 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { |
| 1631 | assert(instance); |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1632 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1633 | if (instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr == NULL) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1634 | return NULL; |
| 1635 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1636 | return instance_data->instance_dispatch_table.GetPhysicalDeviceProcAddr(instance, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { |
Mark Lobodzinski | f42ced6 | 2018-07-02 12:59:27 -0600 | [diff] [blame] | 1640 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 1641 | if (!ApiParentExtensionEnabled(funcName, device_data->device_extension_set)) { |
| 1642 | return nullptr; |
| 1643 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1644 | const auto item = name_to_funcptr_map.find(funcName); |
| 1645 | if (item != name_to_funcptr_map.end()) { |
| 1646 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 1647 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1648 | if (!device_data->device_dispatch_table.GetDeviceProcAddr) return NULL; |
| 1649 | return device_data->device_dispatch_table.GetDeviceProcAddr(device, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1650 | } |
| 1651 | |
| 1652 | VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 1653 | const auto item = name_to_funcptr_map.find(funcName); |
| 1654 | if (item != name_to_funcptr_map.end()) { |
| 1655 | return reinterpret_cast<PFN_vkVoidFunction>(item->second); |
| 1656 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 1657 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 1658 | if (!instance_data->instance_dispatch_table.GetInstanceProcAddr) return nullptr; |
| 1659 | return instance_data->instance_dispatch_table.GetInstanceProcAddr(instance, funcName); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1660 | } |
| 1661 | |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1662 | VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1663 | VkDisplayProperties2KHR *pProperties) { |
| 1664 | bool skip = false; |
| 1665 | { |
| 1666 | std::lock_guard<std::mutex> lock(global_lock); |
| 1667 | skip |= |
| 1668 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
| 1669 | } |
| 1670 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1671 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1672 | VkResult result = |
| 1673 | instance_data->instance_dispatch_table.GetPhysicalDeviceDisplayProperties2KHR(physicalDevice, pPropertyCount, pProperties); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1674 | if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1675 | std::lock_guard<std::mutex> lock(global_lock); |
| 1676 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 1677 | CreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | return result; |
| 1682 | } |
| 1683 | |
| 1684 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1685 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
| 1686 | bool skip = false; |
| 1687 | { |
| 1688 | std::lock_guard<std::mutex> lock(global_lock); |
| 1689 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1690 | "VUID-vkGetDisplayPlaneSupportedDisplaysKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1691 | } |
| 1692 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1693 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1694 | VkResult result = instance_data->instance_dispatch_table.GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, |
| 1695 | pDisplayCount, pDisplays); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1696 | if (pDisplays && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1697 | std::lock_guard<std::mutex> lock(global_lock); |
| 1698 | for (uint32_t index = 0; index < *pDisplayCount; ++index) { |
| 1699 | CreateObject(physicalDevice, pDisplays[index], kVulkanObjectTypeDisplayKHR, nullptr); |
| 1700 | } |
| 1701 | } |
| 1702 | |
| 1703 | return result; |
| 1704 | } |
| 1705 | |
| 1706 | VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 1707 | uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties) { |
| 1708 | bool skip = false; |
| 1709 | { |
| 1710 | std::lock_guard<std::mutex> lock(global_lock); |
| 1711 | skip |= |
| 1712 | ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, kVUIDUndefined, kVUIDUndefined); |
| 1713 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, kVUIDUndefined, kVUIDUndefined); |
| 1714 | } |
| 1715 | if (skip) return VK_ERROR_VALIDATION_FAILED_EXT; |
Mark Lobodzinski | 72ec0d7 | 2018-06-26 08:55:40 -0600 | [diff] [blame] | 1716 | layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); |
| 1717 | VkResult result = |
| 1718 | instance_data->instance_dispatch_table.GetDisplayModeProperties2KHR(physicalDevice, display, pPropertyCount, pProperties); |
Piers Daniell | 16c253f | 2018-05-30 14:34:05 -0600 | [diff] [blame] | 1719 | if (pProperties && (VK_SUCCESS == result || VK_INCOMPLETE == result)) { |
| 1720 | std::lock_guard<std::mutex> lock(global_lock); |
| 1721 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 1722 | CreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, |
| 1723 | nullptr); |
| 1724 | } |
| 1725 | } |
| 1726 | |
| 1727 | return result; |
| 1728 | } |
| 1729 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1730 | } // namespace object_tracker |
| 1731 | |
| 1732 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, |
| 1733 | VkExtensionProperties *pProperties) { |
| 1734 | return object_tracker::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); |
| 1735 | } |
| 1736 | |
| 1737 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, |
| 1738 | VkLayerProperties *pProperties) { |
| 1739 | return object_tracker::EnumerateInstanceLayerProperties(pCount, pProperties); |
| 1740 | } |
| 1741 | |
| 1742 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 1743 | VkLayerProperties *pProperties) { |
| 1744 | // The layer command handles VK_NULL_HANDLE just fine internally |
| 1745 | assert(physicalDevice == VK_NULL_HANDLE); |
| 1746 | return object_tracker::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); |
| 1747 | } |
| 1748 | |
| 1749 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { |
| 1750 | return object_tracker::GetDeviceProcAddr(dev, funcName); |
| 1751 | } |
| 1752 | |
| 1753 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
| 1754 | return object_tracker::GetInstanceProcAddr(instance, funcName); |
| 1755 | } |
| 1756 | |
| 1757 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 1758 | const char *pLayerName, uint32_t *pCount, |
| 1759 | VkExtensionProperties *pProperties) { |
| 1760 | // The layer command handles VK_NULL_HANDLE just fine internally |
| 1761 | assert(physicalDevice == VK_NULL_HANDLE); |
| 1762 | return object_tracker::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); |
| 1763 | } |
| 1764 | |
| 1765 | VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, |
| 1766 | const char *funcName) { |
| 1767 | return object_tracker::GetPhysicalDeviceProcAddr(instance, funcName); |
| 1768 | } |
| 1769 | |
| 1770 | VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { |
| 1771 | assert(pVersionStruct != NULL); |
| 1772 | assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); |
| 1773 | |
| 1774 | // Fill in the function pointers if our version is at least capable of having the structure contain them. |
| 1775 | if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { |
| 1776 | pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; |
| 1777 | pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; |
| 1778 | pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; |
| 1779 | } |
| 1780 | |
| 1781 | if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 1782 | object_tracker::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; |
| 1783 | } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { |
| 1784 | pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; |
| 1785 | } |
| 1786 | |
| 1787 | return VK_SUCCESS; |
| 1788 | } |