gallium: Fix setup of pstipple frag coord var.
authorEric Anholt <eric@anholt.net>
Tue, 21 Apr 2020 23:18:42 +0000 (16:18 -0700)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Apr 2020 18:52:46 +0000 (18:52 +0000)
If the last input was a struct or matrix, we would have overlapped driver
locations for our new position var.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4670>

src/gallium/auxiliary/nir/nir_draw_helpers.c

index 7a6936d63d7b6189b38053d69d404fe7eaed33dc..33fdf4aee690c2800112b271c7f15ca4eb3e2596 100644 (file)
@@ -49,20 +49,16 @@ typedef struct {
 static nir_ssa_def *
 load_frag_coord(nir_builder *b)
 {
-   int max_driver_loc = -1;
    nir_foreach_variable(var, &b->shader->inputs) {
       if (var->data.location == VARYING_SLOT_POS)
          return nir_load_var(b, var);
-      if (max_driver_loc < (int)var->data.driver_location)
-         max_driver_loc = var->data.driver_location;
    }
 
    nir_variable *pos = nir_variable_create(b->shader, nir_var_shader_in,
                                            glsl_vec4_type(), NULL);
    pos->data.location = VARYING_SLOT_POS;
    pos->data.interpolation = INTERP_MODE_NOPERSPECTIVE;
-   pos->data.driver_location = max_driver_loc + 1;
-   b->shader->num_inputs++;
+   pos->data.driver_location = b->shader->num_inputs++;
    return nir_load_var(b, pos);
 }