File: ssbo-atomicCompSwap-float-negative-zero.shader_test

package info (click to toggle)
piglit 0~git20200212-f4710c51b-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 106,972 kB
  • sloc: ansic: 263,763; xml: 48,941; python: 29,918; lisp: 19,789; cpp: 12,142; sh: 22; makefile: 20; pascal: 5
file content (63 lines) | stat: -rw-r--r-- 1,525 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[require]
GL >= 3.3
GLSL >= 3.30
GL_ARB_shader_storage_buffer_object
GL_ARB_shader_atomic_counters
GL_ARB_shader_atomic_counter_ops
GL_INTEL_shader_atomic_float_minmax

[vertex shader passthrough]

[fragment shader]
#extension GL_ARB_shader_storage_buffer_object: require
#extension GL_ARB_shader_atomic_counters: require
#extension GL_ARB_shader_atomic_counter_ops: require
#extension GL_INTEL_shader_atomic_float_minmax: require

layout(binding = 0, std430) buffer bufblock {
	float value[8];
};

/* +0.0 and -0.0 stored as bits.  Storing these in a uniform and converting
 * them to float using uintBitsToFloat should prevent the compiler from
 * silently dropping the sign bit.
 */
uniform uint zeros[] = uint[](0x00000000u, 0x80000000u);

layout(binding = 0) uniform atomic_uint pass;

out vec4 color;

void main()
{
	uint idx = uint(gl_FragCoord.x + gl_FragCoord.y) % uint(value.length());
	float v = uintBitsToFloat(zeros[idx & 1u]);
	float f = atomicCompSwap(value[idx], v, 47.0 + float(idx));

	if (f == 0.0) {
		atomicCounterIncrement(pass);
		color = vec4(0.0, 1.0, 0.0, 1.0);
	} else {
		color = vec4(0.0, 0.0, 1.0, 1.0);
	}
}

[test]
atomic counters 1

ssbo 0 32
ssbo 0 subdata int  0 0x80000000
ssbo 0 subdata int  4 0x00000000
ssbo 0 subdata int  8 0x80000000
ssbo 0 subdata int 12 0x00000000
ssbo 0 subdata int 16 0x80000000
ssbo 0 subdata int 20 0x00000000
ssbo 0 subdata int 24 0x80000000
ssbo 0 subdata int 28 0x00000000

clear color 0.5 0.5 0.5 0.5
clear

draw rect -1 -1 2 2

probe atomic counter 0 == 8