Mesa (staging/19.0): compiler: Mark clip/cull distance arrays as compact before lowering.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 26 18:38:06 UTC 2019


Module: Mesa
Branch: staging/19.0
Commit: bb3fdedadfe71f5f865e2e5b9b81bb77790a498f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb3fdedadfe71f5f865e2e5b9b81bb77790a498f

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Jan 23 01:55:45 2019 -0800

compiler: Mark clip/cull distance arrays as compact before lowering.

nir_lower_clip_cull_distance_arrays() marks the combined clip/cull
distance array as compact.  However, when translating in from GLSL
or SPIR-V, we were not marking the original float[] arrays as compact.

We should do so.  That way, we can detect these corner cases properly.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
(cherry picked from commit ef99f4c8d176f4e854e12afa1545fa53f651d758)
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 src/compiler/glsl/glsl_to_nir.cpp  | 12 ++++++++++++
 src/compiler/spirv/vtn_variables.c |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index d2db0f95aca..47fc2fea160 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -353,6 +353,12 @@ nir_visitor::visit(ir_variable *ir)
               ir->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) {
             var->data.compact = ir->type->without_array()->is_scalar();
          }
+
+         if (shader->info.stage > MESA_SHADER_VERTEX &&
+             ir->data.location >= VARYING_SLOT_CLIP_DIST0 &&
+             ir->data.location <= VARYING_SLOT_CULL_DIST1) {
+            var->data.compact = ir->type->without_array()->is_scalar();
+         }
       }
       break;
 
@@ -363,6 +369,12 @@ nir_visitor::visit(ir_variable *ir)
            ir->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) {
          var->data.compact = ir->type->without_array()->is_scalar();
       }
+
+      if (shader->info.stage <= MESA_SHADER_GEOMETRY &&
+          ir->data.location >= VARYING_SLOT_CLIP_DIST0 &&
+          ir->data.location <= VARYING_SLOT_CULL_DIST1) {
+         var->data.compact = ir->type->without_array()->is_scalar();
+      }
       break;
 
    case ir_var_uniform:
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index ecdfd0c735f..f6b458b7e78 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1444,6 +1444,8 @@ apply_var_decoration(struct vtn_builder *b,
       switch (builtin) {
       case SpvBuiltInTessLevelOuter:
       case SpvBuiltInTessLevelInner:
+      case SpvBuiltInClipDistance:
+      case SpvBuiltInCullDistance:
          var_data->compact = true;
          break;
       case SpvBuiltInFragCoord:




More information about the mesa-commit mailing list