compiler: Mark clip/cull distance arrays as compact before lowering.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 23 Jan 2019 09:55:45 +0000 (01:55 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 5 Feb 2019 21:58:46 +0000 (13:58 -0800)
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@itsqueeze.com>
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/spirv/vtn_variables.c

index 90aa21f314902e028ba5166549df2fe537d7ec23..09599e4cee711b556a5cc8a129346029362c3f3a 100644 (file)
@@ -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:
index ecdfd0c735f6ff7da674703efde6a6d29476085d..f6b458b7e78cc55eb32a8e8173e4b85743572bd5 100644 (file)
@@ -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: