ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / intel_shader_atomic_float_minmax / execution / ssbo-atomicCompSwap-float-NaN.shader_test
blob5919f1c15775ffcc05193ce9c2c4e56f175c1d44
1 [require]
2 GL >= 3.3
3 GLSL >= 3.30
4 GL_ARB_shader_storage_buffer_object
5 GL_INTEL_shader_atomic_float_minmax
7 [vertex shader passthrough]
9 [fragment shader]
10 #extension GL_ARB_shader_storage_buffer_object: require
11 #extension GL_INTEL_shader_atomic_float_minmax: require
13 layout(binding = 0) buffer bufblock {
14         float value[8];
17 #define POS_NAN(x) (0x7f800000u | (0x007fffffu & uint(x)))
18 #define NEG_NAN(x) (0xff800000u | (0x007fffffu & uint(x)))
20 uniform uint comparitors[] = uint[](POS_NAN(0x00ffffff),
21                                     NEG_NAN(0x00ffffff),
22                                     POS_NAN(0x00555555),
23                                     NEG_NAN(0x00555555),
24                                     POS_NAN(0x00aaaaaa),
25                                     NEG_NAN(0x00aaaaaa),
26                                     floatBitsToUint(0.0),
27                                     floatBitsToUint(1.0));
29 out vec4 color;
31 void main()
33         uint idx = uint(gl_FragCoord.x + gl_FragCoord.y) % uint(value.length());
35         /* This compare-and-swap should never succeed because NaN is never
36          * equal to anything.  Either the value in the SSBO or the value being
37          * compared is NaN.  If the compare-and-swap succeeds, the SSBO
38          * element will forever be set to float(idx).
39          */
40         atomicCompSwap(value[idx],
41                        uintBitsToFloat(comparitors[idx]),
42                        42.0);
44         color = value[idx] == 42.0
45                 ? vec4(1.0, 0.0, 0.0, 1.0)
46                 : vec4(0.0, 1.0, 0.0, 1.0);
49 [test]
50 ssbo 0 32
51 ssbo 0 subdata int  0 0x7fffffff
52 ssbo 0 subdata int  4 0xffffffff
53 ssbo 0 subdata int  8 0x7fd55555
54 ssbo 0 subdata int 12 0xffd55555
55 ssbo 0 subdata float 16 0.0
56 ssbo 0 subdata float 20 1.0
57 ssbo 0 subdata int 24 0x7faaaaaa
58 ssbo 0 subdata int 28 0xffaaaaaa
60 clear color 0.5 0.5 0.5 0.5
61 clear
63 draw rect -1 -1 2 2
64 probe all rgba 0.0 1.0 0.0 1.0