Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2019 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2019 Valve Corporation |
| 3 | * Copyright (c) 2015-2019 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2019 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 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 23 | #include "chassis.h" |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 24 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame] | 25 | #include "object_lifetime_validation.h" |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 26 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 27 | uint64_t object_track_index = 0; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 28 | |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 29 | VulkanTypedHandle ObjTrackStateTypedHandle(const ObjTrackState &track_state) { |
| 30 | // TODO: Unify Typed Handle representation (i.e. VulkanTypedHandle everywhere there are handle/type pairs) |
| 31 | VulkanTypedHandle typed_handle; |
| 32 | typed_handle.handle = track_state.handle; |
| 33 | typed_handle.type = track_state.object_type; |
| 34 | return typed_handle; |
| 35 | } |
| 36 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 37 | // Destroy memRef lists and free all memory |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 38 | void ObjectLifetimes::DestroyQueueDataStructures(VkDevice device) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 39 | // Destroy the items in the queue map |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 40 | auto queue = object_map[kVulkanObjectTypeQueue].begin(); |
| 41 | while (queue != object_map[kVulkanObjectTypeQueue].end()) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 42 | uint32_t obj_index = queue->second->object_type; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 43 | assert(num_total_objects > 0); |
| 44 | num_total_objects--; |
| 45 | assert(num_objects[obj_index] > 0); |
| 46 | num_objects[obj_index]--; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 47 | delete queue->second; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 48 | queue = object_map[kVulkanObjectTypeQueue].erase(queue); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 52 | // Look for this device object in any of the instance child devices lists. |
| 53 | // NOTE: This is of dubious value. In most circumstances Vulkan will die a flaming death if a dispatchable object is invalid. |
| 54 | // However, if this layer is loaded first and GetProcAddress is used to make API calls, it will detect bad DOs. |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 55 | bool ObjectLifetimes::ValidateDeviceObject(const VulkanTypedHandle &device_typed, const char *invalid_handle_code, |
| 56 | const char *wrong_device_code) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 57 | auto instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); |
| 58 | auto instance_object_lifetime_data = GetObjectLifetimeData(instance_data->object_dispatch); |
| 59 | for (auto object : instance_object_lifetime_data->object_map[kVulkanObjectTypeDevice]) { |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 60 | if (object.second->handle == device_typed.handle) return false; |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 61 | } |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 62 | return log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, device_typed.handle, |
locke-lunarg | 9edc281 | 2019-06-17 23:18:52 -0600 | [diff] [blame] | 63 | invalid_handle_code, "Invalid %s.", report_data->FormatHandle(device_typed).c_str()); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 66 | void ObjectLifetimes::AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer, |
| 67 | VkCommandBufferLevel level) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 68 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 69 | pNewObjNode->object_type = kVulkanObjectTypeCommandBuffer; |
| 70 | pNewObjNode->handle = HandleToUint64(command_buffer); |
| 71 | pNewObjNode->parent_object = HandleToUint64(command_pool); |
| 72 | if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { |
| 73 | pNewObjNode->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; |
| 74 | } else { |
| 75 | pNewObjNode->status = OBJSTATUS_NONE; |
| 76 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 77 | object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)] = pNewObjNode; |
| 78 | num_objects[kVulkanObjectTypeCommandBuffer]++; |
| 79 | num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 80 | } |
| 81 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 82 | bool ObjectLifetimes::ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 83 | bool skip = false; |
| 84 | uint64_t object_handle = HandleToUint64(command_buffer); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 85 | if (object_map[kVulkanObjectTypeCommandBuffer].find(object_handle) != object_map[kVulkanObjectTypeCommandBuffer].end()) { |
| 86 | ObjTrackState *pNode = object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 87 | |
| 88 | if (pNode->parent_object != HandleToUint64(command_pool)) { |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 89 | // We know that the parent *must* be a command pool |
| 90 | const auto parent_pool = CastFromUint64<VkCommandPool>(pNode->parent_object); |
locke-lunarg | 9edc281 | 2019-06-17 23:18:52 -0600 | [diff] [blame] | 91 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, |
| 92 | object_handle, "VUID-vkFreeCommandBuffers-pCommandBuffers-parent", |
| 93 | "FreeCommandBuffers is attempting to free %s belonging to %s from %s).", |
| 94 | report_data->FormatHandle(command_buffer).c_str(), report_data->FormatHandle(parent_pool).c_str(), |
| 95 | report_data->FormatHandle(command_pool).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 96 | } |
| 97 | } else { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 98 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, object_handle, |
locke-lunarg | 9edc281 | 2019-06-17 23:18:52 -0600 | [diff] [blame] | 99 | "VUID-vkFreeCommandBuffers-pCommandBuffers-00048", "Invalid %s.", |
| 100 | report_data->FormatHandle(command_buffer).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 101 | } |
| 102 | return skip; |
| 103 | } |
| 104 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 105 | void ObjectLifetimes::AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 106 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 107 | pNewObjNode->object_type = kVulkanObjectTypeDescriptorSet; |
| 108 | pNewObjNode->status = OBJSTATUS_NONE; |
| 109 | pNewObjNode->handle = HandleToUint64(descriptor_set); |
| 110 | pNewObjNode->parent_object = HandleToUint64(descriptor_pool); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 111 | object_map[kVulkanObjectTypeDescriptorSet][HandleToUint64(descriptor_set)] = pNewObjNode; |
| 112 | num_objects[kVulkanObjectTypeDescriptorSet]++; |
| 113 | num_total_objects++; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 114 | |
| 115 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptor_pool)); |
| 116 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 117 | ObjTrackState *pPoolNode = itr->second; |
| 118 | pPoolNode->child_objects->insert(HandleToUint64(descriptor_set)); |
| 119 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 120 | } |
| 121 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 122 | bool ObjectLifetimes::ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 123 | bool skip = false; |
| 124 | uint64_t object_handle = HandleToUint64(descriptor_set); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 125 | auto dsItem = object_map[kVulkanObjectTypeDescriptorSet].find(object_handle); |
| 126 | if (dsItem != object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 127 | ObjTrackState *pNode = dsItem->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 128 | |
| 129 | if (pNode->parent_object != HandleToUint64(descriptor_pool)) { |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 130 | // We know that the parent *must* be a descriptor pool |
| 131 | const auto parent_pool = CastFromUint64<VkDescriptorPool>(pNode->parent_object); |
| 132 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, |
| 133 | object_handle, "VUID-vkFreeDescriptorSets-pDescriptorSets-parent", |
locke-lunarg | 9edc281 | 2019-06-17 23:18:52 -0600 | [diff] [blame] | 134 | "FreeDescriptorSets is attempting to free %s" |
| 135 | " belonging to %s from %s).", |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 136 | report_data->FormatHandle(descriptor_set).c_str(), report_data->FormatHandle(parent_pool).c_str(), |
| 137 | report_data->FormatHandle(descriptor_pool).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 138 | } |
| 139 | } else { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 140 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, object_handle, |
locke-lunarg | 9edc281 | 2019-06-17 23:18:52 -0600 | [diff] [blame] | 141 | "VUID-vkFreeDescriptorSets-pDescriptorSets-00310", "Invalid %s.", |
| 142 | report_data->FormatHandle(descriptor_set).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 143 | } |
| 144 | return skip; |
| 145 | } |
| 146 | |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 147 | template <typename DispObj> |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 148 | bool ObjectLifetimes::ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush) { |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 149 | bool skip = false; |
| 150 | |
| 151 | if (!isPush && desc->dstSet) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 152 | skip |= ValidateObject(disp, desc->dstSet, kVulkanObjectTypeDescriptorSet, false, "VUID-VkWriteDescriptorSet-dstSet-00320", |
| 153 | "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 157 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 158 | for (uint32_t idx2 = 0; idx2 < desc->descriptorCount; ++idx2) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 159 | skip |= ValidateObject(disp, desc->pTexelBufferView[idx2], kVulkanObjectTypeBufferView, false, |
| 160 | "VUID-VkWriteDescriptorSet-descriptorType-00323", "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 161 | } |
| 162 | } |
| 163 | |
| 164 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 165 | (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] | 166 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 167 | for (uint32_t idx3 = 0; idx3 < desc->descriptorCount; ++idx3) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 168 | skip |= ValidateObject(disp, desc->pImageInfo[idx3].imageView, kVulkanObjectTypeImageView, false, |
| 169 | "VUID-VkWriteDescriptorSet-descriptorType-00326", "VUID-VkDescriptorImageInfo-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
| 173 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 174 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 175 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 176 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 177 | for (uint32_t idx4 = 0; idx4 < desc->descriptorCount; ++idx4) { |
| 178 | if (desc->pBufferInfo[idx4].buffer) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 179 | skip |= ValidateObject(disp, desc->pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer, false, |
| 180 | "VUID-VkDescriptorBufferInfo-buffer-parameter", kVUIDUndefined); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | return skip; |
| 186 | } |
| 187 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 188 | bool ObjectLifetimes::PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, |
| 189 | VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, |
| 190 | const VkWriteDescriptorSet *pDescriptorWrites) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 191 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 192 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 193 | skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 194 | "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
| 195 | skip |= ValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, |
| 196 | "VUID-vkCmdPushDescriptorSetKHR-layout-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 197 | if (pDescriptorWrites) { |
| 198 | for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) { |
| 199 | skip |= ValidateDescriptorWrite(commandBuffer, &pDescriptorWrites[index0], true); |
| 200 | } |
| 201 | } |
| 202 | return skip; |
| 203 | } |
| 204 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 205 | void ObjectLifetimes::CreateQueue(VkDevice device, VkQueue vkObj) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 206 | ObjTrackState *p_obj_node = NULL; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 207 | auto queue_item = object_map[kVulkanObjectTypeQueue].find(HandleToUint64(vkObj)); |
| 208 | if (queue_item == object_map[kVulkanObjectTypeQueue].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 209 | p_obj_node = new ObjTrackState; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 210 | object_map[kVulkanObjectTypeQueue][HandleToUint64(vkObj)] = p_obj_node; |
| 211 | num_objects[kVulkanObjectTypeQueue]++; |
| 212 | num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 213 | } else { |
| 214 | p_obj_node = queue_item->second; |
| 215 | } |
| 216 | p_obj_node->object_type = kVulkanObjectTypeQueue; |
| 217 | p_obj_node->status = OBJSTATUS_NONE; |
| 218 | p_obj_node->handle = HandleToUint64(vkObj); |
| 219 | } |
| 220 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 221 | void ObjectLifetimes::CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 222 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 223 | pNewObjNode->object_type = kVulkanObjectTypeImage; |
| 224 | pNewObjNode->status = OBJSTATUS_NONE; |
| 225 | pNewObjNode->handle = HandleToUint64(swapchain_image); |
| 226 | pNewObjNode->parent_object = HandleToUint64(swapchain); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 227 | swapchainImageMap[HandleToUint64(swapchain_image)] = pNewObjNode; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 228 | } |
| 229 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 230 | bool ObjectLifetimes::DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code) { |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 231 | bool skip = false; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 232 | for (const auto &item : object_map[object_type]) { |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 233 | const ObjTrackState *object_info = item.second; |
locke-lunarg | 9edc281 | 2019-06-17 23:18:52 -0600 | [diff] [blame] | 234 | skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], object_info->handle, |
| 235 | error_code, "OBJ ERROR : For %s, %s has not been destroyed.", report_data->FormatHandle(device).c_str(), |
| 236 | report_data->FormatHandle(ObjTrackStateTypedHandle(*object_info)).c_str()); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 237 | } |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 238 | return skip; |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 239 | } |
| 240 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 241 | void ObjectLifetimes::DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 242 | while (!object_map[object_type].empty()) { |
| 243 | auto item = object_map[object_type].begin(); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 244 | |
| 245 | ObjTrackState *object_info = item->second; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 246 | DestroyObjectSilently(object_info->handle, object_type); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 250 | bool ObjectLifetimes::PreCallValidateDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 251 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 252 | auto lock = read_shared_lock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 253 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 254 | // We validate here for coverage, though we'd not have made it this for with a bad instance. |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 255 | skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, true, "VUID-vkDestroyInstance-instance-parameter", |
| 256 | kVUIDUndefined); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 257 | |
| 258 | // Validate that child devices have been destroyed |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 259 | for (const auto &iit : object_map[kVulkanObjectTypeDevice]) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 260 | ObjTrackState *pNode = iit.second; |
| 261 | |
| 262 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
| 263 | VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[pNode->object_type]; |
| 264 | |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 265 | skip |= |
| 266 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, pNode->handle, kVUID_ObjectTracker_ObjectLeak, |
| 267 | "OBJ ERROR : %s object %s has not been destroyed.", string_VkDebugReportObjectTypeEXT(debug_object_type), |
| 268 | report_data->FormatHandle(ObjTrackStateTypedHandle(*pNode)).c_str()); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 269 | |
| 270 | // Report any remaining objects in LL |
| 271 | skip |= ReportUndestroyedObjects(device, "VUID-vkDestroyInstance-instance-00629"); |
| 272 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 273 | skip |= ValidateDestroyObject(instance, device, kVulkanObjectTypeDevice, pAllocator, |
| 274 | "VUID-vkDestroyInstance-instance-00630", "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 275 | } |
| 276 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 277 | ValidateDestroyObject(instance, instance, kVulkanObjectTypeInstance, pAllocator, "VUID-vkDestroyInstance-instance-00630", |
| 278 | "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 279 | |
| 280 | return skip; |
| 281 | } |
| 282 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 283 | bool ObjectLifetimes::PreCallValidateEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 284 | VkPhysicalDevice *pPhysicalDevices) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 285 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 286 | bool skip = ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 287 | "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 288 | return skip; |
| 289 | } |
| 290 | |
| 291 | void ObjectLifetimes::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 292 | VkPhysicalDevice *pPhysicalDevices, VkResult result) { |
| 293 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 294 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 295 | if (pPhysicalDevices) { |
| 296 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 297 | CreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | void ObjectLifetimes::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 303 | auto lock = write_shared_lock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 304 | // Destroy physical devices |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 305 | for (auto iit = object_map[kVulkanObjectTypePhysicalDevice].begin(); |
| 306 | iit != object_map[kVulkanObjectTypePhysicalDevice].end();) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 307 | ObjTrackState *pNode = iit->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 308 | VkPhysicalDevice physical_device = reinterpret_cast<VkPhysicalDevice>(pNode->handle); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 309 | RecordDestroyObject(instance, physical_device, kVulkanObjectTypePhysicalDevice); |
| 310 | iit = object_map[kVulkanObjectTypePhysicalDevice].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 311 | } |
| 312 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 313 | // Destroy child devices |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 314 | for (auto iit = object_map[kVulkanObjectTypeDevice].begin(); iit != object_map[kVulkanObjectTypeDevice].end();) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 315 | ObjTrackState *pNode = iit->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 316 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 317 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 318 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 319 | RecordDestroyObject(instance, device, kVulkanObjectTypeDevice); |
| 320 | iit = object_map[kVulkanObjectTypeDevice].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 321 | } |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 322 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 323 | object_map[kVulkanObjectTypeDevice].clear(); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 324 | } |
| 325 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 326 | void ObjectLifetimes::PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 327 | auto lock = write_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 328 | RecordDestroyObject(instance, instance, kVulkanObjectTypeInstance); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 329 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 330 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 331 | bool ObjectLifetimes::PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 332 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 333 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 334 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter", kVUIDUndefined); |
| 335 | skip |= ValidateDestroyObject(physical_device, device, kVulkanObjectTypeDevice, pAllocator, "VUID-vkDestroyDevice-device-00379", |
| 336 | "VUID-vkDestroyDevice-device-00380"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 337 | // Report any remaining objects associated with this VkDevice object in LL |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 338 | skip |= ReportUndestroyedObjects(device, "VUID-vkDestroyDevice-device-00378"); |
| 339 | |
| 340 | return skip; |
| 341 | } |
| 342 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 343 | void ObjectLifetimes::PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 344 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 52db235 | 2018-12-28 09:41:15 -0700 | [diff] [blame] | 345 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physical_device), layer_data_map); |
| 346 | ValidationObject *validation_data = GetValidationObject(instance_data->object_dispatch, LayerObjectTypeObjectTracker); |
| 347 | ObjectLifetimes *object_lifetimes = static_cast<ObjectLifetimes *>(validation_data); |
| 348 | object_lifetimes->RecordDestroyObject(physical_device, device, kVulkanObjectTypeDevice); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 349 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 350 | |
| 351 | // Clean up Queue's MemRef Linked Lists |
| 352 | DestroyQueueDataStructures(device); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 353 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 354 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 355 | bool ObjectLifetimes::PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, |
| 356 | VkQueue *pQueue) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 357 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 358 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 359 | skip |= |
| 360 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 361 | return skip; |
| 362 | } |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 363 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 364 | void ObjectLifetimes::PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, |
| 365 | VkQueue *pQueue) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 366 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 367 | CreateQueue(device, *pQueue); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 368 | } |
| 369 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 370 | bool ObjectLifetimes::PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 371 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 372 | return ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter", |
| 373 | kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 374 | } |
| 375 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 376 | void ObjectLifetimes::PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 377 | auto lock = write_shared_lock(); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 378 | CreateQueue(device, *pQueue); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 379 | } |
| 380 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 381 | bool ObjectLifetimes::PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 382 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 383 | uint32_t descriptorCopyCount, |
| 384 | const VkCopyDescriptorSet *pDescriptorCopies) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 385 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 386 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 387 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter", |
| 388 | kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 389 | if (pDescriptorCopies) { |
| 390 | for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { |
| 391 | if (pDescriptorCopies[idx0].dstSet) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 392 | skip |= ValidateObject(device, pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, |
| 393 | "VUID-VkCopyDescriptorSet-dstSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 394 | } |
| 395 | if (pDescriptorCopies[idx0].srcSet) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 396 | skip |= ValidateObject(device, pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, |
| 397 | "VUID-VkCopyDescriptorSet-srcSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 398 | } |
| 399 | } |
| 400 | } |
| 401 | if (pDescriptorWrites) { |
| 402 | for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { |
| 403 | skip |= ValidateDescriptorWrite(device, &pDescriptorWrites[idx1], false); |
| 404 | } |
| 405 | } |
| 406 | return skip; |
| 407 | } |
| 408 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 409 | bool ObjectLifetimes::PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 410 | VkDescriptorPoolResetFlags flags) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 411 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 412 | auto lock = read_shared_lock(); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 413 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 414 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkResetDescriptorPool-device-parameter", |
| 415 | kVUIDUndefined); |
| 416 | skip |= |
| 417 | ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 418 | "VUID-vkResetDescriptorPool-descriptorPool-parameter", "VUID-vkResetDescriptorPool-descriptorPool-parent"); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 419 | |
| 420 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 421 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 422 | ObjTrackState *pPoolNode = itr->second; |
| 423 | for (auto set : *pPoolNode->child_objects) { |
| 424 | skip |= ValidateDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 425 | kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 426 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 427 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 428 | return skip; |
| 429 | } |
| 430 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 431 | void ObjectLifetimes::PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 432 | VkDescriptorPoolResetFlags flags) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 433 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 434 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. Remove this pool's descriptor sets from |
| 435 | // our descriptorSet map. |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 436 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 437 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 438 | ObjTrackState *pPoolNode = itr->second; |
| 439 | for (auto set : *pPoolNode->child_objects) { |
| 440 | RecordDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 441 | } |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 442 | pPoolNode->child_objects->clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 443 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 444 | } |
| 445 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 446 | bool ObjectLifetimes::PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer, |
| 447 | const VkCommandBufferBeginInfo *begin_info) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 448 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 449 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 450 | skip |= ValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false, |
| 451 | "VUID-vkBeginCommandBuffer-commandBuffer-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 452 | if (begin_info) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 453 | ObjTrackState *pNode = object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 454 | if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && |
| 455 | (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 456 | skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, true, |
| 457 | "VUID-VkCommandBufferBeginInfo-flags-00055", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
| 458 | skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
| 459 | "VUID-VkCommandBufferBeginInfo-flags-00053", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 460 | } |
| 461 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 462 | return skip; |
| 463 | } |
| 464 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 465 | bool ObjectLifetimes::PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 466 | uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 467 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 468 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 469 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
| 470 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
| 471 | skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, |
| 472 | "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", "VUID-vkGetSwapchainImagesKHR-commonparent"); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 473 | return skip; |
| 474 | } |
| 475 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 476 | void ObjectLifetimes::PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 477 | VkImage *pSwapchainImages, VkResult result) { |
| 478 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 479 | auto lock = write_shared_lock(); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 480 | if (pSwapchainImages != NULL) { |
| 481 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 482 | CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 487 | bool ObjectLifetimes::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 488 | const VkAllocationCallbacks *pAllocator, |
| 489 | VkDescriptorSetLayout *pSetLayout) { |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 490 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 491 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 492 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorSetLayout-device-parameter", |
| 493 | kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 494 | if (pCreateInfo) { |
| 495 | if (pCreateInfo->pBindings) { |
| 496 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 497 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 498 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 499 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 500 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 501 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 502 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 503 | skip |= ValidateObject(device, sampler, kVulkanObjectTypeSampler, false, |
| 504 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 505 | } |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | } |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 510 | return skip; |
| 511 | } |
| 512 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 513 | void ObjectLifetimes::PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 514 | const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 515 | VkDescriptorSetLayout *pSetLayout, VkResult result) { |
| 516 | if (result != VK_SUCCESS) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 517 | auto lock = write_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 518 | CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 519 | } |
| 520 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 521 | bool ObjectLifetimes::ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 522 | bool skip = false; |
| 523 | if (pCreateInfo->pBindings) { |
| 524 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 525 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 526 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 527 | skip |= |
| 528 | ValidateObject(device, pCreateInfo->pBindings[index1].pImmutableSamplers[index2], kVulkanObjectTypeSampler, |
| 529 | true, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 530 | } |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | return skip; |
| 535 | } |
| 536 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 537 | bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupport(VkDevice device, |
| 538 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 539 | VkDescriptorSetLayoutSupport *pSupport) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 540 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 541 | bool skip = ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 542 | "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 543 | if (pCreateInfo) { |
| 544 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
| 545 | } |
| 546 | return skip; |
| 547 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 548 | bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupportKHR(VkDevice device, |
| 549 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 550 | VkDescriptorSetLayoutSupport *pSupport) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 551 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 552 | bool skip = ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 553 | "VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 554 | if (pCreateInfo) { |
| 555 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
| 556 | } |
| 557 | return skip; |
| 558 | } |
| 559 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 560 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 561 | uint32_t *pQueueFamilyPropertyCount, |
| 562 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 563 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 564 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 565 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 566 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame] | 567 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 568 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 569 | uint32_t *pQueueFamilyPropertyCount, |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame^] | 570 | VkQueueFamilyProperties *pQueueFamilyProperties) {} |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 571 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 572 | void ObjectLifetimes::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 573 | VkInstance *pInstance, VkResult result) { |
| 574 | if (result != VK_SUCCESS) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 575 | auto lock = write_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 576 | CreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 577 | } |
| 578 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 579 | bool ObjectLifetimes::PreCallValidateAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 580 | VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 581 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 582 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 583 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", |
| 584 | kVUIDUndefined); |
| 585 | skip |= ValidateObject(device, pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
| 586 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 587 | return skip; |
| 588 | } |
| 589 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 590 | void ObjectLifetimes::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 591 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
| 592 | if (result != VK_SUCCESS) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 593 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 594 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
| 595 | AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
| 596 | } |
| 597 | } |
| 598 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 599 | bool ObjectLifetimes::PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 600 | VkDescriptorSet *pDescriptorSets) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 601 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 602 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 603 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", |
| 604 | kVUIDUndefined); |
| 605 | skip |= ValidateObject(device, pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 606 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
| 607 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 608 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 609 | skip |= ValidateObject(device, pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
| 610 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 611 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 612 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 613 | return skip; |
| 614 | } |
| 615 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 616 | void ObjectLifetimes::PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 617 | VkDescriptorSet *pDescriptorSets, VkResult result) { |
| 618 | if (result != VK_SUCCESS) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 619 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 620 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 621 | AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 622 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 623 | } |
| 624 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 625 | bool ObjectLifetimes::PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 626 | const VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 627 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 628 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 629 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", |
| 630 | kVUIDUndefined); |
| 631 | skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, |
| 632 | "VUID-vkFreeCommandBuffers-commandPool-parameter", "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 633 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 634 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
| 635 | skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 636 | skip |= ValidateDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, |
| 637 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 638 | } |
| 639 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 640 | return skip; |
| 641 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 642 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 643 | void ObjectLifetimes::PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 644 | const VkCommandBuffer *pCommandBuffers) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 645 | auto lock = write_shared_lock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 646 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 647 | RecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 648 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 649 | } |
| 650 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 651 | bool ObjectLifetimes::PreCallValidateDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 652 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 653 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 654 | return ValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, |
| 655 | "VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 656 | } |
| 657 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 658 | void ObjectLifetimes::PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 659 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 660 | auto lock = write_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 661 | RecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR); |
| 662 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = swapchainImageMap.begin(); |
| 663 | while (itr != swapchainImageMap.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 664 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 665 | if (pNode->parent_object == HandleToUint64(swapchain)) { |
| 666 | delete pNode; |
| 667 | auto delete_item = itr++; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 668 | swapchainImageMap.erase(delete_item); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 669 | } else { |
| 670 | ++itr; |
| 671 | } |
| 672 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 673 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 674 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 675 | bool ObjectLifetimes::PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 676 | uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 677 | auto lock = read_shared_lock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 678 | bool skip = false; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 679 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", |
| 680 | kVUIDUndefined); |
| 681 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 682 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 683 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 684 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
| 685 | skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 686 | skip |= ValidateDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 687 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 688 | } |
| 689 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 690 | return skip; |
| 691 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 692 | void ObjectLifetimes::PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 693 | const VkDescriptorSet *pDescriptorSets) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 694 | auto lock = write_shared_lock(); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 695 | ObjTrackState *pPoolNode = nullptr; |
| 696 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 697 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 698 | pPoolNode = itr->second; |
| 699 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 700 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 701 | RecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 702 | if (pPoolNode) { |
| 703 | pPoolNode->child_objects->erase(HandleToUint64(pDescriptorSets[i])); |
| 704 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 705 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 706 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 707 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 708 | bool ObjectLifetimes::PreCallValidateDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 709 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 710 | auto lock = read_shared_lock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 711 | bool skip = false; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 712 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", |
| 713 | kVUIDUndefined); |
| 714 | skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
| 715 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
| 716 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 717 | |
| 718 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 719 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 720 | ObjTrackState *pPoolNode = itr->second; |
| 721 | for (auto set : *pPoolNode->child_objects) { |
| 722 | skip |= ValidateDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 723 | kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 724 | } |
| 725 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 726 | skip |= ValidateDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
| 727 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", |
| 728 | "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 729 | return skip; |
| 730 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 731 | void ObjectLifetimes::PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 732 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 733 | auto lock = write_shared_lock(); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 734 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 735 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 736 | ObjTrackState *pPoolNode = itr->second; |
| 737 | for (auto set : *pPoolNode->child_objects) { |
| 738 | RecordDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 739 | } |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 740 | pPoolNode->child_objects->clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 741 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 742 | RecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 743 | } |
| 744 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 745 | bool ObjectLifetimes::PreCallValidateDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 746 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 747 | auto lock = read_shared_lock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 748 | bool skip = false; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 749 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", |
| 750 | kVUIDUndefined); |
| 751 | skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, true, |
| 752 | "VUID-vkDestroyCommandPool-commandPool-parameter", "VUID-vkDestroyCommandPool-commandPool-parent"); |
| 753 | auto itr = object_map[kVulkanObjectTypeCommandBuffer].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 754 | auto del_itr = itr; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 755 | while (itr != object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 756 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 757 | del_itr = itr++; |
| 758 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
| 759 | skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 760 | skip |= ValidateDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), |
| 761 | kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 762 | } |
| 763 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 764 | skip |= ValidateDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
| 765 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 766 | return skip; |
| 767 | } |
| 768 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 769 | void ObjectLifetimes::PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 770 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 771 | auto lock = write_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 772 | auto itr = object_map[kVulkanObjectTypeCommandBuffer].begin(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 773 | auto del_itr = itr; |
| 774 | // A CommandPool's cmd buffers are implicitly deleted when pool is deleted. Remove this pool's cmdBuffers from cmd buffer map. |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 775 | while (itr != object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 776 | ObjTrackState *pNode = (*itr).second; |
| 777 | del_itr = itr++; |
| 778 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 779 | RecordDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 780 | } |
| 781 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 782 | RecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 783 | } |
| 784 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 785 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 786 | uint32_t *pQueueFamilyPropertyCount, |
| 787 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 788 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 789 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 790 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 791 | } |
| 792 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 793 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, |
| 794 | uint32_t *pQueueFamilyPropertyCount, |
| 795 | VkQueueFamilyProperties2 *pQueueFamilyProperties) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 796 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 797 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Shannon McPherson | 3ea6513 | 2018-12-05 10:37:39 -0700 | [diff] [blame] | 798 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 802 | uint32_t *pQueueFamilyPropertyCount, |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame^] | 803 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {} |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 804 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 805 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR( |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame^] | 806 | VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {} |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 807 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 808 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, |
| 809 | uint32_t *pPropertyCount, |
| 810 | VkDisplayPropertiesKHR *pProperties) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 811 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 812 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 813 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 817 | VkDisplayPropertiesKHR *pProperties, VkResult result) { |
| 818 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 819 | auto lock = write_shared_lock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 820 | if (pProperties) { |
| 821 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 822 | CreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 823 | } |
| 824 | } |
| 825 | } |
| 826 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 827 | bool ObjectLifetimes::PreCallValidateGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 828 | uint32_t *pPropertyCount, |
| 829 | VkDisplayModePropertiesKHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 830 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 831 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 832 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 833 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
| 834 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 835 | "VUID-vkGetDisplayModePropertiesKHR-display-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 836 | |
| 837 | return skip; |
| 838 | } |
| 839 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 840 | void ObjectLifetimes::PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 841 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties, |
| 842 | VkResult result) { |
| 843 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 844 | auto lock = write_shared_lock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 845 | if (pProperties) { |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 846 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 847 | CreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 848 | } |
| 849 | } |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 850 | } |
| 851 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 852 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 853 | uint32_t *pPropertyCount, |
| 854 | VkDisplayProperties2KHR *pProperties) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 855 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 856 | return ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 857 | "VUID-vkGetPhysicalDeviceDisplayProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 858 | } |
| 859 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 860 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 861 | uint32_t *pPropertyCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 862 | VkDisplayProperties2KHR *pProperties, VkResult result) { |
| 863 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 864 | auto lock = write_shared_lock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 865 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 866 | CreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 867 | } |
| 868 | } |
| 869 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 870 | bool ObjectLifetimes::PreCallValidateGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 871 | uint32_t *pPropertyCount, |
| 872 | VkDisplayModeProperties2KHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 873 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 874 | auto lock = read_shared_lock(); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 875 | skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 876 | "VUID-vkGetDisplayModeProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
| 877 | skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 878 | "VUID-vkGetDisplayModeProperties2KHR-display-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 879 | |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 880 | return skip; |
| 881 | } |
| 882 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 883 | void ObjectLifetimes::PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 884 | uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties, |
| 885 | VkResult result) { |
| 886 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 887 | auto lock = write_shared_lock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 888 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 889 | CreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, |
| 890 | nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 891 | } |
| 892 | } |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 893 | |
| 894 | bool ObjectLifetimes::PreCallValidateAcquirePerformanceConfigurationINTEL( |
| 895 | VkDevice device, const VkPerformanceConfigurationAcquireInfoINTEL *pAcquireInfo, |
| 896 | VkPerformanceConfigurationINTEL *pConfiguration) { |
| 897 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 898 | auto lock = read_shared_lock(); |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 899 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 900 | "VUID-vkAcquirePerformanceConfigurationINTEL-device-parameter", kVUIDUndefined); |
| 901 | |
| 902 | return skip; |
| 903 | } |
| 904 | |
| 905 | bool ObjectLifetimes::PreCallValidateReleasePerformanceConfigurationINTEL(VkDevice device, |
| 906 | VkPerformanceConfigurationINTEL configuration) { |
| 907 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 908 | auto lock = read_shared_lock(); |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 909 | skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 910 | "VUID-vkReleasePerformanceConfigurationINTEL-device-parameter", kVUIDUndefined); |
| 911 | |
| 912 | return skip; |
| 913 | } |
| 914 | |
| 915 | bool ObjectLifetimes::PreCallValidateQueueSetPerformanceConfigurationINTEL(VkQueue queue, |
| 916 | VkPerformanceConfigurationINTEL configuration) { |
| 917 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 918 | auto lock = read_shared_lock(); |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 919 | skip |= |
| 920 | ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueSetPerformanceConfigurationINTEL-queue-parameter", |
| 921 | "VUID-vkQueueSetPerformanceConfigurationINTEL-commonparent"); |
| 922 | |
| 923 | return skip; |
| 924 | } |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 925 | |
| 926 | bool ObjectLifetimes::PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 927 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer) { |
| 928 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 929 | auto lock = read_shared_lock(); |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 930 | skip |= |
| 931 | ValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateFramebuffer-device-parameter", kVUIDUndefined); |
| 932 | if (pCreateInfo) { |
| 933 | skip |= ValidateObject(device, pCreateInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
| 934 | "VUID-VkFramebufferCreateInfo-renderPass-parameter", "VUID-VkFramebufferCreateInfo-commonparent"); |
| 935 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) { |
| 936 | for (uint32_t index1 = 0; index1 < pCreateInfo->attachmentCount; ++index1) { |
| 937 | skip |= ValidateObject(device, pCreateInfo->pAttachments[index1], kVulkanObjectTypeImageView, true, kVUIDUndefined, |
| 938 | "VUID-VkFramebufferCreateInfo-commonparent"); |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | return skip; |
| 944 | } |
| 945 | |
| 946 | void ObjectLifetimes::PostCallRecordCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 947 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer, |
| 948 | VkResult result) { |
| 949 | if (result != VK_SUCCESS) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 950 | auto lock = write_shared_lock(); |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 951 | CreateObject(device, *pFramebuffer, kVulkanObjectTypeFramebuffer, pAllocator); |
| 952 | } |