diff options
author | Connor Abbott <[email protected]> | 2014-08-05 10:54:27 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-01-15 07:18:58 -0800 |
commit | 494790b2a958f964547fb4362929171efffde153 (patch) | |
tree | 96681fa76d36cae557b22c70a4f9aa04c7b54a2d /src | |
parent | c2f36cf125f1301760e3653404b60d122bc38102 (diff) |
nir: keep track of the number of input, output, and uniform slots
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/nir/nir.c | 4 | ||||
-rw-r--r-- | src/glsl/nir/nir.h | 6 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_variables_scalar.c | 10 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 27436661d14..be293fb029c 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -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; } diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 8395953ab49..868c769d938 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -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) \ diff --git a/src/glsl/nir/nir_lower_variables_scalar.c b/src/glsl/nir/nir_lower_variables_scalar.c index 63c55c09694..48e43fefc79 100644 --- a/src/glsl/nir/nir_lower_variables_scalar.c +++ b/src/glsl/nir/nir_lower_variables_scalar.c @@ -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 |