From bc8232c4a2dae00f24441a56063068844c131802 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Fri, 27 Oct 2023 17:30:04 +0200 Subject: [PATCH] asahi: clc: Handle doorbell and stack mapping intrinsics Also move nir_interleave_agx definition to libagx.h Signed-off-by: Mary Guillemard Part-of: --- src/asahi/clc/asahi_clc.c | 13 +++++++++++++ src/asahi/lib/shaders/libagx.h | 7 +++++++ src/asahi/lib/shaders/texture.cl | 2 -- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/asahi/clc/asahi_clc.c b/src/asahi/clc/asahi_clc.c index a55c0c8fef0..81c67723608 100644 --- a/src/asahi/clc/asahi_clc.c +++ b/src/asahi/clc/asahi_clc.c @@ -79,6 +79,19 @@ lower_builtins(nir_builder *b, nir_instr *instr, void *data) nir_interleave_agx(b, call->params[1].ssa, call->params[2].ssa), 1); return true; + } else if (strcmp(func->name, "nir_doorbell_agx") == 0) { + b->cursor = nir_instr_remove(&call->instr); + nir_doorbell_agx(b, call->params[0].ssa); + return true; + } else if (strcmp(func->name, "nir_stack_map_agx") == 0) { + b->cursor = nir_instr_remove(&call->instr); + nir_stack_map_agx(b, call->params[0].ssa, call->params[1].ssa); + return true; + } else if (strcmp(func->name, "nir_stack_unmap_agx") == 0) { + b->cursor = nir_instr_remove(&call->instr); + nir_store_deref(b, nir_src_as_deref(call->params[0]), + nir_stack_unmap_agx(b, call->params[1].ssa), 1); + return true; } return false; diff --git a/src/asahi/lib/shaders/libagx.h b/src/asahi/lib/shaders/libagx.h index a755920b16c..24ecbd98e63 100644 --- a/src/asahi/lib/shaders/libagx.h +++ b/src/asahi/lib/shaders/libagx.h @@ -19,6 +19,13 @@ typedef long int64_t; typedef int int32_t; typedef short int16_t; typedef int int8_t; + +/* Define NIR intrinsics for CL */ +uint32_t nir_interleave_agx(uint16_t x, uint16_t y); +void nir_doorbell_agx(uint8_t value); +void nir_stack_map_agx(uint16_t index, uint32_t address); +uint32_t nir_stack_unmap_agx(uint16_t index); + #endif #endif diff --git a/src/asahi/lib/shaders/texture.cl b/src/asahi/lib/shaders/texture.cl index f3111b8a4c6..cb768cc37f1 100644 --- a/src/asahi/lib/shaders/texture.cl +++ b/src/asahi/lib/shaders/texture.cl @@ -6,8 +6,6 @@ #include "libagx.h" #include -uint32_t nir_interleave_agx(uint16_t x, uint16_t y); - uint3 libagx_txs(constant struct agx_texture_packed *ptr, uint16_t lod, unsigned nr_comps, bool is_buffer, bool is_1d, bool is_2d,