Host: Move CreateDisplayForAPI() into common code

This commit is contained in:
Connor McLaughlin
2022-08-24 19:12:09 +10:00
parent 4f2da4213d
commit 7277d29ff9
3 changed files with 53 additions and 47 deletions

View File

@ -52,11 +52,21 @@
#ifdef _WIN32
#include "common/windows_headers.h"
#include "frontend-common/d3d11_host_display.h"
#include "frontend-common/d3d12_host_display.h"
#include <KnownFolders.h>
#include <ShlObj.h>
#include <mmsystem.h>
#endif
#ifdef WITH_OPENGL
#include "frontend-common/opengl_host_display.h"
#endif
#ifdef WITH_VULKAN
#include "frontend-common/vulkan_host_display.h"
#endif
Log_SetChannel(CommonHostInterface);
namespace CommonHost {
@ -121,6 +131,44 @@ void CommonHost::PumpMessagesOnCPUThread()
#endif
}
std::unique_ptr<HostDisplay> Host::CreateDisplayForAPI(HostDisplay::RenderAPI api)
{
switch (api)
{
#ifdef WITH_VULKAN
case HostDisplay::RenderAPI::Vulkan:
return std::make_unique<FrontendCommon::VulkanHostDisplay>();
#endif
#ifdef WITH_OPENGL
case HostDisplay::RenderAPI::OpenGL:
case HostDisplay::RenderAPI::OpenGLES:
return std::make_unique<FrontendCommon::OpenGLHostDisplay>();
#endif
#ifdef _WIN32
case HostDisplay::RenderAPI::D3D12:
return std::make_unique<FrontendCommon::D3D12HostDisplay>();
case HostDisplay::RenderAPI::D3D11:
return std::make_unique<FrontendCommon::D3D11HostDisplay>();
#endif
default:
#if defined(_WIN32) && defined(_M_ARM64)
return std::make_unique<FrontendCommon::D3D12HostDisplay>();
#elif defined(_WIN32)
return std::make_unique<FrontendCommon::D3D11HostDisplay>();
#elif defined(WITH_OPENGL)
return std::make_unique<FrontendCommon::OpenGLHostDisplay>();
#elif defined(WITH_VULKAN)
return std::make_unique<FrontendCommon::VulkanHostDisplay>();
#else
return {};
#endif
}
}
bool CommonHost::CreateHostDisplayResources()
{
return true;