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 <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15461>
This commit is contained in:
Alyssa Rosenzweig 2021-12-21 16:55:05 -05:00 committed by Marge Bot
parent 222d17fc67
commit 1b934d5962
3 changed files with 14 additions and 11 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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)
{