Try Vulkan first on Windows

This commit is contained in:
Luke Street 2021-01-23 21:12:20 -05:00
parent 6faff77f86
commit 74aaa605f3
1 changed files with 27 additions and 27 deletions

View File

@ -126,7 +126,7 @@ public:
bool noD3d = false;
#if BOO_HAS_VULKAN
bool useVulkan = false;
bool useVulkan = true;
#endif
if (!gfxApi.empty()) {
#if BOO_HAS_VULKAN
@ -165,6 +165,32 @@ public:
#endif
}
#if BOO_HAS_VULKAN
if (useVulkan) {
HMODULE vulkanLib = LoadLibraryW(L"vulkan-1.dll");
if (vulkanLib) {
m_getVkProc = (PFN_vkGetInstanceProcAddr)GetProcAddress(vulkanLib, "vkGetInstanceProcAddr");
if (m_getVkProc) {
/* Check device support for vulkan */
if (g_VulkanContext.m_instance == VK_NULL_HANDLE) {
auto appName = getUniqueName();
if (g_VulkanContext.initVulkan(WCSTMBS(appName.data()).c_str(), m_getVkProc)) {
if (g_VulkanContext.enumerateDevices()) {
/* Obtain DXGI Factory */
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory1), &m_3dCtx.m_vulkanDxFactory);
if (FAILED(hr))
Log.report(logvisor::Fatal, FMT_STRING("unable to create DXGI factory"));
Log.report(logvisor::Info, FMT_STRING("initialized Vulkan renderer"));
return;
}
}
}
}
}
}
#endif
HMODULE d3d11lib = nullptr;
if (!noD3d)
d3d11lib = LoadLibraryW(L"D3D11.dll");
@ -241,32 +267,6 @@ public:
return;
}
#if BOO_HAS_VULKAN
if (useVulkan) {
HMODULE vulkanLib = LoadLibraryW(L"vulkan-1.dll");
if (vulkanLib) {
m_getVkProc = (PFN_vkGetInstanceProcAddr)GetProcAddress(vulkanLib, "vkGetInstanceProcAddr");
if (m_getVkProc) {
/* Check device support for vulkan */
if (g_VulkanContext.m_instance == VK_NULL_HANDLE) {
auto appName = getUniqueName();
if (g_VulkanContext.initVulkan(WCSTMBS(appName.data()).c_str(), m_getVkProc)) {
if (g_VulkanContext.enumerateDevices()) {
/* Obtain DXGI Factory */
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory1), &m_3dCtx.m_vulkanDxFactory);
if (FAILED(hr))
Log.report(logvisor::Fatal, FMT_STRING("unable to create DXGI factory"));
Log.report(logvisor::Info, FMT_STRING("initialized Vulkan renderer"));
return;
}
}
}
}
}
}
#endif
#if BOO_HAS_GL
/* Finally try OpenGL */
{