From 1f5ca837de0dcf7b3847e5fd90b99c9308034108 Mon Sep 17 00:00:00 2001 From: Pablo Escobar Date: Fri, 27 Mar 2020 03:45:32 +0100 Subject: [PATCH] Vulkan: fall back to deprecated validation layers if necessary --- src/renderer_vk.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 2e6754cda..ca5d2ba26 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -1250,12 +1250,18 @@ VK_IMPORT { #if BGFX_CONFIG_DEBUG "VK_LAYER_KHRONOS_validation", -// "VK_LAYER_LUNARG_vktrace", -// "VK_LAYER_RENDERDOC_Capture", #endif // BGFX_CONFIG_DEBUG /*not used*/ "" }; + const char* fallbackLayerNames[] = + { +#if BGFX_CONFIG_DEBUG + "VK_LAYER_LUNARG_standard_validation", // deprecated +#endif // BGFX_CONFIG_DEBUG + "" + }; + uint32_t numEnabledExtensions = 2; const char* enabledExtension[Extension::Count + 2] = @@ -1297,6 +1303,17 @@ VK_IMPORT , m_allocatorCb , &m_instance ); + + if (result == VK_ERROR_LAYER_NOT_PRESENT) + { + ici.enabledLayerCount = BX_COUNTOF(fallbackLayerNames) - 1; + ici.ppEnabledLayerNames = fallbackLayerNames; + + result = vkCreateInstance(&ici + , m_allocatorCb + , &m_instance + ); + } } if (VK_SUCCESS != result)