From 3eab648d6bd22c58d3789393da3e855dfd88e3fb Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 6 Jun 2021 14:03:54 -0400 Subject: [PATCH] agx: Implement nir_intrinsic_load_frag_coord Depends on matching ABI. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 03991c5..162ecab 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -264,6 +264,25 @@ agx_emit_load_ubo(agx_builder *b, nir_intrinsic_instr *instr) } static agx_instr * +agx_emit_load_frag_coord(agx_builder *b, nir_intrinsic_instr *instr) +{ + agx_index xy[2]; + + for (unsigned i = 0; i < 2; ++i) { + xy[i] = agx_fadd(b, agx_convert(b, agx_immediate(AGX_CONVERT_U32_TO_F), + agx_get_sr(b, 32, AGX_SR_THREAD_POSITION_IN_GRID_X + i), + AGX_ROUND_RTE), agx_immediate_f(0.5f)); + } + + /* Ordering by the ABI */ + agx_index z = agx_ld_vary(b, agx_immediate(1), 1, false); + agx_index w = agx_ld_vary(b, agx_immediate(0), 1, false); + + return agx_p_combine_to(b, agx_dest_index(&instr->dest), + xy[0], xy[1], z, w); +} + +static agx_instr * agx_blend_const(agx_builder *b, agx_index dst, unsigned comp) { agx_index val = agx_indexed_sysval(b->shader, @@ -312,6 +331,9 @@ agx_emit_intrinsic(agx_builder *b, nir_intrinsic_instr *instr) case nir_intrinsic_load_kernel_input: return agx_emit_load_ubo(b, instr); + case nir_intrinsic_load_frag_coord: + return agx_emit_load_frag_coord(b, instr); + case nir_intrinsic_load_back_face_agx: return agx_get_sr_to(b, dst, AGX_SR_BACKFACING); -- 2.7.4