vo_gpu: opengl: reduce versions in mpgl_preferred_gl_versions

Currently mpv requires a bare minimum of GL 2.1, although it tries to
use 3.2+ core contexts when possible.

The GLX and EGL spec effectively guarantee that the implementation will
give you the highest compatible version possible. In other words:

Requesting 3.2 core profile will always give you core profile and the
version will be in the 3.2 .. 4.6 range - as supported by the drivers.

Similarly for 2.1 - implementation will give you either:
 - 2.1 .. 3.1, or
 - 3.2 .. 4.6 compat profile

This has been verified against the Mesa drivers (i965, iris, swrast) and
Nvidia binary drivers.

As such, drop the list to 320, 210 and terminating 0.

v2:
 - mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
 - update ^^ comment

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
Emil Velikov 2021-10-02 17:44:34 +01:00 committed by Dudemanguy
parent 0282196f4a
commit 0b918edfb5
4 changed files with 7 additions and 13 deletions

View File

@ -21,15 +21,9 @@
#include "utils.h"
// 0-terminated list of desktop GL versions a backend should try to
// initialize. The first entry is the most preferred version.
const int mpgl_preferred_gl_versions[] = {
440,
430,
400,
330,
// initialize. Each entry is the minimum required version.
const int mpgl_min_required_gl_versions[] = {
320,
310,
300,
210,
0
};

View File

@ -4,7 +4,7 @@
#include "video/out/gpu/context.h"
#include "common.h"
extern const int mpgl_preferred_gl_versions[];
extern const int mpgl_min_required_gl_versions[];
// Returns whether or not a candidate GL version should be accepted or not
// (based on the --opengl opts). Implementations may call this before

View File

@ -312,8 +312,8 @@ static bool glx_init(struct ra_ctx *ctx)
goto uninit;
bool success = false;
for (int n = 0; mpgl_preferred_gl_versions[n]; n++) {
int version = mpgl_preferred_gl_versions[n];
for (int n = 0; mpgl_min_required_gl_versions[n]; n++) {
int version = mpgl_min_required_gl_versions[n];
MP_VERBOSE(ctx, "Creating OpenGL %d.%d context...\n",
MPGL_VER_P(version));
if (version >= 300) {

View File

@ -184,8 +184,8 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display,
egl_ctx = eglCreateContext(display, config, EGL_NO_CONTEXT, attrs);
} else {
for (int n = 0; mpgl_preferred_gl_versions[n]; n++) {
int ver = mpgl_preferred_gl_versions[n];
for (int n = 0; mpgl_min_required_gl_versions[n]; n++) {
int ver = mpgl_min_required_gl_versions[n];
if (!ra_gl_ctx_test_version(ctx, ver, false))
continue;