[Piglit] [PATCH v2 3/3] ARB_shader_atomic_counters: Add simple VS test with inc/dec/read

Jordan Justen jordan.l.justen at intel.com
Mon Feb 23 10:23:13 PST 2015


Simple test of atomicCounterIncrement, atomicCounterDecrement and
atomicCounter being used in the VS.

v2:
 * Drop CORE requirement
 * Add GL_ARB_shader_atomic_counters requirement
 * Require INT GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS >= 2

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 tests/all.py                                       |  3 +
 .../execution/vs-simple-inc-dec-read.shader_test   | 71 ++++++++++++++++++++++
 2 files changed, 74 insertions(+)
 create mode 100644 tests/spec/arb_shader_atomic_counters/execution/vs-simple-inc-dec-read.shader_test

diff --git a/tests/all.py b/tests/all.py
index 4f477e8..d3588ae 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4410,6 +4410,9 @@ spec['ARB_shader_atomic_counters'] = arb_shader_atomic_counters
 import_glsl_parser_tests(spec['ARB_shader_atomic_counters'],
                          os.path.join(TESTS_DIR, 'spec', 'arb_shader_atomic_counters'),
                          [''])
+add_shader_test_dir(spec['ARB_shader_atomic_counters'],
+                    os.path.join(TESTS_DIR, 'spec', 'arb_shader_atomic_counters'),
+                    recursive=True)
 arb_shader_atomic_counters['active-counters'] = PiglitGLTest(['arb_shader_atomic_counters-active-counters'], run_concurrent=True)
 arb_shader_atomic_counters['array-indexing'] = PiglitGLTest(['arb_shader_atomic_counters-array-indexing'], run_concurrent=True)
 arb_shader_atomic_counters['buffer-binding'] = PiglitGLTest(['arb_shader_atomic_counters-buffer-binding'], run_concurrent=True)
diff --git a/tests/spec/arb_shader_atomic_counters/execution/vs-simple-inc-dec-read.shader_test b/tests/spec/arb_shader_atomic_counters/execution/vs-simple-inc-dec-read.shader_test
new file mode 100644
index 0000000..16ea9db
--- /dev/null
+++ b/tests/spec/arb_shader_atomic_counters/execution/vs-simple-inc-dec-read.shader_test
@@ -0,0 +1,71 @@
+# Simple test of atomicCounterIncrement, atomicCounterDecrement and
+# atomicCounter being used in the VS.
+
+[require]
+GLSL >= 1.40
+GL_ARB_shader_atomic_counters
+INT GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS >= 2
+
+[vertex shader]
+#version 140
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(binding = 0) uniform atomic_uint a0;
+layout(binding = 0) uniform atomic_uint a1;
+
+in vec4 piglit_vertex;
+out vec4 vcolor;
+
+void main()
+{
+	bool passed = true;
+	uint v0, v1;
+
+	/* Test that incrementing, followed by a read of an atomic
+	 * counter results in a larger value.
+	 *
+	 * Note: atomicCounterIncrement return the old value
+	 */
+	v0 = atomicCounterIncrement(a0);
+	v1 = atomicCounter(a0);
+	if (v1 <= v0)
+		passed = false;
+
+	/* Skip one decrement since it may be the 0 => 0xffffffff
+	 * transition.
+	 */
+	atomicCounterDecrement(a1);
+
+	/* Test that a read, followed by a decrement of an atomic
+	 * counter results in a smaller value.
+	 *
+	 * Note: atomicCounterDecrement return the new value
+	 */
+	v0 = atomicCounter(a1);
+	v1 = atomicCounterDecrement(a1);
+	if (v1 >= v0)
+		passed = false;
+
+	if (passed)
+		vcolor = vec4(0.0, 1.0, 0.0, 1.0);
+	else
+		vcolor = vec4(1.0, 0.0, 0.0, 1.0);
+
+	gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+#version 140
+in vec4 vcolor;
+out vec4 fcolor;
+
+void main()
+{
+	fcolor = vcolor;
+}
+
+[test]
+atomic counters 2
+
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
-- 
2.1.4



More information about the Piglit mailing list