diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2021-10-03 13:14:19 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2021-10-16 20:33:53 +0000 |
commit | 6354540cf8c309e11ff4b6f33d2e97d57771399a (patch) | |
tree | 874443fff6fce139c3f9d98a973705851d079330 | |
parent | e869d519baf4b71b33e522f97b4638979fe0d4db (diff) | |
download | mpv-6354540cf8c309e11ff4b6f33d2e97d57771399a.tar.bz2 mpv-6354540cf8c309e11ff4b6f33d2e97d57771399a.tar.xz |
vo_gpu: context_glx: cleanup create_context_x11_gl3 code path
Drop the gl3 suffix from the function name - it's no longer needed, with
the _old function gone.
Push the mpgl_min_required_gl_versions[] looping within the function,
reducing the identical glXGetProcAddress/glXQueryExtensionsString calls
while making the code neater.
v2:
- tabs -> spaces indentation
- mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
- 320 -> 300 (in glx code path)
v3:
- legacy code path is gone \o/
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r-- | video/out/opengl/context_glx.c | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/video/out/opengl/context_glx.c b/video/out/opengl/context_glx.c index e4e23c7b86..1accd36db8 100644 --- a/video/out/opengl/context_glx.c +++ b/video/out/opengl/context_glx.c @@ -72,15 +72,11 @@ static void glx_uninit(struct ra_ctx *ctx) typedef GLXContext (*glXCreateContextAttribsARBProc) (Display*, GLXFBConfig, GLXContext, Bool, const int*); -static bool create_context_x11_gl3(struct ra_ctx *ctx, GL *gl, int gl_version, - bool es) +static bool create_context_x11(struct ra_ctx *ctx, GL *gl, bool es) { struct priv *p = ctx->priv; struct vo *vo = ctx->vo; - if (p->context) - return true; - glXCreateContextAttribsARBProc glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); @@ -108,17 +104,43 @@ static bool create_context_x11_gl3(struct ra_ctx *ctx, GL *gl, int gl_version, } int context_attribs[] = { - GLX_CONTEXT_MAJOR_VERSION_ARB, MPGL_VER_GET_MAJOR(gl_version), - GLX_CONTEXT_MINOR_VERSION_ARB, MPGL_VER_GET_MINOR(gl_version), + GLX_CONTEXT_MAJOR_VERSION_ARB, 0, + GLX_CONTEXT_MINOR_VERSION_ARB, 0, GLX_CONTEXT_PROFILE_MASK_ARB, profile_mask, GLX_CONTEXT_FLAGS_ARB, ctx_flags, None }; - vo_x11_silence_xlib(1); - GLXContext context = glXCreateContextAttribsARB(vo->x11->display, - p->fbc, 0, True, - context_attribs); - vo_x11_silence_xlib(-1); + + GLXContext context; + + if (!es) { + 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)); + + context_attribs[1] = MPGL_VER_GET_MAJOR(version); + context_attribs[3] = MPGL_VER_GET_MINOR(version); + + vo_x11_silence_xlib(1); + context = glXCreateContextAttribsARB(vo->x11->display, + p->fbc, 0, True, + context_attribs); + vo_x11_silence_xlib(-1); + + if (context) + break; + } + } else { + context_attribs[1] = 2; + + vo_x11_silence_xlib(1); + context = glXCreateContextAttribsARB(vo->x11->display, + p->fbc, 0, True, + context_attribs); + vo_x11_silence_xlib(-1); + } + if (!context) return false; @@ -281,18 +303,10 @@ static bool glx_init(struct ra_ctx *ctx) bool success = false; 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)); - success = create_context_x11_gl3(ctx, gl, version, false); - if (success) - break; - } - } + if (mode == GLES_NO || mode == GLES_AUTO) + success = create_context_x11(ctx, gl, false); if (!success && (mode == GLES_YES || mode == GLES_AUTO)) - success = create_context_x11_gl3(ctx, gl, 200, true); + success = create_context_x11(ctx, gl, true); if (success && !glXIsDirect(vo->x11->display, p->context)) gl->mpgl_caps |= MPGL_CAP_SW; if (!success) |