nir: add nir_lower_single_sampled::lower_sample_mask_in option
GLSL defines gl_SampleMaskIn as :
"a fragment language that indicates the set of samples covered
by the primitive generating the fragment during multisample
rasterization"
when variable rate shading is enabled, a single invocation might cover
multiple samples. The lowering done in nir_lower_single_sampled() does
not account for that case, so add an option to selectively disable it.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38641>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user