1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-11 17:37:23 +00:00

vo_gpu/d3d11: mimic libplacebo backbuffer usage

Instead of always having the reference outside of calling resize,
request a backbuffer at start and relieve the backbuffer at
submission for presentation.
This commit is contained in:
Jan Ekström 2022-04-03 19:10:34 +03:00
parent 6102d2bd78
commit 4b8e3f20bc

View File

@ -166,7 +166,10 @@ static bool resize(struct ra_ctx *ctx)
struct priv *p = ctx->priv;
HRESULT hr;
ra_tex_free(ctx->ra, &p->backbuffer);
if (p->backbuffer) {
MP_ERR(ctx, "Attempt at resizing while a frame was in progress!\n");
return false;
}
hr = IDXGISwapChain_ResizeBuffers(p->swapchain, 0, ctx->vo->dwidth,
ctx->vo->dheight, DXGI_FORMAT_UNKNOWN, 0);
@ -175,8 +178,6 @@ static bool resize(struct ra_ctx *ctx)
return false;
}
p->backbuffer = get_backbuffer(ctx);
return true;
}
@ -213,6 +214,9 @@ static bool d3d11_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo)
if (!out_fbo)
return true;
assert(!p->backbuffer);
p->backbuffer = get_backbuffer(sw->ctx);
if (!p->backbuffer)
return false;
@ -227,7 +231,10 @@ static bool d3d11_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo)
static bool d3d11_submit_frame(struct ra_swapchain *sw,
const struct vo_frame *frame)
{
struct priv *p = sw->priv;
ra_d3d11_flush(sw->ctx->ra);
ra_tex_free(sw->ctx->ra, &p->backbuffer);
return true;
}
@ -526,10 +533,6 @@ static bool d3d11_init(struct ra_ctx *ctx)
if (!mp_d3d11_create_swapchain(p->device, ctx->log, &scopts, &p->swapchain))
goto error;
p->backbuffer = get_backbuffer(ctx);
if (!p->backbuffer)
goto error;
return true;
error: