agx: Terminate programs with stop and traps
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 12 Apr 2021 03:00:35 +0000 (23:00 -0400)
committerAlyssa Rosenzweig <none>
Sun, 2 May 2021 21:41:13 +0000 (17:41 -0400)
The function of stop is clear. The function of trap, let alone a whole
sled of them, is less so. Maybe a debugging feature for later.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10582>

src/asahi/compiler/agx_compile.c

index 824b3de..42fea12 100644 (file)
@@ -494,6 +494,15 @@ agx_compile_shader_nir(nir_shader *nir,
       break; /* TODO: Multi-function shaders */
    }
 
+   /* Terminate the shader after the exit block */
+   agx_block *last_block = list_last_entry(&ctx->blocks, agx_block, link);
+   agx_builder _b = agx_init_builder(ctx, agx_after_block(last_block));
+   agx_stop(&_b);
+
+   /* Also add traps to match the blob, unsure what the function is */
+   for (unsigned i = 0; i < 8; ++i)
+      agx_trap(&_b);
+
    unsigned block_source_count = 0;
 
    /* Name blocks now that we're done emitting so the order is consistent */