Mesa (master): lima/ppir: combine varying loads in node_to_instr

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 9 11:46:09 UTC 2020


Module: Mesa
Branch: master
Commit: 09003ba0700ed0ddc57d85e82320f15a2a90c8dd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=09003ba0700ed0ddc57d85e82320f15a2a90c8dd

Author: Erico Nunes <nunes.erico at gmail.com>
Date:   Mon Apr 13 15:26:16 2020 +0200

lima/ppir: combine varying loads in node_to_instr

Varying loads with a single successor have a high potential to be
combined with its successor node, like ppir does for uniforms, rather
than being in a separate instruction.
Even if ppir becomes capable of combining instructions in a separate
step, combining varying loads during node_to_instr is trivial enough
that it seems to be worth doing it in this stage, and this benefits
pretty much every program that uses varyings.

Signed-off-by: Erico Nunes <nunes.erico at gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4535>

---

 src/gallium/drivers/lima/ir/pp/node_to_instr.c | 30 +++++++++++++++++++-------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/lima/ir/pp/node_to_instr.c b/src/gallium/drivers/lima/ir/pp/node_to_instr.c
index 9882951db46..35cf5f10f63 100644
--- a/src/gallium/drivers/lima/ir/pp/node_to_instr.c
+++ b/src/gallium/drivers/lima/ir/pp/node_to_instr.c
@@ -42,23 +42,37 @@ static bool create_new_instr(ppir_block *block, ppir_node *node)
  * successor.
  * Since it has a pipeline dest, it must have only one successor and since we
  * schedule nodes backwards, its successor must have already been scheduled.
+ * Load varyings can't output to a pipeline register but are also potentially
+ * trivial to insert and save an instruction if they have a single successor.
  */
-static bool ppir_do_node_to_instr_pipeline(ppir_block *block, ppir_node *node)
+static bool ppir_do_node_to_instr_try_insert(ppir_block *block, ppir_node *node)
 {
    ppir_dest *dest = ppir_node_get_dest(node);
 
-   if (!dest || dest->type != ppir_target_pipeline)
+   if (dest && dest->type == ppir_target_pipeline) {
+      assert(ppir_node_has_single_src_succ(node));
+      ppir_node *succ = ppir_node_first_succ(node);
+      assert(succ);
+      assert(succ->instr);
+
+      return ppir_instr_insert_node(succ->instr, node);
+   }
+
+   switch (node->type) {
+      case ppir_node_type_load:
+         break;
+      default:
+         return false;
+   }
+
+   if (!ppir_node_has_single_src_succ(node))
       return false;
 
-   assert(ppir_node_has_single_src_succ(node));
    ppir_node *succ = ppir_node_first_succ(node);
    assert(succ);
    assert(succ->instr);
 
-   if (!ppir_instr_insert_node(succ->instr, node))
-      return false;
-
-   return true;
+   return ppir_instr_insert_node(succ->instr, node);
 }
 
 static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node, ppir_node **next)
@@ -184,7 +198,7 @@ static bool ppir_do_node_to_instr(ppir_block *block, ppir_node *node)
    ppir_node *next = node;
 
    /* first try pipeline sched, if that didn't succeed try normal scheduling */
-   if (!ppir_do_node_to_instr_pipeline(block, node))
+   if (!ppir_do_node_to_instr_try_insert(block, node))
       if (!ppir_do_one_node_to_instr(block, node, &next))
          return false;
 



More information about the mesa-commit mailing list