Merge remote-tracking branch 'upstream/master' into merge-upstream

# Conflicts:
#	CMakeLists.txt
#	CMakeSettings.json
#	Data/Sys/GameSettings/GLR.ini
#	Data/Sys/GameSettings/HA9.ini
#	Data/Sys/GameSettings/MB3.ini
#	Data/Sys/GameSettings/MBA.ini
#	Data/Sys/GameSettings/MCV.ini
#	Data/Sys/GameSettings/MCY.ini
#	Data/Sys/GameSettings/NAK.ini
#	Data/Sys/GameSettings/NAL.ini
#	Data/Sys/GameSettings/NAT.ini
#	Data/Sys/GameSettings/R8P.ini
#	Data/Sys/GameSettings/R9I.ini
#	Data/Sys/GameSettings/REF.ini
#	Data/Sys/GameSettings/RES.ini
#	Data/Sys/GameSettings/RMHE08.ini
#	Data/Sys/GameSettings/RMHP08.ini
#	Data/Sys/GameSettings/SE2.ini
#	Data/Sys/GameSettings/WW2.ini
#	Data/Sys/GameSettings/WW3.ini
#	Data/Sys/GameSettings/WWI.ini
#	Externals/Bochs_disasm/Bochs_disasm.vcxproj
#	Externals/FreeSurround/FreeSurround.vcxproj
#	Externals/LZO/LZO.vcxproj
#	Externals/SFML/build/vc2010/SFML_Network.vcxproj
#	Externals/bzip2/bzip2.vcxproj
#	Externals/cpp-optparse/cpp-optparse.vcxproj
#	Externals/cubeb/msvc/cubeb.vcxproj
#	Externals/curl/curl.vcxproj
#	Externals/curl/lib/CMakeLists.txt
#	Externals/discord-rpc/src/discord-rpc.vcxproj
#	Externals/ed25519/ed25519.vcxproj
#	Externals/enet/enet.vcxproj
#	Externals/glslang/glslang.vcxproj
#	Externals/imgui/imgui.vcxproj
#	Externals/liblzma/liblzma.vcxproj
#	Externals/libpng/png/png.vcxproj
#	Externals/libusb/libusb_static_2013.vcxproj
#	Externals/mbedtls/mbedTLS.vcxproj
#	Externals/miniupnpc/miniupnpc.vcxproj
#	Externals/minizip/minizip.vcxproj
#	Externals/picojson/picojson.vcxproj
#	Externals/pugixml/pugixml.vcxproj
#	Externals/soundtouch/SoundTouch.vcxproj
#	Externals/xxhash/xxhash.vcxproj
#	Externals/zlib/zlib.vcxproj
#	Externals/zstd/zstd.vcxproj
#	Languages/Languages.vcxproj
#	Source/Android/jni/MainAndroid.cpp
#	Source/Core/AudioCommon/AudioCommon.vcxproj
#	Source/Core/Common/Common.vcxproj
#	Source/Core/Common/Common.vcxproj.filters
#	Source/Core/Common/Logging/Log.h
#	Source/Core/Common/StringUtil.cpp
#	Source/Core/Core/CMakeLists.txt
#	Source/Core/Core/ConfigManager.cpp
#	Source/Core/Core/ConfigManager.h
#	Source/Core/Core/Core.vcxproj
#	Source/Core/Core/Core.vcxproj.filters
#	Source/Core/Core/HotkeyManager.cpp
#	Source/Core/Core/State.cpp
#	Source/Core/DiscIO/DiscIO.vcxproj
#	Source/Core/DolphinNoGUI/DolphinNoGUI.vcxproj
#	Source/Core/DolphinQt/Config/Graphics/GeneralWidget.cpp
#	Source/Core/DolphinQt/DolphinQt.vcxproj
#	Source/Core/InputCommon/InputCommon.vcxproj
#	Source/Core/InputCommon/InputCommon.vcxproj.filters
#	Source/Core/UICommon/UICommon.vcxproj
#	Source/Core/UpdaterCommon/UpdaterCommon.vcxproj
#	Source/Core/VideoBackends/D3D/D3D.vcxproj
#	Source/Core/VideoBackends/D3D12/D3D12.vcxproj
#	Source/Core/VideoBackends/D3DCommon/D3DCommon.vcxproj
#	Source/Core/VideoBackends/Null/Null.vcxproj
#	Source/Core/VideoBackends/OGL/OGL.vcxproj
#	Source/Core/VideoBackends/Software/Software.vcxproj
#	Source/Core/VideoBackends/Vulkan/Vulkan.vcxproj
#	Source/Core/VideoCommon/OnScreenDisplay.cpp
#	Source/Core/VideoCommon/OnScreenDisplay.h
#	Source/Core/VideoCommon/VideoCommon.vcxproj
#	Source/Core/WinUpdater/WinUpdater.vcxproj
#	Source/DSPTool/DSPTool.vcxproj
#	Source/PCH/pch.vcxproj
#	Source/UnitTests/UnitTests.vcxproj
This commit is contained in:
JosJuice 2020-12-01 22:54:36 +01:00
commit 24a62eec41
970 changed files with 99364 additions and 88078 deletions

View file

