From a5be5a3a765207b55b16661cc182e5c5bbbf55de Mon Sep 17 00:00:00 2001 From: spxtr Date: Mon, 4 Sep 2017 14:35:53 -0700 Subject: Vulkan: Use a separate queue for presenting. Before this change, we simply fail if the device does not expose one queue family that supports both graphics and present. Currently this is fine, since devices tend to lay out their queues in this way. NV, for instance, tends to have one queue family for all graphics operations and one more for transfer only. However, it's not a hard requirement, and it is cheap to use a separate queue, so we might as well. --- Source/Core/VideoBackends/Vulkan/SwapChain.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/Vulkan/SwapChain.cpp') diff --git a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp index 21009510bb..c5b3791637 100644 --- a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp +++ b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp @@ -327,7 +327,6 @@ bool SwapChain::CreateSwapChain() VkSwapchainKHR old_swap_chain = m_swap_chain; // Now we can actually create the swap chain - // TODO: Handle case where the present queue is not the graphics queue. VkSwapchainCreateInfoKHR swap_chain_info = {VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, nullptr, 0, @@ -346,6 +345,17 @@ bool SwapChain::CreateSwapChain() m_present_mode, VK_TRUE, old_swap_chain}; + std::array indices = {{ + g_vulkan_context->GetGraphicsQueueFamilyIndex(), + g_vulkan_context->GetPresentQueueFamilyIndex(), + }}; + if (g_vulkan_context->GetGraphicsQueueFamilyIndex() != + g_vulkan_context->GetPresentQueueFamilyIndex()) + { + swap_chain_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; + swap_chain_info.queueFamilyIndexCount = 2; + swap_chain_info.pQueueFamilyIndices = indices.data(); + } res = vkCreateSwapchainKHR(g_vulkan_context->GetDevice(), &swap_chain_info, nullptr, &m_swap_chain); -- cgit v1.2.3