Ben Clayton | 65576d6 | 2021-04-16 10:46:07 +0100 | [diff] [blame] | 1 | /* Copyright (c) 2015-2021 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2021 Valve Corporation |
| 3 | * Copyright (c) 2015-2021 LunarG, Inc. |
| 4 | * Copyright (C) 2015-2021 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, |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 63 | const char *wrong_device_code) const { |
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 | } |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 69 | return LogError(instance, invalid_handle_code, "Invalid %s.", report_data->FormatHandle(device_typed).c_str()); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Ben Clayton | 65576d6 | 2021-04-16 10:46:07 +0100 | [diff] [blame] | 72 | bool ObjectLifetimes::ValidateAnonymousObject(uint64_t object, VkObjectType core_object_type, bool null_allowed, |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 73 | const char *invalid_handle_code, const char *wrong_device_code) const { |
Ben Clayton | 65576d6 | 2021-04-16 10:46:07 +0100 | [diff] [blame] | 74 | if (null_allowed && (object == HandleToUint64(VK_NULL_HANDLE))) return false; |
Mark Lobodzinski | 8af6bb4 | 2019-09-11 14:37:29 -0600 | [diff] [blame] | 75 | auto object_type = ConvertCoreObjectToVulkanObject(core_object_type); |
| 76 | |
| 77 | if (object_type == kVulkanObjectTypeDevice) { |
Ben Clayton | 65576d6 | 2021-04-16 10:46:07 +0100 | [diff] [blame] | 78 | return ValidateDeviceObject(VulkanTypedHandle(reinterpret_cast<VkDevice>(object), object_type), invalid_handle_code, |
Mark Lobodzinski | 8af6bb4 | 2019-09-11 14:37:29 -0600 | [diff] [blame] | 79 | wrong_device_code); |
| 80 | } |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 81 | |
Ben Clayton | 65576d6 | 2021-04-16 10:46:07 +0100 | [diff] [blame] | 82 | return CheckObjectValidity(object, object_type, null_allowed, invalid_handle_code, wrong_device_code); |
Mark Lobodzinski | 8af6bb4 | 2019-09-11 14:37:29 -0600 | [diff] [blame] | 83 | } |
| 84 | |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 85 | void ObjectLifetimes::AllocateCommandBuffer(const VkCommandPool command_pool, const VkCommandBuffer command_buffer, |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 86 | VkCommandBufferLevel level) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 87 | auto new_obj_node = std::make_shared<ObjTrackState>(); |
| 88 | new_obj_node->object_type = kVulkanObjectTypeCommandBuffer; |
| 89 | new_obj_node->handle = HandleToUint64(command_buffer); |
| 90 | new_obj_node->parent_object = HandleToUint64(command_pool); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 91 | if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 92 | new_obj_node->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 93 | } else { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 94 | new_obj_node->status = OBJSTATUS_NONE; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 95 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 96 | InsertObject(object_map[kVulkanObjectTypeCommandBuffer], command_buffer, kVulkanObjectTypeCommandBuffer, new_obj_node); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 97 | num_objects[kVulkanObjectTypeCommandBuffer]++; |
| 98 | num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 99 | } |
| 100 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 101 | bool ObjectLifetimes::ValidateCommandBuffer(VkCommandPool command_pool, VkCommandBuffer command_buffer) const { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 102 | bool skip = false; |
| 103 | uint64_t object_handle = HandleToUint64(command_buffer); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 104 | auto iter = object_map[kVulkanObjectTypeCommandBuffer].find(object_handle); |
| 105 | if (iter != object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 106 | auto node = iter->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 107 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 108 | if (node->parent_object != HandleToUint64(command_pool)) { |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 109 | // We know that the parent *must* be a command pool |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 110 | const auto parent_pool = CastFromUint64<VkCommandPool>(node->parent_object); |
Mark Lobodzinski | b03bdac | 2020-03-16 18:32:44 -0600 | [diff] [blame] | 111 | LogObjectList objlist(command_buffer); |
| 112 | objlist.add(parent_pool); |
| 113 | objlist.add(command_pool); |
| 114 | skip |= LogError(objlist, "VUID-vkFreeCommandBuffers-pCommandBuffers-parent", |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 115 | "FreeCommandBuffers is attempting to free %s belonging to %s from %s).", |
| 116 | report_data->FormatHandle(command_buffer).c_str(), report_data->FormatHandle(parent_pool).c_str(), |
| 117 | report_data->FormatHandle(command_pool).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 118 | } |
| 119 | } else { |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 120 | skip |= LogError(command_buffer, "VUID-vkFreeCommandBuffers-pCommandBuffers-00048", "Invalid %s.", |
| 121 | report_data->FormatHandle(command_buffer).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 122 | } |
| 123 | return skip; |
| 124 | } |
| 125 | |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 126 | void ObjectLifetimes::AllocateDescriptorSet(VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 127 | auto new_obj_node = std::make_shared<ObjTrackState>(); |
| 128 | new_obj_node->object_type = kVulkanObjectTypeDescriptorSet; |
| 129 | new_obj_node->status = OBJSTATUS_NONE; |
| 130 | new_obj_node->handle = HandleToUint64(descriptor_set); |
| 131 | new_obj_node->parent_object = HandleToUint64(descriptor_pool); |
| 132 | InsertObject(object_map[kVulkanObjectTypeDescriptorSet], descriptor_set, kVulkanObjectTypeDescriptorSet, new_obj_node); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 133 | num_objects[kVulkanObjectTypeDescriptorSet]++; |
| 134 | num_total_objects++; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 135 | |
| 136 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptor_pool)); |
| 137 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 138 | itr->second->child_objects->insert(HandleToUint64(descriptor_set)); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 139 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 140 | } |
| 141 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 142 | bool ObjectLifetimes::ValidateDescriptorSet(VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) const { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 143 | bool skip = false; |
| 144 | uint64_t object_handle = HandleToUint64(descriptor_set); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 145 | auto ds_item = object_map[kVulkanObjectTypeDescriptorSet].find(object_handle); |
| 146 | if (ds_item != object_map[kVulkanObjectTypeDescriptorSet].end()) { |
| 147 | if (ds_item->second->parent_object != HandleToUint64(descriptor_pool)) { |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 148 | // We know that the parent *must* be a descriptor pool |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 149 | const auto parent_pool = CastFromUint64<VkDescriptorPool>(ds_item->second->parent_object); |
Mark Lobodzinski | b03bdac | 2020-03-16 18:32:44 -0600 | [diff] [blame] | 150 | LogObjectList objlist(descriptor_set); |
| 151 | objlist.add(parent_pool); |
| 152 | objlist.add(descriptor_pool); |
| 153 | skip |= LogError(objlist, "VUID-vkFreeDescriptorSets-pDescriptorSets-parent", |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 154 | "FreeDescriptorSets is attempting to free %s" |
| 155 | " belonging to %s from %s).", |
| 156 | report_data->FormatHandle(descriptor_set).c_str(), report_data->FormatHandle(parent_pool).c_str(), |
| 157 | report_data->FormatHandle(descriptor_pool).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 158 | } |
| 159 | } else { |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 160 | skip |= LogError(descriptor_set, "VUID-vkFreeDescriptorSets-pDescriptorSets-00310", "Invalid %s.", |
| 161 | report_data->FormatHandle(descriptor_set).c_str()); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 162 | } |
| 163 | return skip; |
| 164 | } |
| 165 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 166 | bool ObjectLifetimes::ValidateDescriptorWrite(VkWriteDescriptorSet const *desc, bool isPush) const { |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 167 | bool skip = false; |
| 168 | |
| 169 | if (!isPush && desc->dstSet) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 170 | skip |= ValidateObject(desc->dstSet, kVulkanObjectTypeDescriptorSet, false, "VUID-VkWriteDescriptorSet-dstSet-00320", |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 171 | "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 175 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 176 | for (uint32_t idx2 = 0; idx2 < desc->descriptorCount; ++idx2) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 177 | skip |= ValidateObject(desc->pTexelBufferView[idx2], kVulkanObjectTypeBufferView, true, |
| 178 | "VUID-VkWriteDescriptorSet-descriptorType-02994", "VUID-VkWriteDescriptorSet-commonparent"); |
| 179 | if (!null_descriptor_enabled && desc->pTexelBufferView[idx2] == VK_NULL_HANDLE) { |
| 180 | skip |= LogError(desc->dstSet, "VUID-VkWriteDescriptorSet-descriptorType-02995", |
| 181 | "VkWriteDescriptorSet: texel buffer view must not be VK_NULL_HANDLE."); |
| 182 | } |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | |
| 186 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 187 | (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] | 188 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 189 | for (uint32_t idx3 = 0; idx3 < desc->descriptorCount; ++idx3) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 190 | skip |= ValidateObject(desc->pImageInfo[idx3].imageView, kVulkanObjectTypeImageView, true, |
| 191 | "VUID-VkWriteDescriptorSet-descriptorType-02996", "VUID-VkDescriptorImageInfo-commonparent"); |
| 192 | if (!null_descriptor_enabled && desc->pImageInfo[idx3].imageView == VK_NULL_HANDLE) { |
| 193 | skip |= LogError(desc->dstSet, "VUID-VkWriteDescriptorSet-descriptorType-02997", |
| 194 | "VkWriteDescriptorSet: image view must not be VK_NULL_HANDLE."); |
| 195 | } |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | |
| 199 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 200 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 201 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 202 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 203 | for (uint32_t idx4 = 0; idx4 < desc->descriptorCount; ++idx4) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 204 | skip |= ValidateObject(desc->pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer, true, |
Jeff Bolz | c8b18a4 | 2020-04-05 16:47:11 -0500 | [diff] [blame] | 205 | "VUID-VkDescriptorBufferInfo-buffer-parameter", kVUIDUndefined); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 206 | if (!null_descriptor_enabled && desc->pBufferInfo[idx4].buffer == VK_NULL_HANDLE) { |
| 207 | skip |= LogError(desc->dstSet, "VUID-VkDescriptorBufferInfo-buffer-02998", |
| 208 | "VkWriteDescriptorSet: buffer must not be VK_NULL_HANDLE."); |
| 209 | } |
Jeff Bolz | c8b18a4 | 2020-04-05 16:47:11 -0500 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | |
| 213 | if (desc->descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 214 | const auto *acc_info = LvlFindInChain<VkWriteDescriptorSetAccelerationStructureKHR>(desc->pNext); |
Jeff Bolz | c8b18a4 | 2020-04-05 16:47:11 -0500 | [diff] [blame] | 215 | for (uint32_t idx5 = 0; idx5 < desc->descriptorCount; ++idx5) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 216 | skip |= ValidateObject(acc_info->pAccelerationStructures[idx5], kVulkanObjectTypeAccelerationStructureKHR, true, |
Jeff Bolz | c8b18a4 | 2020-04-05 16:47:11 -0500 | [diff] [blame] | 217 | "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-parameter", |
| 218 | kVUIDUndefined); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 219 | } |
| 220 | } |
| 221 | |
| 222 | return skip; |
| 223 | } |
| 224 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 225 | bool ObjectLifetimes::PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, |
| 226 | VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 227 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 228 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 229 | skip |= ValidateObject(commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 230 | "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 231 | skip |= ValidateObject(layout, kVulkanObjectTypePipelineLayout, false, "VUID-vkCmdPushDescriptorSetKHR-layout-parameter", |
| 232 | "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 233 | if (pDescriptorWrites) { |
| 234 | for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 235 | skip |= ValidateDescriptorWrite(&pDescriptorWrites[index0], true); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 236 | } |
| 237 | } |
| 238 | return skip; |
| 239 | } |
| 240 | |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 241 | void ObjectLifetimes::CreateQueue(VkQueue vkObj) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 242 | std::shared_ptr<ObjTrackState> p_obj_node = NULL; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 243 | auto queue_item = object_map[kVulkanObjectTypeQueue].find(HandleToUint64(vkObj)); |
| 244 | if (queue_item == object_map[kVulkanObjectTypeQueue].end()) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 245 | p_obj_node = std::make_shared<ObjTrackState>(); |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 246 | InsertObject(object_map[kVulkanObjectTypeQueue], vkObj, kVulkanObjectTypeQueue, p_obj_node); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 247 | num_objects[kVulkanObjectTypeQueue]++; |
| 248 | num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 249 | } else { |
| 250 | p_obj_node = queue_item->second; |
| 251 | } |
| 252 | p_obj_node->object_type = kVulkanObjectTypeQueue; |
| 253 | p_obj_node->status = OBJSTATUS_NONE; |
| 254 | p_obj_node->handle = HandleToUint64(vkObj); |
| 255 | } |
| 256 | |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 257 | void ObjectLifetimes::CreateSwapchainImageObject(VkImage swapchain_image, VkSwapchainKHR swapchain) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 258 | if (!swapchainImageMap.contains(HandleToUint64(swapchain_image))) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 259 | auto new_obj_node = std::make_shared<ObjTrackState>(); |
| 260 | new_obj_node->object_type = kVulkanObjectTypeImage; |
| 261 | new_obj_node->status = OBJSTATUS_NONE; |
| 262 | new_obj_node->handle = HandleToUint64(swapchain_image); |
| 263 | new_obj_node->parent_object = HandleToUint64(swapchain); |
| 264 | InsertObject(swapchainImageMap, swapchain_image, kVulkanObjectTypeImage, new_obj_node); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 265 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 266 | } |
| 267 | |
Mark Lobodzinski | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 268 | bool ObjectLifetimes::ReportLeakedInstanceObjects(VkInstance instance, VulkanObjectType object_type, |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 269 | const std::string &error_code) const { |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 270 | bool skip = false; |
| 271 | |
| 272 | auto snapshot = object_map[object_type].snapshot(); |
| 273 | for (const auto &item : snapshot) { |
| 274 | const auto object_info = item.second; |
Mark Lobodzinski | b03bdac | 2020-03-16 18:32:44 -0600 | [diff] [blame] | 275 | LogObjectList objlist(instance); |
| 276 | objlist.add(ObjTrackStateTypedHandle(*object_info)); |
| 277 | skip |= LogError(objlist, error_code, "OBJ ERROR : For %s, %s has not been destroyed.", |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 278 | report_data->FormatHandle(instance).c_str(), |
| 279 | report_data->FormatHandle(ObjTrackStateTypedHandle(*object_info)).c_str()); |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 280 | } |
| 281 | return skip; |
| 282 | } |
| 283 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 284 | bool ObjectLifetimes::ReportLeakedDeviceObjects(VkDevice device, VulkanObjectType object_type, |
| 285 | const std::string &error_code) const { |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 286 | bool skip = false; |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 287 | |
| 288 | auto snapshot = object_map[object_type].snapshot(); |
| 289 | for (const auto &item : snapshot) { |
| 290 | const auto object_info = item.second; |
Mark Lobodzinski | b03bdac | 2020-03-16 18:32:44 -0600 | [diff] [blame] | 291 | LogObjectList objlist(device); |
| 292 | objlist.add(ObjTrackStateTypedHandle(*object_info)); |
| 293 | skip |= LogError(objlist, error_code, "OBJ ERROR : For %s, %s has not been destroyed.", |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 294 | report_data->FormatHandle(device).c_str(), |
| 295 | report_data->FormatHandle(ObjTrackStateTypedHandle(*object_info)).c_str()); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 296 | } |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 297 | return skip; |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 300 | bool ObjectLifetimes::PreCallValidateDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) const { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 301 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 302 | |
Petr Kraus | 3e6cd03 | 2020-04-14 20:41:16 +0200 | [diff] [blame] | 303 | // We validate here for coverage, though we'd not have made it this far with a bad instance. |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 304 | skip |= ValidateObject(instance, kVulkanObjectTypeInstance, true, "VUID-vkDestroyInstance-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 305 | |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 306 | auto snapshot = object_map[kVulkanObjectTypeDevice].snapshot(); |
| 307 | for (const auto &iit : snapshot) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 308 | auto node = iit.second; |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 309 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 310 | VkDevice device = reinterpret_cast<VkDevice>(node->handle); |
| 311 | VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[node->object_type]; |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 312 | |
Mark Lobodzinski | cb4784a | 2020-01-29 15:34:59 -0700 | [diff] [blame] | 313 | skip |= LogError(device, kVUID_ObjectTracker_ObjectLeak, "OBJ ERROR : %s object %s has not been destroyed.", |
| 314 | string_VkDebugReportObjectTypeEXT(debug_object_type), |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 315 | report_data->FormatHandle(ObjTrackStateTypedHandle(*node)).c_str()); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 316 | |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 317 | // Throw errors if any device objects belonging to this instance have not been destroyed |
Mark Lobodzinski | 0754809 | 2019-12-17 12:17:12 -0700 | [diff] [blame] | 318 | auto device_layer_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 319 | auto obj_lifetimes_data = reinterpret_cast<ObjectLifetimes *>( |
| 320 | device_layer_data->GetValidationObject(device_layer_data->object_dispatch, LayerObjectTypeObjectTracker)); |
| 321 | skip |= obj_lifetimes_data->ReportUndestroyedDeviceObjects(device, "VUID-vkDestroyDevice-device-00378"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 322 | |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 323 | skip |= ValidateDestroyObject(device, kVulkanObjectTypeDevice, pAllocator, "VUID-vkDestroyInstance-instance-00630", |
| 324 | "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 325 | } |
| 326 | |
Petr Kraus | 3e6cd03 | 2020-04-14 20:41:16 +0200 | [diff] [blame] | 327 | skip |= ValidateDestroyObject(instance, kVulkanObjectTypeInstance, pAllocator, "VUID-vkDestroyInstance-instance-00630", |
| 328 | "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 329 | |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 330 | // Report any remaining instance objects |
| 331 | skip |= ReportUndestroyedInstanceObjects(instance, "VUID-vkDestroyInstance-instance-00629"); |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 332 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 333 | return skip; |
| 334 | } |
| 335 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 336 | bool ObjectLifetimes::PreCallValidateEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 337 | VkPhysicalDevice *pPhysicalDevices) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 338 | bool skip = ValidateObject(instance, kVulkanObjectTypeInstance, false, "VUID-vkEnumeratePhysicalDevices-instance-parameter", |
| 339 | kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 340 | return skip; |
| 341 | } |
| 342 | |
| 343 | void ObjectLifetimes::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 344 | VkPhysicalDevice *pPhysicalDevices, VkResult result) { |
| 345 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 346 | if (pPhysicalDevices) { |
| 347 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Mark Lobodzinski | 1e76a7d | 2019-09-11 11:11:46 -0600 | [diff] [blame] | 348 | CreateObject(pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | void ObjectLifetimes::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 354 | // Destroy physical devices |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 355 | auto snapshot = object_map[kVulkanObjectTypePhysicalDevice].snapshot(); |
| 356 | for (const auto &iit : snapshot) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 357 | auto node = iit.second; |
| 358 | VkPhysicalDevice physical_device = reinterpret_cast<VkPhysicalDevice>(node->handle); |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 359 | RecordDestroyObject(physical_device, kVulkanObjectTypePhysicalDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 360 | } |
| 361 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 362 | // Destroy child devices |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 363 | auto snapshot2 = object_map[kVulkanObjectTypeDevice].snapshot(); |
| 364 | for (const auto &iit : snapshot2) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 365 | auto node = iit.second; |
| 366 | VkDevice device = reinterpret_cast<VkDevice>(node->handle); |
Mark Lobodzinski | e65acca | 2019-09-11 12:06:17 -0600 | [diff] [blame] | 367 | DestroyLeakedInstanceObjects(); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 368 | |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 369 | RecordDestroyObject(device, kVulkanObjectTypeDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 370 | } |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 371 | } |
| 372 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 373 | void ObjectLifetimes::PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 374 | RecordDestroyObject(instance, kVulkanObjectTypeInstance); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 375 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 376 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 377 | bool ObjectLifetimes::PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) const { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 378 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 379 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 380 | skip |= ValidateDestroyObject(device, kVulkanObjectTypeDevice, pAllocator, "VUID-vkDestroyDevice-device-00379", |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 381 | "VUID-vkDestroyDevice-device-00380"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 382 | // Report any remaining objects associated with this VkDevice object in LL |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 383 | skip |= ReportUndestroyedDeviceObjects(device, "VUID-vkDestroyDevice-device-00378"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 384 | |
| 385 | return skip; |
| 386 | } |
| 387 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 388 | void ObjectLifetimes::PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 52db235 | 2018-12-28 09:41:15 -0700 | [diff] [blame] | 389 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physical_device), layer_data_map); |
| 390 | ValidationObject *validation_data = GetValidationObject(instance_data->object_dispatch, LayerObjectTypeObjectTracker); |
| 391 | ObjectLifetimes *object_lifetimes = static_cast<ObjectLifetimes *>(validation_data); |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 392 | object_lifetimes->RecordDestroyObject(device, kVulkanObjectTypeDevice); |
Mark Lobodzinski | e65acca | 2019-09-11 12:06:17 -0600 | [diff] [blame] | 393 | DestroyLeakedDeviceObjects(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 394 | |
| 395 | // Clean up Queue's MemRef Linked Lists |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 396 | DestroyQueueDataStructures(); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 397 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 398 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 399 | bool ObjectLifetimes::PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 400 | VkQueue *pQueue) const { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 401 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 402 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 403 | return skip; |
| 404 | } |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 405 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 406 | void ObjectLifetimes::PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, |
| 407 | VkQueue *pQueue) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 408 | auto lock = WriteSharedLock(); |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 409 | CreateQueue(*pQueue); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 410 | } |
| 411 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 412 | bool ObjectLifetimes::PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 413 | return ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 414 | } |
| 415 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 416 | void ObjectLifetimes::PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 417 | auto lock = WriteSharedLock(); |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 418 | CreateQueue(*pQueue); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 419 | } |
| 420 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 421 | bool ObjectLifetimes::PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 422 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 423 | uint32_t descriptorCopyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 424 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 425 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 426 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 427 | if (pDescriptorCopies) { |
| 428 | for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { |
| 429 | if (pDescriptorCopies[idx0].dstSet) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 430 | skip |= ValidateObject(pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 431 | "VUID-VkCopyDescriptorSet-dstSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 432 | } |
| 433 | if (pDescriptorCopies[idx0].srcSet) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 434 | skip |= ValidateObject(pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 435 | "VUID-VkCopyDescriptorSet-srcSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | } |
| 439 | if (pDescriptorWrites) { |
| 440 | for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 441 | skip |= ValidateDescriptorWrite(&pDescriptorWrites[idx1], false); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | return skip; |
| 445 | } |
| 446 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 447 | bool ObjectLifetimes::PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 448 | VkDescriptorPoolResetFlags flags) const { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 449 | bool skip = false; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 450 | auto lock = ReadSharedLock(); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 451 | |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 452 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkResetDescriptorPool-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 453 | skip |= |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 454 | ValidateObject(descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 455 | "VUID-vkResetDescriptorPool-descriptorPool-parameter", "VUID-vkResetDescriptorPool-descriptorPool-parent"); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 456 | |
| 457 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 458 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 459 | auto pool_node = itr->second; |
| 460 | for (auto set : *pool_node->child_objects) { |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 461 | skip |= ValidateDestroyObject((VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 462 | kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 463 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 464 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 465 | return skip; |
| 466 | } |
| 467 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 468 | void ObjectLifetimes::PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 469 | VkDescriptorPoolResetFlags flags) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 470 | auto lock = WriteSharedLock(); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 471 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. Remove this pool's descriptor sets from |
| 472 | // our descriptorSet map. |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 473 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 474 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 475 | auto pool_node = itr->second; |
| 476 | for (auto set : *pool_node->child_objects) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 477 | RecordDestroyObject((VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 478 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 479 | pool_node->child_objects->clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 480 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 481 | } |
| 482 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 483 | bool ObjectLifetimes::PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 484 | const VkCommandBufferBeginInfo *begin_info) const { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 485 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 486 | skip |= ValidateObject(command_buffer, kVulkanObjectTypeCommandBuffer, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 487 | "VUID-vkBeginCommandBuffer-commandBuffer-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 488 | if (begin_info) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 489 | auto iter = object_map[kVulkanObjectTypeCommandBuffer].find(HandleToUint64(command_buffer)); |
| 490 | if (iter != object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 491 | auto node = iter->second; |
| 492 | if ((begin_info->pInheritanceInfo) && (node->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 493 | (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { |
| 494 | skip |= |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 495 | ValidateObject(begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, true, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 496 | "VUID-VkCommandBufferBeginInfo-flags-00055", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 497 | skip |= |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 498 | ValidateObject(begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 499 | "VUID-VkCommandBufferBeginInfo-flags-00053", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 500 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 501 | } |
| 502 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 503 | return skip; |
| 504 | } |
| 505 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 506 | bool ObjectLifetimes::PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 507 | uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) const { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 508 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 509 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 510 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 511 | skip |= ValidateObject(swapchain, kVulkanObjectTypeSwapchainKHR, false, "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", |
| 512 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 513 | return skip; |
| 514 | } |
| 515 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 516 | void ObjectLifetimes::PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 517 | VkImage *pSwapchainImages, VkResult result) { |
| 518 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 519 | auto lock = WriteSharedLock(); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 520 | if (pSwapchainImages != NULL) { |
| 521 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 522 | CreateSwapchainImageObject(pSwapchainImages[i], swapchain); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 523 | } |
| 524 | } |
| 525 | } |
| 526 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 527 | bool ObjectLifetimes::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 528 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 529 | VkDescriptorSetLayout *pSetLayout) const { |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 530 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 531 | skip |= |
| 532 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorSetLayout-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 533 | if (pCreateInfo) { |
| 534 | if (pCreateInfo->pBindings) { |
| 535 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 536 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 537 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 538 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 539 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 540 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 541 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 542 | skip |= ValidateObject(sampler, kVulkanObjectTypeSampler, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 543 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 544 | } |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | } |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 549 | return skip; |
| 550 | } |
| 551 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 552 | void ObjectLifetimes::PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 553 | const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 554 | VkDescriptorSetLayout *pSetLayout, VkResult result) { |
| 555 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | 1e76a7d | 2019-09-11 11:11:46 -0600 | [diff] [blame] | 556 | CreateObject(*pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 557 | } |
| 558 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 559 | bool ObjectLifetimes::ValidateSamplerObjects(const VkDescriptorSetLayoutCreateInfo *pCreateInfo) const { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 560 | bool skip = false; |
| 561 | if (pCreateInfo->pBindings) { |
| 562 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 563 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 564 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 565 | skip |= ValidateObject(pCreateInfo->pBindings[index1].pImmutableSamplers[index2], kVulkanObjectTypeSampler, |
| 566 | true, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | return skip; |
| 572 | } |
| 573 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 574 | bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupport(VkDevice device, |
| 575 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 576 | VkDescriptorSetLayoutSupport *pSupport) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 577 | bool skip = ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", |
| 578 | kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 579 | if (pCreateInfo) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 580 | skip |= ValidateSamplerObjects(pCreateInfo); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 581 | } |
| 582 | return skip; |
| 583 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 584 | bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupportKHR(VkDevice device, |
| 585 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 586 | VkDescriptorSetLayoutSupport *pSupport) const { |
Mike Schuchardt | 65847d9 | 2019-12-20 13:50:47 -0800 | [diff] [blame] | 587 | bool skip = ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 588 | kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 589 | if (pCreateInfo) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 590 | skip |= ValidateSamplerObjects(pCreateInfo); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 591 | } |
| 592 | return skip; |
| 593 | } |
| 594 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 595 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 596 | uint32_t *pQueueFamilyPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 597 | VkQueueFamilyProperties *pQueueFamilyProperties) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 598 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 599 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 600 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame] | 601 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 602 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 603 | uint32_t *pQueueFamilyPropertyCount, |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame] | 604 | VkQueueFamilyProperties *pQueueFamilyProperties) {} |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 605 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 606 | void ObjectLifetimes::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 607 | VkInstance *pInstance, VkResult result) { |
| 608 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | 1e76a7d | 2019-09-11 11:11:46 -0600 | [diff] [blame] | 609 | CreateObject(*pInstance, kVulkanObjectTypeInstance, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 610 | } |
| 611 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 612 | bool ObjectLifetimes::PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 613 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
| 614 | bool skip = false; |
| 615 | skip |= ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, "VUID-vkCreateDevice-physicalDevice-parameter", |
| 616 | kVUIDUndefined); |
| 617 | |
| 618 | return skip; |
| 619 | } |
| 620 | |
| 621 | void ObjectLifetimes::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 622 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
| 623 | if (result != VK_SUCCESS) return; |
| 624 | CreateObject(*pDevice, kVulkanObjectTypeDevice, pAllocator); |
| 625 | |
| 626 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
| 627 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeObjectTracker); |
| 628 | ObjectLifetimes *object_tracking = static_cast<ObjectLifetimes *>(validation_data); |
| 629 | |
| 630 | object_tracking->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
| 631 | const auto *robustness2_features = |
Mark Lobodzinski | 1f887d3 | 2020-12-30 15:31:33 -0700 | [diff] [blame] | 632 | LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(object_tracking->device_createinfo_pnext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 633 | object_tracking->null_descriptor_enabled = robustness2_features && robustness2_features->nullDescriptor; |
| 634 | } |
| 635 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 636 | bool ObjectLifetimes::PreCallValidateAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 637 | VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 638 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 639 | skip |= |
| 640 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", kVUIDUndefined); |
| 641 | skip |= ValidateObject(pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 642 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 643 | return skip; |
| 644 | } |
| 645 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 646 | void ObjectLifetimes::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 647 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
| 648 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 649 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 650 | AllocateCommandBuffer(pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 651 | } |
| 652 | } |
| 653 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 654 | bool ObjectLifetimes::PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 655 | VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 656 | bool skip = false; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 657 | auto lock = ReadSharedLock(); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 658 | skip |= |
| 659 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", kVUIDUndefined); |
| 660 | skip |= ValidateObject(pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 661 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
| 662 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 663 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 664 | skip |= ValidateObject(pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 665 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 666 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 667 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 668 | return skip; |
| 669 | } |
| 670 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 671 | void ObjectLifetimes::PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 672 | VkDescriptorSet *pDescriptorSets, VkResult result) { |
| 673 | if (result != VK_SUCCESS) return; |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 674 | auto lock = WriteSharedLock(); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 675 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 676 | AllocateDescriptorSet(pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 677 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 678 | } |
| 679 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 680 | bool ObjectLifetimes::PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 681 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 682 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 683 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", kVUIDUndefined); |
| 684 | skip |= ValidateObject(commandPool, kVulkanObjectTypeCommandPool, false, "VUID-vkFreeCommandBuffers-commandPool-parameter", |
| 685 | "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 686 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 687 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 688 | skip |= ValidateCommandBuffer(commandPool, pCommandBuffers[i]); |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 689 | skip |= |
| 690 | ValidateDestroyObject(pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 691 | } |
| 692 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 693 | return skip; |
| 694 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 695 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 696 | void ObjectLifetimes::PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 697 | const VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 698 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 699 | RecordDestroyObject(pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 700 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 701 | } |
| 702 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 703 | bool ObjectLifetimes::PreCallValidateDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 704 | const VkAllocationCallbacks *pAllocator) const { |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 705 | return ValidateDestroyObject(swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, "VUID-vkDestroySwapchainKHR-swapchain-01283", |
| 706 | "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 707 | } |
| 708 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 709 | void ObjectLifetimes::PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 710 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 711 | RecordDestroyObject(swapchain, kVulkanObjectTypeSwapchainKHR); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 712 | |
| 713 | auto snapshot = swapchainImageMap.snapshot( |
| 714 | [swapchain](std::shared_ptr<ObjTrackState> pNode) { return pNode->parent_object == HandleToUint64(swapchain); }); |
| 715 | for (const auto &itr : snapshot) { |
| 716 | swapchainImageMap.erase(itr.first); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 717 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 718 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 719 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 720 | bool ObjectLifetimes::PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 721 | uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets) const { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 722 | auto lock = ReadSharedLock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 723 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 724 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", kVUIDUndefined); |
| 725 | skip |= ValidateObject(descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 726 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 727 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 728 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 729 | skip |= ValidateDescriptorSet(descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 730 | skip |= |
| 731 | ValidateDestroyObject(pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 732 | } |
| 733 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 734 | return skip; |
| 735 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 736 | void ObjectLifetimes::PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 737 | const VkDescriptorSet *pDescriptorSets) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 738 | auto lock = WriteSharedLock(); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 739 | std::shared_ptr<ObjTrackState> pool_node = nullptr; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 740 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 741 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 742 | pool_node = itr->second; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 743 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 744 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 745 | RecordDestroyObject(pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 746 | if (pool_node) { |
| 747 | pool_node->child_objects->erase(HandleToUint64(pDescriptorSets[i])); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 748 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 749 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 750 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 751 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 752 | bool ObjectLifetimes::PreCallValidateDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 753 | const VkAllocationCallbacks *pAllocator) const { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 754 | auto lock = ReadSharedLock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 755 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 756 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", kVUIDUndefined); |
| 757 | skip |= ValidateObject(descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 758 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
| 759 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 760 | |
| 761 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 762 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 763 | auto pool_node = itr->second; |
| 764 | for (auto set : *pool_node->child_objects) { |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 765 | skip |= ValidateDestroyObject((VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 766 | kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 767 | } |
| 768 | } |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 769 | skip |= ValidateDestroyObject(descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 770 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", |
| 771 | "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 772 | return skip; |
| 773 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 774 | void ObjectLifetimes::PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 775 | const VkAllocationCallbacks *pAllocator) { |
Jeremy Gebben | 2e5b41b | 2021-10-11 16:41:49 -0600 | [diff] [blame^] | 776 | auto lock = WriteSharedLock(); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 777 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 778 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 779 | auto pool_node = itr->second; |
| 780 | for (auto set : *pool_node->child_objects) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 781 | RecordDestroyObject((VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 782 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 783 | pool_node->child_objects->clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 784 | } |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 785 | RecordDestroyObject(descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 786 | } |
| 787 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 788 | bool ObjectLifetimes::PreCallValidateDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 789 | const VkAllocationCallbacks *pAllocator) const { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 790 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 791 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", kVUIDUndefined); |
| 792 | skip |= ValidateObject(commandPool, kVulkanObjectTypeCommandPool, true, "VUID-vkDestroyCommandPool-commandPool-parameter", |
| 793 | "VUID-vkDestroyCommandPool-commandPool-parent"); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 794 | |
| 795 | auto snapshot = object_map[kVulkanObjectTypeCommandBuffer].snapshot( |
| 796 | [commandPool](std::shared_ptr<ObjTrackState> pNode) { return pNode->parent_object == HandleToUint64(commandPool); }); |
| 797 | for (const auto &itr : snapshot) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 798 | auto node = itr.second; |
Mark Lobodzinski | 702c6a4 | 2019-09-11 11:52:23 -0600 | [diff] [blame] | 799 | skip |= ValidateCommandBuffer(commandPool, reinterpret_cast<VkCommandBuffer>(itr.first)); |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 800 | skip |= ValidateDestroyObject(reinterpret_cast<VkCommandBuffer>(itr.first), kVulkanObjectTypeCommandBuffer, nullptr, |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 801 | kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 802 | } |
Mark Lobodzinski | 3d89a2c | 2019-09-11 11:41:11 -0600 | [diff] [blame] | 803 | skip |= ValidateDestroyObject(commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 804 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 805 | return skip; |
| 806 | } |
| 807 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 808 | void ObjectLifetimes::PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 809 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 810 | auto snapshot = object_map[kVulkanObjectTypeCommandBuffer].snapshot( |
| 811 | [commandPool](std::shared_ptr<ObjTrackState> pNode) { return pNode->parent_object == HandleToUint64(commandPool); }); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 812 | // 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] | 813 | for (const auto &itr : snapshot) { |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 814 | RecordDestroyObject(reinterpret_cast<VkCommandBuffer>(itr.first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 815 | } |
Mark Lobodzinski | 82742f6 | 2019-09-11 11:20:26 -0600 | [diff] [blame] | 816 | RecordDestroyObject(commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 817 | } |
| 818 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 819 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2( |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 820 | VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 821 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 822 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 823 | } |
| 824 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 825 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2KHR( |
| 826 | VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 827 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Shannon McPherson | 3ea6513 | 2018-12-05 10:37:39 -0700 | [diff] [blame] | 828 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 832 | uint32_t *pQueueFamilyPropertyCount, |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 833 | VkQueueFamilyProperties2 *pQueueFamilyProperties) {} |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 834 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 835 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, |
| 836 | uint32_t *pQueueFamilyPropertyCount, |
| 837 | VkQueueFamilyProperties2 *pQueueFamilyProperties) {} |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 838 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 839 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, |
| 840 | uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 841 | VkDisplayPropertiesKHR *pProperties) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 842 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 843 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 844 | } |
| 845 | |
| 846 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 847 | VkDisplayPropertiesKHR *pProperties, VkResult result) { |
| 848 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 849 | if (pProperties) { |
| 850 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | 1e76a7d | 2019-09-11 11:11:46 -0600 | [diff] [blame] | 851 | CreateObject(pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | } |
| 855 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 856 | bool ObjectLifetimes::PreCallValidateGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 857 | uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 858 | VkDisplayModePropertiesKHR *pProperties) const { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 859 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 860 | skip |= ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 861 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 862 | skip |= ValidateObject(display, kVulkanObjectTypeDisplayKHR, false, "VUID-vkGetDisplayModePropertiesKHR-display-parameter", |
| 863 | kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 864 | |
| 865 | return skip; |
| 866 | } |
| 867 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 868 | void ObjectLifetimes::PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 869 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties, |
| 870 | VkResult result) { |
| 871 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 872 | if (pProperties) { |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 873 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | 1e76a7d | 2019-09-11 11:11:46 -0600 | [diff] [blame] | 874 | CreateObject(pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 875 | } |
| 876 | } |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 877 | } |
| 878 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 879 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 880 | uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 881 | VkDisplayProperties2KHR *pProperties) const { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 882 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 883 | "VUID-vkGetPhysicalDeviceDisplayProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 884 | } |
| 885 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 886 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 887 | uint32_t *pPropertyCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 888 | VkDisplayProperties2KHR *pProperties, VkResult result) { |
| 889 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Timo Suoranta | d2eaa04 | 2020-07-13 11:30:38 +0300 | [diff] [blame] | 890 | if (pProperties) { |
| 891 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 892 | CreateObject(pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
| 893 | } |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 894 | } |
| 895 | } |
| 896 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 897 | bool ObjectLifetimes::PreCallValidateGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 898 | uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 899 | VkDisplayModeProperties2KHR *pProperties) const { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 900 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 901 | skip |= ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 902 | "VUID-vkGetDisplayModeProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 903 | skip |= ValidateObject(display, kVulkanObjectTypeDisplayKHR, false, "VUID-vkGetDisplayModeProperties2KHR-display-parameter", |
| 904 | kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 905 | |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 906 | return skip; |
| 907 | } |
| 908 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 909 | void ObjectLifetimes::PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 910 | uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties, |
| 911 | VkResult result) { |
| 912 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Timo Suoranta | d2eaa04 | 2020-07-13 11:30:38 +0300 | [diff] [blame] | 913 | if (pProperties) { |
| 914 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 915 | CreateObject(pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
| 916 | } |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 917 | } |
| 918 | } |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 919 | |
Mark Lobodzinski | 616ffc6 | 2020-10-22 09:31:00 -0600 | [diff] [blame] | 920 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, |
| 921 | uint32_t *pPropertyCount, |
| 922 | VkDisplayPlanePropertiesKHR *pProperties, |
| 923 | VkResult result) { |
| 924 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
| 925 | if (pProperties) { |
| 926 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 927 | CreateObject(pProperties[index].currentDisplay, kVulkanObjectTypeDisplayKHR, nullptr); |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayPlaneProperties2KHR(VkPhysicalDevice physicalDevice, |
| 933 | uint32_t *pPropertyCount, |
| 934 | VkDisplayPlaneProperties2KHR *pProperties, |
| 935 | VkResult result) { |
| 936 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
| 937 | if (pProperties) { |
| 938 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
| 939 | CreateObject(pProperties[index].displayPlaneProperties.currentDisplay, kVulkanObjectTypeDisplayKHR, nullptr); |
| 940 | } |
| 941 | } |
| 942 | } |
| 943 | |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 944 | bool ObjectLifetimes::PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 945 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer) const { |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 946 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 947 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkCreateFramebuffer-device-parameter", kVUIDUndefined); |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 948 | if (pCreateInfo) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 949 | skip |= ValidateObject(pCreateInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 950 | "VUID-VkFramebufferCreateInfo-renderPass-parameter", "VUID-VkFramebufferCreateInfo-commonparent"); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 951 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 952 | for (uint32_t index1 = 0; index1 < pCreateInfo->attachmentCount; ++index1) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame] | 953 | skip |= ValidateObject(pCreateInfo->pAttachments[index1], kVulkanObjectTypeImageView, true, kVUIDUndefined, |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 954 | "VUID-VkFramebufferCreateInfo-commonparent"); |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | return skip; |
| 960 | } |
| 961 | |
| 962 | void ObjectLifetimes::PostCallRecordCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 963 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer, |
| 964 | VkResult result) { |
| 965 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | 1e76a7d | 2019-09-11 11:11:46 -0600 | [diff] [blame] | 966 | CreateObject(*pFramebuffer, kVulkanObjectTypeFramebuffer, pAllocator); |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 967 | } |
Mark Lobodzinski | 417b757 | 2019-09-11 15:10:26 -0600 | [diff] [blame] | 968 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 969 | bool ObjectLifetimes::PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
| 970 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 417b757 | 2019-09-11 15:10:26 -0600 | [diff] [blame] | 971 | bool skip = false; |
| 972 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkSetDebugUtilsObjectNameEXT-device-parameter", |
| 973 | kVUIDUndefined); |
| 974 | skip |= ValidateAnonymousObject(pNameInfo->objectHandle, pNameInfo->objectType, false, |
| 975 | "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02590", kVUIDUndefined); |
| 976 | |
| 977 | return skip; |
| 978 | } |
| 979 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 980 | bool ObjectLifetimes::PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
| 981 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 417b757 | 2019-09-11 15:10:26 -0600 | [diff] [blame] | 982 | bool skip = false; |
| 983 | skip |= |
| 984 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkSetDebugUtilsObjectTagEXT-device-parameter", kVUIDUndefined); |
| 985 | skip |= ValidateAnonymousObject(pTagInfo->objectHandle, pTagInfo->objectType, false, |
| 986 | "VUID-VkDebugUtilsObjectTagInfoEXT-objectHandle-01910", kVUIDUndefined); |
| 987 | |
| 988 | return skip; |
| 989 | } |
Mark Lobodzinski | 67f8638 | 2019-12-12 12:28:54 -0700 | [diff] [blame] | 990 | |
| 991 | bool ObjectLifetimes::PreCallValidateCreateDescriptorUpdateTemplate(VkDevice device, |
| 992 | const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, |
| 993 | const VkAllocationCallbacks *pAllocator, |
| 994 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate) const { |
| 995 | bool skip = false; |
| 996 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorUpdateTemplate-device-parameter", |
| 997 | kVUIDUndefined); |
| 998 | if (pCreateInfo) { |
| 999 | if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET) { |
| 1000 | skip |= ValidateObject(pCreateInfo->descriptorSetLayout, kVulkanObjectTypeDescriptorSetLayout, false, |
| 1001 | "VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00350", |
| 1002 | "VUID-VkDescriptorUpdateTemplateCreateInfo-commonparent"); |
| 1003 | } |
| 1004 | if (pCreateInfo->templateType == VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR) { |
| 1005 | skip |= ValidateObject(pCreateInfo->pipelineLayout, kVulkanObjectTypePipelineLayout, false, |
| 1006 | "VUID-VkDescriptorUpdateTemplateCreateInfo-templateType-00352", |
| 1007 | "VUID-VkDescriptorUpdateTemplateCreateInfo-commonparent"); |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | return skip; |
| 1012 | } |
| 1013 | |
| 1014 | bool ObjectLifetimes::PreCallValidateCreateDescriptorUpdateTemplateKHR( |
| 1015 | VkDevice device, const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 1016 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate) const { |
| 1017 | return PreCallValidateCreateDescriptorUpdateTemplate(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate); |
| 1018 | } |
| 1019 | |
| 1020 | void ObjectLifetimes::PostCallRecordCreateDescriptorUpdateTemplate(VkDevice device, |
| 1021 | const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, |
| 1022 | const VkAllocationCallbacks *pAllocator, |
| 1023 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate, |
| 1024 | VkResult result) { |
| 1025 | if (result != VK_SUCCESS) return; |
| 1026 | CreateObject(*pDescriptorUpdateTemplate, kVulkanObjectTypeDescriptorUpdateTemplate, pAllocator); |
| 1027 | } |
| 1028 | |
| 1029 | void ObjectLifetimes::PostCallRecordCreateDescriptorUpdateTemplateKHR(VkDevice device, |
| 1030 | const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, |
| 1031 | const VkAllocationCallbacks *pAllocator, |
| 1032 | VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate, |
| 1033 | VkResult result) { |
| 1034 | return PostCallRecordCreateDescriptorUpdateTemplate(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate, result); |
| 1035 | } |
Nathaniel Cesario | 7e5b1a7 | 2021-10-04 23:39:20 -0600 | [diff] [blame] | 1036 | |
| 1037 | bool ObjectLifetimes::ValidateAccelerationStructures(const char *dst_handle_vuid, uint32_t count, |
| 1038 | const VkAccelerationStructureBuildGeometryInfoKHR *infos) const { |
| 1039 | bool skip = false; |
| 1040 | if (infos) { |
| 1041 | const char *device_vuid = "VUID-VkAccelerationStructureBuildGeometryInfoKHR-commonparent"; |
| 1042 | for (uint32_t i = 0; i < count; ++i) { |
| 1043 | skip |= ValidateObject(infos[i].srcAccelerationStructure, kVulkanObjectTypeAccelerationStructureKHR, true, |
| 1044 | kVUIDUndefined, device_vuid); |
| 1045 | skip |= ValidateObject(infos[i].dstAccelerationStructure, kVulkanObjectTypeAccelerationStructureKHR, false, |
| 1046 | dst_handle_vuid, device_vuid); |
| 1047 | } |
| 1048 | } |
| 1049 | |
| 1050 | return skip; |
| 1051 | } |
| 1052 | |
| 1053 | bool ObjectLifetimes::PreCallValidateCmdBuildAccelerationStructuresKHR( |
| 1054 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 1055 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 1056 | bool skip = ValidateObject(commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 1057 | "VUID-vkCmdBuildAccelerationStructuresKHR-commandBuffer-parameter", kVUIDUndefined); |
| 1058 | skip |= |
| 1059 | ValidateAccelerationStructures("VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03800", infoCount, pInfos); |
| 1060 | return skip; |
| 1061 | } |
| 1062 | |
| 1063 | bool ObjectLifetimes::PreCallValidateCmdBuildAccelerationStructuresIndirectKHR( |
| 1064 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 1065 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 1066 | const uint32_t *const *ppMaxPrimitiveCounts) const { |
| 1067 | bool skip = ValidateObject(commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 1068 | "VUID-vkCmdBuildAccelerationStructuresKHR-commandBuffer-parameter", kVUIDUndefined); |
| 1069 | skip |= ValidateAccelerationStructures("VUID-vkCmdBuildAccelerationStructuresIndirectKHR-dstAccelerationStructure-03800", |
| 1070 | infoCount, pInfos); |
| 1071 | return skip; |
| 1072 | } |
| 1073 | |
| 1074 | bool ObjectLifetimes::PreCallValidateBuildAccelerationStructuresKHR( |
| 1075 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 1076 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 1077 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 1078 | bool skip = ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkBuildAccelerationStructuresKHR-device-parameter", |
| 1079 | kVUIDUndefined); |
| 1080 | skip |= ValidateObject(deferredOperation, kVulkanObjectTypeDeferredOperationKHR, true, |
| 1081 | "VUID-vkBuildAccelerationStructuresKHR-deferredOperation-parameter", |
| 1082 | "VUID-vkBuildAccelerationStructuresKHR-deferredOperation-parent"); |
| 1083 | skip |= |
| 1084 | ValidateAccelerationStructures("VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03800", infoCount, pInfos); |
| 1085 | return skip; |
| 1086 | } |