diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2021-10-02 21:30:10 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2021-10-16 20:33:53 +0000 |
commit | 20e9c66fa935807ca5d11eedf82fbfd3db807c04 (patch) | |
tree | c93eb68eb322df5965e42bddcbc203527f5aaf5e | |
parent | 538fb6541e621fd6eb1c0fe42bb88520e8e45dda (diff) | |
download | mpv-20e9c66fa935807ca5d11eedf82fbfd3db807c04.tar.bz2 mpv-20e9c66fa935807ca5d11eedf82fbfd3db807c04.tar.xz |
egl_helpers: fixup the EGL_KHR_create_context-less codepath
With earlier commit f8e62d3d82 ("egl_helpers: fix create_context
fallback behavior") we added a fallback for creating OpenGL context
while EGL_KHR_create_context is missing.
While it looked correct at first, it is missing the eglMakeCurrent()
call after creating the EGL context. Thus calling glGetString() fails.
Instead of doing that we can just remove some code - simply pass the
CLIENT_VERSION 2, as attributes which is honoured by EGL regardless of
the client API. This allows us to remove the special case and drop some
code.
v2:
- mpgl_preferred_gl_versions -> mpgl_min_required_gl_versions
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r-- | video/out/opengl/common.c | 21 | ||||
-rw-r--r-- | video/out/opengl/common.h | 2 | ||||
-rw-r--r-- | video/out/opengl/egl_helpers.c | 30 |
3 files changed, 9 insertions, 44 deletions
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c index ed0b0d4747..1a5efe0460 100644 --- a/video/out/opengl/common.c +++ b/video/out/opengl/common.c @@ -486,27 +486,6 @@ static const struct gl_functions gl_functions[] = { #undef DEF_FN #undef DEF_FN_NAME -void mpgl_check_version(GL *gl, void *(*get_fn)(void *ctx, const char *n), - void *fn_ctx) -{ - gl->GetString = get_fn(fn_ctx, "glGetString"); - if (!gl->GetString) { - gl->version = 0; - return; - } - const char *version_string = gl->GetString(GL_VERSION); - if (!version_string) { - gl->version = 0; - return; - } - int major = 0, minor = 0; - if (sscanf(version_string, "%d.%d", &major, &minor) < 2) { - gl->version = 0; - return; - } - gl->version = MPGL_VER(major, minor); -} - // Fill the GL struct with function pointers and extensions from the current // GL context. Called by the backend. // get_fn: function to resolve function names diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h index c3691cfaf8..38414fe18b 100644 --- a/video/out/opengl/common.h +++ b/video/out/opengl/common.h @@ -70,8 +70,6 @@ enum { #define MPGL_VER_P(ver) MPGL_VER_GET_MAJOR(ver), MPGL_VER_GET_MINOR(ver) -void mpgl_check_version(GL *gl, void *(*get_fn)(void *ctx, const char *n), - void *fn_ctx); void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), const char *ext2, struct mp_log *log); void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), diff --git a/video/out/opengl/egl_helpers.c b/video/out/opengl/egl_helpers.c index 68cfa8e55d..ac40ac4146 100644 --- a/video/out/opengl/egl_helpers.c +++ b/video/out/opengl/egl_helpers.c @@ -163,14 +163,7 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display, EGLContext *egl_ctx = NULL; - if (es) { - EGLint attrs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - - egl_ctx = eglCreateContext(display, config, EGL_NO_CONTEXT, attrs); - } else { + if (!es) { for (int n = 0; mpgl_min_required_gl_versions[n]; n++) { int ver = mpgl_min_required_gl_versions[n]; @@ -186,20 +179,15 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display, if (egl_ctx) break; } + } + if (!egl_ctx) { + // Fallback for EGL 1.4 without EGL_KHR_create_context or GLES + EGLint attrs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; - if (!egl_ctx) { - // Fallback for EGL 1.4 without EGL_KHR_create_context. - EGLint attrs[] = { EGL_NONE }; - egl_ctx = eglCreateContext(display, config, EGL_NO_CONTEXT, attrs); - - GL *gl = talloc_zero(ctx, struct GL); - mpgl_check_version(gl, mpegl_get_proc_address, NULL); - if (gl->version < 210) { - eglDestroyContext(display, egl_ctx); - egl_ctx = NULL; - } - talloc_free(gl); - } + egl_ctx = eglCreateContext(display, config, EGL_NO_CONTEXT, attrs); } if (!egl_ctx) { |