[Piglit] [PATCH 5/7] intel_shader_atomic_float_minmax: Add tests for atomicCompSwap with -0
Ian Romanick
idr at freedesktop.org
Sat Jun 23 05:04:28 UTC 2018
From: Ian Romanick <ian.d.romanick at intel.com>
The idea is that implementations that use the integer compare-and-swap
hardware will not see that 0.0 == -0.0.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
...-atomicCompSwap-float-negative-zero.shader_test | 63 ++++++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-negative-zero.shader_test
diff --git a/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-negative-zero.shader_test b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-negative-zero.shader_test
new file mode 100644
index 000000000..3b16acc34
--- /dev/null
+++ b/tests/spec/intel_shader_atomic_float_minmax/execution/ssbo-atomicCompSwap-float-negative-zero.shader_test
@@ -0,0 +1,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) 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
--
2.14.4
More information about the Piglit
mailing list