[Piglit] [PATCH v2 5/5] arb_bindless_texture: add test for conversion of bound sampler or image to uvec2

Karol Herbst kherbst at redhat.com
Thu Apr 12 10:58:19 UTC 2018


conversion of bounded sampler2D to uvec2 is legal with
ARB_bindless_texture. Currently Mesa fails with an assert:

../src/compiler/glsl/opt_function_inlining.cpp:248:
void ir_call::generate_inline(ir_instruction*): Assertion `deref' failed.

v2: add image test
    convert to compiler test
    quote the spec

Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 .../compiler/images/arith-bound-image.frag         | 33 ++++++++++++++++++++++
 .../samplers/arith-bound-sampler-texture2D.frag    | 32 +++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 tests/spec/arb_bindless_texture/compiler/images/arith-bound-image.frag
 create mode 100644 tests/spec/arb_bindless_texture/compiler/samplers/arith-bound-sampler-texture2D.frag

diff --git a/tests/spec/arb_bindless_texture/compiler/images/arith-bound-image.frag b/tests/spec/arb_bindless_texture/compiler/images/arith-bound-image.frag
new file mode 100644
index 000000000..1876081c9
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/compiler/images/arith-bound-image.frag
@@ -0,0 +1,33 @@
+// [config]
+// expect_result: pass
+// 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 img;
+uniform uvec2 handleOffset;
+
+out vec4 finalColor;
+
+// The ARB_bindless_texture spec says:
+//
+//  "Modify Section 5.4.1, Conversion and Scalar Constructors, p. 60"
+//
+//  "(add the following constructors:)"
+//
+//  "uvec2(any image type)       // Converts an image type to a
+//                               //   pair of 32-bit unsigned integers
+//   any image type(uvec2)       // Converts a pair of 32-bit unsigned integers to
+//                               //   an image type"
+
+void main()
+{
+	uvec2 handle = uvec2(img);
+	handle.x -= 0x12345678u;
+	handle.y -= 0x9abcdef0u;
+	imageStore(image2D(handle + handleOffset), ivec2(0, 0), vec4(1, 2, 3, 4));
+}
diff --git a/tests/spec/arb_bindless_texture/compiler/samplers/arith-bound-sampler-texture2D.frag b/tests/spec/arb_bindless_texture/compiler/samplers/arith-bound-sampler-texture2D.frag
new file mode 100644
index 000000000..cf6a625bf
--- /dev/null
+++ b/tests/spec/arb_bindless_texture/compiler/samplers/arith-bound-sampler-texture2D.frag
@@ -0,0 +1,32 @@
+// [config]
+// expect_result: pass
+// glsl_version: 3.30
+// require_extensions: GL_ARB_bindless_texture
+// [end config]
+
+#version 330
+#extension GL_ARB_bindless_texture: require
+
+uniform sampler2D tex;
+uniform uvec2 handleOffset;
+
+out vec4 finalColor;
+
+// The ARB_bindless_texture spec says:
+//
+//  "Modify Section 5.4.1, Conversion and Scalar Constructors, p. 60"
+//
+//  "(add the following constructors:)"
+//
+//  "uvec2(any sampler type)     // Converts a sampler type to a
+//                               //   pair of 32-bit unsigned integers
+//   any sampler type(uvec2)     // Converts a pair of 32-bit unsigned integers to
+//                               //   a sampler type"
+
+void main()
+{
+	uvec2 handle = uvec2(tex);
+	handle.x -= 0x12345678u;
+	handle.y -= 0x9abcdef0u;
+	finalColor = texture2D(sampler2D(handle + handleOffset), vec2(0, 0));
+}
-- 
2.14.3



More information about the Piglit mailing list