diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2021-10-02 21:22:46 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2021-10-16 20:33:53 +0000 |
commit | 538fb6541e621fd6eb1c0fe42bb88520e8e45dda (patch) | |
tree | 9cdf85b6194fe0ee154ba975309e15658661e324 /video/out/opengl/context_glx.c | |
parent | e3883512b119429004376cefff8a29043dbaff8d (diff) | |
download | mpv-538fb6541e621fd6eb1c0fe42bb88520e8e45dda.tar.bz2 mpv-538fb6541e621fd6eb1c0fe42bb88520e8e45dda.tar.xz |
video: opengl: rework and remove ra_gl_ctx_test_version()
The ra_gl_ctx_test_version() helper is quite clunky, in that it pushes a
simple check too deep into the call chain. As such it makes it hard to
reason, let alone have the GLX and EGL code paths symmetrical.
Introduce a simple helper ra_gl_ctx_get_glesmode() which returns the
current glesmode, so the platforms can clearly reason about should and
should not be executed.
v2:
- mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
- 320 -> 300 (in glx code path)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'video/out/opengl/context_glx.c')
-rw-r--r-- | video/out/opengl/context_glx.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/video/out/opengl/context_glx.c b/video/out/opengl/context_glx.c index ee1fb30abf..529991fac2 100644 --- a/video/out/opengl/context_glx.c +++ b/video/out/opengl/context_glx.c @@ -116,9 +116,6 @@ static bool create_context_x11_gl3(struct ra_ctx *ctx, GL *gl, int gl_version, if (p->context) return true; - if (!ra_gl_ctx_test_version(ctx, gl_version, es)) - return false; - glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); @@ -312,19 +309,23 @@ static bool glx_init(struct ra_ctx *ctx) goto uninit; bool success = false; - 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) { - success = create_context_x11_gl3(ctx, gl, version, false); - } else { - success = create_context_x11_old(ctx, gl); + enum gles_mode mode = ra_gl_ctx_get_glesmode(ctx); + + if (mode == GLES_NO || mode == GLES_AUTO) { + 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) { + success = create_context_x11_gl3(ctx, gl, version, false); + } else { + success = create_context_x11_old(ctx, gl); + } + if (success) + break; } - if (success) - break; } - if (!success) // try again for GLES + if (!success && (mode == GLES_YES || mode == GLES_AUTO)) success = create_context_x11_gl3(ctx, gl, 200, true); if (success && !glXIsDirect(vo->x11->display, p->context)) gl->mpgl_caps |= MPGL_CAP_SW; |