summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2023-03-25 17:16:53 -0700
committerPokechu22 <Pokechu022@gmail.com>2023-06-08 22:07:39 -0700
commitc63f0f37cd84d627dd40ace3205c689efc068ac0 (patch)
tree522c04c05ba22841e9063b1349e855364e844b1f /Source/Core/VideoBackends
parent7845fb00ee1a57b7dd47e2c403345c9329855e27 (diff)
VideoCommon: Pass WindowSystemInfo to InitBackendInfo
Diffstat (limited to 'Source/Core/VideoBackends')
-rw-r--r--Source/Core/VideoBackends/D3D/D3DMain.cpp2
-rw-r--r--Source/Core/VideoBackends/D3D/VideoBackend.h2
-rw-r--r--Source/Core/VideoBackends/D3D12/VideoBackend.cpp2
-rw-r--r--Source/Core/VideoBackends/D3D12/VideoBackend.h2
-rw-r--r--Source/Core/VideoBackends/Metal/MTLMain.mm2
-rw-r--r--Source/Core/VideoBackends/Metal/VideoBackend.h2
-rw-r--r--Source/Core/VideoBackends/Null/NullBackend.cpp2
-rw-r--r--Source/Core/VideoBackends/Null/VideoBackend.h2
-rw-r--r--Source/Core/VideoBackends/OGL/OGLMain.cpp68
-rw-r--r--Source/Core/VideoBackends/OGL/VideoBackend.h4
-rw-r--r--Source/Core/VideoBackends/Software/SWmain.cpp2
-rw-r--r--Source/Core/VideoBackends/Software/VideoBackend.h2
-rw-r--r--Source/Core/VideoBackends/Vulkan/VKMain.cpp2
-rw-r--r--Source/Core/VideoBackends/Vulkan/VideoBackend.h2
14 files changed, 53 insertions, 43 deletions
diff --git a/Source/Core/VideoBackends/D3D/D3DMain.cpp b/Source/Core/VideoBackends/D3D/D3DMain.cpp
index 8256674ad5..4f797fcb26 100644
--- a/Source/Core/VideoBackends/D3D/D3DMain.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DMain.cpp
@@ -63,7 +63,7 @@ std::optional<std::string> VideoBackend::GetWarningMessage() const
return result;
}
-void VideoBackend::InitBackendInfo()
+void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
if (!D3DCommon::LoadLibraries())
return;
diff --git a/Source/Core/VideoBackends/D3D/VideoBackend.h b/Source/Core/VideoBackends/D3D/VideoBackend.h
index 1349d13b2b..6a94f8c7a3 100644
--- a/Source/Core/VideoBackends/D3D/VideoBackend.h
+++ b/Source/Core/VideoBackends/D3D/VideoBackend.h
@@ -18,7 +18,7 @@ public:
std::string GetDisplayName() const override;
std::optional<std::string> GetWarningMessage() const override;
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "D3D";
diff --git a/Source/Core/VideoBackends/D3D12/VideoBackend.cpp b/Source/Core/VideoBackends/D3D12/VideoBackend.cpp
index afc5bb96e8..f82b7d961b 100644
--- a/Source/Core/VideoBackends/D3D12/VideoBackend.cpp
+++ b/Source/Core/VideoBackends/D3D12/VideoBackend.cpp
@@ -36,7 +36,7 @@ std::string VideoBackend::GetDisplayName() const
return "Direct3D 12";
}
-void VideoBackend::InitBackendInfo()
+void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
if (!D3DCommon::LoadLibraries())
return;
diff --git a/Source/Core/VideoBackends/D3D12/VideoBackend.h b/Source/Core/VideoBackends/D3D12/VideoBackend.h
index 7d3126b38c..db03b738d0 100644
--- a/Source/Core/VideoBackends/D3D12/VideoBackend.h
+++ b/Source/Core/VideoBackends/D3D12/VideoBackend.h
@@ -16,7 +16,7 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "D3D12";
diff --git a/Source/Core/VideoBackends/Metal/MTLMain.mm b/Source/Core/VideoBackends/Metal/MTLMain.mm
index f799d5eea1..7042e091fd 100644
--- a/Source/Core/VideoBackends/Metal/MTLMain.mm
+++ b/Source/Core/VideoBackends/Metal/MTLMain.mm
@@ -119,7 +119,7 @@ void Metal::VideoBackend::Shutdown()
ObjectCache::Shutdown();
}
-void Metal::VideoBackend::InitBackendInfo()
+void Metal::VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
@autoreleasepool
{
diff --git a/Source/Core/VideoBackends/Metal/VideoBackend.h b/Source/Core/VideoBackends/Metal/VideoBackend.h
index 3a567718e2..a6a24173e5 100644
--- a/Source/Core/VideoBackends/Metal/VideoBackend.h
+++ b/Source/Core/VideoBackends/Metal/VideoBackend.h
@@ -18,7 +18,7 @@ public:
std::string GetDisplayName() const override;
std::optional<std::string> GetWarningMessage() const override;
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
void PrepareWindow(WindowSystemInfo& wsi) override;
diff --git a/Source/Core/VideoBackends/Null/NullBackend.cpp b/Source/Core/VideoBackends/Null/NullBackend.cpp
index 900a911699..28afcce4dc 100644
--- a/Source/Core/VideoBackends/Null/NullBackend.cpp
+++ b/Source/Core/VideoBackends/Null/NullBackend.cpp
@@ -25,7 +25,7 @@
namespace Null
{
-void VideoBackend::InitBackendInfo()
+void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
g_Config.backend_info.api_type = APIType::Nothing;
g_Config.backend_info.MaxTextureSize = 16384;
diff --git a/Source/Core/VideoBackends/Null/VideoBackend.h b/Source/Core/VideoBackends/Null/VideoBackend.h
index f08098cfd0..4437c0c48d 100644
--- a/Source/Core/VideoBackends/Null/VideoBackend.h
+++ b/Source/Core/VideoBackends/Null/VideoBackend.h
@@ -15,7 +15,7 @@ public:
std::string GetName() const override { return NAME; }
std::string GetDisplayName() const override;
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "Null";
};
diff --git a/Source/Core/VideoBackends/OGL/OGLMain.cpp b/Source/Core/VideoBackends/OGL/OGLMain.cpp
index c47b94ceb8..ef25e40a2a 100644
--- a/Source/Core/VideoBackends/OGL/OGLMain.cpp
+++ b/Source/Core/VideoBackends/OGL/OGLMain.cpp
@@ -74,8 +74,45 @@ std::string VideoBackend::GetDisplayName() const
return _trans("OpenGL");
}
-void VideoBackend::InitBackendInfo()
+void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
+ std::unique_ptr<GLContext> temp_gl_context =
+ GLContext::Create(wsi, g_Config.stereo_mode == StereoMode::QuadBuffer, true, false,
+ Config::Get(Config::GFX_PREFER_GLES));
+
+ if (!temp_gl_context)
+ return;
+
+ FillBackendInfo(temp_gl_context.get());
+}
+
+bool VideoBackend::InitializeGLExtensions(GLContext* context)
+{
+ // Init extension support.
+ if (!GLExtensions::Init(context))
+ {
+ // OpenGL 2.0 is required for all shader based drawings. There is no way to get this by
+ // extensions
+ PanicAlertFmtT("GPU: OGL ERROR: Does your video card support OpenGL 2.0?");
+ return false;
+ }
+
+ if (GLExtensions::Version() < 300)
+ {
+ // integer vertex attributes require a gl3 only function
+ PanicAlertFmtT("GPU: OGL ERROR: Need OpenGL version 3.\n"
+ "GPU: Does your video card support OpenGL 3?");
+ return false;
+ }
+
+ return true;
+}
+
+bool VideoBackend::FillBackendInfo(GLContext* context)
+{
+ if (!InitializeGLExtensions(context))
+ return false;
+
g_Config.backend_info.api_type = APIType::OpenGL;
g_Config.backend_info.MaxTextureSize = 16384;
g_Config.backend_info.bUsesLowerLeftOrigin = true;
@@ -123,33 +160,6 @@ void VideoBackend::InitBackendInfo()
// aamodes - 1 is to stay consistent with D3D (means no AA)
g_Config.backend_info.AAModes = {1, 2, 4, 8};
-}
-
-bool VideoBackend::InitializeGLExtensions(GLContext* context)
-{
- // Init extension support.
- if (!GLExtensions::Init(context))
- {
- // OpenGL 2.0 is required for all shader based drawings. There is no way to get this by
- // extensions
- PanicAlertFmtT("GPU: OGL ERROR: Does your video card support OpenGL 2.0?");
- return false;
- }
-
- if (GLExtensions::Version() < 300)
- {
- // integer vertex attributes require a gl3 only function
- PanicAlertFmtT("GPU: OGL ERROR: Need OpenGL version 3.\n"
- "GPU: Does your video card support OpenGL 3?");
- return false;
- }
-
- return true;
-}
-
-bool VideoBackend::FillBackendInfo()
-{
- InitBackendInfo();
// check for the max vertex attributes
GLint numvertexattribs = 0;
@@ -184,7 +194,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
if (!main_gl_context)
return false;
- if (!InitializeGLExtensions(main_gl_context.get()) || !FillBackendInfo())
+ if (!FillBackendInfo(main_gl_context.get()))
return false;
auto gfx = std::make_unique<OGLGfx>(std::move(main_gl_context), wsi.render_surface_scale);
diff --git a/Source/Core/VideoBackends/OGL/VideoBackend.h b/Source/Core/VideoBackends/OGL/VideoBackend.h
index 4be861954e..53f7f940d5 100644
--- a/Source/Core/VideoBackends/OGL/VideoBackend.h
+++ b/Source/Core/VideoBackends/OGL/VideoBackend.h
@@ -19,12 +19,12 @@ public:
std::string GetName() const override;
std::string GetDisplayName() const override;
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "OGL";
private:
bool InitializeGLExtensions(GLContext* context);
- bool FillBackendInfo();
+ bool FillBackendInfo(GLContext* context);
};
} // namespace OGL
diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp
index 8703ea4b4d..ccb040e8ad 100644
--- a/Source/Core/VideoBackends/Software/SWmain.cpp
+++ b/Source/Core/VideoBackends/Software/SWmain.cpp
@@ -62,7 +62,7 @@ std::optional<std::string> VideoSoftware::GetWarningMessage() const
"really want to enable software rendering? If unsure, select 'No'.");
}
-void VideoSoftware::InitBackendInfo()
+void VideoSoftware::InitBackendInfo(const WindowSystemInfo& wsi)
{
g_Config.backend_info.api_type = APIType::Nothing;
g_Config.backend_info.MaxTextureSize = 16384;
diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h
index 8c3cb081ef..35c3adb1a7 100644
--- a/Source/Core/VideoBackends/Software/VideoBackend.h
+++ b/Source/Core/VideoBackends/Software/VideoBackend.h
@@ -17,7 +17,7 @@ class VideoSoftware : public VideoBackendBase
std::string GetDisplayName() const override;
std::optional<std::string> GetWarningMessage() const override;
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "Software Renderer";
};
diff --git a/Source/Core/VideoBackends/Vulkan/VKMain.cpp b/Source/Core/VideoBackends/Vulkan/VKMain.cpp
index 053b592c14..2eb9b34106 100644
--- a/Source/Core/VideoBackends/Vulkan/VKMain.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VKMain.cpp
@@ -30,7 +30,7 @@
namespace Vulkan
{
-void VideoBackend::InitBackendInfo()
+void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
{
VulkanContext::PopulateBackendInfo(&g_Config);
diff --git a/Source/Core/VideoBackends/Vulkan/VideoBackend.h b/Source/Core/VideoBackends/Vulkan/VideoBackend.h
index a16d149307..4e8c3a5471 100644
--- a/Source/Core/VideoBackends/Vulkan/VideoBackend.h
+++ b/Source/Core/VideoBackends/Vulkan/VideoBackend.h
@@ -16,7 +16,7 @@ public:
std::string GetName() const override { return NAME; }
std::string GetDisplayName() const override { return _trans("Vulkan"); }
- void InitBackendInfo() override;
+ void InitBackendInfo(const WindowSystemInfo& wsi) override;
void PrepareWindow(WindowSystemInfo& wsi) override;
static constexpr const char* NAME = "Vulkan";