From 303f04d3463b15c3c157646ab14ccc7b6b5284de Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 27 Mar 2024 14:22:18 +0100 Subject: [PATCH] pan/bi: Support fragment store_output() with a non-zero offset Fragment color outputs can be defined as a vec4 array. As long as the indexing is not dynamic, we can add the constant offset passed to the store_output() intrinsic to the RT index we extracted from the location. Signed-off-by: Boris Brezillon Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/compiler/bifrost_compile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index 11cafae342d..c996d426011 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -954,6 +954,16 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) bi_index color = bi_src_color_vec4(b, &instr->src[0], T); bi_index color2 = dual ? bi_src_color_vec4(b, &instr->src[4], T2) : bi_null(); + if (instr->intrinsic == nir_intrinsic_store_output && + loc >= FRAG_RESULT_DATA0 && loc <= FRAG_RESULT_DATA7) { + assert(nir_src_is_const(instr->src[1]) && "no indirect outputs"); + + unsigned rt_offs = nir_src_as_uint(instr->src[1]); + + assert(rt + rt_offs < 8 && "RT not in the [0-7] range"); + rt += rt_offs; + } + /* Explicit copy since BLEND inputs are precoloured to R0-R3, * TODO: maybe schedule around this or implement in RA as a * spill */