zink: refcount needs_present resource

it's theoretically possible that this resource could be destroyed
between flush_resource and flush...maybe

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33285>
This commit is contained in:
Mike Blumenkrantz 2025-01-29 08:46:24 -05:00 committed by Marge Bot
parent c1e09c7309
commit 4b0f2d1a2b

View file

@ -3766,7 +3766,7 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
ctx->rp_changed |= !!zink_transient_surface(psurf) != !!zink_transient_surface(state->cbufs[i]);
unbind_fb_surface(ctx, psurf, i, i >= state->nr_cbufs || psurf != state->cbufs[i]);
if (psurf && ctx->needs_present == zink_resource(psurf->texture))
ctx->needs_present = NULL;
zink_resource_reference(&ctx->needs_present, NULL);
}
if (ctx->fb_state.zsbuf) {
struct pipe_surface *psurf = ctx->fb_state.zsbuf;
@ -4008,7 +4008,7 @@ zink_flush(struct pipe_context *pctx,
zink_kopper_readback_update(ctx, ctx->needs_present);
screen->image_barrier(ctx, ctx->needs_present, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, 0, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
}
ctx->needs_present = NULL;
zink_resource_reference(&ctx->needs_present, NULL);
}
if (flags & PIPE_FLUSH_FENCE_FD) {
@ -4296,7 +4296,7 @@ zink_flush_resource(struct pipe_context *pctx,
zink_screen(ctx->base.screen)->image_barrier(ctx, res, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, 0, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT);
zink_batch_reference_resource_rw(ctx, res, true);
} else {
ctx->needs_present = res;
zink_resource_reference(&ctx->needs_present, res);
}
ctx->swapchain = res;
} else if (res->dmabuf)