glsl/nir: Set uses_sample_shading from glsl_to_nir

We don't really want to base this on a late nir_gather_info for two
reasons:

 1) The GL spec says that any static use of a sample-qualified input,
    gl_SampleID, or gl_SamplePosition causes per-sample dispatch.  This
    means we really should gather this information before dead-code has
    a chance to delete anything.

 2) We want to be able to add nir_intrinsic_load_sample_pos intrinsics
    as part of lowering passes without causing per-sample interpolation.
    This means nir_gather_info needs to stop gathering it.

For 1, this doesn't actually get us quite there as GLSL IR may have
deleted something already.  However, it does get us closer.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14020>
This commit is contained in:
Jason Ekstrand 2021-12-01 15:49:38 -06:00 committed by Marge Bot
parent fd17aaf430
commit 830654b7b0
1 changed files with 12 additions and 0 deletions

View File

@ -259,6 +259,18 @@ glsl_to_nir(const struct gl_constants *consts,
shader->info.fs.pixel_center_integer = sh->Program->info.fs.pixel_center_integer;
shader->info.fs.origin_upper_left = sh->Program->info.fs.origin_upper_left;
shader->info.fs.advanced_blend_modes = sh->Program->info.fs.advanced_blend_modes;
nir_foreach_variable_with_modes(var, shader,
nir_var_shader_in |
nir_var_system_value) {
if (var->data.mode == nir_var_system_value &&
(var->data.location == SYSTEM_VALUE_SAMPLE_ID ||
var->data.location == SYSTEM_VALUE_SAMPLE_POS))
shader->info.fs.uses_sample_shading = true;
if (var->data.mode == nir_var_shader_in && var->data.sample)
shader->info.fs.uses_sample_shading = true;
}
}
return shader;