[Piglit] [PATCH v2] Expand ARB_bindless_texture tests with new shader tests

Rhys Perry pendingchaos02 at gmail.com
Thu Jun 7 15:35:51 UTC 2018


Changes in v2:
- Remove useless fragment shader outputs
- Add missing writeonly qualifiers
- Add three new tests ensuring that qualifiers are required in various
  situations

These test a compiler's handling of bound image handles used as r-values
or being cast and it's handling of constant bindless handles.

They were created in response to issues found in Mesa.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
---
 .../compiler/images/cast-without-qualifiers.frag   | 17 +++++++
 .../compiler/images/local-without-qualifiers.frag  | 17 +++++++
 .../images/parameter-without-qualifiers.frag       | 14 +++++
 .../execution/images/bound-image-array.shader_test | 47 +++++++++++++++++
 .../images/bound-image-assignment.shader_test      | 49 ++++++++++++++++++
 .../execution/images/bound-image-cast.shader_test  | 48 ++++++++++++++++++
 .../execution/images/bound-image-comma.shader_test | 31 ++++++++++++
 .../bound-image-function-parameter.shader_test     | 59 ++++++++++++++++++++++
 .../images/bound-image-ternary.shader_test         | 44 ++++++++++++++++
 .../execution/images/constant-handle.shader_test   | 39 ++++++++++++++
 10 files changed, 365 insertions(+)
 create mode 100644 tests/spec/arb_bindless_texture/compiler/images/cast-without-qualifiers.frag
 create mode 100644 tests/spec/arb_bindless_texture/compiler/images/local-without-qualifiers.frag
 create mode 100644 tests/spec/arb_bindless_texture/compiler/images/parameter-without-qualifiers.frag
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/bound-image-array.shader_test
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/bound-image-assignment.shader_test
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/bound-image-cast.shader_test
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/bound-image-comma.shader_test
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/bound-image-function-parameter.shader_test
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/bound-image-ternary.shader_test
 create mode 100644 tests/spec/arb_bindless_texture/execution/images/constant-handle.shader_test

