mirror of
https://github.com/mpv-player/mpv
synced 2024-12-26 00:42:57 +00:00
52dd38a48a
Hardware decoding things often need access to additional handles from the windowing system, such as the X11 or Wayland display when using vaapi. The opengl-cb had nothing dedicated for this, and used the weird GL_MP_MPGetNativeDisplay GL extension (which was mpv specific and not officially registered with OpenGL). This was awkward, and a pain due to having to emulate GL context behavior (like needing a TLS variable to store context for the pseudo GL extension function). In addition (and not inherently due to this), we could pass only one resource from mpv builtin context backends to hwdecs. It was also all GL specific. Replace this with a newer mechanism. It works for all RA backends, not just GL. the API user can explicitly pass the objects at init time via mpv_render_context_create(). Multiple resources are naturally possible. The API uses MPV_RENDER_PARAM_* defines, but internally we use strings. This is done for 2 reasons: 1. trying to leave libmpv and internal mechanisms decoupled, 2. not having to add public API for some of the internal resource types (especially D3D/GL interop stuff). To remain sane, drop support for obscure half-working opengl-cb things, like the DRM interop (was missing necessary things), the RPI window thing (nobody used it), and obscure D3D interop things (not needed with ANGLE, others were undocumented). In order not to break ABI and the C API, we don't remove the associated structs from opengl_cb.h. The parts which are still needed (in particular DRM interop) needs to be ported to the render API.
41 lines
1.6 KiB
C
41 lines
1.6 KiB
C
#pragma once
|
|
|
|
#include "video/out/libmpv.h"
|
|
|
|
struct ra_tex;
|
|
|
|
struct libmpv_gpu_context {
|
|
struct mpv_global *global;
|
|
struct mp_log *log;
|
|
const struct libmpv_gpu_context_fns *fns;
|
|
|
|
struct ra *ra;
|
|
void *priv;
|
|
};
|
|
|
|
// Manage backend specific interaction between libmpv and ra backend, that can't
|
|
// be managed by ra itself (initialization and passing FBOs).
|
|
struct libmpv_gpu_context_fns {
|
|
// The libmpv API type name, see MPV_RENDER_PARAM_API_TYPE.
|
|
const char *api_name;
|
|
// Pretty much works like render_backend_fns.init, except that the
|
|
// API type is already checked by the caller.
|
|
// Successful init must set ctx->ra.
|
|
int (*init)(struct libmpv_gpu_context *ctx, mpv_render_param *params);
|
|
// Wrap the surface passed to mpv_render_context_render() (via the params
|
|
// array) into a ra_tex and return it. Returns a libmpv error code, and sets
|
|
// *out to a temporary object on success. The returned object is valid until
|
|
// another wrap_fbo() or done_frame() is called.
|
|
// This does not need to care about generic attributes, like flipping.
|
|
int (*wrap_fbo)(struct libmpv_gpu_context *ctx, mpv_render_param *params,
|
|
struct ra_tex **out);
|
|
// Signal that the ra_tex object obtained with wrap_fbo is no longer used.
|
|
// For certain backends, this might also be used to signal the end of
|
|
// rendering (like OpenGL doing weird crap).
|
|
void (*done_frame)(struct libmpv_gpu_context *ctx, bool ds);
|
|
// Free all data in ctx->priv.
|
|
void (*destroy)(struct libmpv_gpu_context *ctx);
|
|
};
|
|
|
|
extern const struct libmpv_gpu_context_fns libmpv_gpu_context_gl;
|