mirror of https://github.com/mpv-player/mpv
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>
This commit is contained in:
parent
538fb6541e
commit
20e9c66fa9
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue