summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2023-12-20 23:05:31 -0500
committerDudemanguy <random342@airmail.cc>2024-01-20 17:12:07 +0000
commita0ba10b62e75329d1c707d9f95052c8c66323ac7 (patch)
treebffb7c9583fbb4fa5a20a828df29f79c9e8fa271
parent700f72f8e424486633b1c8da9313182e63072592 (diff)
downloadmpv-a0ba10b62e75329d1c707d9f95052c8c66323ac7.tar.bz2
mpv-a0ba10b62e75329d1c707d9f95052c8c66323ac7.tar.xz
command: export current-gpu-context property
This exports `current-gpu-context` property, which is the string description of the current active GPU context. This allows scripts to uniquely identify the platform and backend used for --vo=gpu and --vo=gpu-next.
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/input.rst4
-rw-r--r--player/command.c8
-rw-r--r--video/out/gpu/context.c1
-rw-r--r--video/out/vo.h3
5 files changed, 17 insertions, 0 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 20084d53f4..d5742d900c 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -28,6 +28,7 @@ Interface changes
--- mpv 0.38.0 ---
- add `--volume-gain`, `--volume-gain-min`, and `--volume-gain-max` options
+ - add `current-gpu-context` property
- add `--secondary-sub-ass-override` option
- remove shared-script-properties (user-data is a replacement)
- add `--secondary-sub-delay`, decouple secondary subtitles from
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 1abdfd416e..490c946f19 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -3332,6 +3332,10 @@ Property list
``current-vo``
Current video output driver (name as used with ``--vo``).
+``current-gpu-context``
+ Current GPU context of video output driver (name as used with ``--gpu-context``).
+ Valid for ``--vo=gpu`` and ``--vo=gpu-next``.
+
``current-ao``
Current audio output driver (name as used with ``--ao``).
diff --git a/player/command.c b/player/command.c
index 9fb420fe00..27a06d46e3 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2766,6 +2766,13 @@ static int mp_property_vo(void *ctx, struct m_property *p, int action, void *arg
mpctx->video_out ? mpctx->video_out->driver->name : NULL);
}
+static int mp_property_gpu_context(void *ctx, struct m_property *p, int action, void *arg)
+{
+ MPContext *mpctx = ctx;
+ return m_property_strdup_ro(action, arg,
+ mpctx->video_out ? mpctx->video_out->context_name : NULL);
+}
+
static int mp_property_osd_dim(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -3923,6 +3930,7 @@ static const struct m_property mp_properties_base[] = {
{"vo-passes", mp_property_vo_passes},
{"perf-info", mp_property_perf_info},
{"current-vo", mp_property_vo},
+ {"current-gpu-context", mp_property_gpu_context},
{"container-fps", mp_property_fps},
{"estimated-vf-fps", mp_property_vf_fps},
{"video-aspect-override", mp_property_video_aspect_override},
diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c
index 5ce18afbe2..41ec2a4107 100644
--- a/video/out/gpu/context.c
+++ b/video/out/gpu/context.c
@@ -208,6 +208,7 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, struct ra_ctx_opts opts)
MP_VERBOSE(ctx, "Initializing GPU context '%s'\n", ctx->fns->name);
if (contexts[i]->init(ctx)) {
vo->probing = old_probing;
+ vo->context_name = ctx->fns->name;
return ctx;
}
diff --git a/video/out/vo.h b/video/out/vo.h
index 40c5746992..e9e2f02901 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -494,6 +494,9 @@ struct vo {
int dwidth;
int dheight;
float monitor_par;
+
+ // current GPU context (--vo=gpu and --vo=gpu-next only)
+ const char *context_name;
};
struct mpv_global;