From 5c5ab9e173cb0fafca4f03c6f9a3a657f6f59a4f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 21 Jun 2022 16:25:32 -0400 Subject: [PATCH] zink: delete zink_resource_object::acquire this was duplicated from the swapchain object for convenience, but really it just leads to desync if a swapchain is shared, so use the swapchain one instead Reviewed-by: Adam Jackson Part-of: --- src/gallium/drivers/zink/zink_context.c | 2 +- src/gallium/drivers/zink/zink_kopper.c | 10 +++++----- src/gallium/drivers/zink/zink_resource.h | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 374ff3c..3fb3664 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -3438,7 +3438,7 @@ zink_flush_resource(struct pipe_context *pctx, struct zink_context *ctx = zink_context(pctx); struct zink_resource *res = zink_resource(pres); if (res->obj->dt) { - if (res->obj->acquire) { + if (zink_kopper_acquired(res->obj->dt, res->obj->dt_idx)) { zink_resource_image_barrier(ctx, res, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, 0, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT); zink_batch_reference_resource_rw(&ctx->batch, res, true); } else { diff --git a/src/gallium/drivers/zink/zink_kopper.c b/src/gallium/drivers/zink/zink_kopper.c index 66c7bcf..fdeba99 100644 --- a/src/gallium/drivers/zink/zink_kopper.c +++ b/src/gallium/drivers/zink/zink_kopper.c @@ -461,7 +461,6 @@ kopper_acquire(struct zink_screen *screen, struct zink_resource *res, uint64_t t if (!res->obj->new_dt && res->obj->dt_idx != UINT32_MAX && (cdt->swapchain->images[res->obj->dt_idx].acquire || cdt->swapchain->images[res->obj->dt_idx].acquired)) return VK_SUCCESS; - res->obj->acquire = VK_NULL_HANDLE; VkSemaphore acquire = VK_NULL_HANDLE; while (true) { @@ -503,7 +502,7 @@ kopper_acquire(struct zink_screen *screen, struct zink_resource *res, uint64_t t break; } - cdt->swapchain->images[res->obj->dt_idx].acquire = res->obj->acquire = acquire; + cdt->swapchain->images[res->obj->dt_idx].acquire = acquire; res->obj->image = cdt->swapchain->images[res->obj->dt_idx].image; cdt->swapchain->images[res->obj->dt_idx].acquired = false; if (!cdt->swapchain->images[res->obj->dt_idx].init) { @@ -578,12 +577,14 @@ zink_kopper_acquire_submit(struct zink_screen *screen, struct zink_resource *res struct kopper_displaytarget *cdt = kopper_displaytarget(res->obj->dt); if (cdt->swapchain->dt_has_data) return VK_NULL_HANDLE; - assert(res->obj->acquire); + assert(res->obj->dt_idx != UINT32_MAX); + assert(cdt->swapchain->images[res->obj->dt_idx].acquire); cdt->swapchain->images[res->obj->dt_idx].acquired = true; /* this is now owned by the batch */ + VkSemaphore acquire = cdt->swapchain->images[res->obj->dt_idx].acquire; cdt->swapchain->images[res->obj->dt_idx].acquire = VK_NULL_HANDLE; cdt->swapchain->dt_has_data = true; - return res->obj->acquire; + return acquire; } VkSemaphore @@ -729,7 +730,6 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res) } else { kopper_present(cpi, screen, -1); } - res->obj->acquire = VK_NULL_HANDLE; res->obj->indefinite_acquire = false; cdt->swapchain->images[res->obj->dt_idx].acquired = false; res->obj->dt_idx = UINT32_MAX; diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h index 84bdec3..2e32801 100644 --- a/src/gallium/drivers/zink/zink_resource.h +++ b/src/gallium/drivers/zink/zink_resource.h @@ -88,7 +88,6 @@ struct zink_resource_object { void *dt; uint32_t dt_idx; uint32_t last_dt_idx; - VkSemaphore acquire; VkSemaphore present; bool new_dt; bool dt_has_data; -- 2.7.4