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