Commit 3703c9b8 authored by Qiang Yu's avatar Qiang Yu

lima/ppir: fix load coord from const node crash

fragment shader from glamor:

precision mediump float;

varying vec2 glyph_pos;
uniform sampler2D sampler;
uniform sampler2D atlas;
void main() {
       vec4 mask = texture2D(atlas, glyph_pos);
       vec4 source = texture2D(sampler, vec2(0.5));
       gl_FragColor = source * mask.a;
}
Signed-off-by: Qiang Yu's avatarQiang Yu <yuq825@gmail.com>
parent cea7264d
......@@ -93,29 +93,34 @@ static bool insert_to_each_succ_instr(ppir_block *block, ppir_node *node)
ppir_node_foreach_succ_safe(node, dep) {
ppir_node *succ = dep->succ;
assert(succ->type == ppir_node_type_alu);
if (!ppir_instr_insert_node(succ->instr, node)) {
/* create a move node to insert for failed node */
if (!move) {
move = ppir_node_create(block, ppir_op_mov, -1, 0);
if (unlikely(!move))
return false;
if (node->op != ppir_op_const || succ->op != ppir_op_load_coords) {
assert(succ->type == ppir_node_type_alu);
ppir_debug("node_to_instr create move %d for %d\n",
move->index, node->index);
if (ppir_instr_insert_node(succ->instr, node))
continue;
}
ppir_alu_node *alu = ppir_node_to_alu(move);
alu->dest = *dest;
alu->num_src = 1;
ppir_node_target_assign(alu->src, dest);
for (int i = 0; i < 4; i++)
alu->src->swizzle[i] = i;
}
/* create a move node to insert for const+load_coords or
* insert failed case */
if (!move) {
move = ppir_node_create(block, ppir_op_mov, -1, 0);
if (unlikely(!move))
return false;
ppir_debug("node_to_instr create move %d for %d\n",
move->index, node->index);
ppir_node_replace_pred(dep, move);
ppir_node_replace_child(succ, node, move);
ppir_alu_node *alu = ppir_node_to_alu(move);
alu->dest = *dest;
alu->num_src = 1;
ppir_node_target_assign(alu->src, dest);
for (int i = 0; i < 4; i++)
alu->src->swizzle[i] = i;
}
ppir_node_replace_pred(dep, move);
ppir_node_replace_child(succ, node, move);
}
if (move) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment