Mesa (master): nir/clip_disable: try for better no-op

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 5 22:15:06 UTC 2020


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Sep  2 10:09:21 2020 -0400

nir/clip_disable: try for better no-op

we can just check the bits using clip_distance_array_size here to simplify
everything and more easily determine if we need to be running this pass

Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6563>

---

 src/compiler/nir/nir_lower_clip_disable.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/compiler/nir/nir_lower_clip_disable.c b/src/compiler/nir/nir_lower_clip_disable.c
index 102eab58deb..3ca25620e7e 100644
--- a/src/compiler/nir/nir_lower_clip_disable.c
+++ b/src/compiler/nir/nir_lower_clip_disable.c
@@ -101,14 +101,11 @@ nir_lower_clip_disable(nir_shader *shader, unsigned clip_plane_enable)
 {
    bool progress = false;
 
-   nir_foreach_shader_out_variable(var, shader) {
-      if (var->data.location == VARYING_SLOT_CLIP_DIST0) {
-         unsigned size = glsl_get_length(var->type);
-         /* if currently-enabled planes match used planes then no-op */
-         if (clip_plane_enable == (1u << size) - 1)
-            return false;
-      }
-   }
+   /* if all user planes are enabled in API that are written in the array, always ignore;
+    * this explicitly covers the 2x vec4 case
+    */
+   if (clip_plane_enable == u_bit_consecutive(0, shader->info.clip_distance_array_size))
+      return false;
 
    nir_foreach_function(function, shader) {
       if (function->impl) {



More information about the mesa-commit mailing list