From 7e66da89f8aad7a6d0df57d2efa34a23bb526da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Wed, 1 Dec 2021 16:24:43 +0100 Subject: [PATCH] nir: Fix sorting per-primitive outputs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 59860d487368e18a1d85ea96988c5f4c904879b0 Signed-off-by: Timur Kristóf Reviewed-by: Marek Olšák Reviewed-by: Timothy Arceri Part-of: --- src/compiler/nir/nir_linking_helpers.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index ffedcc3854f..872eb205692 100644 --- a/src/compiler/nir/nir_linking_helpers.c +++ b/src/compiler/nir/nir_linking_helpers.c @@ -1415,7 +1415,8 @@ insert_sorted(struct exec_list *var_list, nir_variable *new_var) * In the future we can add an option for this, if needed by other HW. */ if (new_var->data.per_primitive < var->data.per_primitive || - var->data.location > new_var->data.location) { + (new_var->data.per_primitive == var->data.per_primitive && + var->data.location > new_var->data.location)) { exec_node_insert_node_before(&var->node, &new_var->node); return; } @@ -1445,7 +1446,8 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode, struct exec_list io_vars; sort_varyings(shader, mode, &io_vars); - int UNUSED last_loc = 0; + int ASSERTED last_loc = 0; + bool ASSERTED last_per_prim = false; bool last_partial = false; nir_foreach_variable_in_list(var, &io_vars) { const struct glsl_type *type = var->type; @@ -1539,10 +1541,13 @@ nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode, * the current array we are processing. * * NOTE: The code below assumes the var list is ordered in ascending - * location order. + * location order, but per-vertex/per-primitive outputs may be + * grouped separately. */ - assert(last_loc <= var->data.location); + assert(last_loc <= var->data.location || + last_per_prim != var->data.per_primitive); last_loc = var->data.location; + last_per_prim = var->data.per_primitive; unsigned last_slot_location = driver_location + var_size; if (last_slot_location > location) { unsigned num_unallocated_slots = last_slot_location - location;