From c63f0f37cd84d627dd40ace3205c689efc068ac0 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sat, 25 Mar 2023 17:16:53 -0700 Subject: VideoCommon: Pass WindowSystemInfo to InitBackendInfo --- Source/Core/VideoBackends/OGL/OGLMain.cpp | 68 ++++++++++++++++++------------- 1 file changed, 39 insertions(+), 29 deletions(-) (limited to 'Source/Core/VideoBackends/OGL/OGLMain.cpp') 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 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(std::move(main_gl_context), wsi.render_surface_scale); -- cgit v1.2.3 From b246a634d42bc50d5b3ba1c97891e195c37293fe Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 19 Mar 2023 22:20:34 -0700 Subject: OpenGL: Check the list of supported AA modes instead of hardcoding --- Source/Core/VideoBackends/OGL/OGLMain.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/OGL/OGLMain.cpp') diff --git a/Source/Core/VideoBackends/OGL/OGLMain.cpp b/Source/Core/VideoBackends/OGL/OGLMain.cpp index ef25e40a2a..13f47a054f 100644 --- a/Source/Core/VideoBackends/OGL/OGLMain.cpp +++ b/Source/Core/VideoBackends/OGL/OGLMain.cpp @@ -142,7 +142,7 @@ bool VideoBackend::FillBackendInfo(GLContext* context) 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; @@ -182,6 +182,13 @@ bool VideoBackend::FillBackendInfo(GLContext* context) 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; } -- cgit v1.2.3