radeonsi: simplify si_emit_spi_map for back-face colors
Just precompute what we need in si_shader_info. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12343>
This commit is contained in:
parent
57f9452b46
commit
5f090891e9
|
@ -511,16 +511,25 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
|
|||
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS) ||
|
||||
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN) ||
|
||||
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_HELPER_INVOCATION));
|
||||
}
|
||||
|
||||
/* Add color inputs to the list of inputs. */
|
||||
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
if ((info->colors_read >> (i * 4)) & 0xf) {
|
||||
info->input[info->num_inputs].semantic = VARYING_SLOT_COL0 + i;
|
||||
info->input[info->num_inputs].interpolate = info->color_interpolate[i];
|
||||
info->input[info->num_inputs].usage_mask = info->colors_read >> (i * 4);
|
||||
info->num_inputs++;
|
||||
/* Add both front and back color inputs. */
|
||||
unsigned num_inputs_with_colors = info->num_inputs;
|
||||
for (unsigned back = 0; back < 2; back++) {
|
||||
for (unsigned i = 0; i < 2; i++) {
|
||||
if ((info->colors_read >> (i * 4)) & 0xf) {
|
||||
unsigned index = num_inputs_with_colors;
|
||||
|
||||
info->input[index].semantic = (back ? VARYING_SLOT_BFC0 : VARYING_SLOT_COL0) + i;
|
||||
info->input[index].interpolate = info->color_interpolate[i];
|
||||
info->input[index].usage_mask = info->colors_read >> (i * 4);
|
||||
num_inputs_with_colors++;
|
||||
|
||||
/* Back-face color don't increment num_inputs. si_emit_spi_map will use
|
||||
* back-face colors conditionally only when they are needed.
|
||||
*/
|
||||
if (!back)
|
||||
info->num_inputs = num_inputs_with_colors;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3604,7 +3604,9 @@ static void si_emit_spi_map(struct si_context *sctx)
|
|||
else
|
||||
vs = si_get_vs(sctx)->current;
|
||||
|
||||
for (i = 0; i < psinfo->num_inputs; i++) {
|
||||
unsigned num_interp = ps->ctx_reg.ps.num_interp;
|
||||
|
||||
for (i = 0; i < num_interp; i++) {
|
||||
unsigned semantic = psinfo->input[i].semantic;
|
||||
unsigned interpolate = psinfo->input[i].interpolate;
|
||||
ubyte fp16_lo_hi_mask = psinfo->input[i].fp16_lo_hi_valid;
|
||||
|
@ -3613,19 +3615,6 @@ static void si_emit_spi_map(struct si_context *sctx)
|
|||
fp16_lo_hi_mask);
|
||||
}
|
||||
|
||||
if (ps->key.part.ps.prolog.color_two_side) {
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (!(psinfo->colors_read & (0xf << (i * 4))))
|
||||
continue;
|
||||
|
||||
unsigned semantic = VARYING_SLOT_BFC0 + i;
|
||||
spi_ps_input_cntl[num_written++] = si_get_ps_input_cntl(sctx, vs, semantic,
|
||||
psinfo->color_interpolate[i],
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned num_interp = ps->ctx_reg.ps.num_interp;
|
||||
assert(num_interp > 0);
|
||||
assert(num_interp == num_written);
|
||||
|
||||
|
|
Loading…
Reference in New Issue