summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2018-08-27 19:07:08 -0700
committerIan Romanick <ian.d.romanick@intel.com>2018-08-27 19:35:30 -0700
commit1754ca968711c98d18f36245c8d92a2c9dd1485b (patch)
treef2c0272c85ca9a7f7af0733c5da6728f55887b0b
parent073264e08526f2d984ee249c880fdcdf3a825651 (diff)
nv_shader_atomic_int64: Add atomicCompSwap testsNV_shader_atomic_int64
-rw-r--r--tests/spec/nv_shader_atomic_int64/execution/shared-atomicCompSwap-int64.shader_test68
-rw-r--r--tests/spec/nv_shader_atomic_int64/execution/ssbo-atomicCompSwap-int64.shader_test89
2 files changed, 157 insertions, 0 deletions
diff --git a/tests/spec/nv_shader_atomic_int64/execution/shared-atomicCompSwap-int64.shader_test b/tests/spec/nv_shader_atomic_int64/execution/shared-atomicCompSwap-int64.shader_test
new file mode 100644
index 000000000..797d7f8a7
--- /dev/null
+++ b/tests/spec/nv_shader_atomic_int64/execution/shared-atomicCompSwap-int64.shader_test
@@ -0,0 +1,68 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_atomic_counters
+GL_ARB_gpu_shader_int64
+GL_NV_shader_atomic_int64
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+#extension GL_ARB_shader_atomic_counters: require
+#extension GL_ARB_gpu_shader_int64: require
+#extension GL_NV_shader_atomic_int64: require
+
+layout(local_size_x = 32) in;
+
+shared int64_t value;
+shared uint mask;
+
+layout(binding = 0) uniform atomic_uint pass;
+layout(binding = 0) uniform atomic_uint fail;
+
+void main()
+{
+ if (gl_LocalInvocationIndex == 0u) {
+ value = int64_t(0);
+ mask = 0u;
+ }
+
+ barrier();
+
+ /* Each local invocation should see a unique value. Each value
+ * observed is tracked in "mask." The test automatically fails if a
+ * duplicate value is observed. The test passes once all 32 possible
+ * values have been observed.
+ */
+ int64_t f = value;
+ int64_t a;
+
+ /* This is an open-coded atomicAdd. */
+ do {
+ a = f;
+ } while ((f = atomicCompSwap(value, f, f + (4L << 28))) != a);
+
+ uint i = uint(uint64_t(f) >> 28) / 4u;
+ uint bit = i % 32u;
+ uint m = 1u << bit;
+
+ if (i < 32u) {
+ /* If the bit was already set, the test fails. */
+ uint r = atomicOr(mask, m);
+ if ((r & m) != 0u)
+ atomicCounterIncrement(fail);
+
+ /* Once all 32 bits are set, the test passes. */
+ if ((r | m) == 0xffffffffu)
+ atomicCounterIncrement(pass);
+ } else {
+ atomicCounterIncrement(fail);
+ }
+}
+
+[test]
+atomic counters 2
+compute 2 3 4
+probe atomic counter 0 == 24
+probe atomic counter 1 == 0
diff --git a/tests/spec/nv_shader_atomic_int64/execution/ssbo-atomicCompSwap-int64.shader_test b/tests/spec/nv_shader_atomic_int64/execution/ssbo-atomicCompSwap-int64.shader_test
new file mode 100644
index 000000000..77fbee564
--- /dev/null
+++ b/tests/spec/nv_shader_atomic_int64/execution/ssbo-atomicCompSwap-int64.shader_test
@@ -0,0 +1,89 @@
+[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_ARB_gpu_shader5
+GL_ARB_gpu_shader_int64
+GL_NV_shader_atomic_int64
+
+[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_ARB_gpu_shader5: require
+#extension GL_ARB_gpu_shader_int64: require
+#extension GL_NV_shader_atomic_int64: require
+
+layout(binding = 0) buffer bufblock {
+ int64_t value;
+};
+
+/* GL_ARB_shader_atomic_counters requires at least 8 total counters. */
+layout(binding = 0) uniform atomic_uint mask[7];
+layout(binding = 0) uniform atomic_uint fail;
+
+out vec4 color;
+
+void main()
+{
+ /* According to issue #22 of the GL_ARB_shader_image_load_store, the
+ * return result of atomic operations in helper invocations is
+ * undefined. To avoid a possible infinite loop (below) in a helper
+ * invocation, bail out now.
+ */
+ if (gl_SampleMaskIn[0] == 0)
+ return;
+
+ /* Each of 32 * N fragments should see a unique value. Each value
+ * observed is tracked in "mask." The test automatically fails if a
+ * duplicate value is observed. After the shaders are done running,
+ * the mask values will be probed to ensure that all possible values
+ * were observed.
+ */
+ int64_t f;
+
+ /* This is an open-coded atomicAdd. */
+ do {
+ f = value;
+ } while (f != atomicCompSwap(value, f, f + (4L << 28)));
+
+ uint i = uint(uint64_t(f) >> 28) / 4u;
+ uint bit = i % 32u;
+ int c = int(i / 32u);
+ uint m = 1u << bit;
+
+ if (c < mask.length()) {
+ /* If the bit was already set, the test fails. */
+ if ((atomicCounterOrARB(mask[c], m) & m) != 0u)
+ atomicCounterIncrement(fail);
+
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+ } else {
+ color = vec4(0.0, 0.0, 1.0, 1.0);
+ }
+}
+
+[test]
+atomic counters 8
+
+ssbo 0 32
+ssbo 0 subdata int 0 0
+ssbo 0 subdata int 4 0
+
+clear color 0.5 0.5 0.5 0.5
+clear
+
+draw rect -1 -1 2 2
+
+probe atomic counter 0 == 4294967295
+probe atomic counter 1 == 4294967295
+probe atomic counter 2 == 4294967295
+probe atomic counter 3 == 4294967295
+probe atomic counter 4 == 4294967295
+probe atomic counter 5 == 4294967295
+probe atomic counter 6 == 4294967295
+probe atomic counter 7 == 0