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 | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 151 | skip |= ValidateObject(desc->dstSet, kVulkanObjectTypeDescriptorSet, false, "VUID-VkWriteDescriptorSet-dstSet-00320", |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 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 | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 158 | skip |= ValidateObject(desc->pTexelBufferView[idx2], kVulkanObjectTypeBufferView, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 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 | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 167 | skip |= ValidateObject(desc->pImageInfo[idx3].imageView, kVulkanObjectTypeImageView, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 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 | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 178 | skip |= ValidateObject(desc->pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 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 | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 191 | skip |= ValidateObject(commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 192 | "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 193 | skip |= ValidateObject(layout, kVulkanObjectTypePipelineLayout, false, "VUID-vkCmdPushDescriptorSetKHR-layout-parameter", |
| 194 | "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 | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 230 | bool ObjectLifetimes::ReportLeakedInstanceObjects(VkInstance instance, VulkanObjectType object_type, |
| 231 | const std::string &error_code) { |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 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 | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 244 | bool ObjectLifetimes::ReportLeakedDeviceObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code) { |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 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 | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 261 | skip |= ValidateObject(instance, kVulkanObjectTypeInstance, true, "VUID-vkDestroyInstance-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 262 | |
| 263 | // Validate that child devices have been destroyed |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 264 | auto snapshot = object_map[kVulkanObjectTypeDevice].snapshot(); |
| 265 | for (const auto &iit : snapshot) { |
| 266 | auto pNode = iit.second; |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 267 | |
| 268 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
| 269 | VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[pNode->object_type]; |
| 270 | |
John Zulauf | 1c3844a | 2019-04-01 17:39:48 -0600 | [diff] [blame] | 271 | skip |= |
| 272 | log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, pNode->handle, kVUID_ObjectTracker_ObjectLeak, |
| 273 | "OBJ ERROR : %s object %s has not been destroyed.", string_VkDebugReportObjectTypeEXT(debug_object_type), |
| 274 | report_data->FormatHandle(ObjTrackStateTypedHandle(*pNode)).c_str()); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 275 | |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 276 | // Throw errors if any device objects belonging to this instance have not been destroyed |
| 277 | skip |= ReportUndestroyedDeviceObjects(device, "VUID-vkDestroyDevice-device-00378"); |
Mark Lobodzinski | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 278 | DestroyLeakedDeviceObjects(device); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 279 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 280 | skip |= ValidateDestroyObject(instance, device, kVulkanObjectTypeDevice, pAllocator, |
| 281 | "VUID-vkDestroyInstance-instance-00630", "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 282 | } |
| 283 | |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 284 | // 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] | 285 | ValidateDestroyObject(instance, instance, kVulkanObjectTypeInstance, pAllocator, "VUID-vkDestroyInstance-instance-00630", |
| 286 | "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 287 | |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 288 | // Report any remaining instance objects |
| 289 | skip |= ReportUndestroyedInstanceObjects(instance, "VUID-vkDestroyInstance-instance-00629"); |
Mark Lobodzinski | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 290 | DestroyLeakedInstanceObjects(instance); |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 291 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 292 | return skip; |
| 293 | } |
| 294 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 295 | bool ObjectLifetimes::PreCallValidateEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 296 | VkPhysicalDevice *pPhysicalDevices) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 297 | bool skip = ValidateObject(instance, kVulkanObjectTypeInstance, false, "VUID-vkEnumeratePhysicalDevices-instance-parameter", |
| 298 | kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 299 | return skip; |
| 300 | } |
| 301 | |
| 302 | void ObjectLifetimes::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 303 | VkPhysicalDevice *pPhysicalDevices, VkResult result) { |
| 304 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 305 | if (pPhysicalDevices) { |
| 306 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 307 | CreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 308 | } |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | void ObjectLifetimes::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 313 | // Destroy physical devices |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 314 | auto snapshot = object_map[kVulkanObjectTypePhysicalDevice].snapshot(); |
| 315 | for (const auto &iit : snapshot) { |
| 316 | auto pNode = iit.second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 317 | VkPhysicalDevice physical_device = reinterpret_cast<VkPhysicalDevice>(pNode->handle); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 318 | RecordDestroyObject(instance, physical_device, kVulkanObjectTypePhysicalDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 319 | } |
| 320 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 321 | // Destroy child devices |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 322 | auto snapshot2 = object_map[kVulkanObjectTypeDevice].snapshot(); |
| 323 | for (const auto &iit : snapshot2) { |
| 324 | auto pNode = iit.second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 325 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
Mark Lobodzinski | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 326 | DestroyLeakedInstanceObjects(instance); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 327 | |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 328 | RecordDestroyObject(instance, device, kVulkanObjectTypeDevice); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 329 | } |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 330 | } |
| 331 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 332 | void ObjectLifetimes::PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 333 | RecordDestroyObject(instance, instance, kVulkanObjectTypeInstance); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 334 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 335 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 336 | bool ObjectLifetimes::PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 337 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 338 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 339 | skip |= ValidateDestroyObject(physical_device, device, kVulkanObjectTypeDevice, pAllocator, "VUID-vkDestroyDevice-device-00379", |
| 340 | "VUID-vkDestroyDevice-device-00380"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 341 | // Report any remaining objects associated with this VkDevice object in LL |
Mark Lobodzinski | 7cef263 | 2019-08-28 15:50:13 -0600 | [diff] [blame] | 342 | skip |= ReportUndestroyedDeviceObjects(device, "VUID-vkDestroyDevice-device-00378"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 343 | |
| 344 | return skip; |
| 345 | } |
| 346 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 347 | void ObjectLifetimes::PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 52db235 | 2018-12-28 09:41:15 -0700 | [diff] [blame] | 348 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physical_device), layer_data_map); |
| 349 | ValidationObject *validation_data = GetValidationObject(instance_data->object_dispatch, LayerObjectTypeObjectTracker); |
| 350 | ObjectLifetimes *object_lifetimes = static_cast<ObjectLifetimes *>(validation_data); |
| 351 | object_lifetimes->RecordDestroyObject(physical_device, device, kVulkanObjectTypeDevice); |
Mark Lobodzinski | be102ad | 2019-09-04 12:03:07 -0600 | [diff] [blame] | 352 | DestroyLeakedDeviceObjects(device); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 353 | |
| 354 | // Clean up Queue's MemRef Linked Lists |
| 355 | DestroyQueueDataStructures(device); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 356 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 357 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 358 | bool ObjectLifetimes::PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, |
| 359 | VkQueue *pQueue) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 360 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 361 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 362 | return skip; |
| 363 | } |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 364 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 365 | void ObjectLifetimes::PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, |
| 366 | VkQueue *pQueue) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 367 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 368 | CreateQueue(device, *pQueue); |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 369 | } |
| 370 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 371 | bool ObjectLifetimes::PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 372 | return ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 373 | } |
| 374 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 375 | void ObjectLifetimes::PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 376 | auto lock = write_shared_lock(); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 377 | CreateQueue(device, *pQueue); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 378 | } |
| 379 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 380 | bool ObjectLifetimes::PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 381 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 382 | uint32_t descriptorCopyCount, |
| 383 | const VkCopyDescriptorSet *pDescriptorCopies) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 384 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 385 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 386 | if (pDescriptorCopies) { |
| 387 | for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { |
| 388 | if (pDescriptorCopies[idx0].dstSet) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 389 | skip |= ValidateObject(pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 390 | "VUID-VkCopyDescriptorSet-dstSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 391 | } |
| 392 | if (pDescriptorCopies[idx0].srcSet) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 393 | skip |= ValidateObject(pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 394 | "VUID-VkCopyDescriptorSet-srcSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | } |
| 398 | if (pDescriptorWrites) { |
| 399 | for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { |
| 400 | skip |= ValidateDescriptorWrite(device, &pDescriptorWrites[idx1], false); |
| 401 | } |
| 402 | } |
| 403 | return skip; |
| 404 | } |
| 405 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 406 | bool ObjectLifetimes::PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 407 | VkDescriptorPoolResetFlags flags) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 408 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 409 | auto lock = read_shared_lock(); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 410 | |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 411 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkResetDescriptorPool-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 412 | skip |= |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 413 | ValidateObject(descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 414 | "VUID-vkResetDescriptorPool-descriptorPool-parameter", "VUID-vkResetDescriptorPool-descriptorPool-parent"); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 415 | |
| 416 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 417 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 418 | auto pPoolNode = itr->second; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 419 | for (auto set : *pPoolNode->child_objects) { |
| 420 | skip |= ValidateDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 421 | kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 422 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 423 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 424 | return skip; |
| 425 | } |
| 426 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 427 | void ObjectLifetimes::PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 428 | VkDescriptorPoolResetFlags flags) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 429 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 430 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. Remove this pool's descriptor sets from |
| 431 | // our descriptorSet map. |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 432 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 433 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 434 | auto pPoolNode = itr->second; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 435 | for (auto set : *pPoolNode->child_objects) { |
| 436 | RecordDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 437 | } |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 438 | pPoolNode->child_objects->clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 439 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 440 | } |
| 441 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 442 | bool ObjectLifetimes::PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer, |
| 443 | const VkCommandBufferBeginInfo *begin_info) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 444 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 445 | skip |= ValidateObject(command_buffer, kVulkanObjectTypeCommandBuffer, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 446 | "VUID-vkBeginCommandBuffer-commandBuffer-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 447 | if (begin_info) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 448 | auto iter = object_map[kVulkanObjectTypeCommandBuffer].find(HandleToUint64(command_buffer)); |
| 449 | if (iter != object_map[kVulkanObjectTypeCommandBuffer].end()) { |
| 450 | auto pNode = iter->second; |
| 451 | if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && |
| 452 | (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { |
| 453 | skip |= |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 454 | ValidateObject(begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, true, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 455 | "VUID-VkCommandBufferBeginInfo-flags-00055", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 456 | skip |= |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 457 | ValidateObject(begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 458 | "VUID-VkCommandBufferBeginInfo-flags-00053", "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 459 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 460 | } |
| 461 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 462 | return skip; |
| 463 | } |
| 464 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 465 | bool ObjectLifetimes::PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 466 | uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 467 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 468 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 469 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 470 | skip |= ValidateObject(swapchain, kVulkanObjectTypeSwapchainKHR, false, "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", |
| 471 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 472 | return skip; |
| 473 | } |
| 474 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 475 | void ObjectLifetimes::PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 476 | VkImage *pSwapchainImages, VkResult result) { |
| 477 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 478 | auto lock = write_shared_lock(); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 479 | if (pSwapchainImages != NULL) { |
| 480 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 481 | CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 486 | bool ObjectLifetimes::PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 487 | const VkAllocationCallbacks *pAllocator, |
| 488 | VkDescriptorSetLayout *pSetLayout) { |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 489 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 490 | skip |= |
| 491 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkCreateDescriptorSetLayout-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 492 | if (pCreateInfo) { |
| 493 | if (pCreateInfo->pBindings) { |
| 494 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 495 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 496 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 497 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 498 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 499 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 500 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 501 | skip |= ValidateObject(sampler, kVulkanObjectTypeSampler, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 502 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | } |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 508 | return skip; |
| 509 | } |
| 510 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 511 | void ObjectLifetimes::PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 512 | const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 513 | VkDescriptorSetLayout *pSetLayout, VkResult result) { |
| 514 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 515 | CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 516 | } |
| 517 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 518 | bool ObjectLifetimes::ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 519 | bool skip = false; |
| 520 | if (pCreateInfo->pBindings) { |
| 521 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 522 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 523 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 524 | skip |= ValidateObject(pCreateInfo->pBindings[index1].pImmutableSamplers[index2], kVulkanObjectTypeSampler, |
| 525 | true, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 526 | } |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | return skip; |
| 531 | } |
| 532 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 533 | bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupport(VkDevice device, |
| 534 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 535 | VkDescriptorSetLayoutSupport *pSupport) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 536 | bool skip = ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", |
| 537 | kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 538 | if (pCreateInfo) { |
| 539 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
| 540 | } |
| 541 | return skip; |
| 542 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 543 | bool ObjectLifetimes::PreCallValidateGetDescriptorSetLayoutSupportKHR(VkDevice device, |
| 544 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 545 | VkDescriptorSetLayoutSupport *pSupport) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 546 | bool skip = ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", |
| 547 | kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 548 | if (pCreateInfo) { |
| 549 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
| 550 | } |
| 551 | return skip; |
| 552 | } |
| 553 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 554 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 555 | uint32_t *pQueueFamilyPropertyCount, |
| 556 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 557 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 558 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 559 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame] | 560 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 561 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, |
| 562 | uint32_t *pQueueFamilyPropertyCount, |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame] | 563 | VkQueueFamilyProperties *pQueueFamilyProperties) {} |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 564 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 565 | void ObjectLifetimes::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 566 | VkInstance *pInstance, VkResult result) { |
| 567 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 568 | CreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 569 | } |
| 570 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 571 | bool ObjectLifetimes::PreCallValidateAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 572 | VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 573 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 574 | skip |= |
| 575 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", kVUIDUndefined); |
| 576 | skip |= ValidateObject(pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 577 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 578 | return skip; |
| 579 | } |
| 580 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 581 | void ObjectLifetimes::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 582 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
| 583 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 584 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
| 585 | AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
| 586 | } |
| 587 | } |
| 588 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 589 | bool ObjectLifetimes::PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 590 | VkDescriptorSet *pDescriptorSets) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 591 | bool skip = false; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 592 | auto lock = read_shared_lock(); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 593 | skip |= |
| 594 | ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", kVUIDUndefined); |
| 595 | skip |= ValidateObject(pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 596 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
| 597 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 598 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 599 | skip |= ValidateObject(pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 600 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 601 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 602 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 603 | return skip; |
| 604 | } |
| 605 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 606 | void ObjectLifetimes::PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 607 | VkDescriptorSet *pDescriptorSets, VkResult result) { |
| 608 | if (result != VK_SUCCESS) return; |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 609 | auto lock = write_shared_lock(); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 610 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 611 | AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 612 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 613 | } |
| 614 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 615 | bool ObjectLifetimes::PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 616 | const VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 617 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 618 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", kVUIDUndefined); |
| 619 | skip |= ValidateObject(commandPool, kVulkanObjectTypeCommandPool, false, "VUID-vkFreeCommandBuffers-commandPool-parameter", |
| 620 | "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 621 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 622 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
| 623 | skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 624 | skip |= ValidateDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, |
| 625 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 626 | } |
| 627 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 628 | return skip; |
| 629 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 630 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 631 | void ObjectLifetimes::PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 632 | const VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 633 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 634 | RecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 635 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 636 | } |
| 637 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 638 | bool ObjectLifetimes::PreCallValidateDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 639 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 640 | return ValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, |
| 641 | "VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 642 | } |
| 643 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 644 | void ObjectLifetimes::PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, |
| 645 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 646 | RecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 647 | |
| 648 | auto snapshot = swapchainImageMap.snapshot( |
| 649 | [swapchain](std::shared_ptr<ObjTrackState> pNode) { return pNode->parent_object == HandleToUint64(swapchain); }); |
| 650 | for (const auto &itr : snapshot) { |
| 651 | swapchainImageMap.erase(itr.first); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 652 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 653 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 654 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 655 | bool ObjectLifetimes::PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 656 | uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 657 | auto lock = read_shared_lock(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 658 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 659 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", kVUIDUndefined); |
| 660 | skip |= ValidateObject(descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 661 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 662 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 663 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
| 664 | skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 665 | skip |= ValidateDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 666 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 667 | } |
| 668 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 669 | return skip; |
| 670 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 671 | void ObjectLifetimes::PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 672 | const VkDescriptorSet *pDescriptorSets) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 673 | auto lock = write_shared_lock(); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 674 | std::shared_ptr<ObjTrackState> pPoolNode = nullptr; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 675 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 676 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
| 677 | pPoolNode = itr->second; |
| 678 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 679 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 680 | RecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 681 | if (pPoolNode) { |
| 682 | pPoolNode->child_objects->erase(HandleToUint64(pDescriptorSets[i])); |
| 683 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 684 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 685 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 686 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 687 | bool ObjectLifetimes::PreCallValidateDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 688 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 689 | auto lock = read_shared_lock(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 690 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 691 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", kVUIDUndefined); |
| 692 | skip |= ValidateObject(descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 693 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
| 694 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 695 | |
| 696 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 697 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 698 | auto pPoolNode = itr->second; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 699 | for (auto set : *pPoolNode->child_objects) { |
| 700 | skip |= ValidateDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 701 | kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 702 | } |
| 703 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 704 | skip |= ValidateDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
| 705 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", |
| 706 | "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 707 | return skip; |
| 708 | } |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 709 | void ObjectLifetimes::PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 710 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | c31aae4 | 2019-08-12 20:29:43 -0500 | [diff] [blame] | 711 | auto lock = write_shared_lock(); |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 712 | auto itr = object_map[kVulkanObjectTypeDescriptorPool].find(HandleToUint64(descriptorPool)); |
| 713 | if (itr != object_map[kVulkanObjectTypeDescriptorPool].end()) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 714 | auto pPoolNode = itr->second; |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 715 | for (auto set : *pPoolNode->child_objects) { |
| 716 | RecordDestroyObject(device, (VkDescriptorSet)set, kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 717 | } |
Jeff Bolz | cf802bc | 2019-02-10 00:18:00 -0600 | [diff] [blame] | 718 | pPoolNode->child_objects->clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 719 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 720 | RecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 721 | } |
| 722 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 723 | bool ObjectLifetimes::PreCallValidateDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 724 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 725 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 726 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", kVUIDUndefined); |
| 727 | skip |= ValidateObject(commandPool, kVulkanObjectTypeCommandPool, true, "VUID-vkDestroyCommandPool-commandPool-parameter", |
| 728 | "VUID-vkDestroyCommandPool-commandPool-parent"); |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 729 | |
| 730 | auto snapshot = object_map[kVulkanObjectTypeCommandBuffer].snapshot( |
| 731 | [commandPool](std::shared_ptr<ObjTrackState> pNode) { return pNode->parent_object == HandleToUint64(commandPool); }); |
| 732 | for (const auto &itr : snapshot) { |
| 733 | auto pNode = itr.second; |
| 734 | skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>(itr.first)); |
| 735 | skip |= ValidateDestroyObject(device, reinterpret_cast<VkCommandBuffer>(itr.first), kVulkanObjectTypeCommandBuffer, nullptr, |
| 736 | kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 737 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 738 | skip |= ValidateDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
| 739 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 740 | return skip; |
| 741 | } |
| 742 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 743 | void ObjectLifetimes::PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 744 | const VkAllocationCallbacks *pAllocator) { |
Jeff Bolz | fd3bb24 | 2019-08-22 06:10:49 -0500 | [diff] [blame] | 745 | auto snapshot = object_map[kVulkanObjectTypeCommandBuffer].snapshot( |
| 746 | [commandPool](std::shared_ptr<ObjTrackState> pNode) { return pNode->parent_object == HandleToUint64(commandPool); }); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 747 | // 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] | 748 | for (const auto &itr : snapshot) { |
| 749 | RecordDestroyObject(device, reinterpret_cast<VkCommandBuffer>(itr.first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 750 | } |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 751 | RecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 752 | } |
| 753 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 754 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 755 | uint32_t *pQueueFamilyPropertyCount, |
| 756 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 757 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 758 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 759 | } |
| 760 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 761 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, |
| 762 | uint32_t *pQueueFamilyPropertyCount, |
| 763 | VkQueueFamilyProperties2 *pQueueFamilyProperties) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 764 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Shannon McPherson | 3ea6513 | 2018-12-05 10:37:39 -0700 | [diff] [blame] | 765 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, |
| 769 | uint32_t *pQueueFamilyPropertyCount, |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame] | 770 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {} |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 771 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 772 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceQueueFamilyProperties2KHR( |
Jeff Bolz | 6d24311 | 2019-08-21 13:24:11 -0500 | [diff] [blame] | 773 | VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) {} |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 774 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 775 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, |
| 776 | uint32_t *pPropertyCount, |
| 777 | VkDisplayPropertiesKHR *pProperties) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 778 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 779 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 783 | VkDisplayPropertiesKHR *pProperties, VkResult result) { |
| 784 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 785 | if (pProperties) { |
| 786 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 787 | CreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 788 | } |
| 789 | } |
| 790 | } |
| 791 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 792 | bool ObjectLifetimes::PreCallValidateGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 793 | uint32_t *pPropertyCount, |
| 794 | VkDisplayModePropertiesKHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 795 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 796 | skip |= ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 797 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 798 | skip |= ValidateObject(display, kVulkanObjectTypeDisplayKHR, false, "VUID-vkGetDisplayModePropertiesKHR-display-parameter", |
| 799 | kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 800 | |
| 801 | return skip; |
| 802 | } |
| 803 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 804 | void ObjectLifetimes::PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 805 | uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties, |
| 806 | VkResult result) { |
| 807 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 808 | if (pProperties) { |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 809 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 810 | CreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 811 | } |
| 812 | } |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 813 | } |
| 814 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 815 | bool ObjectLifetimes::PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 816 | uint32_t *pPropertyCount, |
| 817 | VkDisplayProperties2KHR *pProperties) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 818 | return ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 819 | "VUID-vkGetPhysicalDeviceDisplayProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 820 | } |
| 821 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 822 | void ObjectLifetimes::PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, |
| 823 | uint32_t *pPropertyCount, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 824 | VkDisplayProperties2KHR *pProperties, VkResult result) { |
| 825 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 826 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 827 | CreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 828 | } |
| 829 | } |
| 830 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 831 | bool ObjectLifetimes::PreCallValidateGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 832 | uint32_t *pPropertyCount, |
| 833 | VkDisplayModeProperties2KHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 834 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 835 | skip |= ValidateObject(physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 836 | "VUID-vkGetDisplayModeProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 837 | skip |= ValidateObject(display, kVulkanObjectTypeDisplayKHR, false, "VUID-vkGetDisplayModeProperties2KHR-display-parameter", |
| 838 | kVUIDUndefined); |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 839 | |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 840 | return skip; |
| 841 | } |
| 842 | |
Mark Lobodzinski | 0c66846 | 2018-09-27 10:13:19 -0600 | [diff] [blame] | 843 | void ObjectLifetimes::PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 844 | uint32_t *pPropertyCount, VkDisplayModeProperties2KHR *pProperties, |
| 845 | VkResult result) { |
| 846 | if ((result != VK_SUCCESS) && (result != VK_INCOMPLETE)) return; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 847 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
Mark Lobodzinski | add9323 | 2018-10-09 11:49:42 -0600 | [diff] [blame] | 848 | CreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, |
| 849 | nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 850 | } |
| 851 | } |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 852 | |
| 853 | bool ObjectLifetimes::PreCallValidateAcquirePerformanceConfigurationINTEL( |
| 854 | VkDevice device, const VkPerformanceConfigurationAcquireInfoINTEL *pAcquireInfo, |
| 855 | VkPerformanceConfigurationINTEL *pConfiguration) { |
| 856 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 857 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkAcquirePerformanceConfigurationINTEL-device-parameter", |
| 858 | kVUIDUndefined); |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 859 | |
| 860 | return skip; |
| 861 | } |
| 862 | |
| 863 | bool ObjectLifetimes::PreCallValidateReleasePerformanceConfigurationINTEL(VkDevice device, |
| 864 | VkPerformanceConfigurationINTEL configuration) { |
| 865 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 866 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkReleasePerformanceConfigurationINTEL-device-parameter", |
| 867 | kVUIDUndefined); |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 868 | |
| 869 | return skip; |
| 870 | } |
| 871 | |
| 872 | bool ObjectLifetimes::PreCallValidateQueueSetPerformanceConfigurationINTEL(VkQueue queue, |
| 873 | VkPerformanceConfigurationINTEL configuration) { |
| 874 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 875 | skip |= ValidateObject(queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueSetPerformanceConfigurationINTEL-queue-parameter", |
| 876 | "VUID-vkQueueSetPerformanceConfigurationINTEL-commonparent"); |
Shannon McPherson | f7d9cf6 | 2019-06-26 09:23:57 -0600 | [diff] [blame] | 877 | |
| 878 | return skip; |
| 879 | } |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 880 | |
| 881 | bool ObjectLifetimes::PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 882 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer) { |
| 883 | bool skip = false; |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 884 | skip |= ValidateObject(device, kVulkanObjectTypeDevice, false, "VUID-vkCreateFramebuffer-device-parameter", kVUIDUndefined); |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 885 | if (pCreateInfo) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 886 | skip |= ValidateObject(pCreateInfo->renderPass, kVulkanObjectTypeRenderPass, false, |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 887 | "VUID-VkFramebufferCreateInfo-renderPass-parameter", "VUID-VkFramebufferCreateInfo-commonparent"); |
| 888 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) { |
| 889 | for (uint32_t index1 = 0; index1 < pCreateInfo->attachmentCount; ++index1) { |
Mark Lobodzinski | 3996574 | 2019-09-11 11:03:51 -0600 | [diff] [blame^] | 890 | skip |= ValidateObject(pCreateInfo->pAttachments[index1], kVulkanObjectTypeImageView, true, kVUIDUndefined, |
Tobias Hector | c905742 | 2019-07-23 12:15:52 +0100 | [diff] [blame] | 891 | "VUID-VkFramebufferCreateInfo-commonparent"); |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | return skip; |
| 897 | } |
| 898 | |
| 899 | void ObjectLifetimes::PostCallRecordCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 900 | const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer, |
| 901 | VkResult result) { |
| 902 | if (result != VK_SUCCESS) return; |
| 903 | CreateObject(device, *pFramebuffer, kVulkanObjectTypeFramebuffer, pAllocator); |
| 904 | } |