lima/ppir: optimize tex loads with single successor
authorErico Nunes <nunes.erico@gmail.com>
Thu, 23 Apr 2020 18:12:01 +0000 (20:12 +0200)
committerErico Nunes <nunes.erico@gmail.com>
Sat, 16 May 2020 15:24:03 +0000 (17:24 +0200)
These don't need a mov, and can be used directly with pipeline output.

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

src/gallium/drivers/lima/ir/pp/lower.c
src/gallium/drivers/lima/ir/pp/nir.c

index ada735a160ee0559ba1a2afcabd5d1819739a775..2480d79ffc050572828197c1d503b49bb3dc9eaf 100644 (file)
@@ -162,7 +162,22 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
 {
    ppir_dest *dest = ppir_node_get_dest(node);
 
-   /* Always create move node since there can be successors in other blocks */
+   if (ppir_node_has_single_succ(node)) {
+      ppir_node *succ = ppir_node_first_succ(node);
+      dest->type = ppir_target_pipeline;
+      dest->pipeline = ppir_pipeline_reg_sampler;
+
+      for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
+         ppir_src *src = ppir_node_get_src(succ, i);
+         if (src && src->node == node) {
+            src->type = ppir_target_pipeline;
+            src->pipeline = ppir_pipeline_reg_sampler;
+         }
+      }
+      return true;
+   }
+
+   /* Create move node as fallback */
    ppir_node *move = ppir_node_insert_mov(node);
    if (unlikely(!move))
       return false;
@@ -170,7 +185,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
    ppir_debug("lower texture create move %d for %d\n",
               move->index, node->index);
 
-   ppir_src *mov_src ppir_node_get_src(move, 0);
+   ppir_src *mov_src = ppir_node_get_src(move, 0);
    mov_src->type = dest->type = ppir_target_pipeline;
    mov_src->pipeline = dest->pipeline = ppir_pipeline_reg_sampler;
 
index bb42c35dd763a6e73fcbf79585ad383e06c2a07f..a2f3406e41410ff0bed9e82fae5f5c8fc01e475d 100644 (file)
@@ -349,6 +349,7 @@ static bool ppir_emit_intrinsic(ppir_block *block, nir_instr *ni)
          node = block->comp->var_nodes[instr->src->ssa->index];
          switch (node->op) {
          case ppir_op_load_uniform:
+         case ppir_op_load_texture:
          case ppir_op_const:
             break;
          default: