From 1b934d5962ce25ecd35b2f777d1a4361de6fcdd7 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 21 Dec 2021 16:55:05 -0500 Subject: [PATCH] pan/bi: Emit arch-specific code for bi_dontcare We use bi_dontcare() to specify any encoding where we don't care about the value, with a preference for power-efficient encodings. On Bifrost, a (possibly nonexistant) FAU read is the best encoding. On Valhall, that encoding doesn't exist so just use a zero. That should be good enough in practice. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_schedule.c | 2 +- src/panfrost/bifrost/bifrost_compile.c | 6 +++--- src/panfrost/bifrost/compiler.h | 17 ++++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index 63eb0ae431f..efcd9616141 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -360,7 +360,7 @@ bi_lower_atom_c1(bi_context *ctx, struct bi_clause_state *clause, struct pinstr->op = BI_OPCODE_ATOM_CX; pinstr->src[2] = pinstr->src[1]; pinstr->src[1] = pinstr->src[0]; - pinstr->src[3] = bi_dontcare(); + pinstr->src[3] = bi_dontcare(&b); pinstr->src[0] = bi_null(); return atom_c; diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index b9b1b853306..236f5f7d355 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -123,7 +123,7 @@ bi_varying_src0_for_barycentric(bi_builder *b, nir_intrinsic_instr *intr) /* Need to put the sample ID in the top 16-bits */ case nir_intrinsic_load_barycentric_at_sample: - return bi_mkvec_v2i16(b, bi_half(bi_dontcare(), false), + return bi_mkvec_v2i16(b, bi_half(bi_dontcare(b), false), bi_half(bi_src_index(&intr->src[0]), false)); /* Interpret as 8:8 signed fixed point positions in pixels along X and @@ -164,7 +164,7 @@ bi_varying_src0_for_barycentric(bi_builder *b, nir_intrinsic_instr *intr) case nir_intrinsic_load_barycentric_pixel: default: - return bi_dontcare(); + return b->shader->arch >= 9 ? bi_register(61) : bi_dontcare(b); } } @@ -621,7 +621,7 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) bi_index alpha = (T == nir_type_float16) ? bi_half(bi_word(rgba, 1), true) : (T == nir_type_float32) ? bi_word(rgba, 3) : - bi_dontcare(); + bi_dontcare(b); /* Don't read out-of-bounds */ if (nir_src_num_components(instr->src[0]) < 4) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index bc9875681de..62d86bdbb39 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -199,13 +199,6 @@ bi_passthrough(enum bifrost_packed_src value) }; } -/* Read back power-efficent garbage, TODO maybe merge with null? */ -static inline bi_index -bi_dontcare() -{ - return bi_passthrough(BIFROST_SRC_FAU_HI); -} - /* Extracts a word from a vectored index */ static inline bi_index bi_word(bi_index idx, unsigned component) @@ -1298,6 +1291,16 @@ bi_builder_insert(bi_cursor *cursor, bi_instr *I) unreachable("Invalid cursor option"); } +/* Read back power-efficent garbage, TODO maybe merge with null? */ +static inline bi_index +bi_dontcare(bi_builder *b) +{ + if (b->shader->arch >= 9) + return bi_zero(); + else + return bi_passthrough(BIFROST_SRC_FAU_HI); +} + static inline unsigned bi_word_node(bi_index idx) {