On 11/16/2014 05:51 PM, Thomas Helland wrote: > The spec states that pow is undefined for x < 0. > Just set the range to correspond to a constant 0 > if this is the case.
It is technically undefined, but I think all hardware either follows the SM2.0 rules[1] or the SM5 rules[2]. Since a lot of the applications run on Mesa are, alas, ports of DX apps, they may depend on one of these behaviors. A SM2.0 app will have gone through the HLSL compiler, which I *think* just lowers pow(x,y) to exp(y, log(abs(x)), so it may not matter too much there. I'm not sure what the right answer is. 1: http://msdn.microsoft.com/en-us/library/windows/desktop/bb147286(v=vs.85).aspx 2: http://msdn.microsoft.com/en-us/library/windows/desktop/bb509636(v=vs.85).aspx > --- > src/glsl/opt_minmax.cpp | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/src/glsl/opt_minmax.cpp b/src/glsl/opt_minmax.cpp > index 9852dd9..ad8c88a 100644 > --- a/src/glsl/opt_minmax.cpp > +++ b/src/glsl/opt_minmax.cpp > @@ -335,6 +335,17 @@ get_range(ir_rvalue *rval) > high = add(r0.high, r1.high)->constant_expression_value(); > return minmax_range(low, high); > > + case ir_binop_pow: > + r0 = get_range(expr->operands[0]); > + if (is_greater_than_or_equal_zero(r0.low)) > + low = new(mem_ctx) ir_constant(0.0f); > + // Result is undefined so we can set the range to bikeshed. > + if (is_less_than_zero(r0.high)) { > + low = new(mem_ctx) ir_constant(0.0f); > + high = new(mem_ctx) ir_constant(0.0f); > + } > + return minmax_range(low, high); > + > default: > break; > } > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev