From ecb50b37a983ef030e1ded7dc8c761e344f457b7 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 28 Oct 2020 14:15:28 -0400 Subject: [PATCH] zink: return enum zink_queue from zink_batch_reference_resource_rw() this is a little cleaner Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_batch.c | 10 +++++----- src/gallium/drivers/zink/zink_batch.h | 2 +- src/gallium/drivers/zink/zink_draw.c | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 1de7b44..2f55fc4 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -164,14 +164,14 @@ zink_end_batch(struct zink_context *ctx, struct zink_batch *batch) batch->flush_res = NULL; } -/* returns either the compute batch id or 0 (gfx batch id) based on whether a resource +/* returns a queue based on whether a resource has usage on a different queue than 'batch' belongs to */ -int +enum zink_queue zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource *res, bool write) { unsigned mask = write ? ZINK_RESOURCE_ACCESS_WRITE : ZINK_RESOURCE_ACCESS_READ; - int batch_to_flush = -1; + enum zink_queue batch_to_flush = 0; /* u_transfer_helper unrefs the stencil buffer when the depth buffer is unrefed, * so we add an extra ref here to the stencil buffer to compensate @@ -183,11 +183,11 @@ zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource if (batch->batch_id == ZINK_COMPUTE_BATCH_ID) { if ((write && zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_RW, ZINK_QUEUE_GFX)) || (!write && zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_WRITE, ZINK_QUEUE_GFX))) - batch_to_flush = 0; + batch_to_flush = ZINK_QUEUE_GFX; } else { if ((write && zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_READ, ZINK_QUEUE_COMPUTE)) || zink_resource_has_usage(res, ZINK_RESOURCE_ACCESS_WRITE, ZINK_QUEUE_COMPUTE)) - batch_to_flush = ZINK_COMPUTE_BATCH_ID; + batch_to_flush = ZINK_QUEUE_COMPUTE; } /* if the resource already has usage of any sort set for this batch, we can skip hashing */ diff --git a/src/gallium/drivers/zink/zink_batch.h b/src/gallium/drivers/zink/zink_batch.h index 1fe3d90..3bec402 100644 --- a/src/gallium/drivers/zink/zink_batch.h +++ b/src/gallium/drivers/zink/zink_batch.h @@ -89,7 +89,7 @@ zink_start_batch(struct zink_context *ctx, struct zink_batch *batch); void zink_end_batch(struct zink_context *ctx, struct zink_batch *batch); -int +enum zink_queue zink_batch_reference_resource_rw(struct zink_batch *batch, struct zink_resource *res, bool write); diff --git a/src/gallium/drivers/zink/zink_draw.c b/src/gallium/drivers/zink/zink_draw.c index e4728d7..c7637d3 100644 --- a/src/gallium/drivers/zink/zink_draw.c +++ b/src/gallium/drivers/zink/zink_draw.c @@ -345,7 +345,8 @@ write_descriptors(struct zink_context *ctx, struct zink_descriptor_set *zds, uns struct zink_batch *batch = is_compute ? &ctx->compute_batch : zink_curr_batch(ctx); struct zink_screen *screen = zink_screen(ctx->base.screen); assert(zds->desc_set); - unsigned check_flush_id = is_compute ? 0 : ZINK_COMPUTE_BATCH_ID; + enum zink_queue check_flush_id = is_compute ? ZINK_QUEUE_GFX : ZINK_QUEUE_COMPUTE; + if (!cache_hit && num_wds) vkUpdateDescriptorSets(screen->dev, num_wds, wds, 0, NULL); -- 2.7.4