summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-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
18 files changed, 99 insertions, 86 deletions
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;
}