nir/shader_info: remove uses_demote

This flag is mostly redundant with uses_discard and was only
introduced to implement demote with LLVM when it didn't have
that intrinsic.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27617>
This commit is contained in:
Daniel Schürmann 2024-02-08 16:03:55 +01:00 committed by Marge Bot
parent e52e8dd02e
commit 7af16e9f1e
10 changed files with 6 additions and 14 deletions

View file

@ -176,7 +176,7 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively)
NIR_PASS(progress, shader, nir_remove_dead_variables,
nir_var_function_temp | nir_var_shader_in | nir_var_shader_out | nir_var_mem_shared, NULL);
if (shader->info.stage == MESA_SHADER_FRAGMENT && (shader->info.fs.uses_discard || shader->info.fs.uses_demote)) {
if (shader->info.stage == MESA_SHADER_FRAGMENT && shader->info.fs.uses_discard) {
NIR_PASS(progress, shader, nir_opt_conditional_discard);
NIR_PASS(progress, shader, nir_opt_move_discards_to_top);
}

View file

@ -1917,7 +1917,6 @@ emit_frag_end(struct v3d_compile *c)
if (c->output_position_index == -1 &&
!(c->s->info.num_images || c->s->info.num_ssbos) &&
!c->s->info.fs.uses_discard &&
!c->s->info.fs.uses_demote &&
!c->fs_key->sample_alpha_to_coverage &&
c->output_sample_mask_index == -1 &&
has_any_tlb_color_write) {

View file

@ -467,8 +467,6 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
switch (instr->intrinsic) {
case nir_intrinsic_demote:
case nir_intrinsic_demote_if:
shader->info.fs.uses_demote = true;
FALLTHROUGH; /* quads with helper lanes only might be discarded entirely */
case nir_intrinsic_terminate:
case nir_intrinsic_terminate_if:
/* Freedreno uses discard_if() to end GS invocations that don't produce
@ -1002,7 +1000,6 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
if (shader->info.stage == MESA_SHADER_FRAGMENT) {
shader->info.fs.uses_sample_qualifier = false;
shader->info.fs.uses_discard = false;
shader->info.fs.uses_demote = false;
shader->info.fs.color_is_dual_source = false;
shader->info.fs.uses_fbfetch_output = false;
shader->info.fs.needs_quad_helper_invocations = false;

View file

@ -2561,7 +2561,6 @@ print_shader_info(const struct shader_info *info, FILE *fp)
case MESA_SHADER_FRAGMENT:
print_nz_bool(fp, "uses_discard", info->fs.uses_discard);
print_nz_bool(fp, "uses_demote", info->fs.uses_demote);
print_nz_bool(fp, "uses_fbfetch_output", info->fs.uses_fbfetch_output);
print_nz_bool(fp, "color_is_dual_source", info->fs.color_is_dual_source);

View file

@ -332,7 +332,6 @@ typedef struct shader_info {
struct {
bool uses_discard:1;
bool uses_demote:1;
bool uses_fbfetch_output:1;
bool fbfetch_coherent:1;
bool color_is_dual_source:1;

View file

@ -4421,7 +4421,8 @@ nir_to_spirv(struct nir_shader *s, const struct zink_shader_info *sinfo, const s
case MESA_SHADER_FRAGMENT:
if (s->info.fs.uses_sample_shading)
spirv_builder_emit_cap(&ctx.builder, SpvCapabilitySampleRateShading);
if (s->info.fs.uses_demote && spirv_version < SPIRV_VERSION(1, 6))
if (s->info.fs.uses_discard && spirv_version < SPIRV_VERSION(1, 6) &&
screen->info.have_EXT_shader_demote_to_helper_invocation)
spirv_builder_emit_extension(&ctx.builder,
"SPV_EXT_demote_to_helper_invocation");
break;

View file

@ -3644,8 +3644,7 @@ brw_nir_populate_wm_prog_data(nir_shader *shader,
struct brw_wm_prog_data *prog_data,
const struct brw_mue_map *mue_map)
{
prog_data->uses_kill = shader->info.fs.uses_discard ||
shader->info.fs.uses_demote;
prog_data->uses_kill = shader->info.fs.uses_discard;
prog_data->uses_omask = !key->ignore_sample_mask_out &&
(shader->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK));
prog_data->max_polygons = 1;

View file

@ -6450,7 +6450,6 @@ elk_nir_populate_wm_prog_data(nir_shader *shader,
* so the shader definitely kills pixels.
*/
prog_data->uses_kill = shader->info.fs.uses_discard ||
shader->info.fs.uses_demote ||
key->emit_alpha_test;
prog_data->uses_omask = !key->ignore_sample_mask_out &&
(shader->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK));

View file

@ -1322,7 +1322,7 @@ Converter::parseNIR()
info_out->prop.fp.postDepthCoverage = nir->info.fs.post_depth_coverage;
info_out->prop.fp.readsSampleLocations =
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_POS);
info_out->prop.fp.usesDiscard = nir->info.fs.uses_discard || nir->info.fs.uses_demote;
info_out->prop.fp.usesDiscard = nir->info.fs.uses_discard;
info_out->prop.fp.usesSampleMaskIn =
BITSET_TEST(nir->info.system_values_read, SYSTEM_VALUE_SAMPLE_MASK_IN);
break;

View file

@ -167,8 +167,7 @@ GENX(pan_shader_compile)(nir_shader *s, struct panfrost_compile_inputs *inputs,
/* List of reasons we need to execute frag shaders when things
* are masked off */
info->fs.sidefx = s->info.writes_memory || s->info.fs.uses_discard ||
s->info.fs.uses_demote;
info->fs.sidefx = s->info.writes_memory || s->info.fs.uses_discard;
/* With suitable ZSA/blend, is early-z possible? */
info->fs.can_early_z = !info->fs.sidefx && !info->fs.writes_depth &&