[Piglit] [PATCH 2/4] cs: Test basic texture sampling from a compute shader

Jordan Justen jordan.l.justen at intel.com
Sat Nov 22 11:53:13 PST 2014


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 .../execution/basic-texelFetch.shader_test         | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 tests/spec/arb_compute_shader/execution/basic-texelFetch.shader_test

diff --git a/tests/spec/arb_compute_shader/execution/basic-texelFetch.shader_test b/tests/spec/arb_compute_shader/execution/basic-texelFetch.shader_test
new file mode 100644
index 0000000..063b6db
--- /dev/null
+++ b/tests/spec/arb_compute_shader/execution/basic-texelFetch.shader_test
@@ -0,0 +1,62 @@
+# Verify simple sampling of a texture with output to an atomic counter
+
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_compute_shader
+GL_ARB_shader_atomic_counters
+
+[compute shader]
+#version 330
+#extension GL_ARB_compute_shader: enable
+#extension GL_ARB_shader_atomic_counters: require
+
+layout(binding = 0) uniform atomic_uint r;
+layout(binding = 0) uniform atomic_uint g;
+layout(binding = 0) uniform atomic_uint b;
+layout(binding = 0) uniform atomic_uint w;
+
+uniform sampler2D tex;
+
+layout(local_size_x = 1, local_size_y = 1) in;
+
+#define SIZE 64u
+#define HALF_SIZE (SIZE / 2u)
+#define RED vec3(1, 0, 0)
+#define GREEN vec3(0, 1, 0)
+#define BLUE vec3(0, 0, 1)
+#define WHITE vec3(1, 1, 1)
+
+void main()
+{
+    for (uint y = 0u; y < SIZE; y++) {
+        for (uint x = 0u; x < SIZE; x++) {
+            ivec2 coord = ivec2(x, y);
+            vec3 color = texelFetch(tex, coord, 0).rgb;
+
+            if (color == RED && x < HALF_SIZE && y < HALF_SIZE) {
+                atomicCounterIncrement(r);
+            } else if (color == GREEN && x >= HALF_SIZE && y < HALF_SIZE) {
+                atomicCounterIncrement(g);
+            } else if (color == BLUE && x <HALF_SIZE && y >= HALF_SIZE) {
+                atomicCounterIncrement(b);
+            } else if (color == WHITE && x >= HALF_SIZE && y >= HALF_SIZE) {
+                atomicCounterIncrement(w);
+            }
+        }
+    }
+}
+
+[test]
+# Setup tex image
+texture rgbw 0 (64, 64)
+uniform int tex 0
+image texture 0
+
+atomic counters 4
+
+compute 1 1 1
+probe atomic counter 0 == 1024
+probe atomic counter 1 == 1024
+probe atomic counter 2 == 1024
+probe atomic counter 3 == 1024
-- 
2.1.1



More information about the Piglit mailing list