diff mbox

[V2,3/4] arb_arrays_of_arrays: add simple fs atomic counter execution test

Message ID 1438735003-10626-3-git-send-email-t_arceri@yahoo.com.au
State New
Headers show

Commit Message

'Timothy Arceri' via Patchwork Forward Aug. 5, 2015, 12:36 a.m. UTC
V2: Initialise correct number of counters, remove incorrect testing
of max buffer
---
 .../fs-simple-inc-dec-read.shader_test             | 108 +++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test
diff mbox

Patch

diff --git a/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test
new file mode 100644
index 0000000..68ddc46
--- /dev/null
+++ b/tests/spec/arb_arrays_of_arrays/execution/atomic_counters/fs-simple-inc-dec-read.shader_test
@@ -0,0 +1,108 @@ 
+# Simple test of atomicCounterIncrement, atomicCounterDecrement and
+# atomicCounter being used in the FS.
+
+[require]
+GLSL >= 1.40
+GL_ARB_shader_atomic_counters
+GL_ARB_arrays_of_arrays
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 140
+#extension GL_ARB_shader_atomic_counters: require
+#extension GL_ARB_arrays_of_arrays: require
+
+layout(binding = 0) uniform atomic_uint a0[2][4];
+layout(binding = 0) uniform atomic_uint a1[3][2][2];
+
+out vec4 fcolor;
+
+void main()
+{
+	bool passed = true;
+	uint v0[12];
+	uint v1[12];
+
+	/* Get all initail values of a0 */
+	v0[0] = atomicCounter(a0[0][0]);
+	v0[1] = atomicCounter(a0[0][1]);
+	v0[2] = atomicCounter(a0[0][2]);
+	v0[3] = atomicCounter(a0[0][3]);
+	v0[4] = atomicCounter(a0[1][0]);
+	v0[5] = atomicCounter(a0[1][1]);
+	v0[6] = atomicCounter(a0[1][2]);
+	v0[7] = atomicCounter(a0[1][3]);
+
+	/* Test that incrementing, followed by a read of an atomic
+	 * counter results in a larger value.
+	 * Also test that all other array elements are unaffected. */
+	atomicCounterIncrement(a0[0][0]);
+	atomicCounterIncrement(a0[1][2]);
+	v1[0] = atomicCounter(a0[0][0]);
+	v1[1] = atomicCounter(a0[0][1]);
+	v1[2] = atomicCounter(a0[0][2]);
+	v1[3] = atomicCounter(a0[0][3]);
+	v1[4] = atomicCounter(a0[1][0]);
+	v1[5] = atomicCounter(a0[1][1]);
+	v1[6] = atomicCounter(a0[1][2]);
+	v1[7] = atomicCounter(a0[1][3]);
+	if(v1[0] <= v0[0] || v1[1] != v0[1] || v1[2] != v0[2] ||
+	   v1[3] != v0[3] || v1[4] != v0[4] || v1[5] != v0[5] ||
+	   v1[6] <= v0[6] || v1[7] != v0[7])
+		passed = false;
+
+	/* Skip one decrement since it may be the 0 => 0xffffffff
+	 * transition.
+	 */
+	atomicCounterDecrement(a1[0][1][1]);
+	atomicCounterDecrement(a1[2][0][1]);
+
+	/* Get all initail values of a1 */
+	v0[0] = atomicCounter(a1[0][0][0]);
+	v0[1] = atomicCounter(a1[0][0][1]);
+	v0[2] = atomicCounter(a1[0][1][0]);
+	v0[3] = atomicCounter(a1[0][1][1]);
+	v0[4] = atomicCounter(a1[1][0][0]);
+	v0[5] = atomicCounter(a1[1][0][1]);
+	v0[6] = atomicCounter(a1[1][1][0]);
+	v0[7] = atomicCounter(a1[1][1][1]);
+	v0[8] = atomicCounter(a1[2][0][0]);
+	v0[9] = atomicCounter(a1[2][0][1]);
+	v0[10] = atomicCounter(a1[2][1][0]);
+	v0[11] = atomicCounter(a1[2][1][1]);
+
+	/* Test that a decrement of an atomic
+	 * counter results in a smaller value.
+	 * Also test that all other array elements are unaffected.
+	 */
+	v1[0] = atomicCounter(a1[0][0][0]);
+	v1[1] = atomicCounter(a1[0][0][1]);
+	v1[2] = atomicCounter(a1[0][1][0]);
+	v1[3] = atomicCounterDecrement(a1[0][1][1]);
+	v1[4] = atomicCounter(a1[1][0][0]);
+	v1[5] = atomicCounter(a1[1][0][1]);
+	v1[6] = atomicCounter(a1[1][1][0]);
+	v1[7] = atomicCounter(a1[1][1][1]);
+	v1[8] = atomicCounter(a1[2][0][0]);
+	v1[9] = atomicCounterDecrement(a1[2][0][1]);
+	v1[10] = atomicCounter(a1[2][1][0]);
+	v1[11] = atomicCounter(a1[2][1][1]);
+
+	if(v1[0] != v0[0] || v1[1] != v0[1] || v1[2] != v0[2] ||
+	   v1[3] >= v0[3] || v1[4] != v0[4] || v1[5] != v0[5] ||
+	   v1[6] != v0[6] || v1[7] != v0[7] || v1[8] != v0[8] ||
+	   v1[9] >= v0[9] || v1[10] != v0[10] || v1[11] != v0[11])
+		passed = false;
+
+	if (passed)
+		fcolor = vec4(0.0, 1.0, 0.0, 1.0);
+	else
+		fcolor = vec4(1.0, 0.0, 0.0, 1.0);
+}
+
+[test]
+atomic counters 20
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0