Module: Mesa
Branch: master
Commit: 128b2de63b415e96225a2077846d64bd54edbcff
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=128b2de63b415e96225a2077846d64bd54edbcff

Author: Samuel Pitoiset <[email protected]>
Date:   Wed Dec  2 16:18:13 2020 +0100

nir: gather if a fragment shader uses sample shading

This introduces a new flag in shader_info to know if a fragment
shader uses sample shading, even if there is no inputs.

During NIR linking, constants varyings are optimized and the
per-sample interpolation info (ie. the sample qualifier) might
be removed if nir_shader_gather_info() is called again.

Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7876>

---

 src/compiler/nir/nir_gather_info.c | 11 +++++++++++
 src/compiler/shader_info.h         |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/src/compiler/nir/nir_gather_info.c 
b/src/compiler/nir/nir_gather_info.c
index ad0423ad99e..3d55698cde1 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -859,4 +859,15 @@ nir_shader_gather_info(nir_shader *shader, 
nir_function_impl *entrypoint)
       gather_info_block(block, shader, dead_ctx);
    }
    ralloc_free(dead_ctx);
+
+   if (shader->info.stage == MESA_SHADER_FRAGMENT &&
+       (shader->info.fs.uses_sample_qualifier ||
+        (shader->info.system_values_read & 
BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_ID)) ||
+         shader->info.system_values_read & 
BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_POS))) {
+      /* This shouldn't be cleared because if optimizations remove all
+       * sample-qualified inputs and that pass is run again, the sample
+       * shading must stay enabled.
+       */
+      shader->info.fs.uses_sample_shading = true;
+   }
 }
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index dfaaa4f0fa6..bc3d45b06db 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -286,6 +286,11 @@ typedef struct shader_info {
           */
          bool uses_sample_qualifier:1;
 
+         /**
+          * Whether sample shading is used.
+          */
+         bool uses_sample_shading:1;
+
          /**
           * Whether early fragment tests are enabled as defined by
           * ARB_shader_image_load_store.

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to