return true;
}
+static bool ppir_lower_load(ppir_block *block, ppir_node *node)
+{
+ ppir_node *move = ppir_node_create(block, ppir_op_mov, -1 , 0);
+ 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_uniform;
+
+ alu->num_src = 1;
+ ppir_node_target_assign(&alu->src[0], dest);
+ 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_op_trunc] = ppir_lower_trunc,
[ppir_op_sat] = ppir_lower_sat,
[ppir_op_branch] = ppir_lower_branch,
+ [ppir_op_load_uniform] = ppir_lower_load,
+ [ppir_op_load_temp] = ppir_lower_load,
};
bool ppir_lower_prog(ppir_compiler *comp)
dup->instr = instr;
dup->instr_pos = node->instr_pos;
ppir_node_replace_pred(dep, dup);
-
- if ((node->op == ppir_op_load_uniform) || (node->op == ppir_op_load_temp)) {
- ppir_load_node *load = ppir_node_to_load(node);
- ppir_load_node *dup_load = ppir_node_to_load(dup);
- dup_load->dest = load->dest;
- dup_load->index = load->index;
- dup_load->num_components = load->num_components;
- instr->slots[node->instr_pos] = dup;
- }
}
list_splicetail(&dup_list, &node->list);
break;
}
case ppir_node_type_load:
- if ((node->op == ppir_op_load_uniform) || (node->op == ppir_op_load_temp)) {
- /* merge pred load_uniform into succ instr can save a reg
- * by using pipeline reg */
- if (!insert_to_each_succ_instr(block, node))
- return false;
-
- ppir_load_node *load = ppir_node_to_load(node);
- load->dest.type = ppir_target_pipeline;
- load->dest.pipeline = ppir_pipeline_reg_uniform;
- }
- else if (node->op == ppir_op_load_temp) {
- /* merge pred load_temp into succ instr can save a reg
- * by using pipeline reg */
- if (!insert_to_each_succ_instr(block, node))
- return false;
-
- ppir_load_node *load = ppir_node_to_load(node);
- load->dest.type = ppir_target_pipeline;
- load->dest.pipeline = ppir_pipeline_reg_uniform;
- }
- else if (node->op == ppir_op_load_varying ||
- node->op == ppir_op_load_fragcoord ||
- node->op == ppir_op_load_pointcoord ||
- node->op == ppir_op_load_frontface) {
- /* delay the load varying dup to scheduler */
+ if (node->op == ppir_op_load_varying ||
+ node->op == ppir_op_load_fragcoord ||
+ node->op == ppir_op_load_pointcoord ||
+ node->op == ppir_op_load_frontface) {
if (!create_new_instr(block, node))
return false;
}