From 31c805d0aa7fb82b373e08de0af0f57db8d91154 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 25 Apr 2023 23:20:25 -0400 Subject: [PATCH] agx: Don't wait at the end of the shader This is totally pointless. This saves some waits at the ends of compute kernels (waiting for stores to complete before terminating the thread). I don't know how much this would matter for performance, since the hardware may have to do these waits internally, but it makes the generated code less silly which is always nice. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_insert_waits.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/asahi/compiler/agx_insert_waits.c b/src/asahi/compiler/agx_insert_waits.c index 716c4a31406..3ac4ea78f95 100644 --- a/src/asahi/compiler/agx_insert_waits.c +++ b/src/asahi/compiler/agx_insert_waits.c @@ -120,11 +120,16 @@ agx_insert_waits_local(agx_context *ctx, agx_block *block) } } - /* If there are outstanding messages, wait for them */ - for (unsigned slot = 0; slot < ARRAY_SIZE(slots); ++slot) { - if (slots[slot].nr_pending) { - agx_builder b = agx_init_builder(ctx, agx_after_block_logical(block)); - agx_wait(&b, slot); + /* If there are outstanding messages, wait for them. We don't do this for the + * exit block, though, since nothing else will execute in the shader so + * waiting is pointless. + */ + if (block != agx_exit_block(ctx)) { + agx_builder b = agx_init_builder(ctx, agx_after_block_logical(block)); + + for (unsigned slot = 0; slot < ARRAY_SIZE(slots); ++slot) { + if (slots[slot].nr_pending) + agx_wait(&b, slot); } } }