Mesa (main): nir: Group per-primitive outputs at the end for driver location assign.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 16 08:20:39 UTC 2021


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

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Sun Oct 31 21:09:08 2021 +0100

nir: Group per-primitive outputs at the end for driver location assign.

Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Acked-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13466>

---

 src/compiler/nir/nir_linking_helpers.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c
index 313a234a7f9..ffedcc3854f 100644
--- a/src/compiler/nir/nir_linking_helpers.c
+++ b/src/compiler/nir/nir_linking_helpers.c
@@ -1406,7 +1406,16 @@ static void
 insert_sorted(struct exec_list *var_list, nir_variable *new_var)
 {
    nir_foreach_variable_in_list(var, var_list) {
-      if (var->data.location > new_var->data.location) {
+      /* Use the `per_primitive` bool to sort per-primitive variables
+       * to the end of the list, so they get the last driver locations
+       * by nir_assign_io_var_locations.
+       *
+       * This is done because AMD HW requires that per-primitive outputs
+       * are the last params.
+       * 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) {
          exec_node_insert_node_before(&var->node, &new_var->node);
          return;
       }



More information about the mesa-commit mailing list