glsl: Lower if to conditional select instead of conditional assignment
Platforms that don't have flow control also don't have anything that
could be written that has a side effect. It should be safe to implement
these condition writes as
foo = csel(condition, bar, foo);
This should eliminate the last thing in the GLSL compiler that can
create new conditions on assignments. Everything else that can store
something in ir_assignment::condition derives it from a pre-existing
condition.
v2: Fix bad rebase.
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14573>
This commit is contained in:
@@ -201,14 +201,18 @@ move_block_to_cond_assign(void *mem_ctx,
|
||||
cond_expr->clone(mem_ctx, NULL),
|
||||
assign->rhs);
|
||||
} else {
|
||||
assign->condition = cond_expr->clone(mem_ctx, NULL);
|
||||
assign->rhs =
|
||||
new(mem_ctx) ir_expression(ir_triop_csel,
|
||||
cond_expr->clone(mem_ctx, NULL),
|
||||
assign->rhs,
|
||||
assign->lhs->as_dereference());
|
||||
}
|
||||
} else {
|
||||
assign->condition =
|
||||
new(mem_ctx) ir_expression(ir_binop_logic_and,
|
||||
glsl_type::bool_type,
|
||||
assign->rhs =
|
||||
new(mem_ctx) ir_expression(ir_triop_csel,
|
||||
cond_expr->clone(mem_ctx, NULL),
|
||||
assign->condition);
|
||||
assign->rhs,
|
||||
assign->lhs->as_dereference());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user