[Mesa-dev] [PATCH 4/9] glsl: Optimize ir_triop_lrp(x, y, a) with a = 0.0f or 1.0f
Kenneth Graunke
kenneth at whitecape.org
Tue Feb 26 09:54:00 PST 2013
On 02/19/2013 05:03 PM, Matt Turner wrote:
> ---
> src/glsl/opt_algebraic.cpp | 16 +++++++++++++---
> 1 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
> index 75948db..952941e 100644
> --- a/src/glsl/opt_algebraic.cpp
> +++ b/src/glsl/opt_algebraic.cpp
> @@ -186,12 +186,12 @@ ir_algebraic_visitor::swizzle_if_required(ir_expression *expr,
> ir_rvalue *
> ir_algebraic_visitor::handle_expression(ir_expression *ir)
> {
> - ir_constant *op_const[2] = {NULL, NULL};
> - ir_expression *op_expr[2] = {NULL, NULL};
> + ir_constant *op_const[3] = {NULL, NULL, NULL};
> + ir_expression *op_expr[3] = {NULL, NULL, NULL};
> ir_expression *temp;
> unsigned int i;
>
> - assert(ir->get_num_operands() <= 2);
> + assert(ir->get_num_operands() <= 3);
> for (i = 0; i < ir->get_num_operands(); i++) {
> if (ir->operands[i]->type->is_matrix())
> return ir;
> @@ -415,6 +415,16 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>
> break;
>
> + case ir_triop_lrp:
It might be nice to include a comment here, mostly to remind people that
the operands are x, y, a here (as opposed to y, x, a elsewhere).
Otherwise,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> + if (is_vec_zero(op_const[2])) {
> + this->progress = true;
> + return swizzle_if_required(ir, ir->operands[0]);
> + } else if (is_vec_one(op_const[2])) {
> + this->progress = true;
> + return swizzle_if_required(ir, ir->operands[1]);
> + }
> + break;
> +
> default:
> break;
> }
>
More information about the mesa-dev
mailing list