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