mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
GPUDevice: Memoize preferred renderer for auto
This commit is contained in:
parent
713d396a7e
commit
b8127facdc
|
@ -216,25 +216,32 @@ GPUDevice::~GPUDevice() = default;
|
||||||
|
|
||||||
RenderAPI GPUDevice::GetPreferredAPI()
|
RenderAPI GPUDevice::GetPreferredAPI()
|
||||||
{
|
{
|
||||||
|
static RenderAPI preferred_renderer = RenderAPI::None;
|
||||||
|
if (preferred_renderer == RenderAPI::None) [[unlikely]]
|
||||||
|
{
|
||||||
#if defined(_WIN32) && !defined(_M_ARM64)
|
#if defined(_WIN32) && !defined(_M_ARM64)
|
||||||
// Perfer DX11 on Windows, except ARM64, where QCom has slow DX11 drivers.
|
// Perfer DX11 on Windows, except ARM64, where QCom has slow DX11 drivers.
|
||||||
return RenderAPI::D3D11;
|
preferred_renderer = RenderAPI::D3D11;
|
||||||
#elif defined(_WIN32) && defined(_M_ARM64)
|
#elif defined(_WIN32) && defined(_M_ARM64)
|
||||||
return RenderAPI::D3D12;
|
preferred_renderer = RenderAPI::D3D12;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
// Prefer Metal on MacOS.
|
// Prefer Metal on MacOS.
|
||||||
return RenderAPI::Metal;
|
preferred_renderer = RenderAPI::Metal;
|
||||||
#elif defined(ENABLE_OPENGL) && defined(ENABLE_VULKAN)
|
#elif defined(ENABLE_OPENGL) && defined(ENABLE_VULKAN)
|
||||||
// On Linux, if we have both GL and Vulkan, prefer VK if the driver isn't software.
|
// On Linux, if we have both GL and Vulkan, prefer VK if the driver isn't software.
|
||||||
return VulkanDevice::IsSuitableDefaultRenderer() ? RenderAPI::Vulkan : RenderAPI::OpenGL;
|
preferred_renderer = VulkanDevice::IsSuitableDefaultRenderer() ? RenderAPI::Vulkan : RenderAPI::OpenGL;
|
||||||
#elif defined(ENABLE_OPENGL)
|
#elif defined(ENABLE_OPENGL)
|
||||||
return RenderAPI::OpenGL;
|
preferred_renderer = RenderAPI::OpenGL;
|
||||||
#elif defined(ENABLE_VULKAN)
|
#elif defined(ENABLE_VULKAN)
|
||||||
return RenderAPI::Vulkan;
|
preferred_renderer = RenderAPI::Vulkan;
|
||||||
#else
|
#else
|
||||||
// Uhhh, what?
|
// Uhhh, what?
|
||||||
return RenderAPI::None;
|
Log_ErrorPrint("Somehow don't have any renderers available...");
|
||||||
|
preferred_renderer = RenderAPI::None;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return preferred_renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GPUDevice::RenderAPIToString(RenderAPI api)
|
const char* GPUDevice::RenderAPIToString(RenderAPI api)
|
||||||
|
|
Loading…
Reference in a new issue