[Piglit] [PATCH] arb_shader_clock: add basic execution tests

Nicolai Hähnle nhaehnle at gmail.com
Thu Mar 30 07:23:34 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 .../arb_shader_clock/execution/clock.shader_test   | 54 +++++++++++++++++++
 .../execution/clock2x32.shader_test                | 63 ++++++++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100644 tests/spec/arb_shader_clock/execution/clock.shader_test
 create mode 100644 tests/spec/arb_shader_clock/execution/clock2x32.shader_test

diff --git a/tests/spec/arb_shader_clock/execution/clock.shader_test b/tests/spec/arb_shader_clock/execution/clock.shader_test
new file mode 100644
index 0000000..07530e6
--- /dev/null
+++ b/tests/spec/arb_shader_clock/execution/clock.shader_test
@@ -0,0 +1,54 @@
+[require]
+GL >= 4.3
+GLSL >= 4.30
+GL_ARB_gpu_shader_int64
+GL_ARB_shader_clock
+
+[compute shader]
+#version 430
+#extension GL_ARB_gpu_shader_int64: require
+#extension GL_ARB_shader_clock: require
+
+layout(local_size_x = 1) in;
+
+layout(binding = 0) uniform atomic_uint good;
+layout(binding = 1) uniform atomic_uint bad;
+
+layout(std430, binding = 0) buffer ssbo_data {
+	uint64_t ssbo_time[];
+};
+
+uniform uint phase;
+
+void main() {
+	uint64_t start_time = clockARB();
+
+	if (phase == 0u) {
+		ssbo_time[gl_WorkGroupID.x] = start_time;
+	} else {
+		int64_t diff = int64_t(start_time - ssbo_time[gl_WorkGroupID.x]);
+		if (diff > 0l)
+			atomicCounterIncrement(good);
+	}
+
+	uint64_t late_time = clockARB();
+	int64_t diff = int64_t(late_time - start_time);
+
+	if (diff <= 0l)
+		atomicCounterIncrement(bad);
+}
+
+[test]
+atomic counters 2
+ssbo 0 64
+
+uniform uint phase 0
+compute 8 1 1
+
+memory barrier GL_SHADER_STORAGE_BARRIER_BIT
+
+uniform uint phase 1
+compute 8 1 1
+
+probe atomic counter 0 == 8
+probe atomic counter 1 == 0
diff --git a/tests/spec/arb_shader_clock/execution/clock2x32.shader_test b/tests/spec/arb_shader_clock/execution/clock2x32.shader_test
new file mode 100644
index 0000000..1a2bfef
--- /dev/null
+++ b/tests/spec/arb_shader_clock/execution/clock2x32.shader_test
@@ -0,0 +1,63 @@
+[require]
+GL >= 4.3
+GLSL >= 4.30
+GL_ARB_shader_clock
+
+[compute shader]
+#version 430
+#extension GL_ARB_shader_clock: require
+
+layout(local_size_x = 1) in;
+
+layout(binding = 0) uniform atomic_uint good;
+layout(binding = 1) uniform atomic_uint bad;
+
+layout(std430, binding = 0) buffer ssbo_data {
+	uvec2 ssbo_time[];
+};
+
+uniform uint phase;
+
+bool is_time_ordered(uvec2 a, uvec2 b) {
+	int diff = int(b.y - a.y);
+	if (diff > 0)
+		return true;
+	if (diff < 0)
+		return false;
+
+	diff = int(b.x - a.x);
+	if (diff > 0)
+		return true;
+	return false;
+}
+
+void main() {
+	uvec2 start_time = clock2x32ARB();
+
+	if (phase == 0u) {
+		ssbo_time[gl_WorkGroupID.x] = start_time;
+	} else {
+		if (is_time_ordered(ssbo_time[gl_WorkGroupID.x], start_time))
+			atomicCounterIncrement(good);
+	}
+
+	uvec2 late_time = clock2x32ARB();
+
+	if (!is_time_ordered(start_time, late_time))
+		atomicCounterIncrement(bad);
+}
+
+[test]
+atomic counters 2
+ssbo 0 64
+
+uniform uint phase 0
+compute 8 1 1
+
+memory barrier GL_SHADER_STORAGE_BARRIER_BIT
+
+uniform uint phase 1
+compute 8 1 1
+
+probe atomic counter 0 == 8
+probe atomic counter 1 == 0
-- 
2.9.3



More information about the Piglit mailing list