nir: keep track of the number of input, output, and uniform slots
authorConnor Abbott <connor.abbott@intel.com>
Tue, 5 Aug 2014 17:54:27 +0000 (10:54 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Jan 2015 15:18:58 +0000 (07:18 -0800)
src/glsl/nir/nir.c
src/glsl/nir/nir.h
src/glsl/nir/nir_lower_variables_scalar.c

index 27436661d14e15f7adf07b60b02f36e4b2b5d0b0..be293fb029c2bb33749366505da7b5119690b393 100644 (file)
@@ -49,6 +49,10 @@ nir_shader_create(void *mem_ctx)
    exec_list_make_empty(&shader->system_values);
    shader->reg_alloc = 0;
 
+   shader->num_inputs = 0;
+   shader->num_outputs = 0;
+   shader->num_uniforms = 0;
+
    return shader;
 }
 
index 8395953ab49ee17367dd8114dfd3d45677dd82b9..868c769d938bc47e43aca5ce08e1fa80d6387038 100644 (file)
@@ -1138,6 +1138,12 @@ typedef struct nir_shader {
 
    /** next available global register index */
    unsigned reg_alloc;
+
+   /**
+    * the highest index a load_input_*, load_uniform_*, etc. intrinsic can
+    * access plus one
+    */
+   unsigned num_inputs, num_uniforms, num_outputs;
 } nir_shader;
 
 #define nir_foreach_overload(shader, overload) \
index 63c55c0969426cc6b5e5321df4e78d56679fcb9a..48e43fefc79ecde739141c81eea79dc18f1d2ba7 100644 (file)
@@ -75,7 +75,7 @@ type_size(const struct glsl_type *type)
  */
 
 static void
-assign_var_locations(struct hash_table *ht)
+assign_var_locations(struct hash_table *ht, unsigned *size)
 {
    unsigned location = 0;
 
@@ -93,14 +93,16 @@ assign_var_locations(struct hash_table *ht)
       var->data.driver_location = location;
       location += type_size(var->type);
    }
+
+   *size = location;
 }
 
 static void
 assign_var_locations_shader(nir_shader *shader)
 {
-   assign_var_locations(shader->inputs);
-   assign_var_locations(shader->outputs);
-   assign_var_locations(shader->uniforms);
+   assign_var_locations(shader->inputs, &shader->num_inputs);
+   assign_var_locations(shader->outputs, &shader->num_outputs);
+   assign_var_locations(shader->uniforms, &shader->num_uniforms);
 }
 
 static void