break;
}
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1, 0);
+ ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))
return false;
ppir_debug("lower const create move %d for %d\n",
move->index, node->index);
- ppir_alu_node *alu = ppir_node_to_alu(move);
- alu->dest = *dest;
- alu->num_src = 1;
- ppir_node_target_assign(alu->src, node);
- for (int s = 0; s < 4; s++)
- alu->src->swizzle[s] = s;
-
- ppir_node_foreach_succ_safe(node, dep) {
- ppir_node_replace_pred(dep, move);
- ppir_node_replace_child(succ, node, move);
- }
-
/* Need to be careful with changing src/dst type here:
* it has to be done *after* successors have their children
* replaced, otherwise ppir_node_replace_child() won't find
* matching src/dst and as result won't work
*/
- alu->src->type = dest->type = ppir_target_pipeline;
- alu->src->pipeline = dest->pipeline = ppir_pipeline_reg_const0;
+ 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_const0;
- ppir_node_add_dep(move, node);
- list_addtail(&move->list, &node->list);
return true;
}
return true;
}
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1 , 0);
+ ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))
return false;
- ppir_alu_node *alu = ppir_node_to_alu(move);
-
- alu->dest = *dest;
-
- ppir_node_replace_all_succ(move, node);
-
dest->type = ppir_target_pipeline;
dest->pipeline = ppir_pipeline_reg_uniform;
- alu->num_src = 1;
- ppir_node_target_assign(&alu->src[0], node);
- for (int i = 0; i < 4; i++)
- alu->src->swizzle[i] = i;
-
- ppir_node_add_dep(move, node);
- list_addtail(&move->list, &node->list);
-
return true;
}
static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
{
ppir_load_texture_node *load_tex = ppir_node_to_load_texture(node);
+ ppir_dest *dest = ppir_node_get_dest(node);
+
+ if (ppir_node_is_root(node) && dest->type == ppir_target_ssa) {
+ ppir_node_delete(node);
+ return true;
+ }
/* Create load_coords node */
ppir_load_node *load = ppir_node_create(block, ppir_op_load_coords, -1, 0);
ppir_node_add_dep(node, &load->node);
/* Create move node */
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1 , 0);
+ ppir_node *move = ppir_node_insert_mov(node);
if (unlikely(!move))
return false;
- ppir_alu_node *alu = ppir_node_to_alu(move);
-
- ppir_dest *dest = ppir_node_get_dest(node);
- alu->dest = *dest;
-
- ppir_node_replace_all_succ(move, node);
-
- dest->type = ppir_target_pipeline;
- dest->pipeline = ppir_pipeline_reg_sampler;
-
- alu->num_src = 1;
- ppir_node_target_assign(&alu->src[0], node);
- for (int i = 0; i < 4; i++)
- alu->src->swizzle[i] = i;
+ ppir_debug("lower texture create move %d for %d\n",
+ move->index, node->index);
- ppir_node_add_dep(move, node);
- list_addtail(&move->list, &node->list);
+ 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;
return true;
}