From 2db86874983548c5ecda41c79d9fda27b66d2d17 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 12 Oct 2016 08:55:03 +1300 Subject: [PATCH] layers: Track surface support for gpu+queue Signed-off-by: Chris Forbes --- layers/core_validation.cpp | 20 ++++++++++++++++++++ layers/core_validation.h | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 696120a..2597382 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -12109,6 +12109,24 @@ VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysica return result; } + +VKAPI_ATTR VkResult VKAPI_CALL GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, + VkSurfaceKHR surface, VkBool32 *pSupported) { + auto instance_data = get_my_data_ptr(get_dispatch_key(physicalDevice), instance_layer_data_map); + std::unique_lock lock(global_lock); + auto surface_state = getSurfaceState(instance_data, surface); + lock.unlock(); + + auto result = instance_data->dispatch_table.GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, + pSupported); + + if (result == VK_SUCCESS) { + surface_state->gpu_queue_support[{physicalDevice, queueFamilyIndex}] = *pSupported; + } + + return result; +} + VKAPI_ATTR VkResult VKAPI_CALL CreateDebugReportCallbackEXT(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugReportCallbackEXT *pMsgCallback) { @@ -12452,6 +12470,8 @@ intercept_khr_surface_command(const char *name, VkInstance instance) { &instance_layer_data::surfaceExtensionEnabled}, {"vkGetPhysicalDeviceSurfaceCapabilitiesKHR", reinterpret_cast(GetPhysicalDeviceSurfaceCapabilitiesKHR), &instance_layer_data::surfaceExtensionEnabled}, + {"vkGetPhysicalDeviceSurfaceSupportKHR", reinterpret_cast(GetPhysicalDeviceSurfaceSupportKHR), + &instance_layer_data::surfaceExtensionEnabled}, }; instance_layer_data *instance_data = nullptr; diff --git a/layers/core_validation.h b/layers/core_validation.h index 58383ea..ac43138 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -223,10 +223,28 @@ struct PHYSICAL_DEVICE_STATE { VkSurfaceCapabilitiesKHR surfaceCapabilities = {}; }; +struct GpuQueue { + VkPhysicalDevice gpu; + uint32_t queue_family_index; +}; + +inline bool operator==(GpuQueue const & lhs, GpuQueue const & rhs) { + return (lhs.gpu == rhs.gpu && lhs.queue_family_index == rhs.queue_family_index); +} + +namespace std { +template <> struct hash { + size_t operator()(GpuQueue gq) const throw() { + return hash()((uint64_t)(gq.gpu)) ^ hash()(gq.queue_family_index); + } +}; +} + struct SURFACE_STATE { VkSurfaceKHR surface = VK_NULL_HANDLE; SWAPCHAIN_NODE *swapchain = nullptr; SWAPCHAIN_NODE *old_swapchain = nullptr; + std::unordered_map gpu_queue_support; SURFACE_STATE() {} SURFACE_STATE(VkSurfaceKHR surface) -- 2.7.4