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 | |
| 23 | #include "object_tracker.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 | |
| 26 | namespace object_tracker { |
| 27 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 28 | uint64_t object_track_index = 0; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 29 | |
| 30 | // Add new queue to head of global queue list |
| 31 | void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue) { |
| 32 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 33 | auto queueItem = device_data->objdata.queue_info_map.find(queue); |
| 34 | if (queueItem == device_data->objdata.queue_info_map.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 35 | ObjTrackQueueInfo *p_queue_info = new ObjTrackQueueInfo; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 36 | if (p_queue_info != NULL) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 37 | memset(p_queue_info, 0, sizeof(ObjTrackQueueInfo)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 38 | p_queue_info->queue = queue; |
| 39 | p_queue_info->queue_node_index = queue_node_index; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 40 | device_data->objdata.queue_info_map[queue] = p_queue_info; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 41 | } else { |
| 42 | 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] | 43 | HandleToUint64(queue), kVUID_ObjectTracker_InternalError, |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 44 | "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information"); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // Destroy memRef lists and free all memory |
| 50 | void DestroyQueueDataStructures(VkDevice device) { |
| 51 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 52 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 53 | for (auto queue_item : device_data->objdata.queue_info_map) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 54 | delete queue_item.second; |
| 55 | } |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 56 | device_data->objdata.queue_info_map.clear(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 57 | |
| 58 | // Destroy the items in the queue map |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 59 | auto queue = device_data->objdata.object_map[kVulkanObjectTypeQueue].begin(); |
| 60 | while (queue != device_data->objdata.object_map[kVulkanObjectTypeQueue].end()) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 61 | uint32_t obj_index = queue->second->object_type; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 62 | assert(device_data->objdata.num_total_objects > 0); |
| 63 | device_data->objdata.num_total_objects--; |
| 64 | assert(device_data->objdata.num_objects[obj_index] > 0); |
| 65 | device_data->objdata.num_objects[obj_index]--; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 66 | 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] | 67 | queue->second->handle, kVUID_ObjectTracker_Info, |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 68 | "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] | 69 | 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] | 70 | delete queue->second; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 71 | queue = device_data->objdata.object_map[kVulkanObjectTypeQueue].erase(queue); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 72 | } |
| 73 | } |
| 74 | |
| 75 | // Check Queue type flags for selected queue operations |
| 76 | void ValidateQueueFlags(VkQueue queue, const char *function) { |
| 77 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 78 | auto queue_item = device_data->objdata.queue_info_map.find(queue); |
| 79 | if (queue_item != device_data->objdata.queue_info_map.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 80 | ObjTrackQueueInfo *pQueueInfo = queue_item->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 81 | if (pQueueInfo != NULL) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 82 | instance_layer_data *instance_data = |
| 83 | GetLayerDataPtr(get_dispatch_key(device_data->physical_device), instance_layer_data_map); |
| 84 | if ((instance_data->objdata.queue_family_properties[pQueueInfo->queue_node_index].queueFlags & |
| 85 | VK_QUEUE_SPARSE_BINDING_BIT) == 0) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 86 | 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] | 87 | HandleToUint64(queue), "VUID-vkQueueBindSparse-queuetype", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 88 | "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] | 89 | } |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 94 | // Look for this device object in any of the instance child devices lists. |
| 95 | // NOTE: This is of dubious value. In most circumstances Vulkan will die a flaming death if a dispatchable object is invalid. |
| 96 | // However, if this layer is loaded first and GetProcAddress is used to make API calls, it will detect bad DOs. |
Dave Houlton | 379f142 | 2018-05-23 12:47:07 -0600 | [diff] [blame] | 97 | bool ValidateDeviceObject(uint64_t device_handle, const std::string &invalid_handle_code, const std::string &wrong_device_code) { |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 98 | VkInstance last_instance = nullptr; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 99 | for (auto instance_data : instance_layer_data_map) { |
| 100 | for (auto object : instance_data.second->objdata.object_map[kVulkanObjectTypeDevice]) { |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 101 | // Grab last instance to use for possible error message |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 102 | last_instance = instance_data.second->instance; |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 103 | if (object.second->handle == device_handle) return false; |
| 104 | } |
| 105 | } |
| 106 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 107 | 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] | 108 | 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] | 109 | invalid_handle_code, "Invalid Device Object 0x%" PRIxLEAST64 ".", device_handle); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 112 | void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer, |
| 113 | VkCommandBufferLevel level) { |
| 114 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 115 | |
| 116 | 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] | 117 | 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] | 118 | 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] | 119 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 120 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 121 | pNewObjNode->object_type = kVulkanObjectTypeCommandBuffer; |
| 122 | pNewObjNode->handle = HandleToUint64(command_buffer); |
| 123 | pNewObjNode->parent_object = HandleToUint64(command_pool); |
| 124 | if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { |
| 125 | pNewObjNode->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; |
| 126 | } else { |
| 127 | pNewObjNode->status = OBJSTATUS_NONE; |
| 128 | } |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 129 | device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)] = pNewObjNode; |
| 130 | device_data->objdata.num_objects[kVulkanObjectTypeCommandBuffer]++; |
| 131 | device_data->objdata.num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) { |
| 135 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 136 | bool skip = false; |
| 137 | uint64_t object_handle = HandleToUint64(command_buffer); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 138 | if (device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].find(object_handle) != |
| 139 | device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].end()) { |
| 140 | ObjTrackState *pNode = device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 141 | |
| 142 | if (pNode->parent_object != HandleToUint64(command_pool)) { |
| 143 | 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] | 144 | object_handle, "VUID-vkFreeCommandBuffers-pCommandBuffers-parent", |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 145 | "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 146 | " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 147 | HandleToUint64(command_buffer), pNode->parent_object, HandleToUint64(command_pool)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 148 | } |
| 149 | } else { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 150 | 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] | 151 | object_handle, "VUID-vkFreeCommandBuffers-pCommandBuffers-00048", "Invalid %s Object 0x%" PRIxLEAST64 ".", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 152 | object_string[kVulkanObjectTypeCommandBuffer], object_handle); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 153 | } |
| 154 | return skip; |
| 155 | } |
| 156 | |
| 157 | void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
| 158 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 159 | |
| 160 | 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] | 161 | 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] | 162 | 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] | 163 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 164 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 165 | pNewObjNode->object_type = kVulkanObjectTypeDescriptorSet; |
| 166 | pNewObjNode->status = OBJSTATUS_NONE; |
| 167 | pNewObjNode->handle = HandleToUint64(descriptor_set); |
| 168 | pNewObjNode->parent_object = HandleToUint64(descriptor_pool); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 169 | device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet][HandleToUint64(descriptor_set)] = pNewObjNode; |
| 170 | device_data->objdata.num_objects[kVulkanObjectTypeDescriptorSet]++; |
| 171 | device_data->objdata.num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { |
| 175 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 176 | bool skip = false; |
| 177 | uint64_t object_handle = HandleToUint64(descriptor_set); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 178 | auto dsItem = device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].find(object_handle); |
| 179 | if (dsItem != device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 180 | ObjTrackState *pNode = dsItem->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 181 | |
| 182 | if (pNode->parent_object != HandleToUint64(descriptor_pool)) { |
| 183 | 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] | 184 | object_handle, "VUID-vkFreeDescriptorSets-pDescriptorSets-parent", |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 185 | "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 186 | " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 ").", |
| 187 | HandleToUint64(descriptor_set), pNode->parent_object, HandleToUint64(descriptor_pool)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 188 | } |
| 189 | } else { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 190 | 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] | 191 | object_handle, "VUID-vkFreeDescriptorSets-pDescriptorSets-00310", "Invalid %s Object 0x%" PRIxLEAST64 ".", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 192 | object_string[kVulkanObjectTypeDescriptorSet], object_handle); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 193 | } |
| 194 | return skip; |
| 195 | } |
| 196 | |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 197 | template <typename DispObj> |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 198 | bool ValidateDescriptorWrite(DispObj disp, VkWriteDescriptorSet const *desc, bool isPush) { |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 199 | bool skip = false; |
| 200 | |
| 201 | if (!isPush && desc->dstSet) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 202 | skip |= DeviceValidateObject(disp, desc->dstSet, kVulkanObjectTypeDescriptorSet, false, |
| 203 | "VUID-VkWriteDescriptorSet-dstSet-00320", "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 207 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
| 208 | for (uint32_t idx2 = 0; idx2 < desc->descriptorCount; ++idx2) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 209 | skip |= |
| 210 | DeviceValidateObject(disp, desc->pTexelBufferView[idx2], kVulkanObjectTypeBufferView, false, |
| 211 | "VUID-VkWriteDescriptorSet-descriptorType-00323", "VUID-VkWriteDescriptorSet-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | |
| 215 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 216 | (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] | 217 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 218 | for (uint32_t idx3 = 0; idx3 < desc->descriptorCount; ++idx3) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 219 | skip |= |
| 220 | DeviceValidateObject(disp, desc->pImageInfo[idx3].imageView, kVulkanObjectTypeImageView, false, |
| 221 | "VUID-VkWriteDescriptorSet-descriptorType-00326", "VUID-VkDescriptorImageInfo-commonparent"); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | |
| 225 | if ((desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 226 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 227 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 228 | (desc->descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 229 | for (uint32_t idx4 = 0; idx4 < desc->descriptorCount; ++idx4) { |
| 230 | if (desc->pBufferInfo[idx4].buffer) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 231 | skip |= DeviceValidateObject(disp, desc->pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer, false, |
| 232 | "VUID-VkDescriptorBufferInfo-buffer-parameter", kVUIDUndefined); |
Chris Forbes | 2c600e9 | 2017-10-20 11:13:20 -0700 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | return skip; |
| 238 | } |
| 239 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 240 | bool PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, |
| 241 | VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, |
| 242 | const VkWriteDescriptorSet *pDescriptorWrites) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 243 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 244 | skip |= DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 245 | "VUID-vkCmdPushDescriptorSetKHR-commandBuffer-parameter", |
| 246 | "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
| 247 | skip |= DeviceValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, |
| 248 | "VUID-vkCmdPushDescriptorSetKHR-layout-parameter", "VUID-vkCmdPushDescriptorSetKHR-commonparent"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 249 | if (pDescriptorWrites) { |
| 250 | for (uint32_t index0 = 0; index0 < descriptorWriteCount; ++index0) { |
| 251 | skip |= ValidateDescriptorWrite(commandBuffer, &pDescriptorWrites[index0], true); |
| 252 | } |
| 253 | } |
| 254 | return skip; |
| 255 | } |
| 256 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 257 | void CreateQueue(VkDevice device, VkQueue vkObj) { |
| 258 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 259 | |
| 260 | 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] | 261 | 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] | 262 | object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT", HandleToUint64(vkObj)); |
| 263 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 264 | ObjTrackState *p_obj_node = NULL; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 265 | auto queue_item = device_data->objdata.object_map[kVulkanObjectTypeQueue].find(HandleToUint64(vkObj)); |
| 266 | if (queue_item == device_data->objdata.object_map[kVulkanObjectTypeQueue].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 267 | p_obj_node = new ObjTrackState; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 268 | device_data->objdata.object_map[kVulkanObjectTypeQueue][HandleToUint64(vkObj)] = p_obj_node; |
| 269 | device_data->objdata.num_objects[kVulkanObjectTypeQueue]++; |
| 270 | device_data->objdata.num_total_objects++; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 271 | } else { |
| 272 | p_obj_node = queue_item->second; |
| 273 | } |
| 274 | p_obj_node->object_type = kVulkanObjectTypeQueue; |
| 275 | p_obj_node->status = OBJSTATUS_NONE; |
| 276 | p_obj_node->handle = HandleToUint64(vkObj); |
| 277 | } |
| 278 | |
| 279 | void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) { |
| 280 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); |
| 281 | 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] | 282 | 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] | 283 | object_track_index++, "SwapchainImage", HandleToUint64(swapchain_image)); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 284 | |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 285 | ObjTrackState *pNewObjNode = new ObjTrackState; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 286 | pNewObjNode->object_type = kVulkanObjectTypeImage; |
| 287 | pNewObjNode->status = OBJSTATUS_NONE; |
| 288 | pNewObjNode->handle = HandleToUint64(swapchain_image); |
| 289 | pNewObjNode->parent_object = HandleToUint64(swapchain); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 290 | device_data->objdata.swapchainImageMap[HandleToUint64(swapchain_image)] = pNewObjNode; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 291 | } |
| 292 | |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 293 | bool DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, const std::string &error_code) { |
| 294 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 295 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 296 | 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] | 297 | const ObjTrackState *object_info = item.second; |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 298 | skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], |
| 299 | object_info->handle, error_code, |
| 300 | "OBJ ERROR : For device 0x%" PRIxLEAST64 ", %s object 0x%" PRIxLEAST64 " has not been destroyed.", |
| 301 | 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] | 302 | } |
Mark Lobodzinski | 5183a03 | 2018-09-13 14:44:28 -0600 | [diff] [blame] | 303 | return skip; |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void DeviceDestroyUndestroyedObjects(VkDevice device, VulkanObjectType object_type) { |
| 307 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 308 | while (!device_data->objdata.object_map[object_type].empty()) { |
| 309 | 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] | 310 | |
| 311 | ObjTrackState *object_info = item->second; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 312 | DestroyObjectSilently(&device_data->objdata, object_info->handle, object_type); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 316 | bool PreCallValidateDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 317 | dispatch_key key = get_dispatch_key(instance); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 318 | instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 319 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 320 | |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 321 | // 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] | 322 | skip |= InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, true, "VUID-vkDestroyInstance-instance-parameter", |
| 323 | kVUIDUndefined); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 324 | |
| 325 | // Validate that child devices have been destroyed |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 326 | for (const auto &iit : instance_data->objdata.object_map[kVulkanObjectTypeDevice]) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 327 | ObjTrackState *pNode = iit.second; |
| 328 | |
| 329 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
| 330 | VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[pNode->object_type]; |
| 331 | |
| 332 | skip |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, pNode->handle, |
| 333 | kVUID_ObjectTracker_ObjectLeak, "OBJ ERROR : %s object 0x%" PRIxLEAST64 " has not been destroyed.", |
| 334 | string_VkDebugReportObjectTypeEXT(debug_object_type), pNode->handle); |
| 335 | |
| 336 | // Report any remaining objects in LL |
| 337 | skip |= ReportUndestroyedObjects(device, "VUID-vkDestroyInstance-instance-00629"); |
| 338 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 339 | skip |= InstanceValidateDestroyObject(instance, device, kVulkanObjectTypeDevice, pAllocator, |
| 340 | "VUID-vkDestroyInstance-instance-00630", "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 341 | } |
| 342 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 343 | InstanceValidateDestroyObject(instance, instance, kVulkanObjectTypeInstance, pAllocator, |
| 344 | "VUID-vkDestroyInstance-instance-00630", "VUID-vkDestroyInstance-instance-00631"); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 345 | |
| 346 | return skip; |
| 347 | } |
| 348 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 349 | void PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 350 | dispatch_key key = get_dispatch_key(instance); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 351 | instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 352 | |
| 353 | // Enable the temporary callback(s) here to catch cleanup issues: |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 354 | if (instance_data->num_tmp_debug_messengers > 0) { |
| 355 | layer_enable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers, |
| 356 | instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers); |
| 357 | } |
| 358 | if (instance_data->num_tmp_report_callbacks > 0) { |
| 359 | layer_enable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks, |
| 360 | instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 361 | } |
| 362 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 363 | // Destroy physical devices |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 364 | for (auto iit = instance_data->objdata.object_map[kVulkanObjectTypePhysicalDevice].begin(); |
| 365 | iit != instance_data->objdata.object_map[kVulkanObjectTypePhysicalDevice].end();) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 366 | ObjTrackState *pNode = iit->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 367 | VkPhysicalDevice physical_device = reinterpret_cast<VkPhysicalDevice>(pNode->handle); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 368 | InstanceRecordDestroyObject(instance, physical_device, kVulkanObjectTypePhysicalDevice); |
| 369 | iit = instance_data->objdata.object_map[kVulkanObjectTypePhysicalDevice].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 370 | } |
| 371 | |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 372 | // Destroy child devices |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 373 | for (auto iit = instance_data->objdata.object_map[kVulkanObjectTypeDevice].begin(); |
| 374 | iit != instance_data->objdata.object_map[kVulkanObjectTypeDevice].end();) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 375 | ObjTrackState *pNode = iit->second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 376 | VkDevice device = reinterpret_cast<VkDevice>(pNode->handle); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 377 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 378 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 379 | InstanceRecordDestroyObject(instance, device, kVulkanObjectTypeDevice); |
| 380 | iit = instance_data->objdata.object_map[kVulkanObjectTypeDevice].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 381 | } |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 382 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 383 | instance_data->objdata.object_map[kVulkanObjectTypeDevice].clear(); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 384 | } |
| 385 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 386 | void PostCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 387 | dispatch_key key = get_dispatch_key(instance); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 388 | instance_layer_data *instance_data = GetLayerDataPtr(key, instance_layer_data_map); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 389 | |
| 390 | // Disable and cleanup the temporary callback(s): |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 391 | layer_disable_tmp_debug_messengers(instance_data->report_data, instance_data->num_tmp_debug_messengers, |
| 392 | instance_data->tmp_debug_messengers); |
| 393 | layer_disable_tmp_report_callbacks(instance_data->report_data, instance_data->num_tmp_report_callbacks, |
| 394 | instance_data->tmp_report_callbacks); |
| 395 | if (instance_data->num_tmp_debug_messengers > 0) { |
| 396 | layer_free_tmp_debug_messengers(instance_data->tmp_messenger_create_infos, instance_data->tmp_debug_messengers); |
| 397 | instance_data->num_tmp_debug_messengers = 0; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 398 | } |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 399 | if (instance_data->num_tmp_report_callbacks > 0) { |
| 400 | layer_free_tmp_report_callbacks(instance_data->tmp_report_create_infos, instance_data->tmp_report_callbacks); |
| 401 | instance_data->num_tmp_report_callbacks = 0; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | // Clean up logging callback, if any |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 405 | while (instance_data->logging_messenger.size() > 0) { |
| 406 | VkDebugUtilsMessengerEXT messenger = instance_data->logging_messenger.back(); |
| 407 | layer_destroy_messenger_callback(instance_data->report_data, messenger, pAllocator); |
| 408 | instance_data->logging_messenger.pop_back(); |
| 409 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 410 | while (instance_data->logging_callback.size() > 0) { |
| 411 | VkDebugReportCallbackEXT callback = instance_data->logging_callback.back(); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 412 | layer_destroy_report_callback(instance_data->report_data, callback, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 413 | instance_data->logging_callback.pop_back(); |
| 414 | } |
| 415 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 416 | InstanceRecordDestroyObject(instance, instance, kVulkanObjectTypeInstance); |
GabrÃel Arthúr Pétursson | 3de74ca | 2018-03-18 01:50:54 +0000 | [diff] [blame] | 417 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 418 | layer_debug_utils_destroy_instance(instance_data->report_data); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 419 | FreeLayerDataPtr(key, instance_layer_data_map); |
Mark Lobodzinski | 34f5ea6 | 2018-09-14 09:51:43 -0600 | [diff] [blame] | 420 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 421 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 422 | bool PreCallValidateDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 9bd8119 | 2017-11-13 09:38:23 -0700 | [diff] [blame] | 423 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 424 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 425 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, true, "VUID-vkDestroyDevice-device-parameter", |
| 426 | kVUIDUndefined); |
| 427 | skip |= InstanceValidateDestroyObject(device_data->physical_device, device, kVulkanObjectTypeDevice, pAllocator, |
| 428 | "VUID-vkDestroyDevice-device-00379", "VUID-vkDestroyDevice-device-00380"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 429 | // Report any remaining objects associated with this VkDevice object in LL |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 430 | skip |= ReportUndestroyedObjects(device, "VUID-vkDestroyDevice-device-00378"); |
| 431 | |
| 432 | return skip; |
| 433 | } |
| 434 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 435 | void PreCallRecordDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 436 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 437 | InstanceRecordDestroyObject(device_data->physical_device, device, kVulkanObjectTypeDevice); |
GabrÃel Arthúr Pétursson | fdcb540 | 2018-03-20 21:52:06 +0000 | [diff] [blame] | 438 | DestroyUndestroyedObjects(device); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 439 | |
| 440 | // Clean up Queue's MemRef Linked Lists |
| 441 | DestroyQueueDataStructures(device); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 442 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 443 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 444 | bool PreCallValidateGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
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-vkGetDeviceQueue-device-parameter", |
| 447 | kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 448 | return skip; |
| 449 | } |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 450 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 451 | void PostCallRecordGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { |
Mark Lobodzinski | 439645a | 2017-07-19 15:18:15 -0600 | [diff] [blame] | 452 | CreateQueue(device, *pQueue); |
| 453 | AddQueueInfo(device, queueFamilyIndex, *pQueue); |
| 454 | } |
| 455 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 456 | bool PreCallValidateGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 457 | return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceQueue2-device-parameter", |
| 458 | kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 459 | } |
| 460 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 461 | void PostCallRecordGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 462 | CreateQueue(device, *pQueue); |
| 463 | AddQueueInfo(device, pQueueInfo->queueFamilyIndex, *pQueue); |
| 464 | } |
| 465 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 466 | bool PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 467 | const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, |
| 468 | const VkCopyDescriptorSet *pDescriptorCopies) { |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 469 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 470 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkUpdateDescriptorSets-device-parameter", |
| 471 | kVUIDUndefined); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 472 | if (pDescriptorCopies) { |
| 473 | for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { |
| 474 | if (pDescriptorCopies[idx0].dstSet) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 475 | skip |= DeviceValidateObject(device, pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, |
| 476 | "VUID-VkCopyDescriptorSet-dstSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 477 | } |
| 478 | if (pDescriptorCopies[idx0].srcSet) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 479 | skip |= DeviceValidateObject(device, pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, |
| 480 | "VUID-VkCopyDescriptorSet-srcSet-parameter", "VUID-VkCopyDescriptorSet-commonparent"); |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 481 | } |
| 482 | } |
| 483 | } |
| 484 | if (pDescriptorWrites) { |
| 485 | for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { |
| 486 | skip |= ValidateDescriptorWrite(device, &pDescriptorWrites[idx1], false); |
| 487 | } |
| 488 | } |
| 489 | return skip; |
| 490 | } |
| 491 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 492 | bool PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 493 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 494 | VkPipeline *pPipelines) { |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 495 | bool skip = VK_FALSE; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 496 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkCreateComputePipelines-device-parameter", |
| 497 | kVUIDUndefined); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 498 | if (pCreateInfos) { |
| 499 | for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { |
| 500 | if (pCreateInfos[idx0].basePipelineHandle) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 501 | skip |= DeviceValidateObject(device, pCreateInfos[idx0].basePipelineHandle, kVulkanObjectTypePipeline, true, |
| 502 | "VUID-VkComputePipelineCreateInfo-flags-00697", |
| 503 | "VUID-VkComputePipelineCreateInfo-commonparent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 504 | } |
| 505 | if (pCreateInfos[idx0].layout) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 506 | skip |= DeviceValidateObject(device, pCreateInfos[idx0].layout, kVulkanObjectTypePipelineLayout, false, |
| 507 | "VUID-VkComputePipelineCreateInfo-layout-parameter", |
| 508 | "VUID-VkComputePipelineCreateInfo-commonparent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 509 | } |
| 510 | if (pCreateInfos[idx0].stage.module) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 511 | skip |= DeviceValidateObject(device, pCreateInfos[idx0].stage.module, kVulkanObjectTypeShaderModule, false, |
| 512 | "VUID-VkPipelineShaderStageCreateInfo-module-parameter", kVUIDUndefined); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 513 | } |
| 514 | } |
| 515 | } |
| 516 | if (pipelineCache) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 517 | skip |= DeviceValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true, |
| 518 | "VUID-vkCreateComputePipelines-pipelineCache-parameter", |
| 519 | "VUID-vkCreateComputePipelines-pipelineCache-parent"); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 520 | } |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 521 | if (skip) { |
| 522 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 523 | pPipelines[i] = VK_NULL_HANDLE; |
| 524 | } |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 525 | } |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 526 | return skip; |
| 527 | } |
Mark Lobodzinski | 17de5fd | 2018-06-22 15:09:53 -0600 | [diff] [blame] | 528 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 529 | void PostCallRecordCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 530 | const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, |
| 531 | VkPipeline *pPipelines) { |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 532 | for (uint32_t idx1 = 0; idx1 < createInfoCount; ++idx1) { |
| 533 | if (pPipelines[idx1] != VK_NULL_HANDLE) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 534 | DeviceCreateObject(device, pPipelines[idx1], kVulkanObjectTypePipeline, pAllocator); |
Mark Lobodzinski | 2d26c5f | 2017-07-19 12:37:04 -0600 | [diff] [blame] | 535 | } |
| 536 | } |
Mark Lobodzinski | b58fe78 | 2018-09-14 11:50:27 -0600 | [diff] [blame] | 537 | } |
| 538 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 539 | bool PreCallValidateResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 540 | bool skip = false; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 541 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 542 | |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 543 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkResetDescriptorPool-device-parameter", |
| 544 | kVUIDUndefined); |
| 545 | skip |= DeviceValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 546 | "VUID-vkResetDescriptorPool-descriptorPool-parameter", |
| 547 | "VUID-vkResetDescriptorPool-descriptorPool-parent"); |
| 548 | for (const auto &itr : device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet]) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 549 | if (itr.second->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 550 | skip |= DeviceValidateDestroyObject(device, (VkDescriptorSet)(itr.first), kVulkanObjectTypeDescriptorSet, nullptr, |
| 551 | kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 552 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 553 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 554 | return skip; |
| 555 | } |
| 556 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 557 | void PreCallRecordResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 558 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 559 | |
| 560 | // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. Remove this pool's descriptor sets from |
| 561 | // our descriptorSet map. |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 562 | auto itr = device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].begin(); |
| 563 | while (itr != device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 564 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 565 | auto del_itr = itr++; |
| 566 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 567 | DeviceRecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 568 | } |
| 569 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 570 | } |
| 571 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 572 | bool PreCallValidateBeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 573 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map); |
| 574 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 575 | skip |= DeviceValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false, |
| 576 | "VUID-vkBeginCommandBuffer-commandBuffer-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 577 | if (begin_info) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 578 | ObjTrackState *pNode = device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer][HandleToUint64(command_buffer)]; |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 579 | if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && |
| 580 | (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 581 | skip |= DeviceValidateObject(command_buffer, begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, |
| 582 | true, "VUID-VkCommandBufferBeginInfo-flags-00055", |
| 583 | "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
| 584 | skip |= DeviceValidateObject(command_buffer, begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, |
| 585 | false, "VUID-VkCommandBufferBeginInfo-flags-00053", |
| 586 | "VUID-VkCommandBufferInheritanceInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 587 | } |
| 588 | } |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 589 | return skip; |
| 590 | } |
| 591 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 592 | void PostCallRecordCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, |
| 593 | const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 594 | InstanceCreateObject(instance, *pCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 595 | } |
| 596 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 597 | bool PreCallValidateDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 598 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 599 | bool skip = InstanceValidateDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator, |
| 600 | "VUID-vkDestroyDebugReportCallbackEXT-instance-01242", |
| 601 | "VUID-vkDestroyDebugReportCallbackEXT-instance-01243"); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 602 | return skip; |
| 603 | } |
| 604 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 605 | void PreCallRecordDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, |
| 606 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 607 | InstanceRecordDestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 608 | } |
| 609 | |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 610 | // VK_EXT_debug_utils commands |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 611 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 612 | bool PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 613 | return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 614 | "VUID-vkSetDebugUtilsObjectNameEXT-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 615 | } |
| 616 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 617 | bool PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 618 | return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkSetDebugUtilsObjectTagEXT-device-parameter", |
| 619 | kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 620 | } |
| 621 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 622 | bool PreCallValidateQueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 623 | return DeviceValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueBeginDebugUtilsLabelEXT-queue-parameter", |
| 624 | kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 625 | } |
| 626 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 627 | bool PreCallValidateQueueEndDebugUtilsLabelEXT(VkQueue queue) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 628 | return DeviceValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueEndDebugUtilsLabelEXT-queue-parameter", |
| 629 | kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 630 | } |
| 631 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 632 | bool PreCallValidateQueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 633 | return DeviceValidateObject(queue, queue, kVulkanObjectTypeQueue, false, "VUID-vkQueueInsertDebugUtilsLabelEXT-queue-parameter", |
| 634 | kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 635 | } |
| 636 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 637 | bool PreCallValidateCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 638 | return DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 639 | "VUID-vkCmdBeginDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 642 | bool PreCallValidateCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 643 | return DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 644 | "VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 645 | } |
| 646 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 647 | bool PreCallValidateCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 648 | return DeviceValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, |
| 649 | "VUID-vkCmdInsertDebugUtilsLabelEXT-commandBuffer-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 650 | } |
| 651 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 652 | bool PreCallValidateCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 653 | const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 654 | return InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 655 | "VUID-vkCreateDebugUtilsMessengerEXT-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 656 | } |
| 657 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 658 | void PostCallRecordCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, |
| 659 | const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 660 | InstanceCreateObject(instance, *pMessenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator); |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 661 | } |
| 662 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 663 | bool PreCallValidateDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 664 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 665 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 666 | skip |= InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 667 | "VUID-vkDestroyDebugUtilsMessengerEXT-instance-parameter", kVUIDUndefined); |
| 668 | skip |= InstanceValidateObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, false, |
| 669 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-parameter", |
| 670 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-parent"); |
| 671 | skip |= InstanceValidateDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT, pAllocator, |
| 672 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01915", |
| 673 | "VUID-vkDestroyDebugUtilsMessengerEXT-messenger-01916"); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 674 | return skip; |
| 675 | } |
| 676 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 677 | void PreCallRecordDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, |
| 678 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 679 | InstanceRecordDestroyObject(instance, messenger, kVulkanObjectTypeDebugUtilsMessengerEXT); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 680 | } |
| 681 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 682 | bool PreCallValidateSubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, |
| 683 | VkDebugUtilsMessageTypeFlagsEXT messageTypes, |
| 684 | const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData) { |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 685 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 686 | skip |= InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 687 | "VUID-vkeSubmitDebugUtilsMessageEXT-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | 0de500d | 2018-09-14 15:14:01 -0600 | [diff] [blame] | 688 | return skip; |
Mark Young | 6ba8abe | 2017-11-09 10:37:04 -0700 | [diff] [blame] | 689 | } |
| 690 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 691 | bool PreCallValidateEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, |
| 692 | VkLayerProperties *pProperties) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 693 | // Set null_allowed to true here to cover for the lame loader-layer interface wrapper calls |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 694 | return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, true, |
| 695 | "VUID-vkEnumerateDeviceLayerProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 696 | } |
| 697 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 698 | bool PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, |
| 699 | VkExtensionProperties *pProperties) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 700 | // Set null_allowed to true here to cover for the lame loader-layer interface wrapper calls |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 701 | return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, true, |
| 702 | "VUID-vkEnumerateDeviceExtensionProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 703 | } |
| 704 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 705 | bool PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 706 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 707 | return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 708 | "VUID-vkCreateDevice-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 709 | } |
| 710 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 711 | void PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
| 712 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 713 | instance_layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map); |
| 714 | InstanceCreateObject(phy_dev_data->instance, *pDevice, kVulkanObjectTypeDevice, pAllocator); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 715 | } |
| 716 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 717 | bool PreCallValidateGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 718 | VkImage *pSwapchainImages) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 719 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 720 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetSwapchainImagesKHR-device-parameter", |
| 721 | "VUID-vkGetSwapchainImagesKHR-commonparent"); |
| 722 | skip |= DeviceValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, |
| 723 | "VUID-vkGetSwapchainImagesKHR-swapchain-parameter", "VUID-vkGetSwapchainImagesKHR-commonparent"); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 724 | return skip; |
| 725 | } |
| 726 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 727 | void PostCallRecordGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, |
| 728 | VkImage *pSwapchainImages) { |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 729 | if (pSwapchainImages != NULL) { |
| 730 | for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { |
| 731 | CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); |
| 732 | } |
| 733 | } |
| 734 | } |
| 735 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 736 | bool PreCallValidateCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 737 | const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 738 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 739 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 740 | "VUID-vkCreateDescriptorSetLayout-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 741 | if (pCreateInfo) { |
| 742 | if (pCreateInfo->pBindings) { |
| 743 | for (uint32_t binding_index = 0; binding_index < pCreateInfo->bindingCount; ++binding_index) { |
| 744 | const VkDescriptorSetLayoutBinding &binding = pCreateInfo->pBindings[binding_index]; |
| 745 | const bool is_sampler_type = binding.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER || |
| 746 | binding.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 747 | if (binding.pImmutableSamplers && is_sampler_type) { |
| 748 | for (uint32_t index2 = 0; index2 < binding.descriptorCount; ++index2) { |
| 749 | const VkSampler sampler = binding.pImmutableSamplers[index2]; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 750 | skip |= DeviceValidateObject(device, sampler, kVulkanObjectTypeSampler, false, |
| 751 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Petr Kraus | 42f6f8d | 2017-12-17 17:37:33 +0100 | [diff] [blame] | 752 | } |
| 753 | } |
| 754 | } |
| 755 | } |
| 756 | } |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 757 | return skip; |
| 758 | } |
| 759 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 760 | void PostCallRecordCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 761 | const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 762 | DeviceCreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); |
Mark Lobodzinski | be4b345 | 2018-09-14 16:14:33 -0600 | [diff] [blame] | 763 | } |
| 764 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 765 | inline bool ValidateSamplerObjects(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo) { |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 766 | bool skip = false; |
| 767 | if (pCreateInfo->pBindings) { |
| 768 | for (uint32_t index1 = 0; index1 < pCreateInfo->bindingCount; ++index1) { |
| 769 | for (uint32_t index2 = 0; index2 < pCreateInfo->pBindings[index1].descriptorCount; ++index2) { |
| 770 | if (pCreateInfo->pBindings[index1].pImmutableSamplers) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 771 | skip |= DeviceValidateObject(device, pCreateInfo->pBindings[index1].pImmutableSamplers[index2], |
| 772 | kVulkanObjectTypeSampler, true, |
| 773 | "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", kVUIDUndefined); |
Mark Lobodzinski | 88a1a66 | 2018-07-02 14:09:39 -0600 | [diff] [blame] | 774 | } |
| 775 | } |
| 776 | } |
| 777 | } |
| 778 | return skip; |
| 779 | } |
| 780 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 781 | bool PreCallValidateGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 782 | VkDescriptorSetLayoutSupport *pSupport) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 783 | bool skip = DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 784 | "VUID-vkGetDescriptorSetLayoutSupport-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 785 | if (pCreateInfo) { |
| 786 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
| 787 | } |
| 788 | return skip; |
| 789 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 790 | bool PreCallValidateGetDescriptorSetLayoutSupportKHR(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 791 | VkDescriptorSetLayoutSupport *pSupport) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 792 | bool skip = DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 793 | "VUID-vkGetDescriptorSetLayoutSupportKHR-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 794 | if (pCreateInfo) { |
| 795 | skip |= ValidateSamplerObjects(device, pCreateInfo); |
| 796 | } |
| 797 | return skip; |
| 798 | } |
| 799 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 800 | bool PreCallValidateGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, |
| 801 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 802 | bool skip = InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 803 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 804 | return skip; |
| 805 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 806 | |
| 807 | void PostCallRecordGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, |
| 808 | VkQueueFamilyProperties *pQueueFamilyProperties) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 809 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 810 | auto instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), instance_layer_data_map); |
| 811 | if (instance_data->objdata.queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 812 | instance_data->objdata.queue_family_properties.resize(*pQueueFamilyPropertyCount); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 813 | } |
| 814 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 815 | instance_data->objdata.queue_family_properties[i] = pQueueFamilyProperties[i]; |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 816 | } |
| 817 | } |
| 818 | } |
| 819 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 820 | void PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 821 | VkInstance *pInstance) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 822 | InstanceCreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 823 | } |
| 824 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 825 | bool PreCallValidateEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 826 | VkPhysicalDevice *pPhysicalDevices) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 827 | bool skip = InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 828 | "VUID-vkEnumeratePhysicalDevices-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 829 | return skip; |
| 830 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 831 | |
| 832 | void PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, |
| 833 | VkPhysicalDevice *pPhysicalDevices) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 834 | if (pPhysicalDevices) { |
| 835 | for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 836 | InstanceCreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 837 | } |
| 838 | } |
| 839 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 840 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 841 | bool PreCallValidateAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 842 | VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 843 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 844 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateCommandBuffers-device-parameter", |
| 845 | kVUIDUndefined); |
| 846 | skip |= DeviceValidateObject(device, pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, |
| 847 | "VUID-VkCommandBufferAllocateInfo-commandPool-parameter", kVUIDUndefined); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 848 | return skip; |
| 849 | } |
| 850 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 851 | void PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 852 | VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 853 | for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { |
| 854 | AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); |
| 855 | } |
| 856 | } |
| 857 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 858 | bool PreCallValidateAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 859 | VkDescriptorSet *pDescriptorSets) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 860 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 861 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkAllocateDescriptorSets-device-parameter", |
| 862 | kVUIDUndefined); |
| 863 | skip |= DeviceValidateObject(device, pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 864 | "VUID-VkDescriptorSetAllocateInfo-descriptorPool-parameter", |
| 865 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 866 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 867 | skip |= DeviceValidateObject(device, pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, |
| 868 | "VUID-VkDescriptorSetAllocateInfo-pSetLayouts-parameter", |
| 869 | "VUID-VkDescriptorSetAllocateInfo-commonparent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 870 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 871 | return skip; |
| 872 | } |
| 873 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 874 | void PostCallRecordAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, |
| 875 | VkDescriptorSet *pDescriptorSets) { |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 876 | for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { |
| 877 | AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 878 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 879 | } |
| 880 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 881 | bool PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 882 | const VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 883 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 884 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeCommandBuffers-device-parameter", |
| 885 | kVUIDUndefined); |
| 886 | skip |= DeviceValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, |
| 887 | "VUID-vkFreeCommandBuffers-commandPool-parameter", "VUID-vkFreeCommandBuffers-commandPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 888 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
| 889 | if (pCommandBuffers[i] != VK_NULL_HANDLE) { |
| 890 | skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 891 | skip |= DeviceValidateDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, |
| 892 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 893 | } |
| 894 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 895 | return skip; |
| 896 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 897 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 898 | void PreCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 899 | const VkCommandBuffer *pCommandBuffers) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 900 | for (uint32_t i = 0; i < commandBufferCount; i++) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 901 | DeviceRecordDestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 902 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 903 | } |
| 904 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 905 | bool PreCallValidateDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 906 | return DeviceValidateDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, |
| 907 | "VUID-vkDestroySwapchainKHR-swapchain-01283", "VUID-vkDestroySwapchainKHR-swapchain-01284"); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 908 | } |
| 909 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 910 | void PreCallRecordDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 911 | DeviceRecordDestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR); |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 912 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 913 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = device_data->objdata.swapchainImageMap.begin(); |
| 914 | while (itr != device_data->objdata.swapchainImageMap.end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 915 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 916 | if (pNode->parent_object == HandleToUint64(swapchain)) { |
| 917 | delete pNode; |
| 918 | auto delete_item = itr++; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 919 | device_data->objdata.swapchainImageMap.erase(delete_item); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 920 | } else { |
| 921 | ++itr; |
| 922 | } |
| 923 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 924 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 925 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 926 | bool PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 927 | const VkDescriptorSet *pDescriptorSets) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 928 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 929 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkFreeDescriptorSets-device-parameter", |
| 930 | kVUIDUndefined); |
| 931 | skip |= DeviceValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, |
| 932 | "VUID-vkFreeDescriptorSets-descriptorPool-parameter", |
| 933 | "VUID-vkFreeDescriptorSets-descriptorPool-parent"); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 934 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
| 935 | if (pDescriptorSets[i] != VK_NULL_HANDLE) { |
| 936 | skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 937 | skip |= DeviceValidateDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, kVUIDUndefined, |
| 938 | kVUIDUndefined); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 939 | } |
| 940 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 941 | return skip; |
| 942 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 943 | void PreCallRecordFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, |
| 944 | const VkDescriptorSet *pDescriptorSets) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 945 | for (uint32_t i = 0; i < descriptorSetCount; i++) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 946 | DeviceRecordDestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 947 | } |
Mark Lobodzinski | 1c7fa37 | 2018-09-17 11:35:00 -0600 | [diff] [blame] | 948 | } |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 949 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 950 | bool PreCallValidateDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, |
| 951 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 952 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 953 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 954 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyDescriptorPool-device-parameter", |
| 955 | kVUIDUndefined); |
| 956 | skip |= DeviceValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, true, |
| 957 | "VUID-vkDestroyDescriptorPool-descriptorPool-parameter", |
| 958 | "VUID-vkDestroyDescriptorPool-descriptorPool-parent"); |
| 959 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = |
| 960 | device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].begin(); |
| 961 | while (itr != device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 962 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 963 | auto del_itr = itr++; |
| 964 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 965 | skip |= DeviceValidateDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, |
| 966 | nullptr, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 967 | } |
| 968 | } |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 969 | skip |= DeviceValidateDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, |
| 970 | "VUID-vkDestroyDescriptorPool-descriptorPool-00304", |
| 971 | "VUID-vkDestroyDescriptorPool-descriptorPool-00305"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 972 | return skip; |
| 973 | } |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 974 | void PreCallRecordDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 975 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 976 | std::unordered_map<uint64_t, ObjTrackState *>::iterator itr = |
| 977 | device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].begin(); |
| 978 | while (itr != device_data->objdata.object_map[kVulkanObjectTypeDescriptorSet].end()) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 979 | ObjTrackState *pNode = (*itr).second; |
| 980 | auto del_itr = itr++; |
| 981 | if (pNode->parent_object == HandleToUint64(descriptorPool)) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 982 | DeviceRecordDestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 983 | } |
| 984 | } |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 985 | DeviceRecordDestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 986 | } |
| 987 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 988 | bool PreCallValidateDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 989 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
| 990 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 991 | skip |= DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkDestroyCommandPool-device-parameter", |
| 992 | kVUIDUndefined); |
| 993 | skip |= DeviceValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, true, |
| 994 | "VUID-vkDestroyCommandPool-commandPool-parameter", "VUID-vkDestroyCommandPool-commandPool-parent"); |
| 995 | auto itr = device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].begin(); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 996 | auto del_itr = itr; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 997 | while (itr != device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | efc6439 | 2017-07-18 13:15:47 -0600 | [diff] [blame] | 998 | ObjTrackState *pNode = (*itr).second; |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 999 | del_itr = itr++; |
| 1000 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
| 1001 | skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast<VkCommandBuffer>((*del_itr).first)); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1002 | skip |= DeviceValidateDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), |
| 1003 | kVulkanObjectTypeCommandBuffer, nullptr, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1004 | } |
| 1005 | } |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1006 | skip |= |
| 1007 | DeviceValidateDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, |
| 1008 | "VUID-vkDestroyCommandPool-commandPool-00042", "VUID-vkDestroyCommandPool-commandPool-00043"); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1009 | return skip; |
| 1010 | } |
| 1011 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1012 | void PreCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1013 | layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1014 | auto itr = device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].begin(); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1015 | auto del_itr = itr; |
| 1016 | // 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] | 1017 | while (itr != device_data->objdata.object_map[kVulkanObjectTypeCommandBuffer].end()) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1018 | ObjTrackState *pNode = (*itr).second; |
| 1019 | del_itr = itr++; |
| 1020 | if (pNode->parent_object == HandleToUint64(commandPool)) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1021 | DeviceRecordDestroyObject(device, reinterpret_cast<VkCommandBuffer>((*del_itr).first), kVulkanObjectTypeCommandBuffer); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1022 | } |
| 1023 | } |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1024 | DeviceRecordDestroyObject(device, commandPool, kVulkanObjectTypeCommandPool); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1025 | } |
| 1026 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1027 | bool PreCallValidateGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, |
| 1028 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1029 | return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1030 | "VUID-vkGetPhysicalDeviceQueueFamilyProperties2-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1031 | } |
| 1032 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1033 | void PostCallRecordGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, |
| 1034 | VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1035 | 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] | 1036 | if (pQueueFamilyProperties != NULL) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1037 | if (instance_data->objdata.queue_family_properties.size() < *pQueueFamilyPropertyCount) { |
| 1038 | instance_data->objdata.queue_family_properties.resize(*pQueueFamilyPropertyCount); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1039 | } |
| 1040 | for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1041 | instance_data->objdata.queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1042 | } |
| 1043 | } |
| 1044 | } |
| 1045 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1046 | bool PreCallValidateGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1047 | VkDisplayPropertiesKHR *pProperties) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1048 | bool skip = InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1049 | "VUID-vkGetPhysicalDeviceDisplayPropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1050 | return skip; |
| 1051 | } |
| 1052 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1053 | void PostCallRecordGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1054 | VkDisplayPropertiesKHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1055 | if (pProperties) { |
| 1056 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1057 | InstanceCreateObject(physicalDevice, pProperties[i].display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1062 | bool PreCallValidateGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, |
| 1063 | VkDisplayModePropertiesKHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1064 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1065 | skip |= InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1066 | "VUID-vkGetDisplayModePropertiesKHR-physicalDevice-parameter", kVUIDUndefined); |
| 1067 | skip |= InstanceValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 1068 | "VUID-vkGetDisplayModePropertiesKHR-display-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1069 | |
| 1070 | return skip; |
| 1071 | } |
| 1072 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1073 | void PostCallRecordGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, |
| 1074 | VkDisplayModePropertiesKHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1075 | if (pProperties) { |
Tony-LunarG | cd0c6b0 | 2018-10-26 14:56:44 -0600 | [diff] [blame] | 1076 | for (uint32_t i = 0; i < *pPropertyCount; ++i) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1077 | InstanceCreateObject(physicalDevice, pProperties[i].displayMode, kVulkanObjectTypeDisplayModeKHR, nullptr); |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1078 | } |
| 1079 | } |
Shannon McPherson | 9d5167f | 2018-05-02 15:24:37 -0600 | [diff] [blame] | 1080 | } |
| 1081 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1082 | bool PreCallValidateDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1083 | return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, |
| 1084 | "VUID-vkDebugMarkerSetObjectNameEXT-device-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1085 | } |
| 1086 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1087 | bool PreCallValidateGetDeviceProcAddr(VkDevice device, const char *funcName) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1088 | return DeviceValidateObject(device, device, kVulkanObjectTypeDevice, false, "VUID-vkGetDeviceProcAddr-device-parameter", |
| 1089 | kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1090 | } |
| 1091 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1092 | bool PreCallValidateGetInstanceProcAddr(VkInstance instance, const char *funcName) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1093 | return InstanceValidateObject(instance, instance, kVulkanObjectTypeInstance, false, |
| 1094 | "VUID-vkGetInstanceProcAddr-instance-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1095 | } |
| 1096 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1097 | bool PreCallValidateGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1098 | VkDisplayProperties2KHR *pProperties) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1099 | return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1100 | "VUID-vkGetPhysicalDeviceDisplayProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1101 | } |
| 1102 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1103 | void PostCallRecordGetPhysicalDeviceDisplayProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, |
| 1104 | VkDisplayProperties2KHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1105 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1106 | InstanceCreateObject(physicalDevice, pProperties[index].displayProperties.display, kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1107 | } |
| 1108 | } |
| 1109 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1110 | bool PreCallValidateGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1111 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1112 | return InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1113 | "VUID-vkGetDisplayPlaneSupportedDisplaysKHR-physicalDevice-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1114 | } |
| 1115 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1116 | void PostCallRecordGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, |
| 1117 | uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1118 | for (uint32_t index = 0; index < *pDisplayCount; ++index) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1119 | InstanceCreateObject(physicalDevice, pDisplays[index], kVulkanObjectTypeDisplayKHR, nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1120 | } |
| 1121 | } |
| 1122 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1123 | bool PreCallValidateGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, |
| 1124 | VkDisplayModeProperties2KHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1125 | bool skip = false; |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1126 | skip |= InstanceValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, |
| 1127 | "VUID-vkGetDisplayModeProperties2KHR-physicalDevice-parameter", kVUIDUndefined); |
| 1128 | skip |= InstanceValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, |
| 1129 | "VUID-vkGetDisplayModeProperties2KHR-display-parameter", kVUIDUndefined); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1130 | return skip; |
| 1131 | } |
| 1132 | |
Mark Lobodzinski | 63902f0 | 2018-09-21 10:36:44 -0600 | [diff] [blame^] | 1133 | void PostCallRecordGetDisplayModeProperties2KHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, |
| 1134 | VkDisplayModeProperties2KHR *pProperties) { |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1135 | for (uint32_t index = 0; index < *pPropertyCount; ++index) { |
Mark Lobodzinski | c3ff7a9 | 2018-09-20 11:05:57 -0600 | [diff] [blame] | 1136 | InstanceCreateObject(physicalDevice, pProperties[index].displayModeProperties.displayMode, kVulkanObjectTypeDisplayModeKHR, |
| 1137 | nullptr); |
Mark Lobodzinski | a2e9736 | 2018-09-17 13:58:32 -0600 | [diff] [blame] | 1138 | } |
| 1139 | } |
| 1140 | |
Mark Lobodzinski | b2de97f | 2017-07-06 15:28:11 -0600 | [diff] [blame] | 1141 | } // namespace object_tracker |