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