summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasily Khoruzhick <[email protected]>2019-08-22 07:42:56 -0700
committerVasily Khoruzhick <[email protected]>2019-08-23 18:19:47 -0700
commit8dd195e86570138684910a646e23e70284eacdf2 (patch)
tree2823af8b68e0dc107c4aeed8adc3f3927a03530f
parent7f814d2b467a3bf7082f07a907606a18068dd089 (diff)
lima/ppir: turn store_color into ALU node
We don't have a special OP to store color in PP, all we need to do is to store gl_FragColor into reg0, thus it's just a mov and therefore ALU node. Yet we still need to indicate that it's store_color op so regalloc ignores its destination. Tested-by: Andreas Baierl <[email protected]> Reviewed-by: Qiang Yu <[email protected]> Reviewed-by: Erico Nunes <[email protected]> Signed-off-by: Vasily Khoruzhick <[email protected]>
-rw-r--r--src/gallium/drivers/lima/ir/pp/codegen.c2
-rw-r--r--src/gallium/drivers/lima/ir/pp/nir.c25
-rw-r--r--src/gallium/drivers/lima/ir/pp/node.c6
-rw-r--r--src/gallium/drivers/lima/ir/pp/node_to_instr.c55
4 files changed, 27 insertions, 61 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/codegen.c b/src/gallium/drivers/lima/ir/pp/codegen.c
index 43dd896695c..4b1c48dffa3 100644
--- a/src/gallium/drivers/lima/ir/pp/codegen.c
+++ b/src/gallium/drivers/lima/ir/pp/codegen.c
@@ -168,6 +168,7 @@ static void ppir_codegen_encode_vec_mul(ppir_node *node, void *code)
f->op = shift_to_op(alu->shift);
break;
case ppir_op_mov:
+ case ppir_op_store_color:
f->op = ppir_codegen_vec4_mul_op_mov;
break;
case ppir_op_max:
@@ -310,6 +311,7 @@ static void ppir_codegen_encode_vec_add(ppir_node *node, void *code)
f->op = ppir_codegen_vec4_acc_op_add;
break;
case ppir_op_mov:
+ case ppir_op_store_color:
f->op = ppir_codegen_vec4_acc_op_mov;
break;
case ppir_op_sum3:
diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c
index 3793f2a1543..75a09f0d441 100644
--- a/src/gallium/drivers/lima/ir/pp/nir.c
+++ b/src/gallium/drivers/lima/ir/pp/nir.c
@@ -286,7 +286,7 @@ static ppir_node *ppir_emit_intrinsic(ppir_block *block, nir_instr *ni)
nir_intrinsic_instr *instr = nir_instr_as_intrinsic(ni);
unsigned mask = 0;
ppir_load_node *lnode;
- ppir_store_node *snode;
+ ppir_alu_node *alu_node;
switch (instr->intrinsic) {
case nir_intrinsic_load_input:
@@ -344,20 +344,29 @@ static ppir_node *ppir_emit_intrinsic(ppir_block *block, nir_instr *ni)
return &lnode->node;
- case nir_intrinsic_store_output:
- snode = ppir_node_create_dest(block, ppir_op_store_color, NULL, 0);
- if (!snode)
+ case nir_intrinsic_store_output: {
+ alu_node = ppir_node_create_dest(block, ppir_op_store_color, NULL, 0);
+ if (!alu_node)
return NULL;
- snode->index = nir_intrinsic_base(instr);
+ ppir_dest *dest = ppir_node_get_dest(&alu_node->node);
+ dest->type = ppir_target_ssa;
+ dest->ssa.num_components = instr->num_components;
+ dest->ssa.live_in = INT_MAX;
+ dest->ssa.live_out = 0;
+ dest->ssa.index = 0;
+ dest->write_mask = u_bit_consecutive(0, instr->num_components);
+
+ alu_node->num_src = 1;
for (int i = 0; i < instr->num_components; i++)
- snode->src.swizzle[i] = i;
+ alu_node->src[0].swizzle[i] = i;
- ppir_node_add_src(block->comp, &snode->node, &snode->src, instr->src,
+ ppir_node_add_src(block->comp, &alu_node->node, alu_node->src, instr->src,
u_bit_consecutive(0, instr->num_components));
- return &snode->node;
+ return &alu_node->node;
+ }
case nir_intrinsic_discard:
return ppir_emit_discard(block, ni);
diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c
index 37dd65823fa..59635df3cdf 100644
--- a/src/gallium/drivers/lima/ir/pp/node.c
+++ b/src/gallium/drivers/lima/ir/pp/node.c
@@ -308,7 +308,11 @@ const ppir_op_info ppir_op_infos[] = {
},
[ppir_op_store_color] = {
.name = "st_col",
- .type = ppir_node_type_store,
+ .type = ppir_node_type_alu,
+ .slots = (int []) {
+ PPIR_INSTR_SLOT_ALU_VEC_ADD, PPIR_INSTR_SLOT_ALU_VEC_MUL,
+ PPIR_INSTR_SLOT_END
+ },
},
[ppir_op_store_temp] = {
.name = "st_temp",
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 d1ceb2c67b6..50a3c65ebc7 100644
--- a/src/gallium/drivers/lima/ir/pp/node_to_instr.c
+++ b/src/gallium/drivers/lima/ir/pp/node_to_instr.c
@@ -87,6 +87,9 @@ static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node, ppir_n
if (!node->instr && !create_new_instr(block, node))
return false;
+ if (node->op == ppir_op_store_color)
+ node->instr->is_end = true;
+
break;
}
case ppir_node_type_load:
@@ -118,58 +121,6 @@ static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node, ppir_n
return false;
break;
}
-
- /* Only the store color node should appear here.
- * Currently we always insert a move node as the end instr.
- * But it should only be done when:
- * 1. store a const node
- * 2. store a load node
- * 3. store a reg assigned in another block like loop/if
- */
-
- assert(node->op == ppir_op_store_color);
-
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1, 0);
- if (unlikely(!move))
- return false;
-
- ppir_debug("node_to_instr create move %d from store %d\n",
- move->index, node->index);
-
- ppir_node_foreach_pred_safe(node, dep) {
- ppir_node *pred = dep->pred;
- /* we can't do this in this function except here as this
- * store is the root of this recursion */
- ppir_node_remove_dep(dep);
- ppir_node_add_dep(move, pred);
- }
-
- ppir_node_add_dep(node, move);
- list_addtail(&move->list, &node->list);
-
- ppir_alu_node *alu = ppir_node_to_alu(move);
- ppir_store_node *store = ppir_node_to_store(node);
- alu->src[0] = store->src;
- alu->num_src = 1;
-
- alu->dest.type = ppir_target_ssa;
- alu->dest.ssa.num_components = 4;
- alu->dest.ssa.live_in = INT_MAX;
- alu->dest.ssa.live_out = 0;
- alu->dest.write_mask = 0xf;
-
- store->src.type = ppir_target_ssa;
- store->src.ssa = &alu->dest.ssa;
-
- if (!create_new_instr(block, move))
- return false;
-
- move->instr->is_end = true;
- node->instr = move->instr;
-
- /* use move for the following recursion */
- *next = move;
- break;
}
case ppir_node_type_discard:
if (!create_new_instr(block, node))