From 607cb8dbb7f158cdd00c790d1950153d77984d31 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 23 Jul 2021 18:33:52 +1000 Subject: [PATCH] VulkanHostDisplay: Don't crash when headless --- src/frontend-common/vulkan_host_display.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 6f1f8e37e..ca5032092 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -355,7 +355,16 @@ bool VulkanHostDisplay::HasRenderSurface() const VkRenderPass VulkanHostDisplay::GetRenderPassForDisplay() const { - return m_swap_chain->GetClearRenderPass(); + if (m_swap_chain) + { + return m_swap_chain->GetClearRenderPass(); + } + else + { + // If we're running headless, assume RGBA8. + return g_vulkan_context->GetRenderPass(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_UNDEFINED, VK_SAMPLE_COUNT_1_BIT, + VK_ATTACHMENT_LOAD_OP_CLEAR); + } } bool VulkanHostDisplay::CreateResources()