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