Mesa (main): nir: Fix sorting per-primitive outputs.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Dec 3 17:48:01 UTC 2021


Module: Mesa
Branch: main
Commit: 7e66da89f8aad7a6d0df57d2efa34a23bb526da0
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7e66da89f8aad7a6d0df57d2efa34a23bb526da0

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Wed Dec  1 16:24:43 2021 +0100

nir: Fix sorting per-primitive outputs.

Fixes: 59860d487368e18a1d85ea96988c5f4c904879b0
Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14006>

---

 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;



More information about the mesa-commit mailing list