/* * Copyright (c) 2015-2017 The Khronos Group Inc. * Copyright (c) 2015-2017 Valve Corporation * Copyright (c) 2015-2017 LunarG, Inc. * Copyright (c) 2015-2017 Google, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Mark Lobodzinski * Author: Tobin Ehlis * Author: Courtney Goeltzenleuchter * Author: Jon Ashburn * Author: Mike Stroyan * Author: Tony Barbour */ #include "vk_loader_platform.h" #include "vulkan/vulkan.h" #include #include #include #include #include #include "vk_layer_config.h" #include "vk_layer_data.h" #include "vk_layer_logging.h" #include "vk_layer_table.h" #include "vk_object_types.h" #include "vulkan/vk_layer.h" #include "object_tracker.h" #include "vk_validation_error_messages.h" namespace object_tracker { static uint32_t loader_layer_if_version = CURRENT_LOADER_LAYER_INTERFACE_VERSION; static void InitObjectTracker(layer_data *my_data, const VkAllocationCallbacks *pAllocator) { layer_debug_actions(my_data->report_data, my_data->logging_callback, pAllocator, "lunarg_object_tracker"); } // Add new queue to head of global queue list static void AddQueueInfo(VkDevice device, uint32_t queue_node_index, VkQueue queue) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); auto queueItem = device_data->queue_info_map.find(queue); if (queueItem == device_data->queue_info_map.end()) { OT_QUEUE_INFO *p_queue_info = new OT_QUEUE_INFO; if (p_queue_info != NULL) { memset(p_queue_info, 0, sizeof(OT_QUEUE_INFO)); p_queue_info->queue = queue; p_queue_info->queue_node_index = queue_node_index; device_data->queue_info_map[queue] = p_queue_info; } else { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast(queue), __LINE__, OBJTRACK_INTERNAL_ERROR, LayerName, "ERROR: VK_ERROR_OUT_OF_HOST_MEMORY -- could not allocate memory for Queue Information"); } } } // Destroy memRef lists and free all memory static void DestroyQueueDataStructures(VkDevice device) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); for (auto queue_item : device_data->queue_info_map) { delete queue_item.second; } device_data->queue_info_map.clear(); // Destroy the items in the queue map auto queue = device_data->object_map[kVulkanObjectTypeQueue].begin(); while (queue != device_data->object_map[kVulkanObjectTypeQueue].end()) { uint32_t obj_index = queue->second->object_type; assert(device_data->num_total_objects > 0); device_data->num_total_objects--; assert(device_data->num_objects[obj_index] > 0); device_data->num_objects[obj_index]--; log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, queue->second->handle, __LINE__, OBJTRACK_NONE, LayerName, "OBJ_STAT Destroy Queue obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " Queue objs).", queue->second->handle, device_data->num_total_objects, device_data->num_objects[obj_index]); delete queue->second; queue = device_data->object_map[kVulkanObjectTypeQueue].erase(queue); } } // Check Queue type flags for selected queue operations static void ValidateQueueFlags(VkQueue queue, const char *function) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(queue), layer_data_map); auto queue_item = device_data->queue_info_map.find(queue); if (queue_item != device_data->queue_info_map.end()) { OT_QUEUE_INFO *pQueueInfo = queue_item->second; if (pQueueInfo != NULL) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(device_data->physical_device), layer_data_map); if ((instance_data->queue_family_properties[pQueueInfo->queue_node_index].queueFlags & VK_QUEUE_SPARSE_BINDING_BIT) == 0) { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast(queue), __LINE__, VALIDATION_ERROR_01651, LayerName, "Attempting %s on a non-memory-management capable queue -- VK_QUEUE_SPARSE_BINDING_BIT not set. %s", function, validation_error_map[VALIDATION_ERROR_01651]); } } } } static void AllocateCommandBuffer(VkDevice device, const VkCommandPool command_pool, const VkCommandBuffer command_buffer, VkCommandBufferLevel level) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast(command_buffer), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT", reinterpret_cast(command_buffer)); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = kVulkanObjectTypeCommandBuffer; pNewObjNode->handle = reinterpret_cast(command_buffer); pNewObjNode->parent_object = reinterpret_cast(command_pool); if (level == VK_COMMAND_BUFFER_LEVEL_SECONDARY) { pNewObjNode->status = OBJSTATUS_COMMAND_BUFFER_SECONDARY; } else { pNewObjNode->status = OBJSTATUS_NONE; } device_data->object_map[kVulkanObjectTypeCommandBuffer][reinterpret_cast(command_buffer)] = pNewObjNode; device_data->num_objects[kVulkanObjectTypeCommandBuffer]++; device_data->num_total_objects++; } static bool ValidateCommandBuffer(VkDevice device, VkCommandPool command_pool, VkCommandBuffer command_buffer) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); bool skip = false; uint64_t object_handle = reinterpret_cast(command_buffer); if (device_data->object_map[kVulkanObjectTypeCommandBuffer].find(object_handle) != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { OBJTRACK_NODE *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][reinterpret_cast(command_buffer)]; if (pNode->parent_object != reinterpret_cast(command_pool)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, object_handle, __LINE__, VALIDATION_ERROR_00102, LayerName, "FreeCommandBuffers is attempting to free Command Buffer 0x%" PRIxLEAST64 " belonging to Command Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 "). %s", reinterpret_cast(command_buffer), pNode->parent_object, reinterpret_cast(command_pool), validation_error_map[VALIDATION_ERROR_00102]); } } else { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, object_handle, __LINE__, VALIDATION_ERROR_00097, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", object_string[kVulkanObjectTypeCommandBuffer], object_handle, validation_error_map[VALIDATION_ERROR_00097]); } return skip; } static void AllocateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, reinterpret_cast(descriptor_set), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT", reinterpret_cast(descriptor_set)); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = kVulkanObjectTypeDescriptorSet; pNewObjNode->status = OBJSTATUS_NONE; pNewObjNode->handle = reinterpret_cast(descriptor_set); pNewObjNode->parent_object = reinterpret_cast(descriptor_pool); device_data->object_map[kVulkanObjectTypeDescriptorSet][reinterpret_cast(descriptor_set)] = pNewObjNode; device_data->num_objects[kVulkanObjectTypeDescriptorSet]++; device_data->num_total_objects++; } static bool ValidateDescriptorSet(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); bool skip = false; uint64_t object_handle = reinterpret_cast(descriptor_set); auto dsItem = device_data->object_map[kVulkanObjectTypeDescriptorSet].find(object_handle); if (dsItem != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { OBJTRACK_NODE *pNode = dsItem->second; if (pNode->parent_object != reinterpret_cast(descriptor_pool)) { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, object_handle, __LINE__, VALIDATION_ERROR_00927, LayerName, "FreeDescriptorSets is attempting to free descriptorSet 0x%" PRIxLEAST64 " belonging to Descriptor Pool 0x%" PRIxLEAST64 " from pool 0x%" PRIxLEAST64 "). %s", reinterpret_cast(descriptor_set), pNode->parent_object, reinterpret_cast(descriptor_pool), validation_error_map[VALIDATION_ERROR_00927]); } } else { skip |= log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, object_handle, __LINE__, VALIDATION_ERROR_00920, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", object_string[kVulkanObjectTypeDescriptorSet], object_handle, validation_error_map[VALIDATION_ERROR_00920]); } return skip; } static void CreateQueue(VkDevice device, VkQueue vkObj) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, reinterpret_cast(vkObj), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, "VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT", reinterpret_cast(vkObj)); OBJTRACK_NODE *p_obj_node = NULL; auto queue_item = device_data->object_map[kVulkanObjectTypeQueue].find(reinterpret_cast(vkObj)); if (queue_item == device_data->object_map[kVulkanObjectTypeQueue].end()) { p_obj_node = new OBJTRACK_NODE; device_data->object_map[kVulkanObjectTypeQueue][reinterpret_cast(vkObj)] = p_obj_node; device_data->num_objects[kVulkanObjectTypeQueue]++; device_data->num_total_objects++; } else { p_obj_node = queue_item->second; } p_obj_node->object_type = kVulkanObjectTypeQueue; p_obj_node->status = OBJSTATUS_NONE; p_obj_node->handle = reinterpret_cast(vkObj); } static void CreateSwapchainImageObject(VkDevice dispatchable_object, VkImage swapchain_image, VkSwapchainKHR swapchain) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, reinterpret_cast(swapchain_image), __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, "SwapchainImage", reinterpret_cast(swapchain_image)); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = kVulkanObjectTypeImage; pNewObjNode->status = OBJSTATUS_NONE; pNewObjNode->handle = reinterpret_cast(swapchain_image); pNewObjNode->parent_object = reinterpret_cast(swapchain); device_data->swapchainImageMap[reinterpret_cast(swapchain_image)] = pNewObjNode; } template uint64_t handle_value(T handle) { return reinterpret_cast(handle); } template uint64_t handle_value(T *handle) { return reinterpret_cast(handle); } template static void CreateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, const VkAllocationCallbacks *pAllocator) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); auto object_handle = handle_value(object); bool custom_allocator = pAllocator != nullptr; if (!instance_data->object_map[object_type].count(object_handle)) { VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type]; log_msg(instance_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, __LINE__, OBJTRACK_NONE, LayerName, "OBJ[0x%" PRIxLEAST64 "] : CREATE %s object 0x%" PRIxLEAST64, object_track_index++, object_string[object_type], object_handle); OBJTRACK_NODE *pNewObjNode = new OBJTRACK_NODE; pNewObjNode->object_type = object_type; pNewObjNode->status = custom_allocator ? OBJSTATUS_CUSTOM_ALLOCATOR : OBJSTATUS_NONE; pNewObjNode->handle = object_handle; instance_data->object_map[object_type][object_handle] = pNewObjNode; instance_data->num_objects[object_type]++; instance_data->num_total_objects++; } } template static void DestroyObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, const VkAllocationCallbacks *pAllocator, enum UNIQUE_VALIDATION_ERROR_CODE expected_custom_allocator_code, enum UNIQUE_VALIDATION_ERROR_CODE expected_default_allocator_code) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); auto object_handle = handle_value(object); bool custom_allocator = pAllocator != nullptr; VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type]; if (object_handle != VK_NULL_HANDLE) { auto item = device_data->object_map[object_type].find(object_handle); if (item != device_data->object_map[object_type].end()) { OBJTRACK_NODE *pNode = item->second; assert(device_data->num_total_objects > 0); device_data->num_total_objects--; assert(device_data->num_objects[pNode->object_type] > 0); device_data->num_objects[pNode->object_type]--; log_msg(device_data->report_data, VK_DEBUG_REPORT_INFORMATION_BIT_EXT, debug_object_type, object_handle, __LINE__, OBJTRACK_NONE, LayerName, "OBJ_STAT Destroy %s obj 0x%" PRIxLEAST64 " (%" PRIu64 " total objs remain & %" PRIu64 " %s objs).", object_string[object_type], reinterpret_cast(object), device_data->num_total_objects, device_data->num_objects[pNode->object_type], object_string[object_type]); auto allocated_with_custom = (pNode->status & OBJSTATUS_CUSTOM_ALLOCATOR) ? true : false; if (allocated_with_custom && !custom_allocator && expected_custom_allocator_code != VALIDATION_ERROR_UNDEFINED) { // This check only verifies that custom allocation callbacks were provided to both Create and Destroy calls, // it cannot verify that these allocation callbacks are compatible with each other. log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, expected_custom_allocator_code, LayerName, "Custom allocator not specified while destroying %s obj 0x%" PRIxLEAST64 " but specified at creation. %s", object_string[object_type], object_handle, validation_error_map[expected_custom_allocator_code]); } else if (!allocated_with_custom && custom_allocator && expected_default_allocator_code != VALIDATION_ERROR_UNDEFINED) { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, expected_default_allocator_code, LayerName, "Custom allocator specified while destroying %s obj 0x%" PRIxLEAST64 " but not specified at creation. %s", object_string[object_type], object_handle, validation_error_map[expected_default_allocator_code]); } delete pNode; device_data->object_map[object_type].erase(item); } else { log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, object_handle, __LINE__, OBJTRACK_UNKNOWN_OBJECT, LayerName, "Unable to remove %s obj 0x%" PRIxLEAST64 ". Was it created? Has it already been destroyed?", object_string[object_type], object_handle); } } } template static bool ValidateObject(T1 dispatchable_object, T2 object, VulkanObjectType object_type, bool null_allowed, enum UNIQUE_VALIDATION_ERROR_CODE invalid_handle_code, enum UNIQUE_VALIDATION_ERROR_CODE wrong_device_code) { if (null_allowed && (object == VK_NULL_HANDLE)) { return false; } auto object_handle = handle_value(object); VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[object_type]; layer_data *device_data = GetLayerDataPtr(get_dispatch_key(dispatchable_object), layer_data_map); // Look for object in device object map if (device_data->object_map[object_type].find(object_handle) == device_data->object_map[object_type].end()) { // If object is an image, also look for it in the swapchain image map if ((object_type != kVulkanObjectTypeImage) || (device_data->swapchainImageMap.find(object_handle) == device_data->swapchainImageMap.end())) { // Object not found, look for it in other device object maps for (auto other_device_data : layer_data_map) { if (other_device_data.second != device_data) { if (other_device_data.second->object_map[object_type].find(object_handle) != other_device_data.second->object_map[object_type].end() || (object_type == kVulkanObjectTypeImage && other_device_data.second->swapchainImageMap.find(object_handle) != other_device_data.second->swapchainImageMap.end())) { // Object found on other device, report an error if object has a device parent error code if (wrong_device_code != VALIDATION_ERROR_UNDEFINED) { return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, wrong_device_code, LayerName, "Object 0x%" PRIxLEAST64 " was not created, allocated or retrieved from the correct device. %s", object_handle, validation_error_map[wrong_device_code]); } else { return false; } } } } // Report an error if object was not found anywhere return log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, object_handle, __LINE__, invalid_handle_code, LayerName, "Invalid %s Object 0x%" PRIxLEAST64 ". %s", object_string[object_type], object_handle, validation_error_map[invalid_handle_code]); } } return false; } static void DeviceReportUndestroyedObjects(VkDevice device, VulkanObjectType object_type, enum UNIQUE_VALIDATION_ERROR_CODE error_code) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); for (auto item = device_data->object_map[object_type].begin(); item != device_data->object_map[object_type].end();) { OBJTRACK_NODE *object_info = item->second; log_msg(device_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, get_debug_report_enum[object_type], object_info->handle, __LINE__, error_code, LayerName, "OBJ ERROR : For device 0x%" PRIxLEAST64 ", %s object 0x%" PRIxLEAST64 " has not been destroyed. %s", reinterpret_cast(device), object_string[object_type], object_info->handle, validation_error_map[error_code]); item = device_data->object_map[object_type].erase(item); } } VKAPI_ATTR void VKAPI_CALL DestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { std::unique_lock lock(global_lock); dispatch_key key = get_dispatch_key(instance); layer_data *instance_data = GetLayerDataPtr(key, layer_data_map); // Enable the temporary callback(s) here to catch cleanup issues: bool callback_setup = false; if (instance_data->num_tmp_callbacks > 0) { if (!layer_enable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks, instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks)) { callback_setup = true; } } // TODO: The instance handle can not be validated here. The loader will likely have to validate it. ValidateObject(instance, instance, kVulkanObjectTypeInstance, true, VALIDATION_ERROR_00021, VALIDATION_ERROR_UNDEFINED); DestroyObject(instance, instance, kVulkanObjectTypeInstance, pAllocator, VALIDATION_ERROR_00019, VALIDATION_ERROR_00020); // Report any remaining objects in LL for (auto iit = instance_data->object_map[kVulkanObjectTypeDevice].begin(); iit != instance_data->object_map[kVulkanObjectTypeDevice].end();) { OBJTRACK_NODE *pNode = iit->second; VkDevice device = reinterpret_cast(pNode->handle); VkDebugReportObjectTypeEXT debug_object_type = get_debug_report_enum[pNode->object_type]; log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, debug_object_type, pNode->handle, __LINE__, OBJTRACK_OBJECT_LEAK, LayerName, "OBJ ERROR : %s object 0x%" PRIxLEAST64 " has not been destroyed.", string_VkDebugReportObjectTypeEXT(debug_object_type), pNode->handle); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeCommandBuffer, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSemaphore, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeFence, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDeviceMemory, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeBuffer, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeImage, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeEvent, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeQueryPool, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeBufferView, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeImageView, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeShaderModule, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypePipelineCache, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypePipelineLayout, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeRenderPass, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypePipeline, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorSetLayout, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSampler, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorPool, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorSet, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeFramebuffer, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeCommandPool, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSurfaceKHR, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSwapchainKHR, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDisplayKHR, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDisplayModeKHR, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorUpdateTemplateKHR, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDebugReportCallbackEXT, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeObjectTableNVX, VALIDATION_ERROR_00018); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeIndirectCommandsLayoutNVX, VALIDATION_ERROR_00018); } instance_data->object_map[kVulkanObjectTypeDevice].clear(); VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ot_instance_table_map, instance); pInstanceTable->DestroyInstance(instance, pAllocator); // Disable and cleanup the temporary callback(s): if (callback_setup) { layer_disable_tmp_callbacks(instance_data->report_data, instance_data->num_tmp_callbacks, instance_data->tmp_callbacks); } if (instance_data->num_tmp_callbacks > 0) { layer_free_tmp_callbacks(instance_data->tmp_dbg_create_infos, instance_data->tmp_callbacks); instance_data->num_tmp_callbacks = 0; } // Clean up logging callback, if any while (instance_data->logging_callback.size() > 0) { VkDebugReportCallbackEXT callback = instance_data->logging_callback.back(); layer_destroy_msg_callback(instance_data->report_data, callback, pAllocator); instance_data->logging_callback.pop_back(); } layer_debug_report_destroy_instance(instance_data->report_data); layer_data_map.erase(key); instanceExtMap.erase(pInstanceTable); lock.unlock(); ot_instance_table_map.erase(key); } VKAPI_ATTR void VKAPI_CALL DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator) { std::unique_lock lock(global_lock); ValidateObject(device, device, kVulkanObjectTypeDevice, true, VALIDATION_ERROR_00052, VALIDATION_ERROR_UNDEFINED); DestroyObject(device, device, kVulkanObjectTypeDevice, pAllocator, VALIDATION_ERROR_00050, VALIDATION_ERROR_00051); // Report any remaining objects associated with this VkDevice object in LL DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSemaphore, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeFence, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDeviceMemory, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeBuffer, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeImage, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeEvent, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeQueryPool, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeBufferView, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeImageView, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeShaderModule, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypePipelineCache, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypePipelineLayout, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeRenderPass, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypePipeline, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorSetLayout, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSampler, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorPool, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorSet, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeFramebuffer, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeCommandPool, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSurfaceKHR, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeSwapchainKHR, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDisplayKHR, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDisplayModeKHR, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDescriptorUpdateTemplateKHR, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeDebugReportCallbackEXT, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeObjectTableNVX, VALIDATION_ERROR_00049); DeviceReportUndestroyedObjects(device, kVulkanObjectTypeIndirectCommandsLayoutNVX, VALIDATION_ERROR_00049); // Clean up Queue's MemRef Linked Lists DestroyQueueDataStructures(device); lock.unlock(); dispatch_key key = get_dispatch_key(device); VkLayerDispatchTable *pDisp = get_dispatch_table(ot_device_table_map, device); pDisp->DestroyDevice(device, pAllocator); ot_device_table_map.erase(key); } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01679, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice)->GetPhysicalDeviceFeatures(physicalDevice, pFeatures); } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01683, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties); } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01686, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, pImageFormatProperties); return result; } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_00026, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice)->GetPhysicalDeviceProperties(physicalDevice, pProperties); } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pMemoryProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_00609, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice)->GetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *pName); VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *pName); VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName); VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties); VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties); VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties); VKAPI_ATTR VkResult VKAPI_CALL QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(queue, fence, kVulkanObjectTypeFence, true, VALIDATION_ERROR_00130, VALIDATION_ERROR_00131); if (pSubmits) { for (uint32_t idx0 = 0; idx0 < submitCount; ++idx0) { if (pSubmits[idx0].pCommandBuffers) { for (uint32_t idx1 = 0; idx1 < pSubmits[idx0].commandBufferCount; ++idx1) { skip |= ValidateObject(queue, pSubmits[idx0].pCommandBuffers[idx1], kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00149, VALIDATION_ERROR_00151); } } if (pSubmits[idx0].pSignalSemaphores) { for (uint32_t idx2 = 0; idx2 < pSubmits[idx0].signalSemaphoreCount; ++idx2) { skip |= ValidateObject(queue, pSubmits[idx0].pSignalSemaphores[idx2], kVulkanObjectTypeSemaphore, false, VALIDATION_ERROR_00150, VALIDATION_ERROR_00151); } } if (pSubmits[idx0].pWaitSemaphores) { for (uint32_t idx3 = 0; idx3 < pSubmits[idx0].waitSemaphoreCount; ++idx3) { skip |= ValidateObject(queue, pSubmits[idx0].pWaitSemaphores[idx3], kVulkanObjectTypeSemaphore, false, VALIDATION_ERROR_00146, VALIDATION_ERROR_00151); } } } } if (queue) { skip |= ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, VALIDATION_ERROR_00128, VALIDATION_ERROR_00131); } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, queue)->QueueSubmit(queue, submitCount, pSubmits, fence); return result; } VKAPI_ATTR VkResult VKAPI_CALL QueueWaitIdle(VkQueue queue) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, VALIDATION_ERROR_00317, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, queue)->QueueWaitIdle(queue); return result; } VKAPI_ATTR VkResult VKAPI_CALL DeviceWaitIdle(VkDevice device) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00318, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->DeviceWaitIdle(device); return result; } VKAPI_ATTR VkResult VKAPI_CALL AllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00612, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->AllocateMemory(device, pAllocateInfo, pAllocator, pMemory); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pMemory, kVulkanObjectTypeDeviceMemory, pAllocator); } } return result; } VKAPI_ATTR VkResult VKAPI_CALL FlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00635, VALIDATION_ERROR_UNDEFINED); if (pMemoryRanges) { for (uint32_t idx0 = 0; idx0 < memoryRangeCount; ++idx0) { if (pMemoryRanges[idx0].memory) { skip |= ValidateObject(device, pMemoryRanges[idx0].memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00648, VALIDATION_ERROR_UNDEFINED); } } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->FlushMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges); return result; } VKAPI_ATTR VkResult VKAPI_CALL InvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00638, VALIDATION_ERROR_UNDEFINED); if (pMemoryRanges) { for (uint32_t idx0 = 0; idx0 < memoryRangeCount; ++idx0) { if (pMemoryRanges[idx0].memory) { skip |= ValidateObject(device, pMemoryRanges[idx0].memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00648, VALIDATION_ERROR_UNDEFINED); } } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->InvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges); return result; } VKAPI_ATTR void VKAPI_CALL GetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory, VkDeviceSize *pCommittedMemoryInBytes) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00654, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00655, VALIDATION_ERROR_00657); } if (skip) { return; } get_dispatch_table(ot_device_table_map, device)->GetDeviceMemoryCommitment(device, memory, pCommittedMemoryInBytes); } VKAPI_ATTR VkResult VKAPI_CALL BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00798, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_00799, VALIDATION_ERROR_00801); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00800, VALIDATION_ERROR_00802); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->BindBufferMemory(device, buffer, memory, memoryOffset); return result; } VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00807, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_00808, VALIDATION_ERROR_00810); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00809, VALIDATION_ERROR_00811); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->BindImageMemory(device, image, memory, memoryOffset); return result; } VKAPI_ATTR void VKAPI_CALL GetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00783, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_00784, VALIDATION_ERROR_00786); } if (skip) { return; } get_dispatch_table(ot_device_table_map, device)->GetBufferMemoryRequirements(device, buffer, pMemoryRequirements); } VKAPI_ATTR void VKAPI_CALL GetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00787, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_00788, VALIDATION_ERROR_00790); } if (skip) { return; } get_dispatch_table(ot_device_table_map, device)->GetImageMemoryRequirements(device, image, pMemoryRequirements); } VKAPI_ATTR void VKAPI_CALL GetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements *pSparseMemoryRequirements) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01610, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01611, VALIDATION_ERROR_01614); } if (skip) { return; } get_dispatch_table(ot_device_table_map, device) ->GetImageSparseMemoryRequirements(device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements); } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pPropertyCount, VkSparseImageFormatProperties *pProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01601, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSparseImageFormatProperties(physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties); } VKAPI_ATTR VkResult VKAPI_CALL CreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00166, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateFence(device, pCreateInfo, pAllocator, pFence); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pFence, kVulkanObjectTypeFence, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00176, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, fence, kVulkanObjectTypeFence, true, VALIDATION_ERROR_00177, VALIDATION_ERROR_00179); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, fence, kVulkanObjectTypeFence, pAllocator, VALIDATION_ERROR_00174, VALIDATION_ERROR_00175); } get_dispatch_table(ot_device_table_map, device)->DestroyFence(device, fence, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL ResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00184, VALIDATION_ERROR_UNDEFINED); if (pFences) { for (uint32_t idx0 = 0; idx0 < fenceCount; ++idx0) { skip |= ValidateObject(device, pFences[idx0], kVulkanObjectTypeFence, false, VALIDATION_ERROR_00185, VALIDATION_ERROR_00187); } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->ResetFences(device, fenceCount, pFences); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetFenceStatus(VkDevice device, VkFence fence) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00180, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, fence, kVulkanObjectTypeFence, false, VALIDATION_ERROR_00181, VALIDATION_ERROR_00182); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->GetFenceStatus(device, fence); return result; } VKAPI_ATTR VkResult VKAPI_CALL WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00188, VALIDATION_ERROR_UNDEFINED); if (pFences) { for (uint32_t idx0 = 0; idx0 < fenceCount; ++idx0) { skip |= ValidateObject(device, pFences[idx0], kVulkanObjectTypeFence, false, VALIDATION_ERROR_00189, VALIDATION_ERROR_00191); } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->WaitForFences(device, fenceCount, pFences, waitAll, timeout); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00192, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateSemaphore(device, pCreateInfo, pAllocator, pSemaphore); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pSemaphore, kVulkanObjectTypeSemaphore, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00202, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, semaphore, kVulkanObjectTypeSemaphore, true, VALIDATION_ERROR_00203, VALIDATION_ERROR_00205); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, semaphore, kVulkanObjectTypeSemaphore, pAllocator, VALIDATION_ERROR_00200, VALIDATION_ERROR_00201); } get_dispatch_table(ot_device_table_map, device)->DestroySemaphore(device, semaphore, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkEvent *pEvent) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00206, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateEvent(device, pCreateInfo, pAllocator, pEvent); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pEvent, kVulkanObjectTypeEvent, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00216, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, event, kVulkanObjectTypeEvent, true, VALIDATION_ERROR_00217, VALIDATION_ERROR_00219); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, event, kVulkanObjectTypeEvent, pAllocator, VALIDATION_ERROR_00214, VALIDATION_ERROR_00215); } get_dispatch_table(ot_device_table_map, device)->DestroyEvent(device, event, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL GetEventStatus(VkDevice device, VkEvent event) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00220, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, event, kVulkanObjectTypeEvent, false, VALIDATION_ERROR_00221, VALIDATION_ERROR_00222); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->GetEventStatus(device, event); return result; } VKAPI_ATTR VkResult VKAPI_CALL SetEvent(VkDevice device, VkEvent event) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00223, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, event, kVulkanObjectTypeEvent, false, VALIDATION_ERROR_00224, VALIDATION_ERROR_00225); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->SetEvent(device, event); return result; } VKAPI_ATTR VkResult VKAPI_CALL ResetEvent(VkDevice device, VkEvent event) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00227, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, event, kVulkanObjectTypeEvent, false, VALIDATION_ERROR_00228, VALIDATION_ERROR_00229); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->ResetEvent(device, event); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01002, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateQueryPool(device, pCreateInfo, pAllocator, pQueryPool); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pQueryPool, kVulkanObjectTypeQueryPool, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01015, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, queryPool, kVulkanObjectTypeQueryPool, true, VALIDATION_ERROR_01016, VALIDATION_ERROR_01018); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, queryPool, kVulkanObjectTypeQueryPool, pAllocator, VALIDATION_ERROR_01013, VALIDATION_ERROR_01014); } get_dispatch_table(ot_device_table_map, device)->DestroyQueryPool(device, queryPool, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL GetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void *pData, VkDeviceSize stride, VkQueryResultFlags flags) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01054, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, queryPool, kVulkanObjectTypeQueryPool, false, VALIDATION_ERROR_01055, VALIDATION_ERROR_01059); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device) ->GetQueryPoolResults(device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00659, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateBuffer(device, pCreateInfo, pAllocator, pBuffer); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pBuffer, kVulkanObjectTypeBuffer, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00679, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, buffer, kVulkanObjectTypeBuffer, true, VALIDATION_ERROR_00680, VALIDATION_ERROR_00682); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, buffer, kVulkanObjectTypeBuffer, pAllocator, VALIDATION_ERROR_00677, VALIDATION_ERROR_00678); } get_dispatch_table(ot_device_table_map, device)->DestroyBuffer(device, buffer, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00683, VALIDATION_ERROR_UNDEFINED); if (pCreateInfo) { skip |= ValidateObject(device, pCreateInfo->buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_00699, VALIDATION_ERROR_UNDEFINED); } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateBufferView(device, pCreateInfo, pAllocator, pView); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pView, kVulkanObjectTypeBufferView, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00704, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, bufferView, kVulkanObjectTypeBufferView, true, VALIDATION_ERROR_00705, VALIDATION_ERROR_00707); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, bufferView, kVulkanObjectTypeBufferView, pAllocator, VALIDATION_ERROR_00702, VALIDATION_ERROR_00703); } get_dispatch_table(ot_device_table_map, device)->DestroyBufferView(device, bufferView, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00709, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateImage(device, pCreateInfo, pAllocator, pImage); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pImage, kVulkanObjectTypeImage, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00746, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, image, kVulkanObjectTypeImage, true, VALIDATION_ERROR_00747, VALIDATION_ERROR_00749); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, image, kVulkanObjectTypeImage, pAllocator, VALIDATION_ERROR_00744, VALIDATION_ERROR_00745); } get_dispatch_table(ot_device_table_map, device)->DestroyImage(device, image, pAllocator); } VKAPI_ATTR void VKAPI_CALL GetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, VkSubresourceLayout *pLayout) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00734, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_00735, VALIDATION_ERROR_00738); } if (skip) { return; } get_dispatch_table(ot_device_table_map, device)->GetImageSubresourceLayout(device, image, pSubresource, pLayout); } VKAPI_ATTR VkResult VKAPI_CALL CreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00750, VALIDATION_ERROR_UNDEFINED); if (pCreateInfo) { skip |= ValidateObject(device, pCreateInfo->image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_00763, VALIDATION_ERROR_UNDEFINED); } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateImageView(device, pCreateInfo, pAllocator, pView); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pView, kVulkanObjectTypeImageView, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00779, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, imageView, kVulkanObjectTypeImageView, true, VALIDATION_ERROR_00780, VALIDATION_ERROR_00782); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, imageView, kVulkanObjectTypeImageView, pAllocator, VALIDATION_ERROR_00777, VALIDATION_ERROR_00778); } get_dispatch_table(ot_device_table_map, device)->DestroyImageView(device, imageView, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkShaderModule *pShaderModule) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00466, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pShaderModule, kVulkanObjectTypeShaderModule, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00481, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, shaderModule, kVulkanObjectTypeShaderModule, true, VALIDATION_ERROR_00482, VALIDATION_ERROR_00484); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, shaderModule, kVulkanObjectTypeShaderModule, pAllocator, VALIDATION_ERROR_00479, VALIDATION_ERROR_00480); } get_dispatch_table(ot_device_table_map, device)->DestroyShaderModule(device, shaderModule, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineCache *pPipelineCache) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00562, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pPipelineCache, kVulkanObjectTypePipelineCache, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00585, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true, VALIDATION_ERROR_00586, VALIDATION_ERROR_00588); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, pipelineCache, kVulkanObjectTypePipelineCache, pAllocator, VALIDATION_ERROR_00583, VALIDATION_ERROR_00584); } get_dispatch_table(ot_device_table_map, device)->DestroyPipelineCache(device, pipelineCache, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL GetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t *pDataSize, void *pData) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00578, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, false, VALIDATION_ERROR_00579, VALIDATION_ERROR_00582); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->GetPipelineCacheData(device, pipelineCache, pDataSize, pData); return result; } VKAPI_ATTR VkResult VKAPI_CALL MergePipelineCaches(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache *pSrcCaches) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00572, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, dstCache, kVulkanObjectTypePipelineCache, false, VALIDATION_ERROR_00573, VALIDATION_ERROR_00576); if (pSrcCaches) { for (uint32_t idx0 = 0; idx0 < srcCacheCount; ++idx0) { skip |= ValidateObject(device, pSrcCaches[idx0], kVulkanObjectTypePipelineCache, false, VALIDATION_ERROR_00574, VALIDATION_ERROR_00577); } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->MergePipelineCaches(device, dstCache, srcCacheCount, pSrcCaches); return result; } VKAPI_ATTR void VKAPI_CALL DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00558, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, pipeline, kVulkanObjectTypePipeline, true, VALIDATION_ERROR_00559, VALIDATION_ERROR_00561); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, pipeline, kVulkanObjectTypePipeline, pAllocator, VALIDATION_ERROR_00556, VALIDATION_ERROR_00557); } get_dispatch_table(ot_device_table_map, device)->DestroyPipeline(device, pipeline, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00861, VALIDATION_ERROR_UNDEFINED); if (pCreateInfo) { if (pCreateInfo->pSetLayouts) { for (uint32_t idx0 = 0; idx0 < pCreateInfo->setLayoutCount; ++idx0) { skip |= ValidateObject(device, pCreateInfo->pSetLayouts[idx0], kVulkanObjectTypeDescriptorSetLayout, false, VALIDATION_ERROR_00875, VALIDATION_ERROR_UNDEFINED); } } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreatePipelineLayout(device, pCreateInfo, pAllocator, pPipelineLayout); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pPipelineLayout, kVulkanObjectTypePipelineLayout, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00885, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, pipelineLayout, kVulkanObjectTypePipelineLayout, true, VALIDATION_ERROR_00886, VALIDATION_ERROR_00888); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, pipelineLayout, kVulkanObjectTypePipelineLayout, pAllocator, VALIDATION_ERROR_00883, VALIDATION_ERROR_00884); } get_dispatch_table(ot_device_table_map, device)->DestroyPipelineLayout(device, pipelineLayout, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00812, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateSampler(device, pCreateInfo, pAllocator, pSampler); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pSampler, kVulkanObjectTypeSampler, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00840, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, sampler, kVulkanObjectTypeSampler, true, VALIDATION_ERROR_00841, VALIDATION_ERROR_00843); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, sampler, kVulkanObjectTypeSampler, pAllocator, VALIDATION_ERROR_00838, VALIDATION_ERROR_00839); } get_dispatch_table(ot_device_table_map, device)->DestroySampler(device, sampler, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00844, VALIDATION_ERROR_UNDEFINED); if (pCreateInfo) { if (pCreateInfo->pBindings) { for (uint32_t idx0 = 0; idx0 < pCreateInfo->bindingCount; ++idx0) { if ((pCreateInfo->pBindings[idx0].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || (pCreateInfo->pBindings[idx0].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) { if (pCreateInfo->pBindings[idx0].pImmutableSamplers) { for (uint32_t idx1 = 0; idx1 < pCreateInfo->pBindings[idx0].descriptorCount; ++idx1) { skip |= ValidateObject(device, pCreateInfo->pBindings[idx0].pImmutableSamplers[idx1], kVulkanObjectTypeSampler, false, VALIDATION_ERROR_00852, VALIDATION_ERROR_UNDEFINED); } } } } } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateDescriptorSetLayout(device, pCreateInfo, pAllocator, pSetLayout); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00857, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, descriptorSetLayout, kVulkanObjectTypeDescriptorSetLayout, true, VALIDATION_ERROR_00858, VALIDATION_ERROR_00860); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, descriptorSetLayout, kVulkanObjectTypeDescriptorSetLayout, pAllocator, VALIDATION_ERROR_00855, VALIDATION_ERROR_00856); } get_dispatch_table(ot_device_table_map, device)->DestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00889, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateDescriptorPool(device, pCreateInfo, pAllocator, pDescriptorPool); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pDescriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator); } } return result; } VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags) { bool skip = false; std::unique_lock lock(global_lock); layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00929, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, VALIDATION_ERROR_00930, VALIDATION_ERROR_00932); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } // A DescriptorPool's descriptor sets are implicitly deleted when the pool is reset. // Remove this pool's descriptor sets from our descriptorSet map. auto itr = device_data->object_map[kVulkanObjectTypeDescriptorSet].begin(); while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { OBJTRACK_NODE *pNode = (*itr).second; auto del_itr = itr++; if (pNode->parent_object == reinterpret_cast(descriptorPool)) { DestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } } lock.unlock(); VkResult result = get_dispatch_table(ot_device_table_map, device)->ResetDescriptorPool(device, descriptorPool, flags); return result; } VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00933, VALIDATION_ERROR_UNDEFINED); if (pDescriptorCopies) { for (uint32_t idx0 = 0; idx0 < descriptorCopyCount; ++idx0) { if (pDescriptorCopies[idx0].dstSet) { skip |= ValidateObject(device, pDescriptorCopies[idx0].dstSet, kVulkanObjectTypeDescriptorSet, false, VALIDATION_ERROR_00972, VALIDATION_ERROR_00973); } if (pDescriptorCopies[idx0].srcSet) { skip |= ValidateObject(device, pDescriptorCopies[idx0].srcSet, kVulkanObjectTypeDescriptorSet, false, VALIDATION_ERROR_00971, VALIDATION_ERROR_00973); } } } if (pDescriptorWrites) { for (uint32_t idx1 = 0; idx1 < descriptorWriteCount; ++idx1) { if (pDescriptorWrites[idx1].dstSet) { skip |= ValidateObject(device, pDescriptorWrites[idx1].dstSet, kVulkanObjectTypeDescriptorSet, false, VALIDATION_ERROR_00955, VALIDATION_ERROR_00958); } if ((pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { for (uint32_t idx2 = 0; idx2 < pDescriptorWrites[idx1].descriptorCount; ++idx2) { skip |= ValidateObject(device, pDescriptorWrites[idx1].pTexelBufferView[idx2], kVulkanObjectTypeBufferView, false, VALIDATION_ERROR_00940, VALIDATION_ERROR_00958); } } if ((pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { for (uint32_t idx3 = 0; idx3 < pDescriptorWrites[idx1].descriptorCount; ++idx3) { skip |= ValidateObject(device, pDescriptorWrites[idx1].pImageInfo[idx3].imageView, kVulkanObjectTypeImageView, false, VALIDATION_ERROR_00943, VALIDATION_ERROR_00963); } } if ((pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || (pDescriptorWrites[idx1].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { for (uint32_t idx4 = 0; idx4 < pDescriptorWrites[idx1].descriptorCount; ++idx4) { if (pDescriptorWrites[idx1].pBufferInfo[idx4].buffer) { skip |= ValidateObject(device, pDescriptorWrites[idx1].pBufferInfo[idx4].buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_00962, VALIDATION_ERROR_UNDEFINED); } } } } } } if (skip) { return; } get_dispatch_table(ot_device_table_map, device) ->UpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies); } VKAPI_ATTR VkResult VKAPI_CALL CreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00400, VALIDATION_ERROR_UNDEFINED); if (pCreateInfo) { if (pCreateInfo->pAttachments) { for (uint32_t idx0 = 0; idx0 < pCreateInfo->attachmentCount; ++idx0) { skip |= ValidateObject(device, pCreateInfo->pAttachments[idx0], kVulkanObjectTypeImageView, false, VALIDATION_ERROR_00420, VALIDATION_ERROR_00421); } } if (pCreateInfo->renderPass) { skip |= ValidateObject(device, pCreateInfo->renderPass, kVulkanObjectTypeRenderPass, false, VALIDATION_ERROR_00419, VALIDATION_ERROR_00421); } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pFramebuffer, kVulkanObjectTypeFramebuffer, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00425, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, framebuffer, kVulkanObjectTypeFramebuffer, true, VALIDATION_ERROR_00426, VALIDATION_ERROR_00428); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, framebuffer, kVulkanObjectTypeFramebuffer, pAllocator, VALIDATION_ERROR_00423, VALIDATION_ERROR_00424); } get_dispatch_table(ot_device_table_map, device)->DestroyFramebuffer(device, framebuffer, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00319, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pRenderPass, kVulkanObjectTypeRenderPass, pAllocator); } } return result; } VKAPI_ATTR void VKAPI_CALL DestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00396, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, renderPass, kVulkanObjectTypeRenderPass, true, VALIDATION_ERROR_00397, VALIDATION_ERROR_00399); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(device, renderPass, kVulkanObjectTypeRenderPass, pAllocator, VALIDATION_ERROR_00394, VALIDATION_ERROR_00395); } get_dispatch_table(ot_device_table_map, device)->DestroyRenderPass(device, renderPass, pAllocator); } VKAPI_ATTR void VKAPI_CALL GetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D *pGranularity) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00449, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, renderPass, kVulkanObjectTypeRenderPass, false, VALIDATION_ERROR_00450, VALIDATION_ERROR_00452); } if (skip) { return; } get_dispatch_table(ot_device_table_map, device)->GetRenderAreaGranularity(device, renderPass, pGranularity); } VKAPI_ATTR VkResult VKAPI_CALL CreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00064, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateCommandPool(device, pCreateInfo, pAllocator, pCommandPool); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pCommandPool, kVulkanObjectTypeCommandPool, pAllocator); } } return result; } VKAPI_ATTR VkResult VKAPI_CALL ResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00073, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, VALIDATION_ERROR_00074, VALIDATION_ERROR_00076); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->ResetCommandPool(device, commandPool, flags); return result; } VKAPI_ATTR VkResult VKAPI_CALL BeginCommandBuffer(VkCommandBuffer command_buffer, const VkCommandBufferBeginInfo *begin_info) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(command_buffer), layer_data_map); bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(command_buffer, command_buffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00108, VALIDATION_ERROR_UNDEFINED); if (begin_info) { OBJTRACK_NODE *pNode = device_data->object_map[kVulkanObjectTypeCommandBuffer][reinterpret_cast(command_buffer)]; if ((begin_info->pInheritanceInfo) && (pNode->status & OBJSTATUS_COMMAND_BUFFER_SECONDARY) && (begin_info->flags & VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT)) { skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->framebuffer, kVulkanObjectTypeFramebuffer, true, VALIDATION_ERROR_00112, VALIDATION_ERROR_00121); skip |= ValidateObject(command_buffer, begin_info->pInheritanceInfo->renderPass, kVulkanObjectTypeRenderPass, false, VALIDATION_ERROR_00110, VALIDATION_ERROR_00121); } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, command_buffer)->BeginCommandBuffer(command_buffer, begin_info); return result; } VKAPI_ATTR VkResult VKAPI_CALL EndCommandBuffer(VkCommandBuffer commandBuffer) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00125, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, commandBuffer)->EndCommandBuffer(commandBuffer); return result; } VKAPI_ATTR VkResult VKAPI_CALL ResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00094, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, commandBuffer)->ResetCommandBuffer(commandBuffer, flags); return result; } VKAPI_ATTR void VKAPI_CALL CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00599, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, pipeline, kVulkanObjectTypePipeline, false, VALIDATION_ERROR_00601, VALIDATION_ERROR_00604); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline); } VKAPI_ATTR void VKAPI_CALL CmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01443, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetViewport(commandBuffer, firstViewport, viewportCount, pViewports); } VKAPI_ATTR void VKAPI_CALL CmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01492, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetScissor(commandBuffer, firstScissor, scissorCount, pScissors); } VKAPI_ATTR void VKAPI_CALL CmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01478, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetLineWidth(commandBuffer, lineWidth); } VKAPI_ATTR void VKAPI_CALL CmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01483, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdSetDepthBias(commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor); } VKAPI_ATTR void VKAPI_CALL CmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4]) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01551, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetBlendConstants(commandBuffer, blendConstants); } VKAPI_ATTR void VKAPI_CALL CmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01507, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds); } VKAPI_ATTR void VKAPI_CALL CmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01515, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetStencilCompareMask(commandBuffer, faceMask, compareMask); } VKAPI_ATTR void VKAPI_CALL CmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01521, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetStencilWriteMask(commandBuffer, faceMask, writeMask); } VKAPI_ATTR void VKAPI_CALL CmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01527, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetStencilReference(commandBuffer, faceMask, reference); } VKAPI_ATTR void VKAPI_CALL CmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00979, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, VALIDATION_ERROR_00981, VALIDATION_ERROR_00987); if (pDescriptorSets) { for (uint32_t idx0 = 0; idx0 < descriptorSetCount; ++idx0) { skip |= ValidateObject(commandBuffer, pDescriptorSets[idx0], kVulkanObjectTypeDescriptorSet, false, VALIDATION_ERROR_00982, VALIDATION_ERROR_00987); } } } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets); } VKAPI_ATTR void VKAPI_CALL CmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01353, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01354, VALIDATION_ERROR_01358); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdBindIndexBuffer(commandBuffer, buffer, offset, indexType); } VKAPI_ATTR void VKAPI_CALL CmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01419, VALIDATION_ERROR_UNDEFINED); if (pBuffers) { for (uint32_t idx0 = 0; idx0 < bindingCount; ++idx0) { skip |= ValidateObject(commandBuffer, pBuffers[idx0], kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01420, VALIDATION_ERROR_01425); } } } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdBindVertexBuffers(commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets); } VKAPI_ATTR void VKAPI_CALL CmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01362, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance); } VKAPI_ATTR void VKAPI_CALL CmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01369, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } VKAPI_ATTR void VKAPI_CALL CmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01377, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01378, VALIDATION_ERROR_01382); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdDrawIndirect(commandBuffer, buffer, offset, drawCount, stride); } VKAPI_ATTR void VKAPI_CALL CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01389, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01390, VALIDATION_ERROR_01394); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount, stride); } VKAPI_ATTR void VKAPI_CALL CmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01559, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdDispatch(commandBuffer, x, y, z); } VKAPI_ATTR void VKAPI_CALL CmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01566, VALIDATION_ERROR_01570); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01565, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdDispatchIndirect(commandBuffer, buffer, offset); } VKAPI_ATTR void VKAPI_CALL CmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy *pRegions) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01166, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01168, VALIDATION_ERROR_01174); skip |= ValidateObject(commandBuffer, srcBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01167, VALIDATION_ERROR_01174); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions); } VKAPI_ATTR void VKAPI_CALL CmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01186, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01189, VALIDATION_ERROR_01196); skip |= ValidateObject(commandBuffer, srcImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01187, VALIDATION_ERROR_01196); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); } VKAPI_ATTR void VKAPI_CALL CmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01291, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01294, VALIDATION_ERROR_01302); skip |= ValidateObject(commandBuffer, srcImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01292, VALIDATION_ERROR_01302); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter); } VKAPI_ATTR void VKAPI_CALL CmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01235, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01237, VALIDATION_ERROR_01244); skip |= ValidateObject(commandBuffer, srcBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01236, VALIDATION_ERROR_01244); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdCopyBufferToImage(commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions); } VKAPI_ATTR void VKAPI_CALL CmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01253, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01256, VALIDATION_ERROR_01262); skip |= ValidateObject(commandBuffer, srcImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01254, VALIDATION_ERROR_01262); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions); } VKAPI_ATTR void VKAPI_CALL CmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const uint32_t *pData) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01150, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01151, VALIDATION_ERROR_01157); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData); } VKAPI_ATTR void VKAPI_CALL CmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01138, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01139, VALIDATION_ERROR_01143); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data); } VKAPI_ATTR void VKAPI_CALL CmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue *pColor, uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01089, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01090, VALIDATION_ERROR_01098); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges); } VKAPI_ATTR void VKAPI_CALL CmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange *pRanges) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01104, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01105, VALIDATION_ERROR_01113); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges); } VKAPI_ATTR void VKAPI_CALL CmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment *pAttachments, uint32_t rectCount, const VkClearRect *pRects) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01117, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdClearAttachments(commandBuffer, attachmentCount, pAttachments, rectCount, pRects); } VKAPI_ATTR void VKAPI_CALL CmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01327, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01330, VALIDATION_ERROR_01337); skip |= ValidateObject(commandBuffer, srcImage, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01328, VALIDATION_ERROR_01337); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdResolveImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions); } VKAPI_ATTR void VKAPI_CALL CmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00232, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, event, kVulkanObjectTypeEvent, false, VALIDATION_ERROR_00233, VALIDATION_ERROR_00239); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetEvent(commandBuffer, event, stageMask); } VKAPI_ATTR void VKAPI_CALL CmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00243, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, event, kVulkanObjectTypeEvent, false, VALIDATION_ERROR_00244, VALIDATION_ERROR_00250); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdResetEvent(commandBuffer, event, stageMask); } VKAPI_ATTR void VKAPI_CALL CmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00252, VALIDATION_ERROR_UNDEFINED); if (pBufferMemoryBarriers) { for (uint32_t idx0 = 0; idx0 < bufferMemoryBarrierCount; ++idx0) { if (pBufferMemoryBarriers[idx0].buffer) { skip |= ValidateObject(commandBuffer, pBufferMemoryBarriers[idx0].buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_00259, VALIDATION_ERROR_UNDEFINED); } } } if (pEvents) { for (uint32_t idx1 = 0; idx1 < eventCount; ++idx1) { skip |= ValidateObject(commandBuffer, pEvents[idx1], kVulkanObjectTypeEvent, false, VALIDATION_ERROR_00253, VALIDATION_ERROR_00264); } } if (pImageMemoryBarriers) { for (uint32_t idx2 = 0; idx2 < imageMemoryBarrierCount; ++idx2) { if (pImageMemoryBarriers[idx2].image) { skip |= ValidateObject(commandBuffer, pImageMemoryBarriers[idx2].image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_00260, VALIDATION_ERROR_UNDEFINED); } } } } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdWaitEvents(commandBuffer, eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); } VKAPI_ATTR void VKAPI_CALL CmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00270, VALIDATION_ERROR_UNDEFINED); if (pBufferMemoryBarriers) { for (uint32_t idx0 = 0; idx0 < bufferMemoryBarrierCount; ++idx0) { if (pBufferMemoryBarriers[idx0].buffer) { skip |= ValidateObject(commandBuffer, pBufferMemoryBarriers[idx0].buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_00277, VALIDATION_ERROR_UNDEFINED); } } } if (pImageMemoryBarriers) { for (uint32_t idx1 = 0; idx1 < imageMemoryBarrierCount; ++idx1) { if (pImageMemoryBarriers[idx1].image) { skip |= ValidateObject(commandBuffer, pImageMemoryBarriers[idx1].image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_00278, VALIDATION_ERROR_UNDEFINED); } } } } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers); } VKAPI_ATTR void VKAPI_CALL CmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01035, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, queryPool, kVulkanObjectTypeQueryPool, false, VALIDATION_ERROR_01036, VALIDATION_ERROR_01040); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdBeginQuery(commandBuffer, queryPool, query, flags); } VKAPI_ATTR void VKAPI_CALL CmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01043, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, queryPool, kVulkanObjectTypeQueryPool, false, VALIDATION_ERROR_01044, VALIDATION_ERROR_01047); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdEndQuery(commandBuffer, queryPool, query); } VKAPI_ATTR void VKAPI_CALL CmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01021, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, queryPool, kVulkanObjectTypeQueryPool, false, VALIDATION_ERROR_01022, VALIDATION_ERROR_01026); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdResetQueryPool(commandBuffer, queryPool, firstQuery, queryCount); } VKAPI_ATTR void VKAPI_CALL CmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01078, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, queryPool, kVulkanObjectTypeQueryPool, false, VALIDATION_ERROR_01080, VALIDATION_ERROR_01083); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, query); } VKAPI_ATTR void VKAPI_CALL CmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01068, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, dstBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01070, VALIDATION_ERROR_01075); skip |= ValidateObject(commandBuffer, queryPool, kVulkanObjectTypeQueryPool, false, VALIDATION_ERROR_01069, VALIDATION_ERROR_01075); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdCopyQueryPoolResults(commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags); } VKAPI_ATTR void VKAPI_CALL CmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *pValues) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00993, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, VALIDATION_ERROR_00994, VALIDATION_ERROR_01001); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdPushConstants(commandBuffer, layout, stageFlags, offset, size, pValues); } VKAPI_ATTR void VKAPI_CALL CmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00435, VALIDATION_ERROR_UNDEFINED); if (pRenderPassBegin) { skip |= ValidateObject(commandBuffer, pRenderPassBegin->framebuffer, kVulkanObjectTypeFramebuffer, false, VALIDATION_ERROR_00446, VALIDATION_ERROR_00448); skip |= ValidateObject(commandBuffer, pRenderPassBegin->renderPass, kVulkanObjectTypeRenderPass, false, VALIDATION_ERROR_00445, VALIDATION_ERROR_00448); } } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents); } VKAPI_ATTR void VKAPI_CALL CmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00454, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdNextSubpass(commandBuffer, contents); } VKAPI_ATTR void VKAPI_CALL CmdEndRenderPass(VkCommandBuffer commandBuffer) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00461, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdEndRenderPass(commandBuffer); } VKAPI_ATTR void VKAPI_CALL CmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00159, VALIDATION_ERROR_UNDEFINED); if (pCommandBuffers) { for (uint32_t idx0 = 0; idx0 < commandBufferCount; ++idx0) { skip |= ValidateObject(commandBuffer, pCommandBuffers[idx0], kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_00160, VALIDATION_ERROR_00165); } } } if (skip) { return; } get_dispatch_table(ot_device_table_map, commandBuffer)->CmdExecuteCommands(commandBuffer, commandBufferCount, pCommandBuffers); } VKAPI_ATTR void VKAPI_CALL DestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01847, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(instance, surface, kVulkanObjectTypeSurfaceKHR, true, VALIDATION_ERROR_01848, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } { std::lock_guard lock(global_lock); DestroyObject(instance, surface, kVulkanObjectTypeSurfaceKHR, pAllocator, VALIDATION_ERROR_01845, VALIDATION_ERROR_01846); } get_dispatch_table(ot_instance_table_map, instance)->DestroySurfaceKHR(instance, surface, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01890, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, surface, kVulkanObjectTypeSurfaceKHR, false, VALIDATION_ERROR_01891, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, pSupported); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01907, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, surface, kVulkanObjectTypeSurfaceKHR, false, VALIDATION_ERROR_01908, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, pSurfaceCapabilities); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01910, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, surface, kVulkanObjectTypeSurfaceKHR, false, VALIDATION_ERROR_01911, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01914, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, surface, kVulkanObjectTypeSurfaceKHR, false, VALIDATION_ERROR_01915, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, pPresentModeCount, pPresentModes); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01918, VALIDATION_ERROR_UNDEFINED); if (pCreateInfo) { skip |= ValidateObject(device, pCreateInfo->oldSwapchain, kVulkanObjectTypeSwapchainKHR, true, VALIDATION_ERROR_01935, VALIDATION_ERROR_UNDEFINED); layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); skip |= ValidateObject(device_data->physical_device, pCreateInfo->surface, kVulkanObjectTypeSurfaceKHR, false, VALIDATION_ERROR_01926, VALIDATION_ERROR_UNDEFINED); } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->CreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(device, *pSwapchain, kVulkanObjectTypeSwapchainKHR, pAllocator); } } return result; } VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01954, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, fence, kVulkanObjectTypeFence, true, VALIDATION_ERROR_01957, VALIDATION_ERROR_01960); skip |= ValidateObject(device, semaphore, kVulkanObjectTypeSemaphore, true, VALIDATION_ERROR_01956, VALIDATION_ERROR_01959); skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, VALIDATION_ERROR_01955, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device) ->AcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex); return result; } VKAPI_ATTR VkResult VKAPI_CALL QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) { bool skip = false; { std::lock_guard lock(global_lock); if (pPresentInfo) { if (pPresentInfo->pSwapchains) { for (uint32_t idx0 = 0; idx0 < pPresentInfo->swapchainCount; ++idx0) { skip |= ValidateObject(queue, pPresentInfo->pSwapchains[idx0], kVulkanObjectTypeSwapchainKHR, false, VALIDATION_ERROR_01969, VALIDATION_ERROR_UNDEFINED); } } if (pPresentInfo->pWaitSemaphores) { for (uint32_t idx1 = 0; idx1 < pPresentInfo->waitSemaphoreCount; ++idx1) { skip |= ValidateObject(queue, pPresentInfo->pWaitSemaphores[idx1], kVulkanObjectTypeSemaphore, false, VALIDATION_ERROR_01968, VALIDATION_ERROR_UNDEFINED); } } } skip |= ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, VALIDATION_ERROR_01962, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, queue)->QueuePresentKHR(queue, pPresentInfo); return result; } #ifdef VK_USE_PLATFORM_WIN32_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01820, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateWin32SurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01900, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_FALSE; } VkBool32 result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceWin32PresentationSupportKHR(physicalDevice, queueFamilyIndex); return result; } #endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01827, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t *connection, xcb_visualid_t visual_id) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01902, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_FALSE; } VkBool32 result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice, queueFamilyIndex, connection, visual_id); return result; } #endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01836, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy, VisualID visualID) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01905, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_FALSE; } VkBool32 result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, queueFamilyIndex, dpy, visualID); return result; } #endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_MIR_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateMirSurfaceKHR(VkInstance instance, const VkMirSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01802, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateMirSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceMirPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection *connection) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01894, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_FALSE; } VkBool32 result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceMirPresentationSupportKHR(physicalDevice, queueFamilyIndex, connection); return result; } #endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01811, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateWaylandSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } VKAPI_ATTR VkBool32 VKAPI_CALL GetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display *display) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01897, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_FALSE; } VkBool32 result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceWaylandPresentationSupportKHR(physicalDevice, queueFamilyIndex, display); return result; } #endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR VKAPI_ATTR VkResult VKAPI_CALL CreateAndroidSurfaceKHR(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01794, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateAndroidSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } #endif // VK_USE_PLATFORM_ANDROID_KHR #ifdef VK_USE_PLATFORM_IOS_MVK VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK(VkInstance instance, const VkIOSSurfaceCreateInfoMVK *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateIOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface); if (result == VK_SUCCESS) { std::lock_guard lock(global_lock); CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } return result; } #endif // VK_USE_PLATFORM_IOS_MVK #ifdef VK_USE_PLATFORM_MACOS_MVK VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateMacOSSurfaceMVK(instance, pCreateInfo, pAllocator, pSurface); if (result == VK_SUCCESS) { std::lock_guard lock(global_lock); CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } return result; } #endif // VK_USE_PLATFORM_MACOS_MVK #ifdef VK_USE_PLATFORM_VI_NN VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN(VkInstance instance, const VkViSurfaceCreateInfoNN *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance)->CreateViSurfaceNN(instance, pCreateInfo, pAllocator, pSurface); if (result == VK_SUCCESS) { std::lock_guard lock(global_lock); CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } return result; } #endif // VK_USE_PLATFORM_VI_NN VKAPI_ATTR VkResult VKAPI_CALL CreateSharedSwapchainsKHR(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchains) { bool skip = false; uint32_t i = 0; { std::lock_guard lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01943, VALIDATION_ERROR_UNDEFINED); if (NULL != pCreateInfos) { for (i = 0; i < swapchainCount; i++) { skip |= ValidateObject(device, pCreateInfos[i].oldSwapchain, kVulkanObjectTypeSwapchainKHR, true, VALIDATION_ERROR_01935, VALIDATION_ERROR_UNDEFINED); layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); skip |= ValidateObject(device_data->physical_device, pCreateInfos[i].surface, kVulkanObjectTypeSurfaceKHR, false, VALIDATION_ERROR_01926, VALIDATION_ERROR_UNDEFINED); } } } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device) ->CreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { for (i = 0; i < swapchainCount; i++) { CreateObject(device, pSwapchains[i], kVulkanObjectTypeSwapchainKHR, pAllocator); } } } return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pCallback) { VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ot_instance_table_map, instance); VkResult result = pInstanceTable->CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback); if (VK_SUCCESS == result) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); result = layer_create_msg_callback(instance_data->report_data, false, pCreateInfo, pAllocator, pCallback); CreateObject(instance, *pCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator); } return result; } VKAPI_ATTR void VKAPI_CALL DestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, const VkAllocationCallbacks *pAllocator) { VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ot_instance_table_map, instance); pInstanceTable->DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); layer_destroy_msg_callback(instance_data->report_data, msgCallback, pAllocator); DestroyObject(instance, msgCallback, kVulkanObjectTypeDebugReportCallbackEXT, pAllocator, VALIDATION_ERROR_02049, VALIDATION_ERROR_02050); } VKAPI_ATTR void VKAPI_CALL DebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ot_instance_table_map, instance); pInstanceTable->DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); } static const VkExtensionProperties instance_extensions[] = {{VK_EXT_DEBUG_REPORT_EXTENSION_NAME, VK_EXT_DEBUG_REPORT_SPEC_VERSION}}; static const VkLayerProperties globalLayerProps = {"VK_LAYER_LUNARG_object_tracker", VK_LAYER_API_VERSION, // specVersion 1, // implementationVersion "LunarG Validation Layer"}; VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); } VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, VkLayerProperties *pProperties) { return util_GetLayerProperties(1, &globalLayerProps, pCount, pProperties); } VKAPI_ATTR VkResult VKAPI_CALL EnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) return util_GetExtensionProperties(1, instance_extensions, pCount, pProperties); return VK_ERROR_LAYER_NOT_PRESENT; } VKAPI_ATTR VkResult VKAPI_CALL EnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { if (pLayerName && !strcmp(pLayerName, globalLayerProps.layerName)) return util_GetExtensionProperties(0, nullptr, pCount, pProperties); assert(physicalDevice); VkLayerInstanceDispatchTable *pTable = get_dispatch_table(ot_instance_table_map, physicalDevice); return pTable->EnumerateDeviceExtensionProperties(physicalDevice, NULL, pCount, pProperties); } static inline PFN_vkVoidFunction InterceptMsgCallbackGetProcAddrCommand(const char *name, VkInstance instance) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(instance), layer_data_map); return debug_report_get_instance_proc_addr(instance_data->report_data, name); } VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayPlaneSurfaceKHR(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface); static inline PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkInstance instance) { VkLayerInstanceDispatchTable *pTable = get_dispatch_table(ot_instance_table_map, instance); if (instanceExtMap.size() == 0 || !instanceExtMap[pTable].wsi_enabled) return nullptr; if (!strcmp("vkDestroySurfaceKHR", name)) return reinterpret_cast(DestroySurfaceKHR); if (!strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceSurfaceSupportKHR); if (!strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", name)) return reinterpret_cast(GetPhysicalDeviceSurfaceCapabilitiesKHR); if (!strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", name)) return reinterpret_cast(GetPhysicalDeviceSurfaceFormatsKHR); if (!strcmp("vkGetPhysicalDeviceSurfacePresentModesKHR", name)) return reinterpret_cast(GetPhysicalDeviceSurfacePresentModesKHR); if ((instanceExtMap[pTable].display_enabled == true) && !strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) return reinterpret_cast(CreateDisplayPlaneSurfaceKHR); #ifdef VK_USE_PLATFORM_WIN32_KHR if ((instanceExtMap[pTable].win32_enabled == true) && !strcmp("vkCreateWin32SurfaceKHR", name)) return reinterpret_cast(CreateWin32SurfaceKHR); if ((instanceExtMap[pTable].win32_enabled == true) && !strcmp("vkGetPhysicalDeviceWin32PresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceWin32PresentationSupportKHR); #endif // VK_USE_PLATFORM_WIN32_KHR #ifdef VK_USE_PLATFORM_XCB_KHR if ((instanceExtMap[pTable].xcb_enabled == true) && !strcmp("vkCreateXcbSurfaceKHR", name)) return reinterpret_cast(CreateXcbSurfaceKHR); if ((instanceExtMap[pTable].xcb_enabled == true) && !strcmp("vkGetPhysicalDeviceXcbPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceXcbPresentationSupportKHR); #endif // VK_USE_PLATFORM_XCB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR if ((instanceExtMap[pTable].xlib_enabled == true) && !strcmp("vkCreateXlibSurfaceKHR", name)) return reinterpret_cast(CreateXlibSurfaceKHR); if ((instanceExtMap[pTable].xlib_enabled == true) && !strcmp("vkGetPhysicalDeviceXlibPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceXlibPresentationSupportKHR); #endif // VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_MIR_KHR if ((instanceExtMap[pTable].mir_enabled == true) && !strcmp("vkCreateMirSurfaceKHR", name)) return reinterpret_cast(CreateMirSurfaceKHR); if ((instanceExtMap[pTable].mir_enabled == true) && !strcmp("vkGetPhysicalDeviceMirPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceMirPresentationSupportKHR); #endif // VK_USE_PLATFORM_MIR_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR if ((instanceExtMap[pTable].wayland_enabled == true) && !strcmp("vkCreateWaylandSurfaceKHR", name)) return reinterpret_cast(CreateWaylandSurfaceKHR); if ((instanceExtMap[pTable].wayland_enabled == true) && !strcmp("vkGetPhysicalDeviceWaylandPresentationSupportKHR", name)) return reinterpret_cast(GetPhysicalDeviceWaylandPresentationSupportKHR); #endif // VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_ANDROID_KHR if ((instanceExtMap[pTable].android_enabled == true) && !strcmp("vkCreateAndroidSurfaceKHR", name)) return reinterpret_cast(CreateAndroidSurfaceKHR); #endif // VK_USE_PLATFORM_ANDROID_KHR return nullptr; } static void CheckDeviceRegisterExtensions(const VkDeviceCreateInfo *pCreateInfo, VkDevice device) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { device_data->enables.wsi_display_extension = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME) == 0) { device_data->enables.wsi_display_swapchain = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME) == 0) { device_data->enables.khr_descriptor_update_template = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MAINTENANCE1_EXTENSION_NAME) == 0) { device_data->enables.khr_maintenance1 = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME) == 0) { device_data->enables.khr_push_descriptor = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) { device_data->enables.wsi = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], "OBJTRACK_EXTENSIONS") == 0) { device_data->enables.objtrack_extensions = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHX_DEVICE_GROUP_EXTENSION_NAME) == 0) { device_data->enables.khx_device_group = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHX_EXTERNAL_MEMORY_FD_EXTENSION_NAME) == 0) { device_data->enables.khx_external_memory_fd = true; } #ifdef VK_USE_PLATFORM_WIN32_KHX if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHX_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME) == 0) { device_data->enables.khx_external_memory_win32 = true; } #endif // VK_USE_PLATFORM_WIN32_KHX if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHX_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME) == 0) { device_data->enables.khx_external_semaphore_fd = true; } #ifdef VK_USE_PLATFORM_WIN32_KHX if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHX_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME) == 0) { device_data->enables.khx_external_semaphore_win32 = true; } #endif // VK_USE_PLATFORM_WIN32_KHX if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME) == 0) { device_data->enables.ext_discard_rectangles = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME) == 0) { device_data->enables.ext_display_control = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME) == 0) { device_data->enables.nv_clip_space_w_scaling = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME) == 0) { device_data->enables.nvx_device_generated_commands = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME) == 0) { device_data->enables.google_display_timing = true; } } } static void CheckInstanceRegisterExtensions(const VkInstanceCreateInfo *pCreateInfo, VkInstance instance) { VkLayerInstanceDispatchTable *pDisp = get_dispatch_table(ot_instance_table_map, instance); instanceExtMap[pDisp] = {}; for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { #ifdef VK_USE_PLATFORM_ANDROID_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_ANDROID_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].android_enabled = true; } #endif if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_DISPLAY_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].display_enabled = true; } if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].wsi_enabled = true; } #ifdef VK_USE_PLATFORM_MIR_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_MIR_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].mir_enabled = true; } #endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].wayland_enabled = true; } #endif #ifdef VK_USE_PLATFORM_WIN32_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_WIN32_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].win32_enabled = true; } #endif #ifdef VK_USE_PLATFORM_XCB_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XCB_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].xcb_enabled = true; } #endif #ifdef VK_USE_PLATFORM_XLIB_KHR if (strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_XLIB_SURFACE_EXTENSION_NAME) == 0) { instanceExtMap[pDisp].xlib_enabled = true; } #endif } } VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) { std::lock_guard lock(global_lock); layer_data *phy_dev_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); VkLayerDeviceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); assert(chain_info->u.pLayerInfo); PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; PFN_vkGetDeviceProcAddr fpGetDeviceProcAddr = chain_info->u.pLayerInfo->pfnNextGetDeviceProcAddr; PFN_vkCreateDevice fpCreateDevice = (PFN_vkCreateDevice)fpGetInstanceProcAddr(phy_dev_data->instance, "vkCreateDevice"); if (fpCreateDevice == NULL) { return VK_ERROR_INITIALIZATION_FAILED; } // Advance the link info for the next element on the chain chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice); if (result != VK_SUCCESS) { return result; } layer_data *device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); device_data->report_data = layer_debug_report_create_device(phy_dev_data->report_data, *pDevice); layer_init_device_dispatch_table(*pDevice, &device_data->dispatch_table, fpGetDeviceProcAddr); // Add link back to physDev device_data->physical_device = physicalDevice; initDeviceTable(*pDevice, fpGetDeviceProcAddr, ot_device_table_map); CheckDeviceRegisterExtensions(pCreateInfo, *pDevice); CreateObject(*pDevice, *pDevice, kVulkanObjectTypeDevice, pAllocator); return result; } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_00028, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties); std::lock_guard lock(global_lock); if (pQueueFamilyProperties != NULL) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); } for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { instance_data->queue_family_properties[i] = pQueueFamilyProperties[i]; } } } VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) { VkLayerInstanceCreateInfo *chain_info = get_chain_info(pCreateInfo, VK_LAYER_LINK_INFO); assert(chain_info->u.pLayerInfo); PFN_vkGetInstanceProcAddr fpGetInstanceProcAddr = chain_info->u.pLayerInfo->pfnNextGetInstanceProcAddr; PFN_vkCreateInstance fpCreateInstance = (PFN_vkCreateInstance)fpGetInstanceProcAddr(NULL, "vkCreateInstance"); if (fpCreateInstance == NULL) { return VK_ERROR_INITIALIZATION_FAILED; } // Advance the link info for the next element on the chain chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext; VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance); if (result != VK_SUCCESS) { return result; } layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); instance_data->instance = *pInstance; initInstanceTable(*pInstance, fpGetInstanceProcAddr, ot_instance_table_map); VkLayerInstanceDispatchTable *pInstanceTable = get_dispatch_table(ot_instance_table_map, *pInstance); // Look for one or more debug report create info structures, and copy the // callback(s) for each one found (for use by vkDestroyInstance) layer_copy_tmp_callbacks(pCreateInfo->pNext, &instance_data->num_tmp_callbacks, &instance_data->tmp_dbg_create_infos, &instance_data->tmp_callbacks); instance_data->report_data = debug_report_create_instance(pInstanceTable, *pInstance, pCreateInfo->enabledExtensionCount, pCreateInfo->ppEnabledExtensionNames); InitObjectTracker(instance_data, pAllocator); CheckInstanceRegisterExtensions(pCreateInfo, *pInstance); CreateObject(*pInstance, *pInstance, kVulkanObjectTypeInstance, pAllocator); return result; } VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_00023, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance) ->EnumeratePhysicalDevices(instance, pPhysicalDeviceCount, pPhysicalDevices); lock.lock(); if (result == VK_SUCCESS) { if (pPhysicalDevices) { for (uint32_t i = 0; i < *pPhysicalDeviceCount; i++) { CreateObject(instance, pPhysicalDevices[i], kVulkanObjectTypePhysicalDevice, nullptr); } } } lock.unlock(); return result; } VKAPI_ATTR void VKAPI_CALL GetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue) { std::unique_lock lock(global_lock); ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00062, VALIDATION_ERROR_UNDEFINED); lock.unlock(); get_dispatch_table(ot_device_table_map, device)->GetDeviceQueue(device, queueFamilyIndex, queueIndex, pQueue); lock.lock(); CreateQueue(device, *pQueue); AddQueueInfo(device, queueFamilyIndex, *pQueue); } VKAPI_ATTR void VKAPI_CALL FreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00621, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, true, VALIDATION_ERROR_00622, VALIDATION_ERROR_00624); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, device)->FreeMemory(device, memory, pAllocator); lock.lock(); DestroyObject(device, memory, kVulkanObjectTypeDeviceMemory, pAllocator, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } } VKAPI_ATTR VkResult VKAPI_CALL MapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00630, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00631, VALIDATION_ERROR_00634); lock.unlock(); if (skip == VK_TRUE) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->MapMemory(device, memory, offset, size, flags, ppData); return result; } VKAPI_ATTR void VKAPI_CALL UnmapMemory(VkDevice device, VkDeviceMemory memory) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00650, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_00651, VALIDATION_ERROR_00652); lock.unlock(); if (skip == VK_TRUE) { return; } get_dispatch_table(ot_device_table_map, device)->UnmapMemory(device, memory); } VKAPI_ATTR VkResult VKAPI_CALL QueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, VkFence fence) { std::unique_lock lock(global_lock); ValidateQueueFlags(queue, "QueueBindSparse"); ValidateObject(queue, queue, kVulkanObjectTypeQueue, false, VALIDATION_ERROR_01648, VALIDATION_ERROR_UNDEFINED); ValidateObject(queue, fence, kVulkanObjectTypeFence, true, VALIDATION_ERROR_01650, VALIDATION_ERROR_01652); for (uint32_t i = 0; i < bindInfoCount; i++) { for (uint32_t j = 0; j < pBindInfo[i].bufferBindCount; j++) { ValidateObject(queue, pBindInfo[i].pBufferBinds[j].buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01656, VALIDATION_ERROR_UNDEFINED); } for (uint32_t j = 0; j < pBindInfo[i].imageOpaqueBindCount; j++) { ValidateObject(queue, pBindInfo[i].pImageOpaqueBinds[j].image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01657, VALIDATION_ERROR_UNDEFINED); } for (uint32_t j = 0; j < pBindInfo[i].imageBindCount; j++) { ValidateObject(queue, pBindInfo[i].pImageBinds[j].image, kVulkanObjectTypeImage, false, VALIDATION_ERROR_01658, VALIDATION_ERROR_UNDEFINED); } for (uint32_t j = 0; j < pBindInfo[i].waitSemaphoreCount; j++) { ValidateObject(queue, pBindInfo[i].pWaitSemaphores[j], kVulkanObjectTypeSemaphore, false, VALIDATION_ERROR_01655, VALIDATION_ERROR_01660); } for (uint32_t j = 0; j < pBindInfo[i].signalSemaphoreCount; j++) { ValidateObject(queue, pBindInfo[i].pSignalSemaphores[j], kVulkanObjectTypeSemaphore, false, VALIDATION_ERROR_01659, VALIDATION_ERROR_01660); } } lock.unlock(); VkResult result = get_dispatch_table(ot_device_table_map, queue)->QueueBindSparse(queue, bindInfoCount, pBindInfo, fence); return result; } VKAPI_ATTR VkResult VKAPI_CALL AllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00084, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, pAllocateInfo->commandPool, kVulkanObjectTypeCommandPool, false, VALIDATION_ERROR_00090, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->AllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers); lock.lock(); for (uint32_t i = 0; i < pAllocateInfo->commandBufferCount; i++) { AllocateCommandBuffer(device, pAllocateInfo->commandPool, pCommandBuffers[i], pAllocateInfo->level); } lock.unlock(); return result; } VKAPI_ATTR VkResult VKAPI_CALL AllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00908, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, pAllocateInfo->descriptorPool, kVulkanObjectTypeDescriptorPool, false, VALIDATION_ERROR_00915, VALIDATION_ERROR_00918); for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { skip |= ValidateObject(device, pAllocateInfo->pSetLayouts[i], kVulkanObjectTypeDescriptorSetLayout, false, VALIDATION_ERROR_00916, VALIDATION_ERROR_00918); } lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->AllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets); if (VK_SUCCESS == result) { lock.lock(); for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) { AllocateDescriptorSet(device, pAllocateInfo->descriptorPool, pDescriptorSets[i]); } lock.unlock(); } return result; } VKAPI_ATTR void VKAPI_CALL FreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers) { bool skip = false; std::unique_lock lock(global_lock); ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00098, VALIDATION_ERROR_UNDEFINED); ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, VALIDATION_ERROR_00099, VALIDATION_ERROR_00101); for (uint32_t i = 0; i < commandBufferCount; i++) { if (pCommandBuffers[i] != VK_NULL_HANDLE) { skip |= ValidateCommandBuffer(device, commandPool, pCommandBuffers[i]); } } for (uint32_t i = 0; i < commandBufferCount; i++) { DestroyObject(device, pCommandBuffers[i], kVulkanObjectTypeCommandBuffer, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, device) ->FreeCommandBuffers(device, commandPool, commandBufferCount, pCommandBuffers); } } VKAPI_ATTR void VKAPI_CALL DestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); std::unique_lock lock(global_lock); // A swapchain's images are implicitly deleted when the swapchain is deleted. // Remove this swapchain's images from our map of such images. std::unordered_map::iterator itr = device_data->swapchainImageMap.begin(); while (itr != device_data->swapchainImageMap.end()) { OBJTRACK_NODE *pNode = (*itr).second; if (pNode->parent_object == reinterpret_cast(swapchain)) { delete pNode; auto delete_item = itr++; device_data->swapchainImageMap.erase(delete_item); } else { ++itr; } } DestroyObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, pAllocator, VALIDATION_ERROR_01938, VALIDATION_ERROR_01939); lock.unlock(); get_dispatch_table(ot_device_table_map, device)->DestroySwapchainKHR(device, swapchain, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL FreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets) { bool skip = false; VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00923, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, false, VALIDATION_ERROR_00924, VALIDATION_ERROR_00926); for (uint32_t i = 0; i < descriptorSetCount; i++) { if (pDescriptorSets[i] != VK_NULL_HANDLE) { skip |= ValidateDescriptorSet(device, descriptorPool, pDescriptorSets[i]); } } for (uint32_t i = 0; i < descriptorSetCount; i++) { DestroyObject(device, pDescriptorSets[i], kVulkanObjectTypeDescriptorSet, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } lock.unlock(); if (!skip) { result = get_dispatch_table(ot_device_table_map, device) ->FreeDescriptorSets(device, descriptorPool, descriptorSetCount, pDescriptorSets); } return result; } VKAPI_ATTR void VKAPI_CALL DestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator) { bool skip = VK_FALSE; layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00904, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, true, VALIDATION_ERROR_00905, VALIDATION_ERROR_00907); lock.unlock(); if (skip) { return; } // A DescriptorPool's descriptor sets are implicitly deleted when the pool is deleted. // Remove this pool's descriptor sets from our descriptorSet map. lock.lock(); std::unordered_map::iterator itr = device_data->object_map[kVulkanObjectTypeDescriptorSet].begin(); while (itr != device_data->object_map[kVulkanObjectTypeDescriptorSet].end()) { OBJTRACK_NODE *pNode = (*itr).second; auto del_itr = itr++; if (pNode->parent_object == reinterpret_cast(descriptorPool)) { DestroyObject(device, (VkDescriptorSet)((*del_itr).first), kVulkanObjectTypeDescriptorSet, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } } DestroyObject(device, descriptorPool, kVulkanObjectTypeDescriptorPool, pAllocator, VALIDATION_ERROR_00902, VALIDATION_ERROR_00903); lock.unlock(); get_dispatch_table(ot_device_table_map, device)->DestroyDescriptorPool(device, descriptorPool, pAllocator); } VKAPI_ATTR void VKAPI_CALL DestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00080, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, true, VALIDATION_ERROR_00081, VALIDATION_ERROR_00083); lock.unlock(); if (skip) { return; } lock.lock(); // A CommandPool's command buffers are implicitly deleted when the pool is deleted. // Remove this pool's cmdBuffers from our cmd buffer map. auto itr = device_data->object_map[kVulkanObjectTypeCommandBuffer].begin(); auto del_itr = itr; while (itr != device_data->object_map[kVulkanObjectTypeCommandBuffer].end()) { OBJTRACK_NODE *pNode = (*itr).second; del_itr = itr++; if (pNode->parent_object == reinterpret_cast(commandPool)) { skip |= ValidateCommandBuffer(device, commandPool, reinterpret_cast((*del_itr).first)); DestroyObject(device, reinterpret_cast((*del_itr).first), kVulkanObjectTypeCommandBuffer, nullptr, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } } DestroyObject(device, commandPool, kVulkanObjectTypeCommandPool, pAllocator, VALIDATION_ERROR_00078, VALIDATION_ERROR_00079); lock.unlock(); get_dispatch_table(ot_device_table_map, device)->DestroyCommandPool(device, commandPool, pAllocator); } VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01948, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device) ->GetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages); if (pSwapchainImages != NULL) { lock.lock(); for (uint32_t i = 0; i < *pSwapchainImageCount; i++) { CreateSwapchainImageObject(device, pSwapchainImages[i], swapchain); } lock.unlock(); } return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00519, VALIDATION_ERROR_UNDEFINED); if (pCreateInfos) { for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { if (pCreateInfos[idx0].basePipelineHandle) { skip |= ValidateObject(device, pCreateInfos[idx0].basePipelineHandle, kVulkanObjectTypePipeline, true, VALIDATION_ERROR_00529, VALIDATION_ERROR_00549); } if (pCreateInfos[idx0].layout) { skip |= ValidateObject(device, pCreateInfos[idx0].layout, kVulkanObjectTypePipelineLayout, false, VALIDATION_ERROR_00546, VALIDATION_ERROR_00549); } if (pCreateInfos[idx0].pStages) { for (uint32_t idx1 = 0; idx1 < pCreateInfos[idx0].stageCount; ++idx1) { if (pCreateInfos[idx0].pStages[idx1].module) { skip |= ValidateObject(device, pCreateInfos[idx0].pStages[idx1].module, kVulkanObjectTypeShaderModule, false, VALIDATION_ERROR_00515, VALIDATION_ERROR_UNDEFINED); } } } if (pCreateInfos[idx0].renderPass) { skip |= ValidateObject(device, pCreateInfos[idx0].renderPass, kVulkanObjectTypeRenderPass, false, VALIDATION_ERROR_00547, VALIDATION_ERROR_00549); } } } if (pipelineCache) { skip |= ValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true, VALIDATION_ERROR_00520, VALIDATION_ERROR_00525); } lock.unlock(); if (skip) { for (uint32_t i = 0; i < createInfoCount; i++) { pPipelines[i] = VK_NULL_HANDLE; } return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device) ->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); lock.lock(); for (uint32_t idx2 = 0; idx2 < createInfoCount; ++idx2) { if (pPipelines[idx2] != VK_NULL_HANDLE) { CreateObject(device, pPipelines[idx2], kVulkanObjectTypePipeline, pAllocator); } } lock.unlock(); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_00486, VALIDATION_ERROR_UNDEFINED); if (pCreateInfos) { for (uint32_t idx0 = 0; idx0 < createInfoCount; ++idx0) { if (pCreateInfos[idx0].basePipelineHandle) { skip |= ValidateObject(device, pCreateInfos[idx0].basePipelineHandle, kVulkanObjectTypePipeline, true, VALIDATION_ERROR_00496, VALIDATION_ERROR_00506); } if (pCreateInfos[idx0].layout) { skip |= ValidateObject(device, pCreateInfos[idx0].layout, kVulkanObjectTypePipelineLayout, false, VALIDATION_ERROR_00505, VALIDATION_ERROR_00506); } if (pCreateInfos[idx0].stage.module) { skip |= ValidateObject(device, pCreateInfos[idx0].stage.module, kVulkanObjectTypeShaderModule, false, VALIDATION_ERROR_00515, VALIDATION_ERROR_UNDEFINED); } } } if (pipelineCache) { skip |= ValidateObject(device, pipelineCache, kVulkanObjectTypePipelineCache, true, VALIDATION_ERROR_00487, VALIDATION_ERROR_00492); } lock.unlock(); if (skip) { for (uint32_t i = 0; i < createInfoCount; i++) { pPipelines[i] = VK_NULL_HANDLE; } return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device) ->CreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); lock.lock(); for (uint32_t idx1 = 0; idx1 < createInfoCount; ++idx1) { if (pPipelines[idx1] != VK_NULL_HANDLE) { CreateObject(device, pPipelines[idx1], kVulkanObjectTypePipeline, pAllocator); } } lock.unlock(); return result; } // VK_KHR_display Extension VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPropertiesKHR *pProperties) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01851, VALIDATION_ERROR_UNDEFINED); } if (!skip) { result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties); } return result; } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01854, VALIDATION_ERROR_UNDEFINED); } if (!skip) { result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, pPropertyCount, pProperties); } return result; } VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t *pDisplayCount, VkDisplayKHR *pDisplays) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01858, VALIDATION_ERROR_UNDEFINED); } result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, pDisplayCount, pDisplays); if (((result == VK_SUCCESS) || (result == VK_INCOMPLETE)) && (pDisplays != NULL)) { std::lock_guard lock(global_lock); for (uint32_t displays = 0; displays < *pDisplayCount; displays++) { CreateObject(physicalDevice, pDisplays[displays], kVulkanObjectTypeDisplayKHR, nullptr); } } return result; } VKAPI_ATTR VkResult VKAPI_CALL GetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01861, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, VALIDATION_ERROR_01862, VALIDATION_ERROR_UNDEFINED); } result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetDisplayModePropertiesKHR(physicalDevice, display, pPropertyCount, pProperties); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01865, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, VALIDATION_ERROR_01866, VALIDATION_ERROR_UNDEFINED); } result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->CreateDisplayModeKHR(physicalDevice, display, pCreateInfo, pAllocator, pMode); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(physicalDevice, *pMode, kVulkanObjectTypeDisplayModeKHR, pAllocator); } } return result; } VKAPI_ATTR VkResult VKAPI_CALL GetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01875, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, mode, kVulkanObjectTypeDisplayModeKHR, false, VALIDATION_ERROR_01876, VALIDATION_ERROR_UNDEFINED); } result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetDisplayPlaneCapabilitiesKHR(physicalDevice, mode, planeIndex, pCapabilities); return result; } VKAPI_ATTR VkResult VKAPI_CALL CreateDisplayPlaneSurfaceKHR(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_01878, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(instance, pCreateInfo->displayMode, kVulkanObjectTypeDisplayModeKHR, false, VALIDATION_ERROR_01886, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance) ->CreateDisplayPlaneSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface); { std::lock_guard lock(global_lock); if (result == VK_SUCCESS) { CreateObject(instance, *pSurface, kVulkanObjectTypeSurfaceKHR, pAllocator); } } return result; } // VK_KHR_get_physical_device_properties2 Extension VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2KHR(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR *pFeatures) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice)->GetPhysicalDeviceFeatures2KHR(physicalDevice, pFeatures); } } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2KHR(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2KHR *pProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice)->GetPhysicalDeviceProperties2KHR(physicalDevice, pProperties); } } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFormatProperties2KHR(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2KHR *pFormatProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceFormatProperties2KHR(physicalDevice, format, pFormatProperties); } } VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceImageFormatProperties2KHR( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR *pImageFormatInfo, VkImageFormatProperties2KHR *pImageFormatProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceImageFormatProperties2KHR(physicalDevice, pImageFormatInfo, pImageFormatProperties); return result; } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceQueueFamilyProperties2KHR(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR *pQueueFamilyProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return; } get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceQueueFamilyProperties2KHR(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties); std::lock_guard lock(global_lock); if (pQueueFamilyProperties != NULL) { layer_data *instance_data = GetLayerDataPtr(get_dispatch_key(physicalDevice), layer_data_map); if (instance_data->queue_family_properties.size() < *pQueueFamilyPropertyCount) { instance_data->queue_family_properties.resize(*pQueueFamilyPropertyCount); } for (uint32_t i = 0; i < *pQueueFamilyPropertyCount; i++) { instance_data->queue_family_properties[i] = pQueueFamilyProperties[i].queueFamilyProperties; } } } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceMemoryProperties2KHR(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR *pMemoryProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceMemoryProperties2KHR(physicalDevice, pMemoryProperties); } } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceSparseImageFormatProperties2KHR( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR *pFormatInfo, uint32_t *pPropertyCount, VkSparseImageFormatProperties2KHR *pProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSparseImageFormatProperties2KHR(physicalDevice, pFormatInfo, pPropertyCount, pProperties); } } // VK_KHR_descriptor_update_template VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorUpdateTemplateKHR(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorUpdateTemplateKHR *pDescriptorUpdateTemplate) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = VK_SUCCESS; result = dev_data->dispatch_table.CreateDescriptorUpdateTemplateKHR(device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate); // TODO: Add tracking of VkDescriptorUpdateTemplateKHR return result; } VKAPI_ATTR void VKAPI_CALL DestroyDescriptorUpdateTemplateKHR(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const VkAllocationCallbacks *pAllocator) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); // TODO: Add tracking of VkDescriptorUpdateTemplateKHR lock.unlock(); if (!skip) { layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); dev_data->dispatch_table.DestroyDescriptorUpdateTemplateKHR(device, descriptorUpdateTemplate, pAllocator); } } VKAPI_ATTR void VKAPI_CALL UpdateDescriptorSetWithTemplateKHR(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void *pData) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, descriptorSet, kVulkanObjectTypeDescriptorSet, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); // TODO: Add tracking of VkDescriptorUpdateTemplateKHR lock.unlock(); if (!skip) { layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); dev_data->dispatch_table.UpdateDescriptorSetWithTemplateKHR(device, descriptorSet, descriptorUpdateTemplate, pData); } } VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetWithTemplateKHR(VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void *pData) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); // TODO: Add tracking of VkDescriptorUpdateTemplateKHR lock.unlock(); if (!skip) { layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); dev_data->dispatch_table.CmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate, layout, set, pData); } } // VK_KHR_maintenance1 Extension VKAPI_ATTR void VKAPI_CALL TrimCommandPoolKHR(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlagsKHR flags) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, commandPool, kVulkanObjectTypeCommandPool, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); dev_data->dispatch_table.TrimCommandPoolKHR(device, commandPool, flags); } } // VK_KHR_push_descriptor Extension VKAPI_ATTR void VKAPI_CALL CmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, layout, kVulkanObjectTypePipelineLayout, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, pDescriptorWrites); } } // VK_KHX_device_group Extension VKAPI_ATTR void VKAPI_CALL GetDeviceGroupPeerMemoryFeaturesKHX(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlagsKHX *pPeerMemoryFeatures) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, device) ->GetDeviceGroupPeerMemoryFeaturesKHX(device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures); } } VKAPI_ATTR VkResult VKAPI_CALL BindBufferMemory2KHX(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfoKHX *pBindInfos) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->BindBufferMemory2KHX(device, bindInfoCount, pBindInfos); return result; } VKAPI_ATTR VkResult VKAPI_CALL BindImageMemory2KHX(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfoKHX *pBindInfos) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->BindImageMemory2KHX(device, bindInfoCount, pBindInfos); return result; } VKAPI_ATTR void VKAPI_CALL CmdSetDeviceMaskKHX(VkCommandBuffer commandBuffer, uint32_t deviceMask) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, commandBuffer)->CmdSetDeviceMaskKHX(commandBuffer, deviceMask); } } VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupPresentCapabilitiesKHX(VkDevice device, VkDeviceGroupPresentCapabilitiesKHX *pDeviceGroupPresentCapabilities) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device) ->GetDeviceGroupPresentCapabilitiesKHX(device, pDeviceGroupPresentCapabilities); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetDeviceGroupSurfacePresentModesKHX(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHX *pModes) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->GetDeviceGroupSurfacePresentModesKHX(device, surface, pModes); return result; } VKAPI_ATTR VkResult VKAPI_CALL AcquireNextImage2KHX(VkDevice device, const VkAcquireNextImageInfoKHX *pAcquireInfo, uint32_t *pImageIndex) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->AcquireNextImage2KHX(device, pAcquireInfo, pImageIndex); return result; } VKAPI_ATTR void VKAPI_CALL CmdDispatchBaseKHX(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdDispatchBaseKHX(commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ); } } VKAPI_ATTR void VKAPI_CALL GetPhysicalDevicePresentRectanglesKHX(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pRectCount, VkRect2D *pRects) { bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDevicePresentRectanglesKHX(physicalDevice, surface, pRectCount, pRects); } } // VK_KHX_device_group_creation Extension VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDeviceGroupsKHX( VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupPropertiesKHX *pPhysicalDeviceGroupProperties) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(instance, instance, kVulkanObjectTypeInstance, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, instance) ->EnumeratePhysicalDeviceGroupsKHX(instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties); { lock.lock(); if (result == VK_SUCCESS) { if (nullptr != pPhysicalDeviceGroupProperties) { // NOTE: Each physical device should only appear in one group for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) { for (uint32_t j = 0; j < pPhysicalDeviceGroupProperties[i].physicalDeviceCount; j++) { CreateObject(instance, pPhysicalDeviceGroupProperties[i].physicalDevices[j], kVulkanObjectTypePhysicalDevice, nullptr); } } } } lock.unlock(); } return result; } // VK_KHX_external_memory_capabilities Extension VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalBufferPropertiesKHX( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHX *pExternalBufferInfo, VkExternalBufferPropertiesKHX *pExternalBufferProperties) { bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceExternalBufferPropertiesKHX(physicalDevice, pExternalBufferInfo, pExternalBufferProperties); } } // VK_KHX_external_memory_fd Extension VKAPI_ATTR VkResult VKAPI_CALL GetMemoryFdKHX(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagBitsKHX handleType, int *pFd) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->GetMemoryFdKHX(device, memory, handleType, pFd); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetMemoryFdPropertiesKHX(VkDevice device, VkExternalMemoryHandleTypeFlagBitsKHX handleType, int fd, VkMemoryFdPropertiesKHX *pMemoryFdProperties) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->GetMemoryFdPropertiesKHX(device, handleType, fd, pMemoryFdProperties); return result; } // VK_KHX_external_memory_win32 Extension #ifdef VK_USE_PLATFORM_WIN32_KHX VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleKHX(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagBitsKHX handleType, HANDLE *pHandle) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->GetMemoryWin32HandleKHX(device, memory, handleType, pHandle); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandlePropertiesKHX(VkDevice device, VkExternalMemoryHandleTypeFlagBitsKHX handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHX *pMemoryWin32HandleProperties) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device) ->GetMemoryWin32HandlePropertiesKHX(device, handleType, handle, pMemoryWin32HandleProperties); return result; } #endif // VK_USE_PLATFORM_WIN32_KHX // VK_KHX_external_semaphore_capabilities Extension VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceExternalSemaphorePropertiesKHX( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHX *pExternalSemaphoreInfo, VkExternalSemaphorePropertiesKHX *pExternalSemaphoreProperties) { bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceExternalSemaphorePropertiesKHX(physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties); } } // VK_KHX_external_semaphore_fd Extension VKAPI_ATTR VkResult VKAPI_CALL ImportSemaphoreFdKHX(VkDevice device, const VkImportSemaphoreFdInfoKHX *pImportSemaphoreFdInfo) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->ImportSemaphoreFdKHX(device, pImportSemaphoreFdInfo); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetSemaphoreFdKHX(VkDevice device, VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBitsKHX handleType, int *pFd) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->GetSemaphoreFdKHX(device, semaphore, handleType, pFd); return result; } // VK_KHX_external_semaphore_win32 Extension #ifdef VK_USE_PLATFORM_WIN32_KHX VKAPI_ATTR VkResult VKAPI_CALL ImportSemaphoreWin32HandleKHX(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHX *pImportSemaphoreWin32HandleInfo) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->ImportSemaphoreWin32HandleKHX(device, pImportSemaphoreWin32HandleInfo); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetSemaphoreWin32HandleKHX(VkDevice device, VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBitsKHX handleType, HANDLE *pHandle) { bool skip = false; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = VK_SUCCESS; result = get_dispatch_table(ot_device_table_map, device)->GetSemaphoreWin32HandleKHX(device, semaphore, handleType, pHandle); return result; } #endif // VK_USE_PLATFORM_WIN32_KHX // VK_EXT_acquire_xlib_display Extension #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT VKAPI_ATTR VkResult VKAPI_CALL AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, VkDisplayKHR display) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } result = get_dispatch_table(ot_instance_table_map, physicalDevice)->AcquireXlibDisplayEXT(physicalDevice, dpy, display); return result; } VKAPI_ATTR VkResult VKAPI_CALL GetRandROutputDisplayEXT(VkPhysicalDevice physicalDevice, Display *dpy, RROutput rrOutput, VkDisplayKHR *pDisplay) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetRandROutputDisplayEXT(physicalDevice, dpy, rrOutput, pDisplay); if (result == VK_SUCCESS && pDisplay != NULL) { std::lock_guard lock(global_lock); CreateObject(physicalDevice, pDisplay, kVulkanObjectTypeDisplayKHR, nullptr); } return result; } #endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT // VK_EXT_debug_marker Extension VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectTagEXT(VkDevice device, VkDebugMarkerObjectTagInfoEXT *pTagInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_02007, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.DebugMarkerSetObjectTagEXT(device, pTagInfo); return result; } VKAPI_ATTR VkResult VKAPI_CALL DebugMarkerSetObjectNameEXT(VkDevice device, VkDebugMarkerObjectNameInfoEXT *pNameInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01999, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.DebugMarkerSetObjectNameEXT(device, pNameInfo); return result; } VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerBeginEXT(VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT *pMarkerInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_02014, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdDebugMarkerBeginEXT) { dev_data->dispatch_table.CmdDebugMarkerBeginEXT(commandBuffer, pMarkerInfo); } } VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerEndEXT(VkCommandBuffer commandBuffer) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_02022, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdDebugMarkerEndEXT) { dev_data->dispatch_table.CmdDebugMarkerEndEXT(commandBuffer); } } VKAPI_ATTR void VKAPI_CALL CmdDebugMarkerInsertEXT(VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT *pMarkerInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_02025, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdDebugMarkerInsertEXT) { dev_data->dispatch_table.CmdDebugMarkerInsertEXT(commandBuffer, pMarkerInfo); } } // VK_EXT_direct_mode_display Extension VKAPI_ATTR VkResult VKAPI_CALL ReleaseDisplayEXT(VkPhysicalDevice physicalDevice, VkDisplayKHR display) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(physicalDevice, display, kVulkanObjectTypeDisplayKHR, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } result = get_dispatch_table(ot_instance_table_map, physicalDevice)->ReleaseDisplayEXT(physicalDevice, display); return result; } // VK_EXT_discard_rectangles VKAPI_ATTR void VKAPI_CALL CmdSetDiscardRectangleEXT(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D *pDiscardRectangles) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdSetDiscardRectangleEXT) { dev_data->dispatch_table.CmdSetDiscardRectangleEXT(commandBuffer, firstDiscardRectangle, discardRectangleCount, pDiscardRectangles); } } // VK_EXT_display_control Extension VKAPI_ATTR VkResult VKAPI_CALL DisplayPowerControlEXT(VkDevice device, VkDisplayKHR display, const VkDisplayPowerInfoEXT *pDisplayPowerInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.DisplayPowerControlEXT(device, display, pDisplayPowerInfo); return result; } VKAPI_ATTR VkResult VKAPI_CALL RegisterDeviceEventEXT(VkDevice device, const VkDeviceEventInfoEXT *pDeviceEventInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.RegisterDeviceEventEXT(device, pDeviceEventInfo, pAllocator, pFence); if (result == VK_SUCCESS && pFence != NULL) { std::lock_guard create_lock(global_lock); CreateObject(device, *pFence, kVulkanObjectTypeFence, pAllocator); } return result; } VKAPI_ATTR VkResult VKAPI_CALL RegisterDisplayEventEXT(VkDevice device, VkDisplayKHR display, const VkDisplayEventInfoEXT *pDisplayEventInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.RegisterDisplayEventEXT(device, display, pDisplayEventInfo, pAllocator, pFence); if (result == VK_SUCCESS && pFence != NULL) { std::lock_guard create_lock(global_lock); CreateObject(device, *pFence, kVulkanObjectTypeFence, pAllocator); } return result; } VKAPI_ATTR VkResult VKAPI_CALL GetSwapchainCounterEXT(VkDevice device, VkSwapchainKHR swapchain, VkSurfaceCounterFlagBitsEXT counter, uint64_t *pCounterValue) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.GetSwapchainCounterEXT(device, swapchain, counter, pCounterValue); return result; } // VK_EXT_display_surface_counter Extension VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT *pSurfaceCapabilities) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceSurfaceCapabilities2EXT(physicalDevice, surface, pSurfaceCapabilities); return result; } // VK_AMD_draw_indirect_count Extension VKAPI_ATTR void VKAPI_CALL CmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01771, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01772, VALIDATION_ERROR_01777); skip |= ValidateObject(commandBuffer, countBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01773, VALIDATION_ERROR_01777); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01774, VALIDATION_ERROR_01777); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } } VKAPI_ATTR void VKAPI_CALL CmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_01783, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(commandBuffer, buffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01784, VALIDATION_ERROR_01789); skip |= ValidateObject(commandBuffer, countBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01785, VALIDATION_ERROR_01789); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeBuffer, false, VALIDATION_ERROR_01786, VALIDATION_ERROR_01789); lock.unlock(); if (!skip) { get_dispatch_table(ot_device_table_map, commandBuffer) ->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } } // VK_NV_clip_space_w_scaling Extension VKAPI_ATTR void VKAPI_CALL CmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportWScalingNV *pViewportWScalings) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdSetViewportWScalingNV) { dev_data->dispatch_table.CmdSetViewportWScalingNV(commandBuffer, firstViewport, viewportCount, pViewportWScalings); } } // VK_NV_external_memory_capabilities Extension VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceExternalImageFormatPropertiesNV( VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) { bool skip = false; { std::lock_guard lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_01980, VALIDATION_ERROR_UNDEFINED); } if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceExternalImageFormatPropertiesNV(physicalDevice, format, type, tiling, usage, flags, externalHandleType, pExternalImageFormatProperties); return result; } #ifdef VK_USE_PLATFORM_WIN32_KHR // VK_NV_external_memory_win32 Extension VKAPI_ATTR VkResult VKAPI_CALL GetMemoryWin32HandleNV(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE *pHandle) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_01725, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, memory, kVulkanObjectTypeDeviceMemory, false, VALIDATION_ERROR_01726, VALIDATION_ERROR_01730); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } VkResult result = get_dispatch_table(ot_device_table_map, device)->GetMemoryWin32HandleNV(device, memory, handleType, pHandle); return result; } #endif // VK_USE_PLATFORM_WIN32_KHR // VK_NVX_device_generated_commands Extension VKAPI_ATTR void VKAPI_CALL CmdProcessCommandsNVX(VkCommandBuffer commandBuffer, const VkCmdProcessCommandsInfoNVX *pProcessCommandsInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdProcessCommandsNVX) { dev_data->dispatch_table.CmdProcessCommandsNVX(commandBuffer, pProcessCommandsInfo); } } VKAPI_ATTR void VKAPI_CALL CmdReserveSpaceForCommandsNVX(VkCommandBuffer commandBuffer, const VkCmdReserveSpaceForCommandsInfoNVX *pReserveSpaceInfo) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(commandBuffer, commandBuffer, kVulkanObjectTypeCommandBuffer, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map); if (!skip && dev_data->dispatch_table.CmdReserveSpaceForCommandsNVX) { dev_data->dispatch_table.CmdReserveSpaceForCommandsNVX(commandBuffer, pReserveSpaceInfo); } } VKAPI_ATTR VkResult VKAPI_CALL CreateIndirectCommandsLayoutNVX(VkDevice device, const VkIndirectCommandsLayoutCreateInfoNVX *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkIndirectCommandsLayoutNVX *pIndirectCommandsLayout) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.CreateIndirectCommandsLayoutNVX(device, pCreateInfo, pAllocator, pIndirectCommandsLayout); return result; } VKAPI_ATTR void VKAPI_CALL DestroyIndirectCommandsLayoutNVX(VkDevice device, VkIndirectCommandsLayoutNVX indirectCommandsLayout, const VkAllocationCallbacks *pAllocator) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); dev_data->dispatch_table.DestroyIndirectCommandsLayoutNVX(device, indirectCommandsLayout, pAllocator); } } VKAPI_ATTR VkResult VKAPI_CALL CreateObjectTableNVX(VkDevice device, const VkObjectTableCreateInfoNVX *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkObjectTableNVX *pObjectTable) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.CreateObjectTableNVX(device, pCreateInfo, pAllocator, pObjectTable); return result; } VKAPI_ATTR void VKAPI_CALL DestroyObjectTableNVX(VkDevice device, VkObjectTableNVX objectTable, const VkAllocationCallbacks *pAllocator) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (!skip) { layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); dev_data->dispatch_table.DestroyObjectTableNVX(device, objectTable, pAllocator); } } VKAPI_ATTR VkResult VKAPI_CALL RegisterObjectsNVX(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectTableEntryNVX *const *ppObjectTableEntries, const uint32_t *pObjectIndices) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.RegisterObjectsNVX(device, objectTable, objectCount, ppObjectTableEntries, pObjectIndices); return result; } VKAPI_ATTR VkResult VKAPI_CALL UnregisterObjectsNVX(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectEntryTypeNVX *pObjectEntryTypes, const uint32_t *pObjectIndices) { bool skip = VK_FALSE; std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); lock.unlock(); if (skip) { return VK_ERROR_VALIDATION_FAILED_EXT; } layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); VkResult result = dev_data->dispatch_table.UnregisterObjectsNVX(device, objectTable, objectCount, pObjectEntryTypes, pObjectIndices); return result; } VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceGeneratedCommandsPropertiesNVX(VkPhysicalDevice physicalDevice, VkDeviceGeneratedCommandsFeaturesNVX *pFeatures, VkDeviceGeneratedCommandsLimitsNVX *pLimits) { bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(physicalDevice, physicalDevice, kVulkanObjectTypePhysicalDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (skip) { get_dispatch_table(ot_instance_table_map, physicalDevice) ->GetPhysicalDeviceGeneratedCommandsPropertiesNVX(physicalDevice, pFeatures, pLimits); } } VKAPI_ATTR VkResult VKAPI_CALL GetPastPresentationTimingGOOGLE(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pPresentationTimingCount, VkPastPresentationTimingGOOGLE *pPresentationTimings) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_03181, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, VALIDATION_ERROR_03182, VALIDATION_ERROR_UNDEFINED); } if (!skip) { result = get_dispatch_table(ot_device_table_map, device) ->GetPastPresentationTimingGOOGLE(device, swapchain, pPresentationTimingCount, pPresentationTimings); } return result; } VKAPI_ATTR VkResult VKAPI_CALL GetRefreshCycleDurationGOOGLE(VkDevice device, VkSwapchainKHR swapchain, VkRefreshCycleDurationGOOGLE *pDisplayTimingProperties) { VkResult result = VK_ERROR_VALIDATION_FAILED_EXT; bool skip = false; { std::unique_lock lock(global_lock); skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_03178, VALIDATION_ERROR_UNDEFINED); skip |= ValidateObject(device, swapchain, kVulkanObjectTypeSwapchainKHR, false, VALIDATION_ERROR_03179, VALIDATION_ERROR_UNDEFINED); } if (!skip) { result = get_dispatch_table(ot_device_table_map, device) ->GetRefreshCycleDurationGOOGLE(device, swapchain, pDisplayTimingProperties); } return result; } VKAPI_ATTR void VKAPI_CALL SetHdrMetadataEXT(VkDevice device, uint32_t swapchainCount, const VkSwapchainKHR *pSwapchains, const VkHdrMetadataEXT *pMetadata) { bool skip = false; { std::lock_guard lock(global_lock); if (pSwapchains) { for (uint32_t idx0 = 0; idx0 < swapchainCount; ++idx0) { skip |= ValidateObject(device, pSwapchains[idx0], kVulkanObjectTypeSwapchainKHR, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } } skip |= ValidateObject(device, device, kVulkanObjectTypeDevice, false, VALIDATION_ERROR_UNDEFINED, VALIDATION_ERROR_UNDEFINED); } if (!skip) { get_dispatch_table(ot_device_table_map, device)->SetHdrMetadataEXT(device, swapchainCount, pSwapchains, pMetadata); } } static inline PFN_vkVoidFunction InterceptCoreDeviceCommand(const char *name) { if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; if (!strcmp(name, "GetDeviceProcAddr")) return (PFN_vkVoidFunction)GetDeviceProcAddr; if (!strcmp(name, "DestroyDevice")) return (PFN_vkVoidFunction)DestroyDevice; if (!strcmp(name, "GetDeviceQueue")) return (PFN_vkVoidFunction)GetDeviceQueue; if (!strcmp(name, "QueueSubmit")) return (PFN_vkVoidFunction)QueueSubmit; if (!strcmp(name, "QueueWaitIdle")) return (PFN_vkVoidFunction)QueueWaitIdle; if (!strcmp(name, "DeviceWaitIdle")) return (PFN_vkVoidFunction)DeviceWaitIdle; if (!strcmp(name, "AllocateMemory")) return (PFN_vkVoidFunction)AllocateMemory; if (!strcmp(name, "FreeMemory")) return (PFN_vkVoidFunction)FreeMemory; if (!strcmp(name, "MapMemory")) return (PFN_vkVoidFunction)MapMemory; if (!strcmp(name, "UnmapMemory")) return (PFN_vkVoidFunction)UnmapMemory; if (!strcmp(name, "FlushMappedMemoryRanges")) return (PFN_vkVoidFunction)FlushMappedMemoryRanges; if (!strcmp(name, "InvalidateMappedMemoryRanges")) return (PFN_vkVoidFunction)InvalidateMappedMemoryRanges; if (!strcmp(name, "GetDeviceMemoryCommitment")) return (PFN_vkVoidFunction)GetDeviceMemoryCommitment; if (!strcmp(name, "BindBufferMemory")) return (PFN_vkVoidFunction)BindBufferMemory; if (!strcmp(name, "BindImageMemory")) return (PFN_vkVoidFunction)BindImageMemory; if (!strcmp(name, "GetBufferMemoryRequirements")) return (PFN_vkVoidFunction)GetBufferMemoryRequirements; if (!strcmp(name, "GetImageMemoryRequirements")) return (PFN_vkVoidFunction)GetImageMemoryRequirements; if (!strcmp(name, "GetImageSparseMemoryRequirements")) return (PFN_vkVoidFunction)GetImageSparseMemoryRequirements; if (!strcmp(name, "QueueBindSparse")) return (PFN_vkVoidFunction)QueueBindSparse; if (!strcmp(name, "CreateFence")) return (PFN_vkVoidFunction)CreateFence; if (!strcmp(name, "DestroyFence")) return (PFN_vkVoidFunction)DestroyFence; if (!strcmp(name, "ResetFences")) return (PFN_vkVoidFunction)ResetFences; if (!strcmp(name, "GetFenceStatus")) return (PFN_vkVoidFunction)GetFenceStatus; if (!strcmp(name, "WaitForFences")) return (PFN_vkVoidFunction)WaitForFences; if (!strcmp(name, "CreateSemaphore")) return (PFN_vkVoidFunction)CreateSemaphore; if (!strcmp(name, "DestroySemaphore")) return (PFN_vkVoidFunction)DestroySemaphore; if (!strcmp(name, "CreateEvent")) return (PFN_vkVoidFunction)CreateEvent; if (!strcmp(name, "DestroyEvent")) return (PFN_vkVoidFunction)DestroyEvent; if (!strcmp(name, "GetEventStatus")) return (PFN_vkVoidFunction)GetEventStatus; if (!strcmp(name, "SetEvent")) return (PFN_vkVoidFunction)SetEvent; if (!strcmp(name, "ResetEvent")) return (PFN_vkVoidFunction)ResetEvent; if (!strcmp(name, "CreateQueryPool")) return (PFN_vkVoidFunction)CreateQueryPool; if (!strcmp(name, "DestroyQueryPool")) return (PFN_vkVoidFunction)DestroyQueryPool; if (!strcmp(name, "GetQueryPoolResults")) return (PFN_vkVoidFunction)GetQueryPoolResults; if (!strcmp(name, "CreateBuffer")) return (PFN_vkVoidFunction)CreateBuffer; if (!strcmp(name, "DestroyBuffer")) return (PFN_vkVoidFunction)DestroyBuffer; if (!strcmp(name, "CreateBufferView")) return (PFN_vkVoidFunction)CreateBufferView; if (!strcmp(name, "DestroyBufferView")) return (PFN_vkVoidFunction)DestroyBufferView; if (!strcmp(name, "CreateImage")) return (PFN_vkVoidFunction)CreateImage; if (!strcmp(name, "DestroyImage")) return (PFN_vkVoidFunction)DestroyImage; if (!strcmp(name, "GetImageSubresourceLayout")) return (PFN_vkVoidFunction)GetImageSubresourceLayout; if (!strcmp(name, "CreateImageView")) return (PFN_vkVoidFunction)CreateImageView; if (!strcmp(name, "DestroyImageView")) return (PFN_vkVoidFunction)DestroyImageView; if (!strcmp(name, "CreateShaderModule")) return (PFN_vkVoidFunction)CreateShaderModule; if (!strcmp(name, "DestroyShaderModule")) return (PFN_vkVoidFunction)DestroyShaderModule; if (!strcmp(name, "CreatePipelineCache")) return (PFN_vkVoidFunction)CreatePipelineCache; if (!strcmp(name, "DestroyPipelineCache")) return (PFN_vkVoidFunction)DestroyPipelineCache; if (!strcmp(name, "GetPipelineCacheData")) return (PFN_vkVoidFunction)GetPipelineCacheData; if (!strcmp(name, "MergePipelineCaches")) return (PFN_vkVoidFunction)MergePipelineCaches; if (!strcmp(name, "CreateGraphicsPipelines")) return (PFN_vkVoidFunction)CreateGraphicsPipelines; if (!strcmp(name, "CreateComputePipelines")) return (PFN_vkVoidFunction)CreateComputePipelines; if (!strcmp(name, "DestroyPipeline")) return (PFN_vkVoidFunction)DestroyPipeline; if (!strcmp(name, "CreatePipelineLayout")) return (PFN_vkVoidFunction)CreatePipelineLayout; if (!strcmp(name, "DestroyPipelineLayout")) return (PFN_vkVoidFunction)DestroyPipelineLayout; if (!strcmp(name, "CreateSampler")) return (PFN_vkVoidFunction)CreateSampler; if (!strcmp(name, "DestroySampler")) return (PFN_vkVoidFunction)DestroySampler; if (!strcmp(name, "CreateDescriptorSetLayout")) return (PFN_vkVoidFunction)CreateDescriptorSetLayout; if (!strcmp(name, "DestroyDescriptorSetLayout")) return (PFN_vkVoidFunction)DestroyDescriptorSetLayout; if (!strcmp(name, "CreateDescriptorPool")) return (PFN_vkVoidFunction)CreateDescriptorPool; if (!strcmp(name, "DestroyDescriptorPool")) return (PFN_vkVoidFunction)DestroyDescriptorPool; if (!strcmp(name, "ResetDescriptorPool")) return (PFN_vkVoidFunction)ResetDescriptorPool; if (!strcmp(name, "AllocateDescriptorSets")) return (PFN_vkVoidFunction)AllocateDescriptorSets; if (!strcmp(name, "FreeDescriptorSets")) return (PFN_vkVoidFunction)FreeDescriptorSets; if (!strcmp(name, "UpdateDescriptorSets")) return (PFN_vkVoidFunction)UpdateDescriptorSets; if (!strcmp(name, "CreateFramebuffer")) return (PFN_vkVoidFunction)CreateFramebuffer; if (!strcmp(name, "DestroyFramebuffer")) return (PFN_vkVoidFunction)DestroyFramebuffer; if (!strcmp(name, "CreateRenderPass")) return (PFN_vkVoidFunction)CreateRenderPass; if (!strcmp(name, "DestroyRenderPass")) return (PFN_vkVoidFunction)DestroyRenderPass; if (!strcmp(name, "GetRenderAreaGranularity")) return (PFN_vkVoidFunction)GetRenderAreaGranularity; if (!strcmp(name, "CreateCommandPool")) return (PFN_vkVoidFunction)CreateCommandPool; if (!strcmp(name, "DestroyCommandPool")) return (PFN_vkVoidFunction)DestroyCommandPool; if (!strcmp(name, "ResetCommandPool")) return (PFN_vkVoidFunction)ResetCommandPool; if (!strcmp(name, "AllocateCommandBuffers")) return (PFN_vkVoidFunction)AllocateCommandBuffers; if (!strcmp(name, "FreeCommandBuffers")) return (PFN_vkVoidFunction)FreeCommandBuffers; if (!strcmp(name, "BeginCommandBuffer")) return (PFN_vkVoidFunction)BeginCommandBuffer; if (!strcmp(name, "EndCommandBuffer")) return (PFN_vkVoidFunction)EndCommandBuffer; if (!strcmp(name, "ResetCommandBuffer")) return (PFN_vkVoidFunction)ResetCommandBuffer; if (!strcmp(name, "CmdBindPipeline")) return (PFN_vkVoidFunction)CmdBindPipeline; if (!strcmp(name, "CmdSetViewport")) return (PFN_vkVoidFunction)CmdSetViewport; if (!strcmp(name, "CmdSetScissor")) return (PFN_vkVoidFunction)CmdSetScissor; if (!strcmp(name, "CmdSetLineWidth")) return (PFN_vkVoidFunction)CmdSetLineWidth; if (!strcmp(name, "CmdSetDepthBias")) return (PFN_vkVoidFunction)CmdSetDepthBias; if (!strcmp(name, "CmdSetBlendConstants")) return (PFN_vkVoidFunction)CmdSetBlendConstants; if (!strcmp(name, "CmdSetDepthBounds")) return (PFN_vkVoidFunction)CmdSetDepthBounds; if (!strcmp(name, "CmdSetStencilCompareMask")) return (PFN_vkVoidFunction)CmdSetStencilCompareMask; if (!strcmp(name, "CmdSetStencilWriteMask")) return (PFN_vkVoidFunction)CmdSetStencilWriteMask; if (!strcmp(name, "CmdSetStencilReference")) return (PFN_vkVoidFunction)CmdSetStencilReference; if (!strcmp(name, "CmdBindDescriptorSets")) return (PFN_vkVoidFunction)CmdBindDescriptorSets; if (!strcmp(name, "CmdBindIndexBuffer")) return (PFN_vkVoidFunction)CmdBindIndexBuffer; if (!strcmp(name, "CmdBindVertexBuffers")) return (PFN_vkVoidFunction)CmdBindVertexBuffers; if (!strcmp(name, "CmdDraw")) return (PFN_vkVoidFunction)CmdDraw; if (!strcmp(name, "CmdDrawIndexed")) return (PFN_vkVoidFunction)CmdDrawIndexed; if (!strcmp(name, "CmdDrawIndirect")) return (PFN_vkVoidFunction)CmdDrawIndirect; if (!strcmp(name, "CmdDrawIndexedIndirect")) return (PFN_vkVoidFunction)CmdDrawIndexedIndirect; if (!strcmp(name, "CmdDispatch")) return (PFN_vkVoidFunction)CmdDispatch; if (!strcmp(name, "CmdDispatchIndirect")) return (PFN_vkVoidFunction)CmdDispatchIndirect; if (!strcmp(name, "CmdCopyBuffer")) return (PFN_vkVoidFunction)CmdCopyBuffer; if (!strcmp(name, "CmdCopyImage")) return (PFN_vkVoidFunction)CmdCopyImage; if (!strcmp(name, "CmdBlitImage")) return (PFN_vkVoidFunction)CmdBlitImage; if (!strcmp(name, "CmdCopyBufferToImage")) return (PFN_vkVoidFunction)CmdCopyBufferToImage; if (!strcmp(name, "CmdCopyImageToBuffer")) return (PFN_vkVoidFunction)CmdCopyImageToBuffer; if (!strcmp(name, "CmdUpdateBuffer")) return (PFN_vkVoidFunction)CmdUpdateBuffer; if (!strcmp(name, "CmdFillBuffer")) return (PFN_vkVoidFunction)CmdFillBuffer; if (!strcmp(name, "CmdClearColorImage")) return (PFN_vkVoidFunction)CmdClearColorImage; if (!strcmp(name, "CmdClearDepthStencilImage")) return (PFN_vkVoidFunction)CmdClearDepthStencilImage; if (!strcmp(name, "CmdClearAttachments")) return (PFN_vkVoidFunction)CmdClearAttachments; if (!strcmp(name, "CmdResolveImage")) return (PFN_vkVoidFunction)CmdResolveImage; if (!strcmp(name, "CmdSetEvent")) return (PFN_vkVoidFunction)CmdSetEvent; if (!strcmp(name, "CmdResetEvent")) return (PFN_vkVoidFunction)CmdResetEvent; if (!strcmp(name, "CmdWaitEvents")) return (PFN_vkVoidFunction)CmdWaitEvents; if (!strcmp(name, "CmdPipelineBarrier")) return (PFN_vkVoidFunction)CmdPipelineBarrier; if (!strcmp(name, "CmdBeginQuery")) return (PFN_vkVoidFunction)CmdBeginQuery; if (!strcmp(name, "CmdEndQuery")) return (PFN_vkVoidFunction)CmdEndQuery; if (!strcmp(name, "CmdResetQueryPool")) return (PFN_vkVoidFunction)CmdResetQueryPool; if (!strcmp(name, "CmdWriteTimestamp")) return (PFN_vkVoidFunction)CmdWriteTimestamp; if (!strcmp(name, "CmdCopyQueryPoolResults")) return (PFN_vkVoidFunction)CmdCopyQueryPoolResults; if (!strcmp(name, "CmdPushConstants")) return (PFN_vkVoidFunction)CmdPushConstants; if (!strcmp(name, "CmdBeginRenderPass")) return (PFN_vkVoidFunction)CmdBeginRenderPass; if (!strcmp(name, "CmdNextSubpass")) return (PFN_vkVoidFunction)CmdNextSubpass; if (!strcmp(name, "CmdEndRenderPass")) return (PFN_vkVoidFunction)CmdEndRenderPass; if (!strcmp(name, "CmdExecuteCommands")) return (PFN_vkVoidFunction)CmdExecuteCommands; if (!strcmp(name, "DebugMarkerSetObjectTagEXT")) return (PFN_vkVoidFunction)DebugMarkerSetObjectTagEXT; if (!strcmp(name, "DebugMarkerSetObjectNameEXT")) return (PFN_vkVoidFunction)DebugMarkerSetObjectNameEXT; if (!strcmp(name, "CmdDebugMarkerBeginEXT")) return (PFN_vkVoidFunction)CmdDebugMarkerBeginEXT; if (!strcmp(name, "CmdDebugMarkerEndEXT")) return (PFN_vkVoidFunction)CmdDebugMarkerEndEXT; if (!strcmp(name, "CmdDebugMarkerInsertEXT")) return (PFN_vkVoidFunction)CmdDebugMarkerInsertEXT; #ifdef VK_USE_PLATFORM_WIN32_KHR if (!strcmp(name, "GetMemoryWin32HandleNV")) return (PFN_vkVoidFunction)GetMemoryWin32HandleNV; #endif // VK_USE_PLATFORM_WIN32_KHR if (!strcmp(name, "CmdDrawIndirectCountAMD")) return (PFN_vkVoidFunction)CmdDrawIndirectCountAMD; if (!strcmp(name, "CmdDrawIndexedIndirectCountAMD")) return (PFN_vkVoidFunction)CmdDrawIndexedIndirectCountAMD; if (!strcmp(name, "SetHdrMetadataEXT")) return (PFN_vkVoidFunction)SetHdrMetadataEXT; return NULL; } static inline PFN_vkVoidFunction InterceptCoreInstanceCommand(const char *name) { if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; if (!strcmp(name, "CreateInstance")) return (PFN_vkVoidFunction)CreateInstance; if (!strcmp(name, "DestroyInstance")) return (PFN_vkVoidFunction)DestroyInstance; if (!strcmp(name, "EnumeratePhysicalDevices")) return (PFN_vkVoidFunction)EnumeratePhysicalDevices; if (!strcmp(name, "_layerGetPhysicalDeviceProcAddr")) return (PFN_vkVoidFunction)GetPhysicalDeviceProcAddr; if (!strcmp(name, "GetPhysicalDeviceFeatures")) return (PFN_vkVoidFunction)GetPhysicalDeviceFeatures; if (!strcmp(name, "GetPhysicalDeviceFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties; if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceImageFormatProperties; if (!strcmp(name, "GetPhysicalDeviceProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceProperties; if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceQueueFamilyProperties; if (!strcmp(name, "GetPhysicalDeviceMemoryProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceMemoryProperties; if (!strcmp(name, "GetInstanceProcAddr")) return (PFN_vkVoidFunction)GetInstanceProcAddr; if (!strcmp(name, "CreateDevice")) return (PFN_vkVoidFunction)CreateDevice; if (!strcmp(name, "EnumerateInstanceExtensionProperties")) return (PFN_vkVoidFunction)EnumerateInstanceExtensionProperties; if (!strcmp(name, "EnumerateInstanceLayerProperties")) return (PFN_vkVoidFunction)EnumerateInstanceLayerProperties; if (!strcmp(name, "EnumerateDeviceLayerProperties")) return (PFN_vkVoidFunction)EnumerateDeviceLayerProperties; if (!strcmp(name, "GetPhysicalDeviceSparseImageFormatProperties")) return (PFN_vkVoidFunction)GetPhysicalDeviceSparseImageFormatProperties; if (!strcmp(name, "GetPhysicalDeviceExternalImageFormatPropertiesNV")) return (PFN_vkVoidFunction)GetPhysicalDeviceExternalImageFormatPropertiesNV; return NULL; } static inline PFN_vkVoidFunction InterceptInstanceExtensionCommand(const char *name) { if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; // VK_KHR_get_physical_device_properties2 Extension if (!strcmp(name, "GetPhysicalDeviceFeatures2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceFeatures2KHR; if (!strcmp(name, "GetPhysicalDeviceProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceFormatProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceFormatProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceImageFormatProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceImageFormatProperties2KHR; if (!strcmp(name, "GetPhysicalDeviceQueueFamilyProperties2KHR")) return (PFN_vkVoidFunction)GetPhysicalDeviceQueueFamilyProperties2KHR; // VK_KHX_device_group Extension if (!strcmp(name, "GetPhysicalDevicePresentRectanglesKHX")) return (PFN_vkVoidFunction)GetPhysicalDevicePresentRectanglesKHX; // VK_KHX_device_group_creation Extension if (!strcmp(name, "EnumeratePhysicalDeviceGroupsKHX")) return (PFN_vkVoidFunction)EnumeratePhysicalDeviceGroupsKHX; // VK_KHX_external_memory_capabilities Extension if (!strcmp(name, "GetPhysicalDeviceExternalBufferPropertiesKHX")) return (PFN_vkVoidFunction)GetPhysicalDeviceExternalBufferPropertiesKHX; // VK_KHX_external_semaphore_capabilities Extension if (!strcmp(name, "GetPhysicalDeviceExternalSemaphorePropertiesKHX")) return (PFN_vkVoidFunction)GetPhysicalDeviceExternalSemaphorePropertiesKHX; #ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT // VK_EXT_acquire_xlib_display Extension if (!strcmp(name, "AcquireXlibDisplayEXT")) return (PFN_vkVoidFunction)AcquireXlibDisplayEXT; if (!strcmp(name, "GetRandROutputDisplayEXT")) return (PFN_vkVoidFunction)GetRandROutputDisplayEXT; #endif // VK_USE_PLATFORM_XLIB_XRANDR_EXT // VK_EXT_direct_mode_display Extension if (!strcmp(name, "ReleaseDisplayEXT")) return (PFN_vkVoidFunction)ReleaseDisplayEXT; // VK_EXT_display_surface_counter Extension if (!strcmp(name, "GetPhysicalDeviceSurfaceCapabilities2EXT")) return (PFN_vkVoidFunction)GetPhysicalDeviceSurfaceCapabilities2EXT; // VK_NV_clip_space_w_scaling Extension if (!strcmp(name, "CmdSetViewportWScalingNV")) return (PFN_vkVoidFunction)CmdSetViewportWScalingNV; // VK_NVX_device_generated_commands Extension if (!strcmp(name, "GetPhysicalDeviceGeneratedCommandsPropertiesNVX")) return (PFN_vkVoidFunction)GetPhysicalDeviceGeneratedCommandsPropertiesNVX; return NULL; } static inline PFN_vkVoidFunction InterceptDeviceExtensionCommand(const char *name, VkDevice device) { if (device) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); if (!name || name[0] != 'v' || name[1] != 'k') return NULL; name += 2; if (device_data->enables.khr_descriptor_update_template) { if (!strcmp(name, "CreateDescriptorUpdateTemplateKHR")) return (PFN_vkVoidFunction)CreateDescriptorUpdateTemplateKHR; if (!strcmp(name, "DestroyDescriptorUpdateTemplateKHR")) return (PFN_vkVoidFunction)DestroyDescriptorUpdateTemplateKHR; if (!strcmp(name, "UpdateDescriptorSetWithTemplateKHR")) return (PFN_vkVoidFunction)UpdateDescriptorSetWithTemplateKHR; if (!strcmp(name, "CmdPushDescriptorSetWithTemplateKHR")) return (PFN_vkVoidFunction)CmdPushDescriptorSetWithTemplateKHR; } if (device_data->enables.khr_maintenance1) { if (!strcmp(name, "TrimCommandPoolKHR")) return (PFN_vkVoidFunction)TrimCommandPoolKHR; } if (device_data->enables.khr_push_descriptor) { if (!strcmp(name, "CmdPushDescriptorSetKHR")) return (PFN_vkVoidFunction)CmdPushDescriptorSetKHR; } if (device_data->enables.khx_device_group) { // VK_KHX_device_group Extension if (!strcmp(name, "GetDeviceGroupPeerMemoryFeaturesKHX")) return (PFN_vkVoidFunction)GetDeviceGroupPeerMemoryFeaturesKHX; if (!strcmp(name, "BindBufferMemory2KHX")) return (PFN_vkVoidFunction)BindBufferMemory2KHX; if (!strcmp(name, "BindImageMemory2KHX")) return (PFN_vkVoidFunction)BindImageMemory2KHX; if (!strcmp(name, "CmdSetDeviceMaskKHX")) return (PFN_vkVoidFunction)CmdSetDeviceMaskKHX; if (!strcmp(name, "GetDeviceGroupPresentCapabilitiesKHX")) return (PFN_vkVoidFunction)GetDeviceGroupPresentCapabilitiesKHX; if (!strcmp(name, "GetDeviceGroupSurfacePresentModesKHX")) return (PFN_vkVoidFunction)GetDeviceGroupSurfacePresentModesKHX; if (!strcmp(name, "AcquireNextImage2KHX")) return (PFN_vkVoidFunction)AcquireNextImage2KHX; if (!strcmp(name, "CmdDispatchBaseKHX")) return (PFN_vkVoidFunction)CmdDispatchBaseKHX; } #ifdef VK_USE_PLATFORM_WIN32_KHX if (device_data->enables.khx_external_memory_win32) { if (!strcmp(name, "GetMemoryWin32HandleKHX")) return (PFN_vkVoidFunction)GetMemoryWin32HandleKHX; if (!strcmp(name, "GetMemoryWin32HandlePropertiesKHX")) return (PFN_vkVoidFunction)GetMemoryWin32HandlePropertiesKHX; } #endif // VK_USE_PLATFORM_WIN32_KHX if (device_data->enables.khx_external_memory_fd) { if (!strcmp(name, "GetMemoryFdKHX")) return (PFN_vkVoidFunction)GetMemoryFdKHX; if (!strcmp(name, "GetMemoryFdPropertiesKHX")) return (PFN_vkVoidFunction)GetMemoryFdPropertiesKHX; } #ifdef VK_USE_PLATFORM_WIN32_KHX if (device_data->enables.khx_external_semaphore_win32) { if (!strcmp(name, "ImportSemaphoreWin32HandleKHX")) return (PFN_vkVoidFunction)ImportSemaphoreWin32HandleKHX; if (!strcmp(name, "GetSemaphoreWin32HandleKHX")) return (PFN_vkVoidFunction)GetSemaphoreWin32HandleKHX; } #endif // VK_USE_PLATFORM_WIN32_KHX if (device_data->enables.khx_external_semaphore_fd) { if (!strcmp(name, "ImportSemaphoreFdKHX")) return (PFN_vkVoidFunction)ImportSemaphoreFdKHX; if (!strcmp(name, "GetSemaphoreFdKHX")) return (PFN_vkVoidFunction)GetSemaphoreFdKHX; } if (device_data->enables.ext_discard_rectangles) { if (!strcmp(name, "CmdSetDiscardRectangleEXT")) return (PFN_vkVoidFunction)CmdSetDiscardRectangleEXT; } if (device_data->enables.ext_display_control) { if (!strcmp(name, "DisplayPowerControlEXT")) return (PFN_vkVoidFunction)DisplayPowerControlEXT; if (!strcmp(name, "RegisterDeviceEventEXT")) return (PFN_vkVoidFunction)RegisterDeviceEventEXT; if (!strcmp(name, "RegisterDisplayEventEXT")) return (PFN_vkVoidFunction)RegisterDisplayEventEXT; if (!strcmp(name, "GetSwapchainCounterEXT")) return (PFN_vkVoidFunction)GetSwapchainCounterEXT; } if (device_data->enables.nvx_device_generated_commands) { if (!strcmp(name, "CmdProcessCommandsNVX")) return (PFN_vkVoidFunction)CmdProcessCommandsNVX; if (!strcmp(name, "CmdReserveSpaceForCommandsNVX")) return (PFN_vkVoidFunction)CmdReserveSpaceForCommandsNVX; if (!strcmp(name, "CreateIndirectCommandsLayoutNVX")) return (PFN_vkVoidFunction)CreateIndirectCommandsLayoutNVX; if (!strcmp(name, "DestroyIndirectCommandsLayoutNVX")) return (PFN_vkVoidFunction)DestroyIndirectCommandsLayoutNVX; if (!strcmp(name, "CreateObjectTableNVX")) return (PFN_vkVoidFunction)CreateObjectTableNVX; if (!strcmp(name, "DestroyObjectTableNVX")) return (PFN_vkVoidFunction)DestroyObjectTableNVX; if (!strcmp(name, "RegisterObjectsNVX")) return (PFN_vkVoidFunction)RegisterObjectsNVX; if (!strcmp(name, "UnregisterObjectsNVX")) return (PFN_vkVoidFunction)UnregisterObjectsNVX; } if (device_data->enables.google_display_timing) { if (!strcmp(name, "GetPastPresentationTimingGOOGLE")) return (PFN_vkVoidFunction)GetPastPresentationTimingGOOGLE; if (!strcmp(name, "GetRefreshCycleDurationGOOGLE")) return (PFN_vkVoidFunction)GetRefreshCycleDurationGOOGLE; } } return NULL; } static inline PFN_vkVoidFunction InterceptWsiEnabledCommand(const char *name, VkDevice device) { if (device) { layer_data *device_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map); if (device_data->enables.wsi) { if (!strcmp("vkCreateSwapchainKHR", name)) return reinterpret_cast(CreateSwapchainKHR); if (!strcmp("vkDestroySwapchainKHR", name)) return reinterpret_cast(DestroySwapchainKHR); if (!strcmp("vkGetSwapchainImagesKHR", name)) return reinterpret_cast(GetSwapchainImagesKHR); if (!strcmp("vkAcquireNextImageKHR", name)) return reinterpret_cast(AcquireNextImageKHR); if (!strcmp("vkQueuePresentKHR", name)) return reinterpret_cast(QueuePresentKHR); } if (device_data->enables.wsi_display_swapchain) { if (!strcmp("vkCreateSharedSwapchainsKHR", name)) { return reinterpret_cast(CreateSharedSwapchainsKHR); } } if (device_data->enables.wsi_display_extension) { if (!strcmp("vkGetPhysicalDeviceDisplayPropertiesKHR", name)) return reinterpret_cast(GetPhysicalDeviceDisplayPropertiesKHR); if (!strcmp("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", name)) return reinterpret_cast(GetPhysicalDeviceDisplayPlanePropertiesKHR); if (!strcmp("vkGetDisplayPlaneSupportedDisplaysKHR", name)) return reinterpret_cast(GetDisplayPlaneSupportedDisplaysKHR); if (!strcmp("vkGetDisplayModePropertiesKHR", name)) return reinterpret_cast(GetDisplayModePropertiesKHR); if (!strcmp("vkCreateDisplayModeKHR", name)) return reinterpret_cast(CreateDisplayModeKHR); if (!strcmp("vkGetDisplayPlaneCapabilitiesKHR", name)) return reinterpret_cast(GetDisplayPlaneCapabilitiesKHR); if (!strcmp("vkCreateDisplayPlaneSurfaceKHR", name)) return reinterpret_cast(CreateDisplayPlaneSurfaceKHR); } } return nullptr; } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetDeviceProcAddr(VkDevice device, const char *funcName) { PFN_vkVoidFunction addr; addr = InterceptCoreDeviceCommand(funcName); if (addr) { return addr; } assert(device); addr = InterceptWsiEnabledCommand(funcName, device); if (addr) { return addr; } addr = InterceptDeviceExtensionCommand(funcName, device); if (addr) { return addr; } if (get_dispatch_table(ot_device_table_map, device)->GetDeviceProcAddr == NULL) { return NULL; } return get_dispatch_table(ot_device_table_map, device)->GetDeviceProcAddr(device, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetInstanceProcAddr(VkInstance instance, const char *funcName) { PFN_vkVoidFunction addr; addr = InterceptCoreInstanceCommand(funcName); if (!addr) { addr = InterceptCoreDeviceCommand(funcName); } if (!addr) { addr = InterceptWsiEnabledCommand(funcName, VkDevice(VK_NULL_HANDLE)); } if (addr) { return addr; } assert(instance); addr = InterceptMsgCallbackGetProcAddrCommand(funcName, instance); if (addr) { return addr; } addr = InterceptWsiEnabledCommand(funcName, instance); if (addr) { return addr; } addr = InterceptInstanceExtensionCommand(funcName); if (addr) { return addr; } if (get_dispatch_table(ot_instance_table_map, instance)->GetInstanceProcAddr == NULL) { return NULL; } return get_dispatch_table(ot_instance_table_map, instance)->GetInstanceProcAddr(instance, funcName); } VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL GetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { assert(instance); if (get_dispatch_table(ot_instance_table_map, instance)->GetPhysicalDeviceProcAddr == NULL) { return NULL; } return get_dispatch_table(ot_instance_table_map, instance)->GetPhysicalDeviceProcAddr(instance, funcName); } } // namespace object_tracker // vk_layer_logging.h expects these to be defined VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pMsgCallback) { return object_tracker::CreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pMsgCallback); } VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT msgCallback, const VkAllocationCallbacks *pAllocator) { object_tracker::DestroyDebugReportCallbackEXT(instance, msgCallback, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t object, size_t location, int32_t msgCode, const char *pLayerPrefix, const char *pMsg) { object_tracker::DebugReportMessageEXT(instance, flags, objType, object, location, msgCode, pLayerPrefix, pMsg); } // Loader-layer interface v0, just wrappers since there is only a layer VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { return object_tracker::EnumerateInstanceExtensionProperties(pLayerName, pCount, pProperties); } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pCount, VkLayerProperties *pProperties) { return object_tracker::EnumerateInstanceLayerProperties(pCount, pProperties); } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pCount, VkLayerProperties *pProperties) { // The layer command handles VK_NULL_HANDLE just fine internally assert(physicalDevice == VK_NULL_HANDLE); return object_tracker::EnumerateDeviceLayerProperties(VK_NULL_HANDLE, pCount, pProperties); } VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice dev, const char *funcName) { return object_tracker::GetDeviceProcAddr(dev, funcName); } VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *funcName) { return object_tracker::GetInstanceProcAddr(instance, funcName); } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pCount, VkExtensionProperties *pProperties) { // The layer command handles VK_NULL_HANDLE just fine internally assert(physicalDevice == VK_NULL_HANDLE); return object_tracker::EnumerateDeviceExtensionProperties(VK_NULL_HANDLE, pLayerName, pCount, pProperties); } VK_LAYER_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_layerGetPhysicalDeviceProcAddr(VkInstance instance, const char *funcName) { return object_tracker::GetPhysicalDeviceProcAddr(instance, funcName); } VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) { assert(pVersionStruct != NULL); assert(pVersionStruct->sType == LAYER_NEGOTIATE_INTERFACE_STRUCT); // Fill in the function pointers if our version is at least capable of having the structure contain them. if (pVersionStruct->loaderLayerInterfaceVersion >= 2) { pVersionStruct->pfnGetInstanceProcAddr = vkGetInstanceProcAddr; pVersionStruct->pfnGetDeviceProcAddr = vkGetDeviceProcAddr; pVersionStruct->pfnGetPhysicalDeviceProcAddr = vk_layerGetPhysicalDeviceProcAddr; } if (pVersionStruct->loaderLayerInterfaceVersion < CURRENT_LOADER_LAYER_INTERFACE_VERSION) { object_tracker::loader_layer_if_version = pVersionStruct->loaderLayerInterfaceVersion; } else if (pVersionStruct->loaderLayerInterfaceVersion > CURRENT_LOADER_LAYER_INTERFACE_VERSION) { pVersionStruct->loaderLayerInterfaceVersion = CURRENT_LOADER_LAYER_INTERFACE_VERSION; } return VK_SUCCESS; }