2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2011 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2011-01-31 01:28:32 +00:00
|
|
|
|
|
|
|
// TODO: ugly
|
|
|
|
#ifdef _WIN32
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/D3D/VideoBackend.h"
|
2011-01-31 01:28:32 +00:00
|
|
|
#endif
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/OGL/VideoBackend.h"
|
|
|
|
#include "VideoBackends/Software/VideoBackend.h"
|
2011-03-16 22:48:17 +00:00
|
|
|
|
2014-02-19 01:27:20 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
std::vector<VideoBackendBase*> g_available_video_backends;
|
|
|
|
VideoBackendBase* g_video_backend = nullptr;
|
|
|
|
static VideoBackendBase* s_default_backend = nullptr;
|
2011-01-31 01:28:32 +00:00
|
|
|
|
2011-03-19 12:58:55 +00:00
|
|
|
#ifdef _WIN32
|
2013-08-11 14:30:19 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2014-10-04 19:12:15 +00:00
|
|
|
// Nvidia drivers >= v302 will check if the application exports a global
|
|
|
|
// variable named NvOptimusEnablement to know if it should run the app in high
|
|
|
|
// performance graphics mode or using the IGP.
|
|
|
|
extern "C" {
|
|
|
|
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
|
|
|
|
}
|
2011-03-19 12:58:55 +00:00
|
|
|
#endif
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
void VideoBackendBase::PopulateList()
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
2016-01-12 08:35:24 +00:00
|
|
|
VideoBackendBase* backends[4] = { nullptr };
|
2013-03-20 23:17:43 +00:00
|
|
|
|
2014-01-14 20:57:32 +00:00
|
|
|
// OGL > D3D11 > SW
|
|
|
|
g_available_video_backends.push_back(backends[0] = new OGL::VideoBackend);
|
2011-01-31 01:28:32 +00:00
|
|
|
#ifdef _WIN32
|
2015-09-18 19:10:44 +00:00
|
|
|
g_available_video_backends.push_back(backends[1] = new DX11::VideoBackend);
|
2012-12-17 20:54:20 +00:00
|
|
|
#endif
|
2013-03-20 23:17:43 +00:00
|
|
|
g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware);
|
2011-02-08 14:51:53 +00:00
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
for (VideoBackendBase* backend : backends)
|
2013-03-20 23:17:43 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
if (backend)
|
2013-03-20 23:17:43 +00:00
|
|
|
{
|
2013-10-29 05:09:01 +00:00
|
|
|
s_default_backend = g_video_backend = backend;
|
2013-03-20 23:17:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-31 01:28:32 +00:00
|
|
|
}
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
void VideoBackendBase::ClearList()
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
|
|
|
while (!g_available_video_backends.empty())
|
|
|
|
{
|
|
|
|
delete g_available_video_backends.back();
|
|
|
|
g_available_video_backends.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
void VideoBackendBase::ActivateBackend(const std::string& name)
|
2011-01-31 01:28:32 +00:00
|
|
|
{
|
2014-03-09 20:14:26 +00:00
|
|
|
if (name.length() == 0) // If nullptr, set it to the default backend (expected behavior)
|
2013-03-20 23:17:43 +00:00
|
|
|
g_video_backend = s_default_backend;
|
2012-09-25 00:47:37 +00:00
|
|
|
|
2016-01-12 08:35:24 +00:00
|
|
|
for (VideoBackendBase* backend : g_available_video_backends)
|
2014-02-12 15:00:34 +00:00
|
|
|
if (name == backend->GetName())
|
|
|
|
g_video_backend = backend;
|
2011-01-31 01:28:32 +00:00
|
|
|
}
|