@ -10,23 +10,19 @@
#include <string>
#include <vector>
#include "fmt/format.h"
#include <fmt/format.h>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/Event.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
// OpenGL is not available on Windows-on-ARM64
#if !defined(_WIN32) || !defined(_M_ARM64)
#define HAS_OPENGL 1
#endif
// TODO: ugly
#ifdef _WIN32
#include "VideoBackends/D3D/VideoBackend.h"
@ -37,7 +33,9 @@
#include "VideoBackends/OGL/VideoBackend.h"
#include "VideoBackends/Software/VideoBackend.h"
#endif
#ifdef HAS_VULKAN
#include "VideoBackends/Vulkan/VideoBackend.h"
#endif
#include "VideoCommon/AsyncRequests.h"
#include "VideoCommon/BPStructs.h"
@ -58,9 +56,7 @@
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoState.h"
std::vector<std::unique_ptr<VideoBackendBase>> g_available_video_backends;
VideoBackendBase* g_video_backend = nullptr;
static VideoBackendBase* s_default_backend = nullptr;
#ifdef _WIN32
#include <windows.h>
@ -68,8 +64,11 @@ static VideoBackendBase* s_default_backend = nullptr;
// 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.
// AMD drivers >= 13.35 do the same, but for the variable
// named AmdPowerXpressRequestHighPerformance instead.
extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
@ -164,8 +163,9 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index)
static bool warn_once = true;
if (warn_once)
{
ERROR_LOG(VIDEO, "BBox shall be used but it is disabled. Please use a gameini to enable it "
"for this game.");
ERROR_LOG_FMT(VIDEO,
"BBox shall be used but it is disabled. Please use a gameini to enable it "
"for this game.");
}
warn_once = false;
return 0;
@ -176,9 +176,10 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index)
static bool warn_once = true;
if (warn_once)
{
PanicAlertT("This game requires bounding box emulation to run properly but your graphics "
"card or its drivers do not support it. As a result you will experience bugs or "
"freezes while running this game.");
PanicAlertFmtT(
"This game requires bounding box emulation to run properly but your graphics "
"card or its drivers do not support it. As a result you will experience bugs or "
"freezes while running this game.");
}
warn_once = false;
return 0;
@ -197,49 +198,61 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index)
return result;
}
void VideoBackendBase::PopulateList()
static VideoBackendBase* GetDefaultVideoBackend()
{
// OGL > D3D11 > Vulkan > SW > Null
#ifdef HAS_OPENGL
g_available_video_backends.push_back(std::make_unique<OGL::VideoBackend>());
#endif
#ifdef _WIN32
g_available_video_backends.push_back(std::make_unique<DX11::VideoBackend>());
g_available_video_backends.push_back(std::make_unique<DX12::VideoBackend>());
#endif
g_available_video_backends.push_back(std::make_unique<Vulkan::VideoBackend>());
#ifdef HAS_OPENGL
g_available_video_backends.push_back(std::make_unique<SW::VideoSoftware>());
#endif
g_available_video_backends.push_back(std::make_unique<Null::VideoBackend>());
const auto iter =
std::find_if(g_available_video_backends.begin(), g_available_video_backends.end(),
[](const auto& backend) { return backend != nullptr; });
if (iter == g_available_video_backends.end())
return;
s_default_backend = iter->get();
g_video_backend = iter->get();
const auto& backends = VideoBackendBase::GetAvailableBackends();
if (backends.empty())
return nullptr;
return backends.front().get();
}
void VideoBackendBase::ClearList()
std::string VideoBackendBase::GetDefaultBackendName()
{
g_available_video_backends.clear();
auto* default_backend = GetDefaultVideoBackend();
return default_backend ? default_backend->GetName() : "";
}
const std::vector<std::unique_ptr<VideoBackendBase>>& VideoBackendBase::GetAvailableBackends()
{
static auto s_available_backends = [] {
std::vector<std::unique_ptr<VideoBackendBase>> backends;
// OGL > D3D11 > D3D12 > Vulkan > SW > Null
#ifdef HAS_OPENGL
backends.push_back(std::make_unique<OGL::VideoBackend>());
#endif
#ifdef _WIN32
backends.push_back(std::make_unique<DX11::VideoBackend>());
backends.push_back(std::make_unique<DX12::VideoBackend>());
#endif
#ifdef HAS_VULKAN
backends.push_back(std::make_unique<Vulkan::VideoBackend>());
#endif
#ifdef HAS_OPENGL
backends.push_back(std::make_unique<SW::VideoSoftware>());
#endif
backends.push_back(std::make_unique<Null::VideoBackend>());
if (!backends.empty())
g_video_backend = backends.front().get();
return backends;
}();
return s_available_backends;
}
void VideoBackendBase::ActivateBackend(const std::string& name)
{
// If empty, set it to the default backend (expected behavior)
if (name.empty())
g_video_backend = s_default_backend;
g_video_backend = GetDefaultVideoBackend();
const auto iter =
std::find_if(g_available_video_backends.begin(), g_available_video_backends.end(),
[&name](const auto& backend) { return name == backend->GetName(); });
const auto& backends = GetAvailableBackends();
const auto iter = std::find_if(backends.begin(), backends.end(), [&name](const auto& backend) {
return name == backend->GetName();
});
if (iter == g_available_video_backends.end())
if (iter == backends.end())
return;
g_video_backend = iter->get();