Skip to content

Commit

Permalink
vo_gpu: d3d11: check for NULL backbuffer in start_frame
Browse files Browse the repository at this point in the history
In a lost device scenario, resize() will fail and p->backbuffer will be
NULL. We can't recover from lost devices yet, but we should still check
for a NULL backbuffer in start_frame() rather than crashing.

Also remove a NULL check for p->swapchain. This was a red herring, since
p->swapchain never becomes NULL in an error condition, but p->backbuffer
actually does.

This should fix the crash in mpv-player#5320, but it doesn't fix the underlying
reason for the lost device (which is probably a driver bug.)
  • Loading branch information
rossy committed Jan 4, 2018
1 parent baa18f7 commit a9a4d63
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions video/out/d3d11/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ struct priv {
static struct mp_image *d3d11_screenshot(struct ra_swapchain *sw)
{
struct priv *p = sw->ctx->priv;
if (!p->swapchain)
return NULL;
return mp_d3d11_screenshot(p->swapchain);
}

Expand Down Expand Up @@ -131,6 +129,10 @@ static int d3d11_color_depth(struct ra_swapchain *sw)
static bool d3d11_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo)
{
struct priv *p = sw->priv;

if (!p->backbuffer)
return false;

*out_fbo = (struct ra_fbo) {
.tex = p->backbuffer,
.flip = false,
Expand Down Expand Up @@ -226,6 +228,8 @@ static bool d3d11_init(struct ra_ctx *ctx)
goto error;

p->backbuffer = get_backbuffer(ctx);
if (!p->backbuffer)
goto error;

return true;

Expand Down

0 comments on commit a9a4d63

Please sign in to comment.