glsl: Convert mix() to use a new ir_triop_lrp opcode.
Many GPUs have an instruction to do linear interpolation which is more efficient than simply performing the algebra necessary (two multiplies, an add, and a subtract). Pattern matching or peepholing this is more desirable, but can be tricky. By using an opcode, we can at least make shaders which use the mix() built-in get the more efficient behavior. Currently, all consumers lower ir_triop_lrp. Subsequent patches will actually generate different code. v2 [mattst88]: - Add LRP_TO_ARITH flag to ir_to_mesa.cpp. Will be removed in a subsequent patch and ir_triop_lrp translated directly. v3 [mattst88]: - Move changes from the next patch to opt_algebraic.cpp to accept 3-src operations. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:

committed by
Matt Turner

parent
18281d6088
commit
93066ce129
@@ -1478,6 +1478,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
|
||||
assert(!"not supported");
|
||||
break;
|
||||
|
||||
case ir_triop_lrp:
|
||||
assert(!"ir_triop_lrp should have been lowered.");
|
||||
break;
|
||||
|
||||
case ir_quadop_vector:
|
||||
/* This operation should have already been handled.
|
||||
*/
|
||||
@@ -2993,7 +2997,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
/* Lowering */
|
||||
do_mat_op_to_vec(ir);
|
||||
lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
|
||||
| LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
|
||||
| LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP | LRP_TO_ARITH
|
||||
| ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
|
||||
|
||||
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
|
||||
|
Reference in New Issue
Block a user