summaryrefslogtreecommitdiffstats
path: root/video/out/d3d11
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:13:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:13:14 +0000
commit5a3b54c78ce63d899f76dbb3db72e4894b40bd53 (patch)
tree50693d13eeefc4d683bdf5417f0861b0ef274a0c /video/out/d3d11
parentAdding debian version 0.37.0-1. (diff)
downloadmpv-5a3b54c78ce63d899f76dbb3db72e4894b40bd53.tar.xz
mpv-5a3b54c78ce63d899f76dbb3db72e4894b40bd53.zip
Merging upstream version 0.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'video/out/d3d11')
-rw-r--r--video/out/d3d11/context.c75
-rw-r--r--video/out/d3d11/context.h4
2 files changed, 36 insertions, 43 deletions
diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c
index 05f04fd..c563b5f 100644
--- a/video/out/d3d11/context.c
+++ b/video/out/d3d11/context.c
@@ -27,10 +27,6 @@
#include "context.h"
#include "ra_d3d11.h"
-static int d3d11_validate_adapter(struct mp_log *log,
- const struct m_option *opt,
- struct bstr name, const char **value);
-
struct d3d11_opts {
int feature_level;
int warp;
@@ -62,7 +58,7 @@ const struct m_sub_options d3d11_conf = {
{"d3d11-flip", OPT_BOOL(flip)},
{"d3d11-sync-interval", OPT_INT(sync_interval), M_RANGE(0, 4)},
{"d3d11-adapter", OPT_STRING_VALIDATE(adapter_name,
- d3d11_validate_adapter)},
+ mp_dxgi_validate_adapter)},
{"d3d11-output-format", OPT_CHOICE(output_format,
{"auto", DXGI_FORMAT_UNKNOWN},
{"rgba8", DXGI_FORMAT_R8G8B8A8_UNORM},
@@ -100,7 +96,7 @@ struct priv {
struct ra_tex *backbuffer;
ID3D11Device *device;
IDXGISwapChain *swapchain;
- struct mp_colorspace swapchain_csp;
+ struct pl_color_space swapchain_csp;
int64_t perf_freq;
unsigned sync_refresh_count;
@@ -109,37 +105,6 @@ struct priv {
int64_t last_submit_qpc;
};
-static int d3d11_validate_adapter(struct mp_log *log,
- const struct m_option *opt,
- struct bstr name, const char **value)
-{
- struct bstr param = bstr0(*value);
- bool help = bstr_equals0(param, "help");
- bool adapter_matched = false;
- struct bstr listing = { 0 };
-
- if (bstr_equals0(param, "")) {
- return 0;
- }
-
- adapter_matched = mp_d3d11_list_or_verify_adapters(log,
- help ? bstr0(NULL) : param,
- help ? &listing : NULL);
-
- if (help) {
- mp_info(log, "Available D3D11 adapters:\n%.*s",
- BSTR_P(listing));
- talloc_free(listing.start);
- return M_OPT_EXIT;
- }
-
- if (!adapter_matched) {
- mp_err(log, "No adapter matching '%.*s'!\n", BSTR_P(param));
- }
-
- return adapter_matched ? 0 : M_OPT_INVALID;
-}
-
static struct ra_tex *get_backbuffer(struct ra_ctx *ctx)
{
struct priv *p = ctx->priv;
@@ -189,6 +154,11 @@ static bool d3d11_reconfig(struct ra_ctx *ctx)
static int d3d11_color_depth(struct ra_swapchain *sw)
{
struct priv *p = sw->priv;
+
+ DXGI_OUTPUT_DESC1 desc1;
+ if (mp_get_dxgi_output_desc(p->swapchain, &desc1))
+ return desc1.BitsPerColor;
+
DXGI_SWAP_CHAIN_DESC desc;
HRESULT hr = IDXGISwapChain_GetDesc(p->swapchain, &desc);
@@ -514,6 +484,9 @@ static bool d3d11_init(struct ra_ctx *ctx)
if (!vo_w32_init(ctx->vo))
goto error;
+ if (ctx->opts.want_alpha)
+ vo_w32_set_transparency(ctx->vo, ctx->opts.want_alpha);
+
UINT usage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT;
if (ID3D11Device_GetFeatureLevel(p->device) >= D3D_FEATURE_LEVEL_11_0 &&
p->opts->output_format != DXGI_FORMAT_B8G8R8A8_UNORM)
@@ -544,6 +517,11 @@ error:
return false;
}
+static void d3d11_update_render_opts(struct ra_ctx *ctx)
+{
+ vo_w32_set_transparency(ctx->vo, ctx->opts.want_alpha);
+}
+
IDXGISwapChain *ra_d3d11_ctx_get_swapchain(struct ra_ctx *ra)
{
if (ra->swapchain->fns != &d3d11_swapchain)
@@ -556,11 +534,22 @@ IDXGISwapChain *ra_d3d11_ctx_get_swapchain(struct ra_ctx *ra)
return p->swapchain;
}
+bool ra_d3d11_ctx_prefer_8bit_output_format(struct ra_ctx *ra)
+{
+ if (ra->swapchain->fns != &d3d11_swapchain)
+ return false;
+
+ struct priv *p = ra->priv;
+
+ return p->opts->output_format == DXGI_FORMAT_R8G8B8A8_UNORM;
+}
+
const struct ra_ctx_fns ra_ctx_d3d11 = {
- .type = "d3d11",
- .name = "d3d11",
- .reconfig = d3d11_reconfig,
- .control = d3d11_control,
- .init = d3d11_init,
- .uninit = d3d11_uninit,
+ .type = "d3d11",
+ .name = "d3d11",
+ .reconfig = d3d11_reconfig,
+ .control = d3d11_control,
+ .update_render_opts = d3d11_update_render_opts,
+ .init = d3d11_init,
+ .uninit = d3d11_uninit,
};
diff --git a/video/out/d3d11/context.h b/video/out/d3d11/context.h
index 8a9ef4c..25488f2 100644
--- a/video/out/d3d11/context.h
+++ b/video/out/d3d11/context.h
@@ -7,3 +7,7 @@
// Get the underlying D3D11 swap chain from an RA context. The returned swap chain is
// refcounted and must be released by the caller.
IDXGISwapChain *ra_d3d11_ctx_get_swapchain(struct ra_ctx *ra);
+
+// Returns true if an 8-bit output format is explicitly requested for
+// d3d11-output-format for an RA context.
+bool ra_d3d11_ctx_prefer_8bit_output_format(struct ra_ctx *ra);