summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/OGLMain.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-06-09 15:07:07 +0200
committerGitHub <noreply@github.com>2023-06-09 15:07:07 +0200
commit8f51a9d2d8a88993167cd1c3b8d447bee1ca6407 (patch)
tree31ea53fda80c4e7e4476cd2a16b17de89102b9c7 /Source/Core/VideoBackends/OGL/OGLMain.cpp
parent092773ad0cd31cb0f3d111254e4e0bdb24f2c795 (diff)
parentac48b2eea43164349e6b112604d44490a4d731c5 (diff)
Merge pull request #11699 from Pokechu22/gl-check-maximum-samples
OpenGL: Check the list of supported AA modes instead of hardcoding
Diffstat (limited to 'Source/Core/VideoBackends/OGL/OGLMain.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/OGLMain.cpp77
1 files changed, 47 insertions, 30 deletions
diff --git a/Source/Core/VideoBackends/OGL/OGLMain.cpp b/Source/Core/VideoBackends/OGL/OGLMain.cpp
index c47b94ceb8..13f47a054f 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;
@@ -105,7 +142,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsGPUTextureDecoding = true;
g_Config.backend_info.bSupportsBBox = true;
- // Overwritten in OGLRender.cpp later
+ // Overwritten in OGLConfig.cpp later
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsPaletteConversion = 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;
@@ -172,6 +182,13 @@ bool VideoBackend::FillBackendInfo()
return false;
}
+ if (!PopulateConfig(context))
+ {
+ // Not all needed extensions are supported, so we have to stop here.
+ // Else some of the next calls might crash.
+ return false;
+ }
+
// TODO: Move the remaining fields from the Renderer constructor here.
return true;
}
@@ -184,7 +201,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);