Mesa (main): glsl/nir: Set uses_sample_shading from glsl_to_nir

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 13 21:04:29 UTC 2022


Module: Mesa
Branch: main
Commit: 830654b7b0fc13f489c8e485ac68ca850a6f5b7f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=830654b7b0fc13f489c8e485ac68ca850a6f5b7f

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Dec  1 15:49:38 2021 -0600

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 at intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14020>

---

 src/compiler/glsl/glsl_to_nir.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 983d89f19b8..7dff79114c4 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -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;



More information about the mesa-commit mailing list