[Piglit] [PATCH 08/13] arb_compute_shader: Add tests for atomic{Min, Max}({u, }int, {u, }int)

Ian Romanick idr at freedesktop.org
Fri Jun 1 22:43:13 UTC 2018


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 .../execution/shared-atomicMax-int.shader_test     | 137 ++++++++++++++++++++
 .../execution/shared-atomicMax-uint.shader_test    | 137 ++++++++++++++++++++
 .../execution/shared-atomicMin-int.shader_test     | 141 +++++++++++++++++++++
 .../execution/shared-atomicMin-uint.shader_test    | 140 ++++++++++++++++++++
 4 files changed, 555 insertions(+)
 create mode 100644 tests/spec/arb_compute_shader/execution/shared-atomicMax-int.shader_test
 create mode 100644 tests/spec/arb_compute_shader/execution/shared-atomicMax-uint.shader_test
 create mode 100644 tests/spec/arb_compute_shader/execution/shared-atomicMin-int.shader_test
 create mode 100644 tests/spec/arb_compute_shader/execution/shared-atomicMin-uint.shader_test

diff --git a/tests/spec/arb_compute_shader/execution/shared-atomicMax-int.shader_test b/tests/spec/arb_compute_shader/execution/shared-atomicMax-int.shader_test
new file mode 100644
index 000000000..642e417d0
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/shared-atomicMax-int.shader_test
@@ -0,0 +1,137 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_storage_buffer_object
+GL_ARB_shader_atomic_counters
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+#extension GL_ARB_shader_storage_buffer_object: require
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(local_size_x = 64) in;
+
+layout(binding = 0) buffer bufblock {
+	int source_array[64];
+	int source_value;
+};
+
+shared int array[source_array.length()];
+shared int value;
+
+layout(binding = 0) uniform atomic_uint fail;
+
+void main()
+{
+	if (gl_LocalInvocationIndex == 0u) {
+		array = source_array;
+		value = source_value;
+	}
+
+	barrier();
+
+	int local_index = int(gl_LocalInvocationIndex);
+	int v;
+
+	/* For value, every instance should get 2147483647. */
+	v = atomicMax(value, local_index);
+	if (v != 2147483647)
+		atomicCounterIncrement(fail);
+
+	if (value != 2147483647)
+		atomicCounterIncrement(fail);
+
+	int first_expected = (local_index + 1) * -4;
+	int second_expected = local_index * 4;
+
+	/* The per-instance value should give the old value on the first step.
+	 * This is expected to be the negative byte offset of the next array
+	 * element.
+	 */
+	v = atomicMax(array[local_index], second_expected);
+	if (v != first_expected)
+		atomicCounterIncrement(fail);
+
+	/* The per-instance value should give the new value on the second
+	 * step.  This is expected to be the byte offset of the current array
+	 * element.
+	 */
+	v = atomicExchange(array[local_index], first_expected);
+	if (v != second_expected)
+		atomicCounterIncrement(fail);
+}
+
+[test]
+atomic counters 1
+
+ssbo 0 260
+ssbo 0 subdata int 0 -4
+ssbo 0 subdata int 4 -8
+ssbo 0 subdata int 8 -12
+ssbo 0 subdata int 12 -16
+ssbo 0 subdata int 16 -20
+ssbo 0 subdata int 20 -24
+ssbo 0 subdata int 24 -28
+ssbo 0 subdata int 28 -32
+ssbo 0 subdata int 32 -36
+ssbo 0 subdata int 36 -40
+ssbo 0 subdata int 40 -44
+ssbo 0 subdata int 44 -48
+ssbo 0 subdata int 48 -52
+ssbo 0 subdata int 52 -56
+ssbo 0 subdata int 56 -60
+ssbo 0 subdata int 60 -64
+ssbo 0 subdata int 64 -68
+ssbo 0 subdata int 68 -72
+ssbo 0 subdata int 72 -76
+ssbo 0 subdata int 76 -80
+ssbo 0 subdata int 80 -84
+ssbo 0 subdata int 84 -88
+ssbo 0 subdata int 88 -92
+ssbo 0 subdata int 92 -96
+ssbo 0 subdata int 96 -100
+ssbo 0 subdata int 100 -104
+ssbo 0 subdata int 104 -108
+ssbo 0 subdata int 108 -112
+ssbo 0 subdata int 112 -116
+ssbo 0 subdata int 116 -120
+ssbo 0 subdata int 120 -124
+ssbo 0 subdata int 124 -128
+ssbo 0 subdata int 128 -132
+ssbo 0 subdata int 132 -136
+ssbo 0 subdata int 136 -140
+ssbo 0 subdata int 140 -144
+ssbo 0 subdata int 144 -148
+ssbo 0 subdata int 148 -152
+ssbo 0 subdata int 152 -156
+ssbo 0 subdata int 156 -160
+ssbo 0 subdata int 160 -164
+ssbo 0 subdata int 164 -168
+ssbo 0 subdata int 168 -172
+ssbo 0 subdata int 172 -176
+ssbo 0 subdata int 176 -180
+ssbo 0 subdata int 180 -184
+ssbo 0 subdata int 184 -188
+ssbo 0 subdata int 188 -192
+ssbo 0 subdata int 192 -196
+ssbo 0 subdata int 196 -200
+ssbo 0 subdata int 200 -204
+ssbo 0 subdata int 204 -208
+ssbo 0 subdata int 208 -212
+ssbo 0 subdata int 212 -216
+ssbo 0 subdata int 216 -220
+ssbo 0 subdata int 220 -224
+ssbo 0 subdata int 224 -228
+ssbo 0 subdata int 228 -232
+ssbo 0 subdata int 232 -236
+ssbo 0 subdata int 236 -240
+ssbo 0 subdata int 240 -244
+ssbo 0 subdata int 244 -248
+ssbo 0 subdata int 248 -252
+ssbo 0 subdata int 252 -256
+ssbo 0 subdata int 256 2147483647
+
+compute 2 3 4
+probe atomic counter 0 == 0
diff --git a/tests/spec/arb_compute_shader/execution/shared-atomicMax-uint.shader_test b/tests/spec/arb_compute_shader/execution/shared-atomicMax-uint.shader_test
new file mode 100644
index 000000000..8264653e0
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/shared-atomicMax-uint.shader_test
@@ -0,0 +1,137 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_storage_buffer_object
+GL_ARB_shader_atomic_counters
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+#extension GL_ARB_shader_storage_buffer_object: require
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(local_size_x = 64) in;
+
+layout(binding = 0) buffer bufblock {
+	uint source_array[64];
+	uint source_value;
+};
+
+shared uint array[source_array.length()];
+shared uint value;
+
+layout(binding = 0) uniform atomic_uint fail;
+
+void main()
+{
+	if (gl_LocalInvocationIndex == 0u) {
+		array = source_array;
+		value = source_value;
+	}
+
+	barrier();
+
+	uint local_index = gl_LocalInvocationIndex;
+	uint v;
+
+	/* For value, every instance should get 2147483647. */
+	v = atomicMax(value, local_index);
+	if (v != 2147483647u)
+		atomicCounterIncrement(fail);
+
+	if (value != 2147483647u)
+		atomicCounterIncrement(fail);
+
+	uint first_expected = local_index * 4u;
+	uint second_expected = (local_index + 1u) * 4u;
+
+	/* The per-instance value should give the old value on the first step.
+	 * This is expected to be the byte offset of the current array
+	 * element.
+	 */
+	v = atomicMax(array[local_index], second_expected);
+	if (v != first_expected)
+		atomicCounterIncrement(fail);
+
+	/* The per-instance value should give the new value on the second
+	 * step.  This is expected to be the byte offset of the next array
+	 * element.
+	 */
+	v = atomicExchange(array[local_index], first_expected);
+	if (v != second_expected)
+		atomicCounterIncrement(fail);
+}
+
+[test]
+atomic counters 1
+
+ssbo 0 260
+ssbo 0 subdata int 0 0
+ssbo 0 subdata int 4 4
+ssbo 0 subdata int 8 8
+ssbo 0 subdata int 12 12
+ssbo 0 subdata int 16 16
+ssbo 0 subdata int 20 20
+ssbo 0 subdata int 24 24
+ssbo 0 subdata int 28 28
+ssbo 0 subdata int 32 32
+ssbo 0 subdata int 36 36
+ssbo 0 subdata int 40 40
+ssbo 0 subdata int 44 44
+ssbo 0 subdata int 48 48
+ssbo 0 subdata int 52 52
+ssbo 0 subdata int 56 56
+ssbo 0 subdata int 60 60
+ssbo 0 subdata int 64 64
+ssbo 0 subdata int 68 68
+ssbo 0 subdata int 72 72
+ssbo 0 subdata int 76 76
+ssbo 0 subdata int 80 80
+ssbo 0 subdata int 84 84
+ssbo 0 subdata int 88 88
+ssbo 0 subdata int 92 92
+ssbo 0 subdata int 96 96
+ssbo 0 subdata int 100 100
+ssbo 0 subdata int 104 104
+ssbo 0 subdata int 108 108
+ssbo 0 subdata int 112 112
+ssbo 0 subdata int 116 116
+ssbo 0 subdata int 120 120
+ssbo 0 subdata int 124 124
+ssbo 0 subdata int 128 128
+ssbo 0 subdata int 132 132
+ssbo 0 subdata int 136 136
+ssbo 0 subdata int 140 140
+ssbo 0 subdata int 144 144
+ssbo 0 subdata int 148 148
+ssbo 0 subdata int 152 152
+ssbo 0 subdata int 156 156
+ssbo 0 subdata int 160 160
+ssbo 0 subdata int 164 164
+ssbo 0 subdata int 168 168
+ssbo 0 subdata int 172 172
+ssbo 0 subdata int 176 176
+ssbo 0 subdata int 180 180
+ssbo 0 subdata int 184 184
+ssbo 0 subdata int 188 188
+ssbo 0 subdata int 192 192
+ssbo 0 subdata int 196 196
+ssbo 0 subdata int 200 200
+ssbo 0 subdata int 204 204
+ssbo 0 subdata int 208 208
+ssbo 0 subdata int 212 212
+ssbo 0 subdata int 216 216
+ssbo 0 subdata int 220 220
+ssbo 0 subdata int 224 224
+ssbo 0 subdata int 228 228
+ssbo 0 subdata int 232 232
+ssbo 0 subdata int 236 236
+ssbo 0 subdata int 240 240
+ssbo 0 subdata int 244 244
+ssbo 0 subdata int 248 248
+ssbo 0 subdata int 252 252
+ssbo 0 subdata int 256 2147483647
+
+compute 2 3 4
+probe atomic counter 0 == 0
diff --git a/tests/spec/arb_compute_shader/execution/shared-atomicMin-int.shader_test b/tests/spec/arb_compute_shader/execution/shared-atomicMin-int.shader_test
new file mode 100644
index 000000000..c06bd0ed3
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/shared-atomicMin-int.shader_test
@@ -0,0 +1,141 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_storage_buffer_object
+GL_ARB_shader_atomic_counters
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+#extension GL_ARB_shader_storage_buffer_object: require
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(local_size_x = 64) in;
+
+layout(binding = 0) buffer bufblock {
+	int source_array[64];
+	int source_value;
+};
+
+shared int array[source_array.length()];
+shared int value;
+
+layout(binding = 0) uniform atomic_uint fail;
+
+void main()
+{
+	if (gl_LocalInvocationIndex == 0u) {
+		array = source_array;
+		value = source_value;
+	}
+
+	barrier();
+
+	int local_index = int(gl_LocalInvocationIndex);
+	int v;
+
+	/* For value, every instance should get 5. */
+	v = atomicMin(value, 7 + local_index);
+	if (v != 5)
+		atomicCounterIncrement(fail);
+
+	if (value != 5)
+		atomicCounterIncrement(fail);
+
+	int first_expected = local_index * 4;
+	int second_expected = -first_expected;
+
+	/* The per-instance value should give the old value on the first step.
+	 * This is expected to be the byte offset of the current array
+	 * element.
+	 */
+	v = atomicMin(array[local_index], second_expected);
+	if (v != first_expected)
+		atomicCounterIncrement(fail);
+
+	/* The per-instance value should give the new value on the second
+	 * step.  This is expected to be the negative byte offset of the
+	 * current array element.
+	 */
+	v = atomicExchange(array[local_index], first_expected);
+	if (v != second_expected)
+		atomicCounterIncrement(fail);
+}
+
+[test]
+atomic counters 1
+
+ssbo 0 260
+ssbo 0 subdata int 0 0
+ssbo 0 subdata int 4 4
+ssbo 0 subdata int 8 8
+ssbo 0 subdata int 12 12
+ssbo 0 subdata int 16 16
+ssbo 0 subdata int 20 20
+ssbo 0 subdata int 24 24
+ssbo 0 subdata int 28 28
+ssbo 0 subdata int 32 32
+ssbo 0 subdata int 36 36
+ssbo 0 subdata int 40 40
+ssbo 0 subdata int 44 44
+ssbo 0 subdata int 48 48
+ssbo 0 subdata int 52 52
+ssbo 0 subdata int 56 56
+ssbo 0 subdata int 60 60
+ssbo 0 subdata int 64 64
+ssbo 0 subdata int 68 68
+ssbo 0 subdata int 72 72
+ssbo 0 subdata int 76 76
+ssbo 0 subdata int 80 80
+ssbo 0 subdata int 84 84
+ssbo 0 subdata int 88 88
+ssbo 0 subdata int 92 92
+ssbo 0 subdata int 96 96
+ssbo 0 subdata int 100 100
+ssbo 0 subdata int 104 104
+ssbo 0 subdata int 108 108
+ssbo 0 subdata int 112 112
+ssbo 0 subdata int 116 116
+ssbo 0 subdata int 120 120
+ssbo 0 subdata int 124 124
+ssbo 0 subdata int 128 128
+ssbo 0 subdata int 132 132
+ssbo 0 subdata int 136 136
+ssbo 0 subdata int 140 140
+ssbo 0 subdata int 144 144
+ssbo 0 subdata int 148 148
+ssbo 0 subdata int 152 152
+ssbo 0 subdata int 156 156
+ssbo 0 subdata int 160 160
+ssbo 0 subdata int 164 164
+ssbo 0 subdata int 168 168
+ssbo 0 subdata int 172 172
+ssbo 0 subdata int 176 176
+ssbo 0 subdata int 180 180
+ssbo 0 subdata int 184 184
+ssbo 0 subdata int 188 188
+ssbo 0 subdata int 192 192
+ssbo 0 subdata int 196 196
+ssbo 0 subdata int 200 200
+ssbo 0 subdata int 204 204
+ssbo 0 subdata int 208 208
+ssbo 0 subdata int 212 212
+ssbo 0 subdata int 216 216
+ssbo 0 subdata int 220 220
+ssbo 0 subdata int 224 224
+ssbo 0 subdata int 228 228
+ssbo 0 subdata int 232 232
+ssbo 0 subdata int 236 236
+ssbo 0 subdata int 240 240
+ssbo 0 subdata int 244 244
+ssbo 0 subdata int 248 248
+ssbo 0 subdata int 252 252
+ssbo 0 subdata int 256 5
+
+clear color 0.5 0.5 0.5 0.5
+clear
+
+draw rect -1 -1 2 2
+
+probe atomic counter 0 == 0
diff --git a/tests/spec/arb_compute_shader/execution/shared-atomicMin-uint.shader_test b/tests/spec/arb_compute_shader/execution/shared-atomicMin-uint.shader_test
new file mode 100644
index 000000000..93b799327
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/shared-atomicMin-uint.shader_test
@@ -0,0 +1,140 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_storage_buffer_object
+GL_ARB_shader_atomic_counters
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: require
+#extension GL_ARB_shader_storage_buffer_object: require
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(local_size_x = 64) in;
+
+layout(binding = 0) buffer bufblock {
+	uint source_array[64];
+	uint source_value;
+};
+
+shared uint array[source_array.length()];
+shared uint value;
+
+layout(binding = 0) uniform atomic_uint fail;
+
+void main()
+{
+	if (gl_LocalInvocationIndex == 0u) {
+		array = source_array;
+		value = source_value;
+	}
+
+	barrier();
+
+	uint local_index = gl_LocalInvocationIndex;
+	uint v;
+
+	/* For value, every instance should get 3. */
+	v = atomicMin(value, 7u + local_index);
+	if (v != 3u)
+		atomicCounterIncrement(fail);
+
+	if (value != 3u)
+		atomicCounterIncrement(fail);
+
+	uint first_expected = (local_index + 1u) * 4u;
+	uint second_expected = local_index * 4u;
+
+	/* The per-instance value should give the old value on the first step.
+	 * This is expected to be the byte offset of the next array element.
+	 */
+	v = atomicMin(array[local_index], second_expected);
+	if (v != first_expected)
+		atomicCounterIncrement(fail);
+
+	/* The per-instance value should give the new value on the second
+	 * step.  This is expected to be the byte offset of the current array
+	 * element.
+	 */
+	v = atomicExchange(array[local_index], first_expected);
+	if (v != second_expected)
+		atomicCounterIncrement(fail);
+}
+
+[test]
+atomic counters 1
+
+ssbo 0 260
+ssbo 0 subdata int 0 4
+ssbo 0 subdata int 4 8
+ssbo 0 subdata int 8 12
+ssbo 0 subdata int 12 16
+ssbo 0 subdata int 16 20
+ssbo 0 subdata int 20 24
+ssbo 0 subdata int 24 28
+ssbo 0 subdata int 28 32
+ssbo 0 subdata int 32 36
+ssbo 0 subdata int 36 40
+ssbo 0 subdata int 40 44
+ssbo 0 subdata int 44 48
+ssbo 0 subdata int 48 52
+ssbo 0 subdata int 52 56
+ssbo 0 subdata int 56 60
+ssbo 0 subdata int 60 64
+ssbo 0 subdata int 64 68
+ssbo 0 subdata int 68 72
+ssbo 0 subdata int 72 76
+ssbo 0 subdata int 76 80
+ssbo 0 subdata int 80 84
+ssbo 0 subdata int 84 88
+ssbo 0 subdata int 88 92
+ssbo 0 subdata int 92 96
+ssbo 0 subdata int 96 100
+ssbo 0 subdata int 100 104
+ssbo 0 subdata int 104 108
+ssbo 0 subdata int 108 112
+ssbo 0 subdata int 112 116
+ssbo 0 subdata int 116 120
+ssbo 0 subdata int 120 124
+ssbo 0 subdata int 124 128
+ssbo 0 subdata int 128 132
+ssbo 0 subdata int 132 136
+ssbo 0 subdata int 136 140
+ssbo 0 subdata int 140 144
+ssbo 0 subdata int 144 148
+ssbo 0 subdata int 148 152
+ssbo 0 subdata int 152 156
+ssbo 0 subdata int 156 160
+ssbo 0 subdata int 160 164
+ssbo 0 subdata int 164 168
+ssbo 0 subdata int 168 172
+ssbo 0 subdata int 172 176
+ssbo 0 subdata int 176 180
+ssbo 0 subdata int 180 184
+ssbo 0 subdata int 184 188
+ssbo 0 subdata int 188 192
+ssbo 0 subdata int 192 196
+ssbo 0 subdata int 196 200
+ssbo 0 subdata int 200 204
+ssbo 0 subdata int 204 208
+ssbo 0 subdata int 208 212
+ssbo 0 subdata int 212 216
+ssbo 0 subdata int 216 220
+ssbo 0 subdata int 220 224
+ssbo 0 subdata int 224 228
+ssbo 0 subdata int 228 232
+ssbo 0 subdata int 232 236
+ssbo 0 subdata int 236 240
+ssbo 0 subdata int 240 244
+ssbo 0 subdata int 244 248
+ssbo 0 subdata int 248 252
+ssbo 0 subdata int 252 256
+ssbo 0 subdata int 256 3
+
+clear color 0.5 0.5 0.5 0.5
+clear
+
+draw rect -1 -1 2 2
+
+probe atomic counter 0 == 0
-- 
2.14.4



More information about the Piglit mailing list