diff --git a/src/asahi/lib/agx_nir_lower_msaa.c b/src/asahi/lib/agx_nir_lower_msaa.c index d5acc852857..351b4b861c7 100644 --- a/src/asahi/lib/agx_nir_lower_msaa.c +++ b/src/asahi/lib/agx_nir_lower_msaa.c @@ -126,9 +126,12 @@ agx_nir_lower_monolithic_msaa(nir_shader *shader, uint8_t nr_samples) /* In single sampled programs, interpolateAtSample needs to return the * center pixel. */ - if (nr_samples == 1) - nir_lower_single_sampled(shader); - else if (shader->info.fs.uses_sample_shading) { + if (nr_samples == 1) { + nir_lower_single_sampled_options lss_opts = { + .lower_sample_mask_in = true, + }; + nir_lower_single_sampled(shader, &lss_opts); + } else if (shader->info.fs.uses_sample_shading) { agx_nir_lower_to_per_sample(shader); agx_nir_wrap_per_sample_loop(shader, nr_samples); } diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 448a8851a27..b4514330adf 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5631,7 +5631,12 @@ bool nir_lower_uniforms_to_ubo(nir_shader *shader, bool dword_packed, bool load_ bool nir_lower_is_helper_invocation(nir_shader *shader); -bool nir_lower_single_sampled(nir_shader *shader); +typedef struct nir_lower_single_sampled_options { + bool lower_sample_mask_in; +} nir_lower_single_sampled_options; + +bool nir_lower_single_sampled(nir_shader *shader, + const nir_lower_single_sampled_options *options); bool nir_lower_sample_shading(nir_shader *shader); bool nir_lower_atomics(nir_shader *shader, nir_instr_filter_cb filter); diff --git a/src/compiler/nir/nir_lower_single_sampled.c b/src/compiler/nir/nir_lower_single_sampled.c index dfe7c2dcd7c..a0db14f3b8c 100644 --- a/src/compiler/nir/nir_lower_single_sampled.c +++ b/src/compiler/nir/nir_lower_single_sampled.c @@ -27,8 +27,10 @@ static bool lower_single_sampled_instr(nir_builder *b, nir_intrinsic_instr *intrin, - UNUSED void *cb_data) + void *cb_data) { + const nir_lower_single_sampled_options *options = cb_data; + nir_def *lowered; switch (intrin->intrinsic) { case nir_intrinsic_load_sample_id: @@ -45,7 +47,7 @@ lower_single_sampled_instr(nir_builder *b, /* Don't lower to helper invocations if helper invocations are going * to be lowered right back to sample mask. */ - if (b->shader->options->lower_helper_invocation) + if (!options->lower_sample_mask_in || b->shader->options->lower_helper_invocation) return false; b->cursor = nir_before_instr(&intrin->instr); @@ -90,7 +92,7 @@ lower_single_sampled_instr(nir_builder *b, * barycentrics to pixel, and constant-folds various built-ins. */ bool -nir_lower_single_sampled(nir_shader *shader) +nir_lower_single_sampled(nir_shader *shader, const nir_lower_single_sampled_options *options) { assert(shader->info.stage == MESA_SHADER_FRAGMENT); @@ -118,6 +120,6 @@ nir_lower_single_sampled(nir_shader *shader) return nir_shader_intrinsics_pass(shader, lower_single_sampled_instr, nir_metadata_control_flow, - NULL) || + (void *)options) || progress; } diff --git a/src/intel/compiler/brw/brw_nir.c b/src/intel/compiler/brw/brw_nir.c index f0dc7ede52f..98e4f1b320d 100644 --- a/src/intel/compiler/brw/brw_nir.c +++ b/src/intel/compiler/brw/brw_nir.c @@ -1064,7 +1064,10 @@ brw_nir_lower_fs_inputs(nir_shader *nir, brw_nir_lower_fs_barycentrics(nir); if (key->multisample_fbo == INTEL_NEVER) { - NIR_PASS(_, nir, nir_lower_single_sampled); + nir_lower_single_sampled_options lss_opts = { + .lower_sample_mask_in = key->coarse_pixel == INTEL_NEVER, + }; + NIR_PASS(_, nir, nir_lower_single_sampled, &lss_opts); } else if (key->persample_interp == INTEL_ALWAYS) { NIR_PASS(_, nir, nir_shader_intrinsics_pass, lower_barycentric_per_sample, diff --git a/src/intel/compiler/elk/elk_nir.c b/src/intel/compiler/elk/elk_nir.c index f37f3dc8233..7b4d8661205 100644 --- a/src/intel/compiler/elk/elk_nir.c +++ b/src/intel/compiler/elk/elk_nir.c @@ -594,7 +594,10 @@ elk_nir_lower_fs_inputs(nir_shader *nir, nir_lower_io_use_interpolated_input_intrinsics); if (key->multisample_fbo == ELK_NEVER) { - nir_lower_single_sampled(nir); + nir_lower_single_sampled_options lss_opts = { + .lower_sample_mask_in = true, + }; + nir_lower_single_sampled(nir, &lss_opts); } else if (key->persample_interp == ELK_ALWAYS) { nir_shader_intrinsics_pass(nir, lower_barycentric_per_sample, nir_metadata_control_flow,