summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-08-19 13:51:50 +0200
committerNiklas Haas <git@haasn.dev>2022-08-19 13:54:50 +0200
commit37aea112c15958052bcc6d0582593edf3bfead8f (patch)
treea70138a21f1dc53fab4eef165c4b9f2511988820 /video/out
parent891c9c869f61bfe16e46a9244a6af2ed93f67b23 (diff)
downloadmpv-37aea112c15958052bcc6d0582593edf3bfead8f.tar.bz2
mpv-37aea112c15958052bcc6d0582593edf3bfead8f.tar.xz
vo_gpu_next: pass GL get_proc_addr pointer to libplacebo
Facing down the multitude of ways to somehow wrangle the get_fn pointer out of the GL environment and into libplacebo, I decided the easiest is to just store it inside the GL struct itself. The lifetime of this get_fn function is a bit murky, since it's not clear on whether or not it survives the VO init call (especially in the case of the GL render API, which explicitly states that parameters do not need to survive the call they're passed to), so just add a disclaimer. (It's fine for us to use like this because `gpu_ctx_create` is still part of VO init) Closes https://code.videolan.org/videolan/libplacebo/-/issues/216
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gpu_next/context.c4
-rw-r--r--video/out/opengl/common.c2
-rw-r--r--video/out/opengl/common.h5
3 files changed, 11 insertions, 0 deletions
diff --git a/video/out/gpu_next/context.c b/video/out/gpu_next/context.c
index c24a7c197a..b825eab243 100644
--- a/video/out/gpu_next/context.c
+++ b/video/out/gpu_next/context.c
@@ -148,6 +148,10 @@ struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts)
pl_opengl_params(
.debug = ctx_opts->debug,
.allow_software = ctx_opts->allow_sw,
+# if PL_API_VER >= 215
+ .get_proc_addr_ex = (void *) ra_gl_get(ctx->ra_ctx->ra)->get_fn,
+ .proc_ctx = ra_gl_get(ctx->ra_ctx->ra)->fn_ctx,
+# endif
# if HAVE_EGL
.egl_display = eglGetCurrentDisplay(),
.egl_context = eglGetCurrentContext(),
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index d5883d4a4d..8e8638df9f 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -504,6 +504,8 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n),
talloc_free(gl->extensions);
*gl = (GL) {
.extensions = talloc_strdup(gl, ext2 ? ext2 : ""),
+ .get_fn = get_fn,
+ .fn_ctx = fn_ctx,
};
gl->GetString = get_fn(fn_ctx, "glGetString");
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index 1292be45b2..a9e67d9756 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -87,6 +87,11 @@ struct GL {
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
+ // Copy of function pointer used to load GL.
+ // Caution: Not necessarily valid to use after VO init has completed!
+ void *(*get_fn)(void *ctx, const char *n);
+ void *fn_ctx;
+
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
void (GLAPIENTRY *GenTextures)(GLsizei, GLuint *);