From 632a921bd0dd40ad3167a0b8a74fe7054a78256a Mon Sep 17 00:00:00 2001 From: Erico Nunes Date: Thu, 23 Apr 2020 20:12:01 +0200 Subject: [PATCH] lima/ppir: optimize tex loads with single successor These don't need a mov, and can be used directly with pipeline output. Signed-off-by: Erico Nunes Reviewed-by: Vasily Khoruzhick Part-of: --- src/gallium/drivers/lima/ir/pp/lower.c | 19 +++++++++++++++++-- src/gallium/drivers/lima/ir/pp/nir.c | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c index ada735a160e..2480d79ffc0 100644 --- a/src/gallium/drivers/lima/ir/pp/lower.c +++ b/src/gallium/drivers/lima/ir/pp/lower.c @@ -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; diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index bb42c35dd76..a2f3406e414 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -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: -- 2.30.2