summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2020-04-21 16:07:55 -0700
committerMarge Bot <[email protected]>2020-04-23 18:52:46 +0000
commit91668ae8391d3e4d14f5cfe60d2755385a81a64d (patch)
treea8610102b42c5766a49c857bd259ef1cfaf488f3 /src/compiler
parent49ce749d0e25d957c6a38f1165b63a31baed708d (diff)
nir/lower_two_sided_color: Fix picking of new driver location.
We have shader->num_inputs for "last used input + 1" already, which respects struct/matrix varyings. Reviewed-by: Connor Abbott <[email protected]> Reviewed-by: Jose Maria Casanova Crespo <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4670>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_lower_two_sided_color.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c
index 8fd0c0a264a..04bb5d1ec76 100644
--- a/src/compiler/nir/nir_lower_two_sided_color.c
+++ b/src/compiler/nir/nir_lower_two_sided_color.c
@@ -46,23 +46,21 @@ typedef struct {
*/
static nir_variable *
-create_input(nir_shader *shader, unsigned drvloc, gl_varying_slot slot,
+create_input(nir_shader *shader, gl_varying_slot slot,
enum glsl_interp_mode interpolation)
{
nir_variable *var = rzalloc(shader, nir_variable);
- var->data.driver_location = drvloc;
+ var->data.driver_location = shader->num_inputs++;
var->type = glsl_vec4_type();
var->data.mode = nir_var_shader_in;
- var->name = ralloc_asprintf(var, "in_%d", drvloc);
+ var->name = ralloc_asprintf(var, "in_%d", var->data.driver_location);
var->data.index = 0;
var->data.location = slot;
var->data.interpolation = interpolation;
exec_list_push_tail(&shader->inputs, &var->node);
- shader->num_inputs++; /* TODO use type_size() */
-
return var;
}
@@ -84,17 +82,8 @@ load_input(nir_builder *b, nir_variable *in)
static int
setup_inputs(lower_2side_state *state)
{
- int maxloc = -1;
-
/* find color inputs: */
nir_foreach_variable(var, &state->shader->inputs) {
- int loc = var->data.driver_location;
-
- /* keep track of last used driver-location.. we'll be
- * appending BCLr after last existing input:
- */
- maxloc = MAX2(maxloc, loc);
-
switch (var->data.location) {
case VARYING_SLOT_COL0:
case VARYING_SLOT_COL1:
@@ -119,7 +108,7 @@ setup_inputs(lower_2side_state *state)
slot = VARYING_SLOT_BFC1;
state->colors[i].back = create_input(
- state->shader, ++maxloc, slot,
+ state->shader, slot,
state->colors[i].front->data.interpolation);
}