mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 06:29:00 +01:00
GLContext: Try GL versions 3.2-4.6 when getting a context
GLX previously was only creating a 4.0 context.
This commit is contained in:
parent
c95802afeb
commit
2c6d96433c
@ -25,6 +25,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const std::array<std::pair<int, int>, 9> GLContext::s_desktop_opengl_versions = {
|
||||
{{4, 6}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}, {3, 2}}};
|
||||
|
||||
GLContext::~GLContext() = default;
|
||||
|
||||
bool GLContext::Initialize(void* display_handle, void* window_handle, bool stereo, bool core)
|
||||
|
@ -4,8 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
@ -58,4 +60,8 @@ protected:
|
||||
u32 m_backbuffer_width = 0;
|
||||
u32 m_backbuffer_height = 0;
|
||||
bool m_is_shared = false;
|
||||
|
||||
// A list of desktop OpenGL versions to attempt to create a context for.
|
||||
// (4.6-3.2, geometry shaders is a minimum requirement since we're using core profile).
|
||||
static const std::array<std::pair<int, int>, 9> s_desktop_opengl_versions;
|
||||
};
|
||||
|
@ -222,17 +222,7 @@ bool GLContextEGL::Initialize(void* display_handle, void* window_handle, bool st
|
||||
|
||||
if (supports_core_profile && core && m_opengl_mode == Mode::OpenGL)
|
||||
{
|
||||
std::array<std::pair<int, int>, 7> versions_to_try = {{
|
||||
{4, 5},
|
||||
{4, 4},
|
||||
{4, 3},
|
||||
{4, 2},
|
||||
{4, 1},
|
||||
{4, 0},
|
||||
{3, 3},
|
||||
}};
|
||||
|
||||
for (const auto& version : versions_to_try)
|
||||
for (const auto& version : s_desktop_opengl_versions)
|
||||
{
|
||||
std::vector<EGLint> core_attribs = {EGL_CONTEXT_MAJOR_VERSION_KHR,
|
||||
version.first,
|
||||
|
@ -134,30 +134,29 @@ bool GLContextGLX::Initialize(void* display_handle, void* window_handle, bool st
|
||||
XErrorHandler oldHandler = XSetErrorHandler(&ctxErrorHandler);
|
||||
|
||||
// Create a GLX context.
|
||||
// We try to get a 4.0 core profile, else we try 3.3, else try it with anything we get.
|
||||
std::array<int, 9> context_attribs = {
|
||||
{GLX_CONTEXT_MAJOR_VERSION_ARB, 4, GLX_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, GLX_CONTEXT_FLAGS_ARB,
|
||||
GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, None}};
|
||||
m_context = nullptr;
|
||||
if (core)
|
||||
{
|
||||
m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs[0]);
|
||||
XSync(m_display, False);
|
||||
m_attribs.insert(m_attribs.end(), context_attribs.begin(), context_attribs.end());
|
||||
}
|
||||
if (core && (!m_context || s_glxError))
|
||||
{
|
||||
std::array<int, 9> context_attribs_33 = {
|
||||
{GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3,
|
||||
GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB, GLX_CONTEXT_FLAGS_ARB,
|
||||
GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, None}};
|
||||
s_glxError = false;
|
||||
m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs_33[0]);
|
||||
XSync(m_display, False);
|
||||
m_attribs.clear();
|
||||
m_attribs.insert(m_attribs.end(), context_attribs_33.begin(), context_attribs_33.end());
|
||||
for (const auto& version : s_desktop_opengl_versions)
|
||||
{
|
||||
std::array<int, 9> context_attribs = {
|
||||
{GLX_CONTEXT_MAJOR_VERSION_ARB, version.first, GLX_CONTEXT_MINOR_VERSION_ARB,
|
||||
version.second, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, None}};
|
||||
|
||||
s_glxError = false;
|
||||
m_context = glXCreateContextAttribs(m_display, m_fbconfig, 0, True, &context_attribs[0]);
|
||||
XSync(m_display, False);
|
||||
m_attribs.insert(m_attribs.end(), context_attribs.begin(), context_attribs.end());
|
||||
if (!m_context || s_glxError)
|
||||
continue;
|
||||
|
||||
// Got a context.
|
||||
INFO_LOG(VIDEO, "Created a GLX context with version %d.%d", version.first, version.second);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Failed to create any core contexts, try for anything.
|
||||
if (!m_context || s_glxError)
|
||||
{
|
||||
std::array<int, 5> context_attribs_legacy = {
|
||||
|
@ -371,12 +371,7 @@ HGLRC GLContextWGL::CreateCoreContext(HDC dc, HGLRC share_context)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// List of versions to attempt context creation for. (4.5-3.2, geometry shaders is a minimum
|
||||
// requirement since we're using core profile)
|
||||
static constexpr std::array<std::pair<int, int>, 8> try_versions = {
|
||||
{{4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {4, 0}, {3, 3}, {3, 2}}};
|
||||
|
||||
for (const auto& version : try_versions)
|
||||
for (const auto& version : s_desktop_opengl_versions)
|
||||
{
|
||||
// Construct list of attributes. Prefer a forward-compatible, core context.
|
||||
std::array<int, 5 * 2> attribs = {WGL_CONTEXT_PROFILE_MASK_ARB,
|
||||
|
Loading…
x
Reference in New Issue
Block a user