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