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