From 43be9a867e1b874b6f50cfc17caac7668c02b98b Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 24 Aug 2023 09:40:42 -0400 Subject: [PATCH] zink: reset unordered flags for image barriers on non-matching batch access this allows more reordering when the first barrier in a new cmdbuf can be reordered after previous ordered access exists KHR-GLES3.copy_tex_image_conversions.required.texture2d_cubemap_negz: before - ordered 68 after - ordered 16 Part-of: --- src/gallium/drivers/zink/zink_synchronization.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/zink/zink_synchronization.cpp b/src/gallium/drivers/zink/zink_synchronization.cpp index fb440566421..2e369daa5c5 100644 --- a/src/gallium/drivers/zink/zink_synchronization.cpp +++ b/src/gallium/drivers/zink/zink_synchronization.cpp @@ -335,7 +335,15 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res, (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); VkCommandBuffer cmdbuf; + if (!usage_matches) { + res->obj->unordered_write = true; + if (is_write || zink_resource_usage_check_completion_fast(zink_screen(ctx->base.screen), res, ZINK_RESOURCE_ACCESS_RW)) + res->obj->unordered_read = true; + } /* if current batch usage exists with ordered non-transfer access, never promote * this avoids layout dsync * TODO: figure out how to link up unordered layout -> ordered layout and delete @@ -359,7 +367,6 @@ zink_resource_image_barrier(struct zink_context *ctx, struct zink_resource *res, } assert(new_layout); bool marker = zink_cmd_debug_marker_begin(ctx, cmdbuf, "image_barrier(%s->%s)", vk_ImageLayout_to_str(res->layout), vk_ImageLayout_to_str(new_layout)); - enum zink_resource_access rw = is_write ? ZINK_RESOURCE_ACCESS_RW : ZINK_RESOURCE_ACCESS_WRITE; if (HAS_SYNC2) { VkImageMemoryBarrier2 imb; zink_resource_image_barrier2_init(&imb, res, new_layout, flags, pipeline);