From 1d1e1e781b06aad34d616e13ccb47485f3c0db14 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Thu, 3 Aug 2023 14:16:22 +0100 Subject: [PATCH] Vulkan: Retry instance creation if validation layer is not present (#909) --- src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 953862846..cfe7d3f49 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -350,7 +350,15 @@ VulkanRenderer::VulkanRenderer() create_info.ppEnabledLayerNames = m_layerNames.data(); create_info.enabledLayerCount = m_layerNames.size(); - if ((err = vkCreateInstance(&create_info, nullptr, &m_instance)) != VK_SUCCESS) + err = vkCreateInstance(&create_info, nullptr, &m_instance); + + if (err == VK_ERROR_LAYER_NOT_PRESENT) { + cemuLog_log(LogType::Force, "Failed to enable vulkan validation (VK_LAYER_KHRONOS_validation)"); + create_info.enabledLayerCount = 0; + err = vkCreateInstance(&create_info, nullptr, &m_instance); + } + + if (err != VK_SUCCESS) throw std::runtime_error(fmt::format("Unable to create a Vulkan instance: {}", err)); if (!InitializeInstanceVulkan(m_instance))