diff options
author | Timothy Arceri <[email protected]> | 2016-05-18 10:26:05 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-07-07 10:26:43 +1000 |
commit | 448adfbc67f4f6d0268a2f94dac311a26dc19864 (patch) | |
tree | 48dc87befc3feb9ecce2f1dfe567a8a3fd29aba0 /src/compiler/nir | |
parent | 0eea6b3297930d36cd510fa6b0e35c91935928f2 (diff) |
nir: use the same driver location for packed varyings
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir.h | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_io.c | 28 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 23f7f1f66cf..a7921eeb2ab 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2312,8 +2312,8 @@ void nir_lower_io_to_temporaries(nir_shader *shader, nir_function *entrypoint, void nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint); -void nir_assign_var_locations(struct exec_list *var_list, - unsigned *size, +void nir_assign_var_locations(struct exec_list *var_list, unsigned *size, + unsigned base_offset, int (*type_size)(const struct glsl_type *)); void nir_lower_io(nir_shader *shader, diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 72f1b05e675..c25790a6c3c 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -43,10 +43,18 @@ struct lower_io_state { void nir_assign_var_locations(struct exec_list *var_list, unsigned *size, + unsigned base_offset, int (*type_size)(const struct glsl_type *)) { unsigned location = 0; + /* There are 32 regular and 32 patch varyings allowed */ + int locations[64][2]; + for (unsigned i = 0; i < 64; i++) { + for (unsigned j = 0; j < 2; j++) + locations[i][j] = -1; + } + nir_foreach_variable(var, var_list) { /* * UBO's have their own address spaces, so don't count them towards the @@ -56,8 +64,24 @@ nir_assign_var_locations(struct exec_list *var_list, unsigned *size, var->interface_type != NULL) continue; - var->data.driver_location = location; - location += type_size(var->type); + /* Make sure we give the same location to varyings packed with + * ARB_enhanced_layouts. + */ + int idx = var->data.location - base_offset; + if (base_offset && idx >= 0) { + assert(idx < ARRAY_SIZE(locations)); + + if (locations[idx][var->data.index] == -1) { + var->data.driver_location = location; + locations[idx][var->data.index] = location; + location += type_size(var->type); + } else { + var->data.driver_location = locations[idx][var->data.index]; + } + } else { + var->data.driver_location = location; + location += type_size(var->type); + } } *size = location; |