summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/client-api-changes.rst10
-rw-r--r--libmpv/client.h2
-rw-r--r--libmpv/opengl_cb.h55
-rw-r--r--libmpv/render.h12
-rw-r--r--libmpv/render_gl.h9
-rw-r--r--player/client.c3
-rw-r--r--video/out/gpu/libmpv_gpu.c15
-rw-r--r--video/out/gpu/libmpv_gpu.h2
-rw-r--r--video/out/gpu/ra.c20
-rw-r--r--video/out/gpu/ra.h21
-rw-r--r--video/out/opengl/common.c11
-rw-r--r--video/out/opengl/common.h8
-rw-r--r--video/out/opengl/context.c13
-rw-r--r--video/out/opengl/context.h4
-rw-r--r--video/out/opengl/context_drm_egl.c4
-rw-r--r--video/out/opengl/context_dxinterop.c18
-rw-r--r--video/out/opengl/context_rpi.c4
-rw-r--r--video/out/opengl/context_wayland.c4
-rw-r--r--video/out/opengl/context_x11egl.c4
-rw-r--r--video/out/opengl/hwdec_drmprime_drm.c16
-rw-r--r--video/out/opengl/hwdec_dxva2gldx.c4
-rw-r--r--video/out/opengl/hwdec_rpi.c4
-rw-r--r--video/out/opengl/hwdec_vaegl.c20
-rw-r--r--video/out/opengl/libmpv_gl.c13
24 files changed, 132 insertions, 144 deletions
diff --git a/DOCS/client-api-changes.rst b/DOCS/client-api-changes.rst
index e029b29979..38fbc284b0 100644
--- a/DOCS/client-api-changes.rst
+++ b/DOCS/client-api-changes.rst
@@ -33,6 +33,11 @@ API changes
::
--- mpv 0.29.0 ---
+ 1.100 - bump API number to avoid confusion with mpv release versions
+ - actually apply the GL_MP_MPGetNativeDisplay change for the new render
+ API. This also means compatibility for anything but x11 and wayland
+ through the old opengl-cb GL_MP_MPGetNativeDisplay method is now
+ unsupported.
1.29 - the behavior of mpv_terminate_destroy() and mpv_detach_destroy()
changes subtly (see documentation in the header file). In particular,
mpv_detach_destroy() will not leave the player running in all
@@ -55,6 +60,11 @@ API changes
mpv_opengl_cb_report_flip => mpv_render_context_report_swap
mpv_opengl_cb_uninit_gl => mpv_render_context_free
The VO opengl-cb is also renamed to "libmpv".
+ Also, the GL_MP_MPGetNativeDisplay pseudo extension is not used by the
+ render API anymore, and the old opengl-cb API only handles the "x11"
+ and "wl" names anymore. Support for everything else has been removed.
+ The new render API uses proper API parameters, e.g. for X11 you pass
+ MPV_RENDER_PARAM_X11_DISPLAY directly.
- deprecate the qthelper.hpp header file. This provided some C++ helper
utility functions for Qt with use of libmpv. There is no reason to
keep this in the mpv git repository, nor to make it part of the libmpv
diff --git a/libmpv/client.h b/libmpv/client.h
index 1483f1afd6..12459f7a0d 100644
--- a/libmpv/client.h
+++ b/libmpv/client.h
@@ -210,7 +210,7 @@ extern "C" {
* relational operators (<, >, <=, >=).
*/
#define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL)
-#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 29)
+#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(1, 100)
/**
* The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before
diff --git a/libmpv/opengl_cb.h b/libmpv/opengl_cb.h
index ce88a8570a..dd9ab2cf09 100644
--- a/libmpv/opengl_cb.h
+++ b/libmpv/opengl_cb.h
@@ -159,20 +159,9 @@ extern "C" {
* See below what names are defined. Usually, libmpv will use the native handle
* up until mpv_opengl_cb_uninit_gl() is called. If the name is not anything
* you know/expected, return NULL from the function.
- *
- * * Windowing system scaling
- * ------------------------------------
- *
- * When using GL, sometimes GL rendering window is upscaled to display buffer.
- * Typically with drm where GL framebuffer can be upscaled at later stage.
- * In That case glMPGetNativeDisplay("opengl-cb-window-pos") should return an
- * mpv_opengl_cb_window_pos struct pointer defined below.
- * Note : The intended use is for hardware overlays that might require
- * upscaling features (typically upscaling GL windows with drm to screen size).
- *
- * This is never used for GL rendering - only to map hardware overlays to
- * GL rendering (for backends which support it).
*/
+
+// Legacy - not supported anymore.
struct mpv_opengl_cb_window_pos {
int x; // left coordinates of window (usually 0)
int y; // top coordinates of window (usually 0)
@@ -180,22 +169,7 @@ struct mpv_opengl_cb_window_pos {
int height; // height of GL window
};
-/**
- * Windowing system interop on Intel/Linux with VAAPI
- * --------------------------------------------------
- *
- * The new VAAPI OpenGL interop requires an EGL context. EGL provides no way
- * to query the X11 Display associated to a specific EGL context, so this API
- * is used to pass it through.
- *
- * glMPGetNativeDisplay("x11") should return a X11 "Display*", which then will
- * be used to create the hardware decoder state.
- *
- * glMPGetNativeDisplay("wl") should return a Wayland "struct wl_display *".
- *
- * glMPGetNativeDisplay("opengl-cb-drm-params") should return an
- * mpv_opengl_cb_drm_params structure pointer :
- */
+// Legacy - not supported anymore.
struct mpv_opengl_cb_drm_params {
// DRM fd (int). set this to -1 if invalid.
int fd;
@@ -218,29 +192,6 @@ struct mpv_opengl_cb_drm_params {
* You should use ANGLE, and make sure your application and libmpv are linked
* to the same ANGLE DLLs. libmpv will pick the device context (needed for
* hardware decoding) from the current ANGLE EGL context.
- *
- * Windowing system interop on RPI
- * -------------------------------
- *
- * The RPI uses no proper interop, but hardware overlays instead. To place the
- * overlay correctly, you can communicate the window parameters as follows to
- * libmpv. glMPGetNativeDisplay("MPV_RPI_WINDOW") returns an array of type int
- * with the following 4 elements:
- * 0: display number (default 0)
- * 1: layer number of the GL layer - video will be placed in the layer
- * directly below (default: 0)
- * 2: absolute x position of the GL context (default: 0)
- * 3: absolute y position of the GL context (default: 0)
- * The (x,y) position must be the absolute screen pixel position of the
- * top/left pixel of the dispmanx layer used for the GL context. If you render
- * to a FBO, the position must be that of the final position of the FBO
- * contents on screen. You can't transform or scale the video other than what
- * mpv will render to the video overlay. The defaults are suitable for
- * rendering the video at fullscreen.
- * The parameters are checked on every draw by calling MPGetNativeDisplay and
- * checking the values in the returned array for changes. The returned array
- * must remain valid until the libmpv render function returns; then it can be
- * deallocated by the API user.
*/
/**
diff --git a/libmpv/render.h b/libmpv/render.h
index 75153befb8..cefe922b34 100644
--- a/libmpv/render.h
+++ b/libmpv/render.h
@@ -152,6 +152,18 @@ typedef enum mpv_render_param_type {
* This can be used for automatic gamma correction.
*/
MPV_RENDER_PARAM_AMBIENT_LIGHT = 7,
+ /**
+ * X11 Display, sometimes used for hwdec. Valid for
+ * mpv_render_context_create().
+ * Type: Display*
+ */
+ MPV_RENDER_PARAM_X11_DISPLAY = 8,
+ /**
+ * Wayland display, sometimes used for hwdec. Valid for
+ * mpv_render_context_create().
+ * Type: struct wl_display*
+ */
+ MPV_RENDER_PARAM_WL_DISPLAY = 9,
} mpv_render_param_type;
/**
diff --git a/libmpv/render_gl.h b/libmpv/render_gl.h
index 01c09e80df..a4872a066b 100644
--- a/libmpv/render_gl.h
+++ b/libmpv/render_gl.h
@@ -88,8 +88,9 @@ extern "C" {
* There may be certain requirements on the OpenGL implementation:
*
* - Windows: ANGLE is required (although in theory GL/DX interop could be used)
- * - Intel/Linux: EGL is required, and also a glMPGetNativeDisplay() callback
- * must be provided (see sections below)
+ * - Intel/Linux: EGL is required, and also the native display resource needs
+ * to be provided (e.g. MPV_RENDER_PARAM_X11_DISPLAY for X11 and
+ * MPV_RENDER_PARAM_WL_DISPLAY for Wayland)
* - nVidia/Linux: Both GLX and EGL should work (GLX is required if vdpau is
* used, e.g. due to old drivers.)
* - OSX: CGL is required (CGLGetCurrentContext() returning non-NULL)
@@ -118,9 +119,7 @@ typedef struct mpv_opengl_init_params {
*/
void *get_proc_address_ctx;
/**
- * This should not be used. The main purpose is signaling support for
- * "GL_MP_MPGetNativeDisplay", which is needed for compatibility with the
- * opengl_cb API only. Thus it's deprecated and will be removed or ignored
+ * This should not be used. It is deprecated and will be removed or ignored
* when the opengl_cb API is removed.
*/
const char *extra_exts;
diff --git a/player/client.c b/player/client.c
index 3bad543c98..c6803806c9 100644
--- a/player/client.c
+++ b/player/client.c
@@ -1829,6 +1829,9 @@ int mpv_opengl_cb_init_gl(mpv_opengl_cb_context *ctx, const char *exts,
.get_proc_address_ctx = get_proc_address_ctx,
.extra_exts = exts,
}},
+ // Hack for explicit legacy hwdec loading. We really want to make it
+ // impossible for proper render API users to trigger this.
+ {(mpv_render_param_type)-1, ctx->client_api->mpctx->global},
{0}
};
int err = mpv_render_context_create(&ctx->client_api->render_context,
diff --git a/video/out/gpu/libmpv_gpu.c b/video/out/gpu/libmpv_gpu.c
index bd597c302a..cc0ff85376 100644
--- a/video/out/gpu/libmpv_gpu.c
+++ b/video/out/gpu/libmpv_gpu.c
@@ -17,6 +17,11 @@ struct priv {
struct gl_video *renderer;
};
+static const char *const native_resource_map[] = {
+ [MPV_RENDER_PARAM_X11_DISPLAY] = "x11",
+ [MPV_RENDER_PARAM_WL_DISPLAY] = "wl",
+};
+
static int init(struct render_backend *ctx, mpv_render_param *params)
{
ctx->priv = talloc_zero(NULL, struct priv);
@@ -46,6 +51,16 @@ static int init(struct render_backend *ctx, mpv_render_param *params)
if (err < 0)
return err;
+ for (int n = 0; params && params[n].type; n++) {
+ if (params[n].type > 0 &&
+ params[n].type < MP_ARRAY_SIZE(native_resource_map) &&
+ native_resource_map[params[n].type])
+ {
+ ra_add_native_resource(p->context->ra,
+ native_resource_map[params[n].type], params[n].data);
+ }
+ }
+
p->renderer = gl_video_init(p->context->ra, ctx->log, ctx->global);
ctx->hwdec_devs = hwdec_devices_create();
diff --git a/video/out/gpu/libmpv_gpu.h b/video/out/gpu/libmpv_gpu.h
index 5b41116f14..2c9f712fce 100644
--- a/video/out/gpu/libmpv_gpu.h
+++ b/video/out/gpu/libmpv_gpu.h
@@ -2,6 +2,8 @@
#include "video/out/libmpv.h"
+struct ra_tex;
+
struct libmpv_gpu_context {
struct mpv_global *global;
struct mp_log *log;
diff --git a/video/out/gpu/ra.c b/video/out/gpu/ra.c
index fdb20fe1d5..0c1565149f 100644
--- a/video/out/gpu/ra.c
+++ b/video/out/gpu/ra.c
@@ -4,6 +4,26 @@
#include "ra.h"
+void ra_add_native_resource(struct ra *ra, const char *name, void *data)
+{
+ struct ra_native_resource r = {
+ .name = name,
+ .data = data,
+ };
+ MP_TARRAY_APPEND(ra, ra->native_resources, ra->num_native_resources, r);
+}
+
+void *ra_get_native_resource(struct ra *ra, const char *name)
+{
+ for (int n = 0; n < ra->num_native_resources; n++) {
+ struct ra_native_resource *r = &ra->native_resources[n];
+ if (strcmp(r->name, name) == 0)
+ return r->data;
+ }
+
+ return NULL;
+}
+
struct ra_tex *ra_tex_create(struct ra *ra, const struct ra_tex_params *params)
{
return ra->fns->tex_create(ra, params);
diff --git a/video/out/gpu/ra.h b/video/out/gpu/ra.h
index 05a7c54a66..79caacc919 100644
--- a/video/out/gpu/ra.h
+++ b/video/out/gpu/ra.h
@@ -39,8 +39,29 @@ struct ra {
// RA_CAP_DIRECT_UPLOAD is supported. This is basically only relevant for
// OpenGL. Set by the RA user.
bool use_pbo;
+
+ // Array of native resources. For the most part an "escape" mechanism, and
+ // usually does not contain parameters required for basic functionality.
+ struct ra_native_resource *native_resources;
+ int num_native_resources;
+};
+
+// For passing through windowing system specific parameters and such. The
+// names are always internal (except for legacy opengl-cb uses; the libmpv
+// render API uses mpv_render_param_type and maps them to names internally).
+// For example, a name="x11" entry has a X11 display as (Display*)data.
+struct ra_native_resource {
+ const char *name;
+ void *data;
};
+// Add a ra_native_resource entry. Both name and data pointers must stay valid
+// until ra termination.
+void ra_add_native_resource(struct ra *ra, const char *name, void *data);
+
+// Search ra->native_resources, returns NULL on failure.
+void *ra_get_native_resource(struct ra *ra, const char *name);
+
enum {
RA_CAP_TEX_1D = 1 << 0, // supports 1D textures (as shader inputs)
RA_CAP_TEX_3D = 1 << 1, // supports 3D textures (as shader inputs)
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index fda40da43e..4b0cbcc1c4 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -453,6 +453,7 @@ static const struct gl_functions gl_functions[] = {
},
// These don't exist - they are for the sake of mpv internals, and libmpv
// interaction (see libmpv/opengl_cb.h).
+ // This is not used by the render API, only the deprecated opengl-cb API.
{
.extension = "GL_MP_MPGetNativeDisplay",
.functions = (const struct gl_function[]) {
@@ -664,13 +665,3 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
{
mpgl_load_functions2(gl, get_procaddr_wrapper, getProcAddress, ext2, log);
}
-
-void *mpgl_get_native_display(struct GL *gl, const char *name)
-{
- void *res = NULL;
- if (gl->get_native_display)
- res = gl->get_native_display(gl->get_native_display_ctx, name);
- if (!res && gl->MPGetNativeDisplay)
- res = gl->MPGetNativeDisplay(name);
- return res;
-}
diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h
index b9f582b79f..38414fe18b 100644
--- a/video/out/opengl/common.h
+++ b/video/out/opengl/common.h
@@ -78,9 +78,6 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n),
typedef void (GLAPIENTRY *MP_GLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum,
GLsizei, const GLchar *,const void *);
-// Return a named host API reference (e.g. "wl" -> wl_display).
-void *mpgl_get_native_display(struct GL *gl, const char *name);
-
//function pointers loaded from the OpenGL library
struct GL {
int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
@@ -90,11 +87,6 @@ struct GL {
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
- // Use mpgl_get_native_display() instead. Also, this is set to use the
- // fields in MPGLContext by default (if set).
- void *get_native_display_ctx;
- void *(*get_native_display)(void *ctx, const char *name);
-
void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY *Clear)(GLbitfield);
void (GLAPIENTRY *GenTextures)(GLsizei, GLuint *);
diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c
index 0bf8d7436e..43b57aa4ed 100644
--- a/video/out/opengl/context.c
+++ b/video/out/opengl/context.c
@@ -125,17 +125,6 @@ done:
return ret;
}
-static void *get_native_display(void *priv, const char *name)
-{
- struct priv *p = priv;
- if (!p->params.native_display_type || !name)
- return NULL;
- if (strcmp(p->params.native_display_type, name) != 0)
- return NULL;
-
- return p->params.native_display;
-}
-
void ra_gl_ctx_uninit(struct ra_ctx *ctx)
{
if (ctx->swapchain) {
@@ -191,8 +180,6 @@ bool ra_gl_ctx_init(struct ra_ctx *ctx, GL *gl, struct ra_gl_ctx_params params)
}
gl->debug_context = ctx->opts.debug;
- gl->get_native_display_ctx = p;
- gl->get_native_display = get_native_display;
if (gl->SwapInterval) {
gl->SwapInterval(p->opts->swapinterval);
diff --git a/video/out/opengl/context.h b/video/out/opengl/context.h
index 95ed374555..5fccc70033 100644
--- a/video/out/opengl/context.h
+++ b/video/out/opengl/context.h
@@ -34,10 +34,6 @@ struct ra_gl_ctx_params {
// ra_swapchain_fns structs will entirely replace the equivalent ra_gl_ctx
// functions in the resulting ra_swapchain.
const struct ra_swapchain_fns *external_swapchain;
-
- // For hwdec_vaegl.c:
- const char *native_display_type;
- void *native_display;
};
void ra_gl_ctx_uninit(struct ra_ctx *ctx);
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c
index c2585049fc..e56055bc97 100644
--- a/video/out/opengl/context_drm_egl.c
+++ b/video/out/opengl/context_drm_egl.c
@@ -555,14 +555,14 @@ static bool drm_egl_init(struct ra_ctx *ctx)
p->drm_params.atomic_request = p->kms->atomic_context->request;
struct ra_gl_ctx_params params = {
.swap_buffers = drm_egl_swap_buffers,
- .native_display_type = "opengl-cb-drm-params",
- .native_display = &p->drm_params,
.external_swapchain = p->kms->atomic_context ? &drm_atomic_swapchain :
NULL,
};
if (!ra_gl_ctx_init(ctx, &p->gl, params))
return false;
+ ra_add_native_resource(ctx->ra, "opengl-cb-drm-params", &p->drm_params);
+
return true;
}
diff --git a/video/out/opengl/context_dxinterop.c b/video/out/opengl/context_dxinterop.c
index 85d84bf677..2e65a8956e 100644
--- a/video/out/opengl/context_dxinterop.c
+++ b/video/out/opengl/context_dxinterop.c
@@ -481,20 +481,6 @@ static int GLAPIENTRY dxgl_swap_interval(int interval)
return 1;
}
-static void * GLAPIENTRY dxgl_get_native_display(const char *name)
-{
- if (!current_ctx || !name)
- return NULL;
- struct priv *p = current_ctx->priv;
-
- if (p->device && strcmp("IDirect3DDevice9Ex", name) == 0) {
- return p->device;
- } else if (p->device_h && strcmp("dxinterop_device_HANDLE", name) == 0) {
- return p->device_h;
- }
- return NULL;
-}
-
static void dxgl_swap_buffers(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv;
@@ -560,7 +546,6 @@ static bool dxgl_init(struct ra_ctx *ctx)
current_ctx = ctx;
gl->SwapInterval = dxgl_swap_interval;
- gl->MPGetNativeDisplay = dxgl_get_native_display;
if (d3d_create(ctx) < 0)
goto fail;
@@ -577,6 +562,9 @@ static bool dxgl_init(struct ra_ctx *ctx)
if (!ra_gl_ctx_init(ctx, gl, params))
goto fail;
+ ra_add_native_resource(ctx->ra, "IDirect3DDevice9Ex", p->device);
+ ra_add_native_resource(ctx->ra, "dxinterop_device_HANDLE", p->device_h);
+
DwmEnableMMCSS(TRUE);
return true;
fail:
diff --git a/video/out/opengl/context_rpi.c b/video/out/opengl/context_rpi.c
index 1b81e6a460..fbd9721b89 100644
--- a/video/out/opengl/context_rpi.c
+++ b/video/out/opengl/context_rpi.c
@@ -241,13 +241,13 @@ static bool rpi_init(struct ra_ctx *ctx)
struct ra_gl_ctx_params params = {
.swap_buffers = rpi_swap_buffers,
- .native_display_type = "MPV_RPI_WINDOW",
- .native_display = p->win_params,
};
if (!ra_gl_ctx_init(ctx, &p->gl, params))
goto fail;
+ ra_add_native_resource(ctx->ra, "MPV_RPI_WINDOW", p->win_params);
+
ra_gl_ctx_resize(ctx->swapchain, ctx->vo->dwidth, ctx->vo->dheight, 0);
return true;
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index f686fcc4cf..650072c73c 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -78,13 +78,13 @@ static bool egl_create_context(struct ra_ctx *ctx)
struct ra_gl_ctx_params params = {
.swap_buffers = wayland_egl_swap_buffers,
- .native_display_type = "wl",
- .native_display = wl->display,
};
if (!ra_gl_ctx_init(ctx, &p->gl, params))
return false;
+ ra_add_native_resource(ctx->ra, "wl", wl->display);
+
return true;
}
diff --git a/video/out/opengl/context_x11egl.c b/video/out/opengl/context_x11egl.c
index 7ab4fe0579..32530cc11d 100644
--- a/video/out/opengl/context_x11egl.c
+++ b/video/out/opengl/context_x11egl.c
@@ -142,13 +142,13 @@ static bool mpegl_init(struct ra_ctx *ctx)
struct ra_gl_ctx_params params = {
.swap_buffers = mpegl_swap_buffers,
- .native_display_type = "x11",
- .native_display = vo->x11->display,
};
if (!ra_gl_ctx_init(ctx, &p->gl, params))
goto uninit;
+ ra_add_native_resource(ctx->ra, "x11", vo->x11->display);
+
return true;
uninit:
diff --git a/video/out/opengl/hwdec_drmprime_drm.c b/video/out/opengl/hwdec_drmprime_drm.c
index b1d5e98c1f..422612287c 100644
--- a/video/out/opengl/hwdec_drmprime_drm.c
+++ b/video/out/opengl/hwdec_drmprime_drm.c
@@ -35,8 +35,6 @@
#include "video/out/gpu/hwdec.h"
#include "video/mp_image.h"
-#include "ra_gl.h"
-
extern const struct m_sub_options drm_conf;
struct drm_frame {
@@ -114,7 +112,6 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
struct mp_rect *src, struct mp_rect *dst, bool newframe)
{
struct priv *p = hw->priv;
- GL *gl = ra_gl_get(hw->ra);
AVDRMFrameDescriptor *desc = NULL;
drmModeAtomicReq *request = NULL;
struct drm_frame next_frame = {0};
@@ -125,8 +122,7 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
// grab opengl-cb windowing info to eventually upscale the overlay
// as egl windows could be upscaled to primary plane.
struct mpv_opengl_cb_window_pos *glparams =
- gl ? (struct mpv_opengl_cb_window_pos *)
- mpgl_get_native_display(gl, "opengl-cb-window-pos") : NULL;
+ ra_get_native_resource(hw->ra, "opengl-cb-window-pos");
if (glparams) {
scale_dst_rect(hw, glparams->width, glparams->height, dst, &p->dst);
} else {
@@ -136,8 +132,7 @@ static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
// grab drm interop info
struct mpv_opengl_cb_drm_params *drmparams =
- gl ? (struct mpv_opengl_cb_drm_params *)
- mpgl_get_native_display(gl, "opengl-cb-drm-params") : NULL;
+ ra_get_native_resource(hw->ra, "opengl-cb-drm-params");
if (drmparams)
request = (drmModeAtomicReq *)drmparams->atomic_request;
@@ -208,9 +203,6 @@ static int init(struct ra_hwdec *hw)
struct priv *p = hw->priv;
int drm_overlay;
- if (!ra_is_gl(hw->ra))
- return -1;
-
p->log = hw->log;
void *tmp = talloc_new(NULL);
@@ -218,10 +210,8 @@ static int init(struct ra_hwdec *hw)
drm_overlay = opts->drm_overlay_id;
talloc_free(tmp);
- GL *gl = ra_gl_get(hw->ra);
struct mpv_opengl_cb_drm_params *params =
- gl ? (struct mpv_opengl_cb_drm_params *)
- mpgl_get_native_display(gl, "opengl-cb-drm-params") : NULL;
+ ra_get_native_resource(hw->ra, "opengl-cb-drm-params");
if (!params) {
MP_VERBOSE(hw, "Could not get drm interop info.\n");
goto err;
diff --git a/video/out/opengl/hwdec_dxva2gldx.c b/video/out/opengl/hwdec_dxva2gldx.c
index 984fd7f098..bbf76b09b4 100644
--- a/video/out/opengl/hwdec_dxva2gldx.c
+++ b/video/out/opengl/hwdec_dxva2gldx.c
@@ -67,12 +67,12 @@ static int init(struct ra_hwdec *hw)
// AMD drivers won't open multiple dxinterop HANDLES on the same D3D device,
// so we request the one already in use by context_dxinterop
- p->device_h = mpgl_get_native_display(gl, "dxinterop_device_HANDLE");
+ p->device_h = ra_get_native_resource(hw->ra, "dxinterop_device_HANDLE");
if (!p->device_h)
return -1;
// But we also still need the actual D3D device
- p->device = mpgl_get_native_display(gl, "IDirect3DDevice9Ex");
+ p->device = ra_get_native_resource(hw->ra, "IDirect3DDevice9Ex");
if (!p->device)
return -1;
IDirect3DDevice9Ex_AddRef(p->device);
diff --git a/video/out/opengl/hwdec_rpi.c b/video/out/opengl/hwdec_rpi.c
index 6c080f1942..045fa75a35 100644
--- a/video/out/opengl/hwdec_rpi.c
+++ b/video/out/opengl/hwdec_rpi.c
@@ -36,7 +36,6 @@
#include "video/out/gpu/hwdec.h"
#include "common.h"
-#include "ra_gl.h"
struct priv {
struct mp_log *log;
@@ -126,13 +125,12 @@ static void disable_renderer(struct ra_hwdec *hw)
static void update_overlay(struct ra_hwdec *hw, bool check_window_only)
{
struct priv *p = hw->priv;
- GL *gl = ra_is_gl(hw->ra) ? ra_gl_get(hw->ra) : NULL;
MMAL_PORT_T *input = p->renderer->input[0];
struct mp_rect src = p->src;
struct mp_rect dst = p->dst;
int defs[4] = {0, 0, 0, 0};
- int *z = gl ? mpgl_get_native_display(gl, "MPV_RPI_WINDOW") : NULL;
+ int *z = ra_get_native_resource(hw->ra, "MPV_RPI_WINDOW");
if (!z)
z = defs;
diff --git a/video/out/opengl/hwdec_vaegl.c b/video/out/opengl/hwdec_vaegl.c
index b4587c5eb9..1620617c03 100644
--- a/video/out/opengl/hwdec_vaegl.c
+++ b/video/out/opengl/hwdec_vaegl.c
@@ -55,9 +55,9 @@ typedef void *EGLImageKHR;
#if HAVE_VAAPI_X11
#include <va/va_x11.h>
-static VADisplay *create_x11_va_display(GL *gl)
+static VADisplay *create_x11_va_display(struct ra *ra)
{
- Display *x11 = mpgl_get_native_display(gl, "x11");
+ Display *x11 = ra_get_native_resource(ra, "x11");
return x11 ? vaGetDisplay(x11) : NULL;
}
#endif
@@ -65,9 +65,9 @@ static VADisplay *create_x11_va_display(GL *gl)
#if HAVE_VAAPI_WAYLAND
#include <va/va_wayland.h>
-static VADisplay *create_wayland_va_display(GL *gl)
+static VADisplay *create_wayland_va_display(struct ra *ra)
{
- struct wl_display *wl = mpgl_get_native_display(gl, "wl");
+ struct wl_display *wl = ra_get_native_resource(ra, "wl");
return wl ? vaGetDisplayWl(wl) : NULL;
}
#endif
@@ -75,9 +75,9 @@ static VADisplay *create_wayland_va_display(GL *gl)
#if HAVE_VAAPI_DRM
#include <va/va_drm.h>
-static VADisplay *create_drm_va_display(GL *gl)
+static VADisplay *create_drm_va_display(struct ra *ra)
{
- int drm_fd = (intptr_t)mpgl_get_native_display(gl, "drm");
+ int drm_fd = (intptr_t)ra_get_native_resource(ra, "drm");
// Note: yes, drm_fd==0 could be valid - but it's rare and doesn't fit with
// our slightly crappy way of passing it through, so consider 0 not
// valid.
@@ -87,7 +87,7 @@ static VADisplay *create_drm_va_display(GL *gl)
struct va_create_native {
const char *name;
- VADisplay *(*create)(GL *gl);
+ VADisplay *(*create)(struct ra *ra);
};
static const struct va_create_native create_native_cbs[] = {
@@ -102,12 +102,12 @@ static const struct va_create_native create_native_cbs[] = {
#endif
};
-static VADisplay *create_native_va_display(GL *gl, struct mp_log *log)
+static VADisplay *create_native_va_display(struct ra *ra, struct mp_log *log)
{
for (int n = 0; n < MP_ARRAY_SIZE(create_native_cbs); n++) {
const struct va_create_native *disp = &create_native_cbs[n];
mp_verbose(log, "Trying to open a %s VA display...\n", disp->name);
- VADisplay *display = disp->create(gl);
+ VADisplay *display = disp->create(ra);
if (display)
return display;
}
@@ -169,7 +169,7 @@ static int init(struct ra_hwdec *hw)
!(gl->mpgl_caps & MPGL_CAP_TEX_RG))
return -1;
- p->display = create_native_va_display(gl, hw->log);
+ p->display = create_native_va_display(hw->ra, hw->log);
if (!p->display) {
MP_VERBOSE(hw, "Could not create a VA display.\n");
return -1;
diff --git a/video/out/opengl/libmpv_gl.c b/video/out/opengl/libmpv_gl.c
index 5278d6f51a..ae6ec66ca4 100644
--- a/video/out/opengl/libmpv_gl.c
+++ b/video/out/opengl/libmpv_gl.c
@@ -62,6 +62,19 @@ static int init(struct libmpv_gpu_context *ctx, mpv_render_param *params)
ra_gl_set_debug(p->ra_ctx->ra, debug);
ctx->ra = p->ra_ctx->ra;
+
+ // Legacy API user loading for opengl-cb. Explicitly inactive for render API.
+ if (get_mpv_render_param(params, (mpv_render_param_type)-1, NULL) ==
+ ctx->global && p->gl->MPGetNativeDisplay)
+ {
+ void *x11 = p->gl->MPGetNativeDisplay("x11");
+ if (x11)
+ ra_add_native_resource(ctx->ra, "x11", x11);
+ void *wl = p->gl->MPGetNativeDisplay("wl");
+ if (wl)
+ ra_add_native_resource(ctx->ra, "wl", wl);
+ }
+
return 0;
}