Skip to content

Commit 0bbcc91

Browse files
ikas-mckasper93
authored andcommitted
video/out/d3d11: add changing size support for composition mode
1 parent 764da99 commit 0bbcc91

File tree

8 files changed

+38
-2
lines changed

8 files changed

+38
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add `--d3d11-output-mode` enable use specific output mode for creating the D3D11 swapchain.
2+
add `--d3d11-composition-size=<WxH>` support for d3d11 composition mode.

DOCS/man/options.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6937,6 +6937,13 @@ them.
69376937

69386938
Android with ``--gpu-context=android`` only.
69396939

6940+
``--d3d11-composition-size=<WxH>``
6941+
Set size of the output for d3d11 composition mode.
6942+
When use composition mode, there is no window, must set the output size by
6943+
the embedding application.
6944+
6945+
Windows with ``--gpu-context=d3d11`` and ``--d3d11-output-mode=composition`` only.
6946+
69406947
``--gpu-sw``
69416948
Continue even if a software renderer is detected. This only works with
69426949
OpenGL/Vulkan backends. For d3d11, see ``--d3d11-warp``.

options/options.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ static const m_option_t mp_vo_opt_list[] = {
244244
#endif
245245
#if HAVE_EGL_ANDROID
246246
{"android-surface-size", OPT_SIZE_BOX(android_surface_size)},
247+
#endif
248+
#if HAVE_D3D11
249+
{"d3d11-composition-size", OPT_SIZE_BOX(d3d11_composition_size)},
247250
#endif
248251
{"swapchain-depth", OPT_INT(swapchain_depth), M_RANGE(1, VO_MAX_SWAPCHAIN_DEPTH)},
249252
{"override-display-fps", OPT_REPLACED("display-fps-override")},

options/options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ typedef struct mp_vo_opts {
8686

8787
struct m_geometry android_surface_size;
8888

89+
struct m_geometry d3d11_composition_size;
90+
8991
int swapchain_depth; // max number of images to render ahead
9092

9193
struct m_geometry video_crop;

player/command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7999,7 +7999,7 @@ void mp_option_run_callback(struct MPContext *mpctx, struct mp_option_callback *
79997999
queue_seek(mpctx, MPSEEK_RELATIVE, 0.0, MPSEEK_EXACT, 0);
80008000
}
80018001

8002-
if (opt_ptr == &opts->vo->android_surface_size) {
8002+
if (opt_ptr == &opts->vo->android_surface_size || opt_ptr == &opts->vo->d3d11_composition_size) {
80038003
if (mpctx->video_out)
80048004
vo_control(mpctx->video_out, VOCTRL_EXTERNAL_RESIZE, NULL);
80058005
}

video/out/d3d11/context.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ static bool resize(struct ra_ctx *ctx)
167167

168168
static bool d3d11_reconfig(struct ra_ctx *ctx)
169169
{
170-
if (!ctx->opts.composition)
170+
if (ctx->opts.composition) {
171+
vo_w32_composition_size(ctx->vo);
172+
} else {
171173
vo_w32_config(ctx->vo);
174+
}
172175
return resize(ctx);
173176
}
174177

@@ -524,6 +527,9 @@ static bool d3d11_init(struct ra_ctx *ctx)
524527
if (!ctx->opts.composition && !vo_w32_init(ctx->vo))
525528
goto error;
526529

530+
if (ctx->opts.composition && !vo_w32_composition_size(ctx->vo))
531+
goto error;
532+
527533
if (!ctx->opts.composition && ctx->opts.want_alpha)
528534
vo_w32_set_transparency(ctx->vo, ctx->opts.want_alpha);
529535

video/out/w32_common.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,22 @@ void vo_w32_swapchain(struct vo *vo, void *swapchain)
25442544
vo->display_swapchain = swapchain;
25452545
}
25462546

2547+
bool vo_w32_composition_size(struct vo *vo)
2548+
{
2549+
int w = vo->opts->d3d11_composition_size.w;
2550+
int h = vo->opts->d3d11_composition_size.h;
2551+
2552+
if (w <= 0 || h <= 0) {
2553+
MP_ERR(vo, "Failed to get height and width!\n");
2554+
return false;
2555+
}
2556+
2557+
vo->dwidth = w;
2558+
vo->dheight = h;
2559+
2560+
return true;
2561+
}
2562+
25472563
void vo_w32_run_on_thread(struct vo *vo, void (*cb)(void *ctx), void *ctx)
25482564
{
25492565
struct vo_w32_state *w32 = vo->w32;

video/out/w32_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ int vo_w32_control(struct vo *vo, int *events, int request, void *arg);
3232
void vo_w32_config(struct vo *vo);
3333
HWND vo_w32_hwnd(struct vo *vo);
3434
void vo_w32_swapchain(struct vo *vo, void *swapchain);
35+
bool vo_w32_composition_size(struct vo *vo);
3536
void vo_w32_run_on_thread(struct vo *vo, void (*cb)(void *ctx), void *ctx);
3637
void vo_w32_set_transparency(struct vo *vo, bool enable);
3738

0 commit comments

Comments
 (0)