瀏覽代碼

Vulkan: fall back to deprecated validation layers if necessary

Pablo Escobar 5 年之前
父節點
當前提交
1f5ca837de
共有 1 個文件被更改,包括 19 次插入2 次删除
  1. 19 2
      src/renderer_vk.cpp

+ 19 - 2
src/renderer_vk.cpp

@@ -1250,12 +1250,18 @@ VK_IMPORT
 				{
 				{
 #if BGFX_CONFIG_DEBUG
 #if BGFX_CONFIG_DEBUG
 					"VK_LAYER_KHRONOS_validation",
 					"VK_LAYER_KHRONOS_validation",
-//					"VK_LAYER_LUNARG_vktrace",
-//					"VK_LAYER_RENDERDOC_Capture",
 #endif // BGFX_CONFIG_DEBUG
 #endif // BGFX_CONFIG_DEBUG
 					/*not used*/ ""
 					/*not used*/ ""
 				};
 				};
 
 
+				const char* fallbackLayerNames[] =
+				{
+#if BGFX_CONFIG_DEBUG
+					"VK_LAYER_LUNARG_standard_validation", // deprecated
+#endif // BGFX_CONFIG_DEBUG
+					""
+				};
+
 				uint32_t numEnabledExtensions = 2;
 				uint32_t numEnabledExtensions = 2;
 
 
 				const char* enabledExtension[Extension::Count + 2] =
 				const char* enabledExtension[Extension::Count + 2] =
@@ -1297,6 +1303,17 @@ VK_IMPORT
 						, m_allocatorCb
 						, m_allocatorCb
 						, &m_instance
 						, &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)
 			if (VK_SUCCESS != result)