radeonsi: remove gl_BackColor VS outputs on demand if color_two_side is disabled

We just need to set the ps_inputs_read_or_disabled mask correctly.

The VS outputs_written mask should set BFCn instead of COLn, which is why
this removes the is_varying parameter that forced COLn to be set for BFCn.

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22833>
This commit is contained in:
Marek Olšák
2023-05-07 20:33:07 -04:00
committed by Marge Bot
parent a1d938d318
commit b72a1883e2
5 changed files with 27 additions and 20 deletions
+5 -12
View File
@@ -84,7 +84,7 @@ unsigned si_shader_io_get_unique_index_patch(unsigned semantic)
* less than 64, so that a 64-bit bitmask of used inputs or outputs can be
* calculated.
*/
unsigned si_shader_io_get_unique_index(unsigned semantic, bool is_varying)
unsigned si_shader_io_get_unique_index(unsigned semantic)
{
switch (semantic) {
case VARYING_SLOT_POS:
@@ -107,16 +107,9 @@ unsigned si_shader_io_get_unique_index(unsigned semantic, bool is_varying)
case VARYING_SLOT_COL1:
return SI_UNIQUE_SLOT_COL1;
case VARYING_SLOT_BFC0:
/* If it's a varying, COLOR and BCOLOR alias. */
if (is_varying)
return SI_UNIQUE_SLOT_COL0;
else
return SI_UNIQUE_SLOT_BFC0;
return SI_UNIQUE_SLOT_BFC0;
case VARYING_SLOT_BFC1:
if (is_varying)
return SI_UNIQUE_SLOT_COL1;
else
return SI_UNIQUE_SLOT_BFC1;
return SI_UNIQUE_SLOT_BFC1;
case VARYING_SLOT_TEX0:
case VARYING_SLOT_TEX1:
case VARYING_SLOT_TEX2:
@@ -1546,7 +1539,7 @@ static bool si_nir_kill_outputs(nir_shader *nir, const union si_shader_key *key)
if (nir_slot_is_varying(sem.location) &&
key->ge.opt.kill_outputs &
(1ull << si_shader_io_get_unique_index(sem.location, true))) {
(1ull << si_shader_io_get_unique_index(sem.location))) {
nir_remove_varying(intr, MESA_SHADER_FRAGMENT);
progress = true;
}
@@ -1637,7 +1630,7 @@ static unsigned si_map_io_driver_location(unsigned semantic)
semantic == VARYING_SLOT_TESS_LEVEL_OUTER)
return si_shader_io_get_unique_index_patch(semantic);
return si_shader_io_get_unique_index(semantic, false);
return si_shader_io_get_unique_index(semantic);
}
static bool si_lower_io_to_mem(struct si_shader *shader, nir_shader *nir,
+1 -1
View File
@@ -1035,7 +1035,7 @@ bool si_create_shader_variant(struct si_screen *sscreen, struct ac_llvm_compiler
struct si_shader *shader, struct util_debug_callback *debug);
void si_shader_destroy(struct si_shader *shader);
unsigned si_shader_io_get_unique_index_patch(unsigned semantic);
unsigned si_shader_io_get_unique_index(unsigned semantic, bool is_varying);
unsigned si_shader_io_get_unique_index(unsigned semantic);
bool si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader,
uint64_t scratch_va);
bool si_can_dump_shader(struct si_screen *sscreen, gl_shader_stage stage,
@@ -748,14 +748,14 @@ void si_nir_scan_shader(struct si_screen *sscreen, const struct nir_shader *nir,
info->patch_outputs_written |= 1ull << si_shader_io_get_unique_index_patch(semantic);
} else if ((semantic <= VARYING_SLOT_VAR31 || semantic >= VARYING_SLOT_VAR0_16BIT) &&
semantic != VARYING_SLOT_EDGE) {
info->outputs_written |= 1ull << si_shader_io_get_unique_index(semantic, false);
info->outputs_written |= 1ull << si_shader_io_get_unique_index(semantic);
/* Ignore outputs that are not passed from VS to PS. */
if (semantic != VARYING_SLOT_POS &&
semantic != VARYING_SLOT_PSIZ &&
semantic != VARYING_SLOT_CLIP_VERTEX) {
info->outputs_written_before_ps |= 1ull
<< si_shader_io_get_unique_index(semantic, true);
<< si_shader_io_get_unique_index(semantic);
}
}
}
@@ -813,7 +813,7 @@ void si_nir_scan_shader(struct si_screen *sscreen, const struct nir_shader *nir,
if ((semantic <= VARYING_SLOT_VAR31 || semantic >= VARYING_SLOT_VAR0_16BIT) &&
semantic != VARYING_SLOT_PNTC) {
info->inputs_read |= 1ull << si_shader_io_get_unique_index(semantic, true);
info->inputs_read |= 1ull << si_shader_io_get_unique_index(semantic);
}
}
@@ -231,7 +231,7 @@ static LLVMValueRef si_nir_load_tcs_varyings(struct ac_shader_abi *abi, LLVMType
ubyte semantic = info->input[driver_location].semantic;
/* Load the TCS input from a VGPR. */
unsigned func_param = ctx->args->ac.tcs_rel_ids.arg_index + 1 +
si_shader_io_get_unique_index(semantic, false) * 4;
si_shader_io_get_unique_index(semantic) * 4;
LLVMValueRef value[4];
for (unsigned i = component; i < component + num_components; i++) {
@@ -541,7 +541,7 @@ void si_llvm_ls_build_end(struct si_shader_context *ctx)
if (shader->key.ge.opt.same_patch_vertices) {
for (unsigned i = 0; i < info->num_outputs; i++) {
unsigned semantic = info->output_semantic[i];
int param = si_shader_io_get_unique_index(semantic, false);
int param = si_shader_io_get_unique_index(semantic);
for (unsigned chan = 0; chan < 4; chan++) {
if (!(info->output_usagemask[i] & (1 << chan)))
@@ -2125,7 +2125,21 @@ void si_update_ps_inputs_read_or_disabled(struct si_context *sctx)
(!ps_colormask && !ps_modifies_zs && !ps->info.base.writes_memory);
}
sctx->ps_inputs_read_or_disabled = ps_disabled ? 0 : ps->info.inputs_read;
if (ps_disabled) {
sctx->ps_inputs_read_or_disabled = 0;
} else {
uint64_t inputs_read = ps->info.inputs_read;
if (sctx->shader.ps.key.ps.part.prolog.color_two_side) {
if (inputs_read & BITFIELD64_BIT(SI_UNIQUE_SLOT_COL0))
inputs_read |= BITFIELD64_BIT(SI_UNIQUE_SLOT_BFC0);
if (inputs_read & BITFIELD64_BIT(SI_UNIQUE_SLOT_COL1))
inputs_read |= BITFIELD64_BIT(SI_UNIQUE_SLOT_BFC1);
}
sctx->ps_inputs_read_or_disabled = inputs_read;
}
}
static void si_get_vs_key_outputs(struct si_context *sctx, struct si_shader_selector *vs,
@@ -3037,7 +3051,7 @@ static void si_init_shader_selector_async(void *job, void *gdata, int thread_ind
semantic != VARYING_SLOT_PSIZ &&
semantic != VARYING_SLOT_CLIP_VERTEX &&
semantic != VARYING_SLOT_EDGE) {
id = si_shader_io_get_unique_index(semantic, true);
id = si_shader_io_get_unique_index(semantic);
sel->info.outputs_written_before_ps &= ~(1ull << id);
}
}