From 3497cd2ed2b6dced22979672e000f774ca442712 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 30 Aug 2024 17:22:10 -0400 Subject: [PATCH] asahi/clc: add bindless image intrinsics for decomp. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/clc/asahi_clc.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/asahi/clc/asahi_clc.c b/src/asahi/clc/asahi_clc.c index 532546b4b57..c4fe4a14536 100644 --- a/src/asahi/clc/asahi_clc.c +++ b/src/asahi/clc/asahi_clc.c @@ -94,6 +94,46 @@ lower_builtins(nir_builder *b, nir_instr *instr, void *data) b->cursor = nir_instr_remove(&call->instr); nir_fence_helper_exit_agx(b); return true; + } else if (strcmp(func->name, "nir_bindless_image_load_array") == 0) { + b->cursor = nir_instr_remove(&call->instr); + + nir_def *texel = nir_bindless_image_load( + b, 4, 32, call->params[1].ssa, call->params[2].ssa, nir_imm_int(b, 0), + nir_imm_int(b, 0), .image_array = true, + .image_dim = GLSL_SAMPLER_DIM_2D, .dest_type = nir_type_uint32, + .access = ACCESS_IN_BOUNDS_AGX); + + nir_store_deref(b, nir_src_as_deref(call->params[0]), texel, 0xf); + return true; + } else if (strcmp(func->name, "nir_bindless_image_store_array") == 0) { + b->cursor = nir_instr_remove(&call->instr); + + nir_bindless_image_store( + b, call->params[0].ssa, call->params[1].ssa, nir_imm_int(b, 0), + call->params[2].ssa, nir_imm_int(b, 0), .image_array = true, + .image_dim = GLSL_SAMPLER_DIM_2D, .src_type = nir_type_uint32, + .access = ACCESS_NON_READABLE); + return true; + } else if (strcmp(func->name, "nir_bindless_image_load_ms_array") == 0) { + b->cursor = nir_instr_remove(&call->instr); + + nir_def *texel = nir_bindless_image_load( + b, 4, 32, call->params[1].ssa, call->params[2].ssa, + call->params[3].ssa, nir_imm_int(b, 0), .image_array = true, + .image_dim = GLSL_SAMPLER_DIM_MS, .dest_type = nir_type_uint32, + .access = ACCESS_IN_BOUNDS_AGX); + + nir_store_deref(b, nir_src_as_deref(call->params[0]), texel, 0xf); + return true; + } else if (strcmp(func->name, "nir_bindless_image_store_ms_array") == 0) { + b->cursor = nir_instr_remove(&call->instr); + + nir_bindless_image_store( + b, call->params[0].ssa, call->params[1].ssa, call->params[2].ssa, + call->params[3].ssa, nir_imm_int(b, 0), .image_array = true, + .image_dim = GLSL_SAMPLER_DIM_MS, .src_type = nir_type_uint32, + .access = ACCESS_NON_READABLE); + return true; } return false;