These test a compiler's handling of bound image handles used as l-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 <pendingchao...@gmail.com>
---
 .../execution/images/bound-image-array.shader_test | 46 +++++++++++++++++
 .../images/bound-image-assignment.shader_test      | 51 +++++++++++++++++++
 .../execution/images/bound-image-cast.shader_test  | 50 ++++++++++++++++++
 .../execution/images/bound-image-comma.shader_test | 31 ++++++++++++
 .../bound-image-function-parameter.shader_test     | 59 ++++++++++++++++++++++
 .../images/bound-image-ternary.shader_test         | 46 +++++++++++++++++
 .../execution/images/constant-handle.shader_test   | 39 ++++++++++++++
 7 files changed, 322 insertions(+)
 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/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..b05d45aad
--- /dev/null
+++ 
b/tests/spec/arb_bindless_texture/execution/images/bound-image-array.shader_test
@@ -0,0 +1,46 @@
+[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;
+out vec4 outcolor;
+
+void main()
+{
+       imageStore(image2D[](img0, img1)[index], ivec2(0), color);
+       outcolor = vec4(0.0, 0.0, 0.0, 1.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
+
+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..8f6198702
--- /dev/null
+++ 
b/tests/spec/arb_bindless_texture/execution/images/bound-image-assignment.shader_test
@@ -0,0 +1,51 @@
+[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;
+out vec4 outcolor;
+
+void main()
+{
+       image2D img;
+       if (cond)
+               img = img1;
+       else
+               img = img0;
+       imageStore(img, ivec2(0), color);
+       outcolor = vec4(0.0, 0.0, 0.0, 1.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
+
+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..bb0396f2c
--- /dev/null
+++ 
b/tests/spec/arb_bindless_texture/execution/images/bound-image-cast.shader_test
@@ -0,0 +1,50 @@
+# 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;
+out vec4 outcolor;
+
+void main()
+{
+       uvec2 handle = uvec2(tex);
+       handle.x -= 0x12345678u;
+       handle.y -= 0x9abcdef0u;
+
+       image2D fixedTex = image2D(handle + handleOffset);
+
+       imageStore(fixedTex, ivec2(gl_FragCoord.xy), color);
+       outcolor = vec4(0.0, 0.0, 0.0, 1.0);
+}
+
+[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..f3b4b80ab
--- /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 image2D bar, in image2D baz, in 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 */
+       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..f1eca9824
--- /dev/null
+++ 
b/tests/spec/arb_bindless_texture/execution/images/bound-image-ternary.shader_test
@@ -0,0 +1,46 @@
+[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;
+out vec4 outcolor;
+
+void main()
+{
+       imageStore(cond ? img1 : img0, ivec2(0), color);
+       outcolor = vec4(0.0, 0.0, 0.0, 1.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
+
+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

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to