zink: set and manage a flag indicating that swapchain readback needs updating

not currently used, but this is more coherent than relying on other flags

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27553>
This commit is contained in:
Mike Blumenkrantz 2024-02-21 16:37:18 -05:00
parent 114a5da790
commit 417a1986fb
3 changed files with 15 additions and 1 deletions

View file

@ -842,6 +842,14 @@ zink_kopper_update_last_written(struct zink_resource *res)
res->obj->last_dt_idx = res->obj->dt_idx;
}
void
zink_kopper_set_readback_needs_update(struct zink_resource *res)
{
struct kopper_displaytarget *cdt = res->obj->dt;
struct kopper_swapchain *cswap = cdt->swapchain;
cswap->images[res->obj->dt_idx].readback_needs_update = true;
}
static bool
kopper_ensure_readback(struct zink_screen *screen, struct zink_resource *res)
{
@ -976,6 +984,7 @@ zink_kopper_readback_update(struct zink_context *ctx, struct zink_resource *res)
if (readback)
ctx->base.resource_copy_region(&ctx->base, readback, 0, 0, 0, 0, &res->base.b, 0, &box);
cswap->images[res->obj->dt_idx].readback_needs_update = false;
}
bool

View file

@ -41,6 +41,7 @@ struct zink_batch_usage;
struct kopper_swapchain_image {
bool init;
bool readback_needs_update;
bool dt_has_data;
int age;
VkImage image;
@ -163,6 +164,8 @@ int
zink_kopper_query_buffer_age(struct pipe_context *pctx, struct pipe_resource *pres);
void
zink_kopper_prune_batch_usage(struct kopper_displaytarget *cdt, const struct zink_batch_usage *u);
void
zink_kopper_set_readback_needs_update(struct zink_resource *res);
#ifdef __cplusplus
}

View file

@ -515,10 +515,12 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res,
if (!flags)
flags = access_dst_flags(new_layout);
bool is_write = zink_resource_access_is_write(flags);
if (is_write && zink_is_swapchain(res))
zink_kopper_set_readback_needs_update(res);
if (!res->obj->needs_zs_evaluate && !zink_resource_image_needs_barrier(res, new_layout, flags, pipeline) &&
(res->queue == zink_screen(ctx->base.screen)->gfx_queue || res->queue == VK_QUEUE_FAMILY_IGNORED))
return;
bool is_write = zink_resource_access_is_write(flags);
enum zink_resource_access rw = is_write ? ZINK_RESOURCE_ACCESS_RW : ZINK_RESOURCE_ACCESS_WRITE;
bool completed = zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, rw);
bool usage_matches = !completed && zink_resource_usage_matches(res, ctx->batch.state);