From 4b0f2d1a2b30e5a288f909683203bfa3bbfacf50 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 29 Jan 2025 08:46:24 -0500 Subject: [PATCH] zink: refcount needs_present resource it's theoretically possible that this resource could be destroyed between flush_resource and flush...maybe Part-of: --- src/gallium/drivers/zink/zink_context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index fa5738b624e..51f70f8753c 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -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)