summaryrefslogtreecommitdiffstats
path: root/video/out/gpu/libmpv_gpu.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-02-20 13:30:18 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-28 00:55:06 -0800
commitb03712143012f08591de59d09675fdd3a0eaeed8 (patch)
tree34bdfe31802573c1452dcbe023610acad3f1b5a9 /video/out/gpu/libmpv_gpu.h
parente76fda8594a7fa19888260c86d95396c5e799cad (diff)
downloadmpv-b03712143012f08591de59d09675fdd3a0eaeed8.tar.bz2
mpv-b03712143012f08591de59d09675fdd3a0eaeed8.tar.xz
client API: deprecate opengl-cb API and introduce a replacement API
The purpose of the new API is to make it useable with other APIs than OpenGL, especially D3D11 and vulkan. In theory it's now possible to support other vo_gpu backends, as well as backends that don't use the vo_gpu code at all. This also aims to get rid of the dumb mpv_get_sub_api() function. The life cycle of the new mpv_render_context is a bit different from mpv_opengl_cb_context, and you explicitly create/destroy the new context, instead of calling init/uninit on an object returned by mpv_get_sub_api(). In other to make the render API generic, it's annoyingly EGL style, and requires you to pass in API-specific objects to generic functions. This is to avoid explicit objects like the internal ra API has, because that sounds more complicated and annoying for an API that's supposed to never change. The opengl_cb API will continue to exist for a bit longer, but internally there are already a few tradeoffs, like reduced thread-safety. Mostly untested. Seems to work fine with mpc-qt.
Diffstat (limited to 'video/out/gpu/libmpv_gpu.h')
-rw-r--r--video/out/gpu/libmpv_gpu.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/video/out/gpu/libmpv_gpu.h b/video/out/gpu/libmpv_gpu.h
new file mode 100644
index 0000000000..5b41116f14
--- /dev/null
+++ b/video/out/gpu/libmpv_gpu.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include "video/out/libmpv.h"
+
+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;