From 26f4cc39b58854698015c518f4ba94141fc60690 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 7 Aug 2025 10:12:12 -0400 Subject: [PATCH] zink: add a fastpath for nooping vertex and draw buffer barriers even doing this mechanism inside the barrier function doesn't yield anywhere near the same gains (~15-20% in viewperf catia), mostly for the draw buffers, so I'd assume it's just added register pressure from the huge draw function Part-of: --- src/gallium/drivers/zink/zink_context.c | 8 +++++--- src/gallium/drivers/zink/zink_draw.cpp | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index f7a88c3f9bf..6eb9cea8e7f 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -1414,9 +1414,11 @@ zink_set_vertex_buffers_internal(struct pipe_context *pctx, res->barrier_access[0] |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT; update_res_bind_count(ctx, res, false, false); ctx_vb->buffer_offset = vb->buffer_offset; - /* always barrier before possible rebind */ - zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, - VK_PIPELINE_STAGE_VERTEX_INPUT_BIT); + /* fastpath for viewperf */ + if (res->obj->access != VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT || res->obj->access_stage != VK_PIPELINE_STAGE_VERTEX_INPUT_BIT) + /* always barrier before possible rebind */ + zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT, + VK_PIPELINE_STAGE_VERTEX_INPUT_BIT); zink_batch_resource_usage_set(ctx->bs, res, false, true); res->obj->unordered_read = false; } else { diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp index a9ed3c21f74..d0d4ebf9b40 100644 --- a/src/gallium/drivers/zink/zink_draw.cpp +++ b/src/gallium/drivers/zink/zink_draw.cpp @@ -91,7 +91,9 @@ ALWAYS_INLINE static void check_buffer_barrier(struct zink_context *ctx, struct pipe_resource *pres, VkAccessFlags flags, VkPipelineStageFlags pipeline) { struct zink_resource *res = zink_resource(pres); - zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, flags, pipeline); + /* fastpath for viewperf */ + if (res->obj->access != flags || res->obj->access_stage != pipeline) + zink_screen(ctx->base.screen)->buffer_barrier(ctx, res, flags, pipeline); if (!ctx->unordered_blitting) res->obj->unordered_read = false; }