nir: Add per_view attribute to nir_variable
[mesa.git] / src / compiler / nir / nir_gather_info.c
index ef5d053c26673ab46b8f987c3a05969f7a1bcacf..e80a65f19fd618dc8333ce476c3f562fde21f600 100644 (file)
@@ -161,6 +161,17 @@ mark_whole_variable(nir_shader *shader, nir_variable *var,
       type = glsl_get_array_element(type);
    }
 
+   if (var->data.per_view) {
+      /* TODO: Per view and Per Vertex are not currently used together.  When
+       * they start to be used (e.g. when adding Primitive Replication for GS
+       * on Intel), verify that "peeling" the type twice is correct.  This
+       * assert ensures we remember it.
+       */
+      assert(!nir_is_per_vertex_io(var, shader->info.stage));
+      assert(glsl_type_is_array(type));
+      type = glsl_get_array_element(type);
+   }
+
    const unsigned slots =
       var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
                         : glsl_count_attribute_slots(type, false);
@@ -209,6 +220,10 @@ try_mask_partial_io(nir_shader *shader, nir_variable *var,
       type = glsl_get_array_element(type);
    }
 
+   /* Per view variables will be considered as a whole. */
+   if (var->data.per_view)
+      return false;
+
    /* The code below only handles:
     *
     * - Indexing into matrices