diff --git a/tests/spec/arb_bindless_texture/compiler/images/cast-without-qualifiers.frag b/tests/spec/arb_bindless_texture/compiler/images/cast-without-qualifiers.frag
new file mode 100644
index 000000000..15710a980
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/compiler/images/cast-without-qualifiers.frag
@@ -0,0 +1,17 @@
+// [config]
+// expect_result: fail
+// glsl_version: 3.30
+// require_extensions: GL_ARB_bindless_texture GL_ARB_shader_image_load_store
+// [end config]
+
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: enable
+
+uniform uvec2 img1;
+
+void main()
+{
+	/* cast without qualifiers */
+	image2D(img1);
+}
diff --git a/tests/spec/arb_bindless_texture/compiler/images/local-without-qualifiers.frag b/tests/spec/arb_bindless_texture/compiler/images/local-without-qualifiers.frag
new file mode 100644
index 000000000..706e322a5
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/compiler/images/local-without-qualifiers.frag
@@ -0,0 +1,17 @@
+// [config]
+// expect_result: fail
+// glsl_version: 3.30
+// require_extensions: GL_ARB_bindless_texture GL_ARB_shader_image_load_store
+// [end config]
+
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: enable
+
+writeonly uniform image2D img0;
+
+void main()
+{
+	/* declaring local variables without qualifiers */
+	image2D baz = img0;
+}
diff --git a/tests/spec/arb_bindless_texture/compiler/images/parameter-without-qualifiers.frag b/tests/spec/arb_bindless_texture/compiler/images/parameter-without-qualifiers.frag
new file mode 100644
index 000000000..577c7e2d2
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/compiler/images/parameter-without-qualifiers.frag
@@ -0,0 +1,14 @@
+// [config]
+// expect_result: fail
+// glsl_version: 3.30
+// require_extensions: GL_ARB_bindless_texture GL_ARB_shader_image_load_store
+// [end config]
+
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: enable
+
+/* declaring image parameters without qualifiers */
+void foo(in image2D bar) {}
+
+void main() {}
diff --git a/tests/spec/arb_bindless_texture/execution/images/bound-image-array.shader_test b/tests/spec/arb_bindless_texture/execution/images/bound-image-array.shader_test
new file mode 100644
index 000000000..dcfa64611
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/bound-image-array.shader_test
@@ -0,0 +1,47 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+uniform uint index;
+uniform vec4 color;
+writeonly uniform image2D img0;
+writeonly uniform image2D img1;
+
+void main()
+{
+	writeonly image2D arr[2];
+	arr[0] = img0;
+	arr[1] = img1;
+	imageStore(arr[index], ivec2(0), color);
+}
+
+[test]
+texture rgbw 0 (1, 1) GL_RGBA8
+texture rgbw 1 (1, 1) GL_RGBA8
+image texture 0 GL_RGBA8
+image texture 1 GL_RGBA8
+uniform int img0 0
+uniform int img1 1
+
+uniform uint index 0
+uniform vec4 color 0.5 0.0 0.0 0.0
+draw rect -1 -1 2 2
+
+uniform uint index 1
+uniform vec4 color 0.0 0.5 0.0 0.0
+draw rect -1 -1 2 2
+
+memory barrier GL_FRAMEBUFFER_BARRIER_BIT
+fb tex 2d 0
+probe all rgba 0.5 0.0 0.0 0.0
+fb tex 2d 1
+probe all rgba 0.0 0.5 0.0 0.0
diff --git a/tests/spec/arb_bindless_texture/execution/images/bound-image-assignment.shader_test b/tests/spec/arb_bindless_texture/execution/images/bound-image-assignment.shader_test
new file mode 100644
index 000000000..d89c32641
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/bound-image-assignment.shader_test
@@ -0,0 +1,49 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+uniform bool cond;
+uniform vec4 color;
+writeonly uniform image2D img0;
+writeonly uniform image2D img1;
+
+void main()
+{
+	writeonly image2D img;
+	if (cond)
+		img = img1;
+	else
+		img = img0;
+	imageStore(img, ivec2(0), color);
+}
+
+[test]
+texture rgbw 0 (1, 1) GL_RGBA8
+texture rgbw 1 (1, 1) GL_RGBA8
+image texture 0 GL_RGBA8
+image texture 1 GL_RGBA8
+uniform int img0 0
+uniform int img1 1
+
+uniform int cond 0
+uniform vec4 color 0.5 0.0 0.0 0.0
+draw rect -1 -1 2 2
+
+uniform int cond 1
+uniform vec4 color 0.0 0.5 0.0 0.0
+draw rect -1 -1 2 2
+
+memory barrier GL_FRAMEBUFFER_BARRIER_BIT
+fb tex 2d 0
+probe all rgba 0.5 0.0 0.0 0.0
+fb tex 2d 1
+probe all rgba 0.0 0.5 0.0 0.0
diff --git a/tests/spec/arb_bindless_texture/execution/images/bound-image-cast.shader_test b/tests/spec/arb_bindless_texture/execution/images/bound-image-cast.shader_test
new file mode 100644
index 000000000..10dbacbd4
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/bound-image-cast.shader_test
@@ -0,0 +1,48 @@
+# Same as basic-arithmetic-uvec2-imageStore.shader_test, but with bound images
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: enable
+
+uniform vec4 color;
+writeonly uniform image2D tex;
+uniform uvec2 handleOffset;
+
+void main()
+{
+	uvec2 handle = uvec2(tex);
+	handle.x -= 0x12345678u;
+	handle.y -= 0x9abcdef0u;
+
+	writeonly image2D fixedTex = writeonly image2D(handle + handleOffset);
+
+	imageStore(fixedTex, ivec2(gl_FragCoord.xy), color);
+}
+
+[test]
+# Texture 0 is the imageStore output.
+texture rgbw 0 (16, 16) GL_RGBA8
+image texture 0 GL_RGBA8
+uniform int tex 0
+uniform uvec2 handleOffset 0x12345678 0x9abcdef0
+
+# Texture 1 is the rendering output. We don't care about this.
+texture rgbw 1 (16, 16) GL_RGBA8
+
+# Store red using imageStore
+uniform vec4 color 0.5 0.0 0.0 1.0
+fb tex 2d 1
+draw rect -1 -1 2 2
+
+# Test the result of imageStore
+memory barrier GL_FRAMEBUFFER_BARRIER_BIT
+fb tex 2d 0
+probe all rgba 0.5 0.0 0.0 1.0
diff --git a/tests/spec/arb_bindless_texture/execution/images/bound-image-comma.shader_test b/tests/spec/arb_bindless_texture/execution/images/bound-image-comma.shader_test
new file mode 100644
index 000000000..9946147e1
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/bound-image-comma.shader_test
@@ -0,0 +1,31 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+writeonly uniform image2D img0;
+writeonly uniform image2D img1;
+
+void main()
+{
+	imageStore((img0, img1), ivec2(0), vec4(0.0, 0.5, 0.0, 0.0));
+}
+
+[test]
+texture rgbw 1 (1, 1) GL_RGBA8
+image texture 1 GL_RGBA8
+uniform int img1 1
+
+draw rect -1 -1 2 2
+
+memory barrier GL_FRAMEBUFFER_BARRIER_BIT
+fb tex 2d 1
+probe all rgba 0.0 0.5 0.0 0.0
diff --git a/tests/spec/arb_bindless_texture/execution/images/bound-image-function-parameter.shader_test b/tests/spec/arb_bindless_texture/execution/images/bound-image-function-parameter.shader_test
new file mode 100644
index 000000000..3e242930f
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/bound-image-function-parameter.shader_test
@@ -0,0 +1,59 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+writeonly uniform image2D img0;
+writeonly uniform image2D img1;
+out vec4 outcolor;
+
+void foo(out writeonly image2D bar, in writeonly image2D baz, in writeonly image2D qux, in vec4 val)
+{
+	/* Since the variables supplied to out parameters are only updated once the
+	 * funciton returns, foo(b, a, b, ...) should call imageStore with b, not a
+	 * Such errors can occur with incorrect variable replacement during
+	 * function inlining. */
+	bar = baz;
+	imageStore(qux, ivec2(0), val);
+}
+
+void main()
+{
+	/* write vec4(0.5, 0.0, 0.0, 0.0) to img0 */
+	writeonly image2D a = img1, b = img0;
+	foo(b, a, b, vec4(0.5, 0.0, 0.0, 0.0));
+	outcolor.r = uvec2(b) == uvec2(a) ? 0.5 : 0.0;
+
+	/* write vec4(0.0, 0.5, 0.0, 0.0) to img1 */
+	a = img0;
+	b = img1;
+	foo(b, a, b, vec4(0.0, 0.5, 0.0, 0.0));
+	outcolor.g = uvec2(b) == uvec2(a) ? 0.5 : 0.0;
+
+	outcolor.ba = vec2(0.0);
+}
+
+[test]
+texture rgbw 0 (1, 1) GL_RGBA8
+texture rgbw 1 (1, 1) GL_RGBA8
+image texture 0 GL_RGBA8
+image texture 1 GL_RGBA8
+uniform int img0 0
+uniform int img1 1
+
+draw rect -1 -1 2 2
+probe all rgba 0.5 0.5 0.0 0.0
+
+memory barrier GL_FRAMEBUFFER_BARRIER_BIT
+fb tex 2d 0
+probe all rgba 0.5 0.0 0.0 0.0
+fb tex 2d 1
+probe all rgba 0.0 0.5 0.0 0.0
diff --git a/tests/spec/arb_bindless_texture/execution/images/bound-image-ternary.shader_test b/tests/spec/arb_bindless_texture/execution/images/bound-image-ternary.shader_test
new file mode 100644
index 000000000..d2f4d88e1
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/bound-image-ternary.shader_test
@@ -0,0 +1,44 @@
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+uniform bool cond;
+uniform vec4 color;
+writeonly uniform image2D img0;
+writeonly uniform image2D img1;
+
+void main()
+{
+	imageStore(cond ? img1 : img0, ivec2(0), color);
+}
+
+[test]
+texture rgbw 0 (1, 1) GL_RGBA8
+texture rgbw 1 (1, 1) GL_RGBA8
+image texture 0 GL_RGBA8
+image texture 1 GL_RGBA8
+uniform int img0 0
+uniform int img1 1
+
+uniform int cond 0
+uniform vec4 color 0.5 0.0 0.0 0.0
+draw rect -1 -1 2 2
+
+uniform int cond 1
+uniform vec4 color 0.0 0.5 0.0 0.0
+draw rect -1 -1 2 2
+
+memory barrier GL_FRAMEBUFFER_BARRIER_BIT
+fb tex 2d 0
+probe all rgba 0.5 0.0 0.0 0.0
+fb tex 2d 1
+probe all rgba 0.0 0.5 0.0 0.0
diff --git a/tests/spec/arb_bindless_texture/execution/images/constant-handle.shader_test b/tests/spec/arb_bindless_texture/execution/images/constant-handle.shader_test
new file mode 100644
index 000000000..b530e83c7
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/execution/images/constant-handle.shader_test
@@ -0,0 +1,39 @@
+# Tests that an image handle can be constructed from a constant
+[require]
+GL >= 3.3
+GLSL >= 3.30
+GL_ARB_bindless_texture
+GL_ARB_shader_image_load_store
+
+[vertex shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+in vec4 piglit_vertex;
+flat out image2D img;
+
+void main()
+{
+	gl_Position = piglit_vertex;
+	img = image2D(uvec2(0x12345678, 0x9abcdef0));
+}
+
+[fragment shader]
+#version 330
+#extension GL_ARB_bindless_texture: require
+#extension GL_ARB_shader_image_load_store: require
+
+flat in image2D img;
+out vec4 outcolor;
+
+void main()
+{
+	outcolor.g = uvec2(img) == uvec2(0x12345678, 0x9abcdef0) ? 1.0 : 0.0;
+	outcolor.r = 1.0 - outcolor.g;
+	outcolor = vec4(outcolor.rg * 0.5, 0.0, 1.0);
+}
+
+[test]
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.5 0.0 1.0
-- 
2.14.4



More information about the Piglit mailing list