summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/lima
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/lima')
-rw-r--r--src/gallium/drivers/lima/ir/pp/lower.c110
-rw-r--r--src/gallium/drivers/lima/lima_program.c11
2 files changed, 14 insertions, 107 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c
index 20520073001..2b4da2c2992 100644
--- a/src/gallium/drivers/lima/ir/pp/lower.c
+++ b/src/gallium/drivers/lima/ir/pp/lower.c
@@ -72,101 +72,6 @@ static bool ppir_lower_const(ppir_block *block, ppir_node *node)
return true;
}
-static ppir_reg *create_reg(ppir_compiler *comp, int num_components)
-{
- ppir_reg *r = rzalloc(comp, ppir_reg);
- if (!r)
- return NULL;
-
- r->num_components = num_components;
- r->live_in = INT_MAX;
- r->live_out = 0;
- r->is_head = false;
- list_addtail(&r->list, &comp->reg_list);
-
- return r;
-}
-
-/* lower vector alu node to multi scalar nodes */
-static bool ppir_lower_vec_to_scalar(ppir_block *block, ppir_node *node)
-{
- ppir_alu_node *alu = ppir_node_to_alu(node);
- ppir_dest *dest = &alu->dest;
-
- int n = 0;
- int index[4];
-
- unsigned mask = dest->write_mask;
- while (mask)
- index[n++] = u_bit_scan(&mask);
-
- if (n == 1)
- return true;
-
- ppir_reg *r;
- /* we need a reg for scalar nodes to store output */
- if (dest->type == ppir_target_register)
- r = dest->reg;
- else {
- r = create_reg(block->comp, n);
- if (!r)
- return false;
-
- /* change all successors to use reg r */
- ppir_node_foreach_succ(node, dep) {
- ppir_node *succ = dep->succ;
- if (succ->type == ppir_node_type_alu) {
- ppir_alu_node *sa = ppir_node_to_alu(succ);
- for (int i = 0; i < sa->num_src; i++) {
- ppir_src *src = sa->src + i;
- if (ppir_node_target_equal(src, dest)) {
- src->type = ppir_target_register;
- src->reg = r;
- }
- }
- }
- else {
- assert(succ->type == ppir_node_type_store);
- ppir_store_node *ss = ppir_node_to_store(succ);
- ppir_src *src = &ss->src;
- src->type = ppir_target_register;
- src->reg = r;
- }
- }
- }
-
- /* create each component's scalar node */
- for (int i = 0; i < n; i++) {
- ppir_node *s = ppir_node_create(block, node->op, -1, 0);
- if (!s)
- return false;
- list_addtail(&s->list, &node->list);
-
- ppir_alu_node *sa = ppir_node_to_alu(s);
- ppir_dest *sd = &sa->dest;
- sd->type = ppir_target_register;
- sd->reg = r;
- sd->modifier = dest->modifier;
- sd->write_mask = 1 << index[i];
-
- for (int j = 0; j < alu->num_src; j++)
- sa->src[j] = alu->src[j];
- sa->num_src = alu->num_src;
-
- /* TODO: need per reg component dependancy */
- ppir_node_foreach_succ(node, dep) {
- ppir_node_add_dep(dep->succ, s);
- }
-
- ppir_node_foreach_pred(node, dep) {
- ppir_node_add_dep(s, dep->pred);
- }
- }
-
- ppir_node_delete(node);
- return true;
-}
-
static bool ppir_lower_swap_args(ppir_block *block, ppir_node *node)
{
/* swapped op must be the next op */
@@ -210,9 +115,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
return true;
}
-/* Prepare for sin and cos and then lower vector alu node to multi
- * scalar nodes */
-static bool ppir_lower_sin_cos_vec_to_scalar(ppir_block *block, ppir_node *node)
+static bool ppir_lower_sin_cos(ppir_block *block, ppir_node *node)
{
ppir_alu_node *alu = ppir_node_to_alu(node);
@@ -264,7 +167,7 @@ static bool ppir_lower_sin_cos_vec_to_scalar(ppir_block *block, ppir_node *node)
ppir_node_add_dep(node, mul_node);
ppir_node_add_dep(mul_node, inv_2pi_node);
- return ppir_lower_vec_to_scalar(block, node);
+ return true;
}
/* insert a move as the select condition to make sure it can
@@ -402,13 +305,8 @@ static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, ppir_node *) = {
[ppir_op_abs] = ppir_lower_abs,
[ppir_op_neg] = ppir_lower_neg,
[ppir_op_const] = ppir_lower_const,
- [ppir_op_rcp] = ppir_lower_vec_to_scalar,
- [ppir_op_rsqrt] = ppir_lower_vec_to_scalar,
- [ppir_op_log2] = ppir_lower_vec_to_scalar,
- [ppir_op_exp2] = ppir_lower_vec_to_scalar,
- [ppir_op_sqrt] = ppir_lower_vec_to_scalar,
- [ppir_op_sin] = ppir_lower_sin_cos_vec_to_scalar,
- [ppir_op_cos] = ppir_lower_sin_cos_vec_to_scalar,
+ [ppir_op_sin] = ppir_lower_sin_cos,
+ [ppir_op_cos] = ppir_lower_sin_cos,
[ppir_op_lt] = ppir_lower_swap_args,
[ppir_op_le] = ppir_lower_swap_args,
[ppir_op_load_texture] = ppir_lower_texture,
diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c
index 51cd180cf47..13fd31166ae 100644
--- a/src/gallium/drivers/lima/lima_program.c
+++ b/src/gallium/drivers/lima/lima_program.c
@@ -139,8 +139,17 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
void
lima_program_optimize_fs_nir(struct nir_shader *s)
{
+ BITSET_DECLARE(alu_lower, nir_num_opcodes) = {0};
bool progress;
+ BITSET_SET(alu_lower, nir_op_frcp);
+ BITSET_SET(alu_lower, nir_op_frsq);
+ BITSET_SET(alu_lower, nir_op_flog2);
+ BITSET_SET(alu_lower, nir_op_fexp2);
+ BITSET_SET(alu_lower, nir_op_fsqrt);
+ BITSET_SET(alu_lower, nir_op_fsin);
+ BITSET_SET(alu_lower, nir_op_fcos);
+
NIR_PASS_V(s, nir_lower_fragcoord_wtrans);
NIR_PASS_V(s, nir_lower_io, nir_var_all, type_size, 0);
NIR_PASS_V(s, nir_lower_regs_to_ssa);
@@ -150,7 +159,7 @@ lima_program_optimize_fs_nir(struct nir_shader *s)
progress = false;
NIR_PASS_V(s, nir_lower_vars_to_ssa);
- //NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL);
+ NIR_PASS(progress, s, nir_lower_alu_to_scalar, alu_lower);
NIR_PASS(progress, s, nir_lower_phis_to_scalar);
NIR_PASS(progress, s, nir_copy_prop);
NIR_PASS(progress, s, nir_opt_remove_phis);