perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / tests / spec / glsl-1.30 / execution / vs-isnan-and-more-comparison.shader_test
blob638ebf305c3904a440b342ce85666df1a1edeacc
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
7 # shader.
9 [require]
10 GLSL >= 1.30
12 [vertex shader]
13 #version 130
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;
20 out vec4 color;
22 void main()
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.
35     */
36    if (!isnan(b) && a < b && a < c)
37       color = vec4(1., 0., 0., 1.);
38    else
39       color = vec4(0., 1., 0., 1.);
42 [fragment shader]
43 #version 130
45 in vec4 color;
46 out vec4 piglit_fragcolor;
48 void main()
50    piglit_fragcolor = color;
53 [test]
54 draw rect -1 -1 2 2
55 probe rgba 0 0 0.0 1.0 0.0 1.0