1 # Test proper behavior of the isnan(vec2) function.
3 # Note: testing behavior if isnan() is challenging because the GLSL
4 # 1.30 spec does not explicitly define any circumstances under which
5 # NaN values are required to be generated. This test assumes that the
6 # expression 0.0/0.0 produces a NaN value when evaluated in the
14 uniform float numerator = 0.0;
15 uniform float denominator = 0.0;
16 uniform float a = -99999.0;
17 uniform float c = 99999.0;
19 in vec4 piglit_vertex;
24 gl_Position = piglit_vertex;
26 float b = numerator / denominator;
28 /* We're attempting to trick the optimizer. We're assuming that
29 * isnan is implemented as x != x. It's possible that an optimizer
30 * might replace x == x && y < x with just y < x because the result
31 * is the same. Since nothing here is marked precise, it's also
32 * possible that the optimizer might replace y < x && y < z with y
33 * < min(x, z). It is likely that min(x, z) will produce z when x
34 * is NaN, and that final result is incorrect.
36 if (!isnan(b) && a < b && a < c)
37 color = vec4(1., 0., 0., 1.);
39 color = vec4(0., 1., 0., 1.);
46 out vec4 piglit_fragcolor;
50 piglit_fragcolor = color;
55 probe rgba 0 0 0.0 1.0 0.0 1.0