diff options
author | Roland Scheidegger <[email protected]> | 2016-12-03 17:08:05 +0100 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2016-12-06 04:10:43 +0100 |
commit | df33f11b39abf313a0db7b9fefaf739b88133161 (patch) | |
tree | baa8bf7b746ce641b1ed39e65ca31feb4bd23101 | |
parent | 3015a23fe0eab17cde163b1de141f75c2f6410e4 (diff) |
glsl: fix ldexp lowering if bitfield insert lowering is also requested
Trivial, this just resurrects the code which was there once upon a time
(the code can't lower instructions generated in the lowering pass there,
and even if it could it would probably be suboptimal).
This fixes piglit mesa_shader_integer_functions fs-ldexp.shader_test and
vs-ldexp.shader_test with llvmpipe.
Reviewed-by: Matt Turner <[email protected]>
-rw-r--r-- | src/compiler/glsl/lower_instructions.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/compiler/glsl/lower_instructions.cpp b/src/compiler/glsl/lower_instructions.cpp index 372ded180a5..3e25e2b91bf 100644 --- a/src/compiler/glsl/lower_instructions.cpp +++ b/src/compiler/glsl/lower_instructions.cpp @@ -392,7 +392,6 @@ lower_instructions_visitor::ldexp_to_arith(ir_expression *ir) ir_constant *sign_mask = new(ir) ir_constant(0x80000000u, vec_elem); ir_constant *exp_shift = new(ir) ir_constant(23, vec_elem); - ir_constant *exp_width = new(ir) ir_constant(8, vec_elem); /* Temporary variables */ ir_variable *x = new(ir) ir_variable(ir->type, "x", ir_var_temporary); @@ -455,10 +454,22 @@ lower_instructions_visitor::ldexp_to_arith(ir_expression *ir) */ ir_constant *exp_shift_clone = exp_shift->clone(ir, NULL); - ir->operation = ir_unop_bitcast_i2f; - ir->operands[0] = bitfield_insert(bitcast_f2i(x), resulting_biased_exp, - exp_shift_clone, exp_width); - ir->operands[1] = NULL; + + /* Don't generate new IR that would need to be lowered in an additional + * pass. + */ + if (!lowering(INSERT_TO_SHIFTS)) { + ir_constant *exp_width = new(ir) ir_constant(8u, vec_elem); + ir->operation = ir_unop_bitcast_i2f; + ir->operands[0] = bitfield_insert(bitcast_f2i(x), resulting_biased_exp, + exp_shift_clone, exp_width); + ir->operands[1] = NULL; + } else { + ir_constant *sign_mantissa_mask = new(ir) ir_constant(0x807fffffu, vec_elem); + ir->operation = ir_unop_bitcast_u2f; + ir->operands[0] = bit_or(bit_and(bitcast_f2u(x), sign_mantissa_mask), + lshift(i2u(resulting_biased_exp), exp_shift_clone)); + } this->progress = true; } |