From 3c4b8433dc5df1206a8c76e820f8fe01c1b72998 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Thu, 20 Jan 2022 22:34:45 +1100 Subject: [PATCH] vo_gpu/d3d11: add more usage flags to the swapchain images vo_gpu_next and libplacebo expect swapchain images to be able to be blitted to, which for libplacebo on FL11_0 and up means they have to have DXGI_USAGE_UNORDERED_ACCESS, since libplacebo uses a compute shader to emulate certain kinds of blits. For libplacebo's benefit, set all applicable usage flags on swapchain images. --- video/out/d3d11/context.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index 3d4bf165fd..72e3447788 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -492,6 +492,13 @@ static bool d3d11_init(struct ra_ctx *ctx) if (!vo_w32_init(ctx->vo)) goto error; + 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) + { + usage |= DXGI_USAGE_UNORDERED_ACCESS; + } + struct d3d11_swapchain_opts scopts = { .window = vo_w32_hwnd(ctx->vo), .width = ctx->vo->dwidth, @@ -503,7 +510,7 @@ static bool d3d11_init(struct ra_ctx *ctx) // Add one frame for the backbuffer and one frame of "slack" to reduce // contention with the window manager when acquiring the backbuffer .length = ctx->vo->opts->swapchain_depth + 2, - .usage = DXGI_USAGE_RENDER_TARGET_OUTPUT, + .usage = usage, }; if (!mp_d3d11_create_swapchain(p->device, ctx->log, &scopts, &p->swapchain)) goto error;