Allow alternative mix() implementation
authorPyry Haulos <phaulos@google.com>
Fri, 29 May 2015 21:06:53 +0000 (14:06 -0700)
committerPyry Haulos <phaulos@google.com>
Fri, 29 May 2015 21:50:21 +0000 (14:50 -0700)
Some compilers translate mix(a, b, x) to a + (b - a)*x which produces
slightly different results than the form a*(1 - x) + b*x suggested by
the GLSL specification. This change relaxes tests to allow both forms.

Bug: 21110253
Change-Id: I3af056145ef8e64c0fc998302770fd38d105481a

modules/glshared/glsBuiltinPrecisionTests.cpp

index b954cad..c7d2928 100644 (file)
@@ -3240,7 +3240,8 @@ ExprP<float> clamp(const ExprP<float>& x, const ExprP<float>& minVal, const Expr
        return app<Clamp>(x, minVal, maxVal);
 }
 
-DEFINE_DERIVED_FLOAT3(Mix, mix, x, y, a, (x * (constant(1.0f) - a)) + y * a);
+DEFINE_DERIVED_FLOAT3(Mix, mix, x, y, a, alternatives((x * (constant(1.0f) - a)) + y * a,
+                                                                                                         x + (y - x) * a));
 
 static double step (double edge, double x)
 {