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