Vulkan: Support running surfaceless

This commit is contained in:
Connor McLaughlin 2022-10-22 21:16:12 +10:00 committed by refractionpcsx2
parent bf2575c3c9
commit 61de98d651
3 changed files with 14 additions and 12 deletions

View File

@ -536,7 +536,7 @@ namespace Vulkan
Console.Error("Vulkan: Failed to find an acceptable graphics queue.");
return false;
}
if (surface && m_present_queue_family_index == queue_family_count)
if (surface != VK_NULL_HANDLE && m_present_queue_family_index == queue_family_count)
{
Console.Error("Vulkan: Failed to find an acceptable present queue.");
return false;
@ -570,7 +570,7 @@ namespace Vulkan
}};
device_info.queueCreateInfoCount = 1;
if (m_graphics_queue_family_index != m_present_queue_family_index)
if (surface != VK_NULL_HANDLE && m_graphics_queue_family_index != m_present_queue_family_index)
{
device_info.queueCreateInfoCount = 2;
}
@ -1445,8 +1445,7 @@ namespace Vulkan
}
const VkSubpassDescriptionFlags subpass_flags =
(key.color_feedback_loop && g_vulkan_context->GetOptionalExtensions().vk_arm_rasterization_order_attachment_access)
? VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM : 0;
(key.color_feedback_loop && g_vulkan_context->GetOptionalExtensions().vk_arm_rasterization_order_attachment_access) ? VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM : 0;
const VkSubpassDescription subpass = {subpass_flags, VK_PIPELINE_BIND_POINT_GRAPHICS, input_reference_ptr ? 1u : 0u,
input_reference_ptr ? input_reference_ptr : nullptr, color_reference_ptr ? 1u : 0u,
color_reference_ptr ? color_reference_ptr : nullptr, nullptr, depth_reference_ptr, 0, nullptr};

View File

@ -311,7 +311,12 @@ bool VulkanHostDisplay::HasSurface() const
bool VulkanHostDisplay::CreateImGuiContext()
{
return ImGui_ImplVulkan_Init(m_swap_chain->GetClearRenderPass());
const VkRenderPass render_pass =
m_swap_chain ? m_swap_chain->GetClearRenderPass() : g_vulkan_context->GetRenderPass(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_UNDEFINED);
if (render_pass == VK_NULL_HANDLE)
return false;
return ImGui_ImplVulkan_Init(render_pass);
}
void VulkanHostDisplay::DestroyImGuiContext()

View File

@ -1513,13 +1513,11 @@ bool GSDeviceVK::CompilePresentPipelines()
{
// we may not have a swap chain if running in headless mode.
Vulkan::SwapChain* swapchain = static_cast<Vulkan::SwapChain*>(g_host_display->GetSurface());
if (swapchain)
{
m_swap_chain_render_pass =
g_vulkan_context->GetRenderPass(swapchain->GetSurfaceFormat().format, VK_FORMAT_UNDEFINED);
if (!m_swap_chain_render_pass)
return false;
}
m_swap_chain_render_pass = swapchain ?
swapchain->GetClearRenderPass() :
g_vulkan_context->GetRenderPass(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_UNDEFINED);
if (!m_swap_chain_render_pass)
return false;
std::optional<std::string> shader = Host::ReadResourceFileToString("shaders/vulkan/present.glsl");
if (!shader)