Module: Mesa Branch: main Commit: bc4f418cb40e0c8978197cf641173809987dafab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc4f418cb40e0c8978197cf641173809987dafab
Author: Alyssa Rosenzweig <[email protected]> Date: Fri Sep 9 16:59:23 2022 -0400 agx: Implement load_global(_constant) Found in compute shaders, maps to a subset of device_load, and will be used for some lowerings soon. Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18525> --- src/asahi/compiler/agx_compile.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 1fa225d335e..babee57fe83 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -507,6 +507,21 @@ agx_format_for_bits(unsigned bits) } } +static void +agx_emit_load_global(agx_builder *b, agx_index *dests, nir_intrinsic_instr *instr) +{ + agx_index addr = agx_src_index(&instr->src[0]); + agx_index offset = agx_immediate(0); + enum agx_format fmt = agx_format_for_bits(nir_dest_bit_size(instr->dest)); + + agx_index vec = agx_vec_for_intr(b->shader, instr); + agx_device_load_to(b, vec, addr, offset, fmt, + BITFIELD_MASK(nir_dest_num_components(instr->dest)), 0); + agx_wait(b, 0); + + agx_emit_split(b, dests, vec, 4); +} + static agx_instr * agx_emit_load_ubo(agx_builder *b, agx_index dst, nir_intrinsic_instr *instr) { @@ -622,6 +637,11 @@ agx_emit_intrinsic(agx_builder *b, nir_intrinsic_instr *instr) break; + case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: + agx_emit_load_global(b, dests, instr); + break; + case nir_intrinsic_store_output: if (stage == MESA_SHADER_FRAGMENT) return agx_emit_fragment_out(b, instr);
