[Piglit] [PATCH 1/2] arb_shading_language_420pack: check different binding points

Andres Gomez agomez at igalia.com
Wed Feb 8 17:04:28 UTC 2017


This adds tests to check that, in the case of Uniform Blocks and
Shader Storage Blocks, it is allowed to specify different binding
points among the compilation units for blocks with the same name
while, in the case of Opaque-Uniforms, a link error is expected.

>From page 60 (page 66 of the PDF) of the GLSL 4.20 spec, v11:

  " A link error will result if two compilation units in a program
    specify different integer-constant bindings for the same
    opaque-uniform name. However, it is not an error to specify a
    binding on some but not all declarations for the same name, as
    shown in the examples below."

Although this restriction is not included in the
ARB_shading_language_420pack spec, it is reasonable to believe that it
applies to it too.

Signed-off-by: Andres Gomez <agomez at igalia.com>
Cc: Matt Turner <mattst88 at gmail.com>
Cc: Kenneth Graunke <kenneth at whitecape.org>
---
 .../linker/different-bindings-image2D.shader_test  | 56 ++++++++++++++++++++
 .../different-bindings-sampler2D.shader_test       | 53 +++++++++++++++++++
 ...rent-bindings-shader-storage-blocks.shader_test | 59 ++++++++++++++++++++++
 .../different-bindings-uniform-blocks.shader_test  | 56 ++++++++++++++++++++
 4 files changed, 224 insertions(+)
 create mode 100644 tests/spec/arb_shading_language_420pack/linker/different-bindings-image2D.shader_test
 create mode 100644 tests/spec/arb_shading_language_420pack/linker/different-bindings-sampler2D.shader_test
 create mode 100644 tests/spec/arb_shading_language_420pack/linker/different-bindings-shader-storage-blocks.shader_test
 create mode 100644 tests/spec/arb_shading_language_420pack/linker/different-bindings-uniform-blocks.shader_test

diff --git a/tests/spec/arb_shading_language_420pack/linker/different-bindings-image2D.shader_test b/tests/spec/arb_shading_language_420pack/linker/different-bindings-image2D.shader_test
new file mode 100644
index 000000000..97579678e
--- /dev/null
+++ b/tests/spec/arb_shading_language_420pack/linker/different-bindings-image2D.shader_test
@@ -0,0 +1,56 @@
+/* The GLSL 4.20 spec, v11, says:
+ *
+ *     "A link error will result if two compilation units in a program
+ *      specify different integer-constant bindings for the same
+ *      opaque-uniform name. However, it is not an error to specify a
+ *      binding on some but not all declarations for the same name, as
+ *      shown in the examples below."
+ *
+ * Although this restriction is not included in the
+ * ARB_shading_language_420pack spec, it is reasonable to believe that
+ * it applies to it too.
+ *
+ * Verify that a link error happens when using different binding
+ * points for an opaque type (image2D) with the same name in
+ * different compilation units.
+ */
+
+[require]
+GLSL >= 1.30
+GL_ARB_shading_language_420pack
+GL_ARB_shader_image_load_store
+
+[vertex shader]
+#version 130
+#extension GL_ARB_shading_language_420pack: require
+#extension GL_ARB_shader_image_load_store: require
+
+layout (rgba8, binding = 0) uniform image2D img;
+
+in vec4 piglit_vertex;
+out vec4 vs_fs;
+
+void main()
+{
+	vs_fs = imageLoad(img, ivec2(gl_Vertex.xy));
+	gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+#version 130
+#extension GL_ARB_shading_language_420pack: require
+#extension GL_ARB_shader_image_load_store: require
+
+layout (rgba8, binding = 1) uniform image2D img;
+
+uniform ivec4 cst;
+in  vec4 vs_fs;
+out vec4 fs_out;
+
+void main()
+{
+	fs_out = vs_fs * imageLoad(img, cst.xy).x;
+}
+
+[test]
+link error
diff --git a/tests/spec/arb_shading_language_420pack/linker/different-bindings-sampler2D.shader_test b/tests/spec/arb_shading_language_420pack/linker/different-bindings-sampler2D.shader_test
new file mode 100644
index 000000000..37a388be6
--- /dev/null
+++ b/tests/spec/arb_shading_language_420pack/linker/different-bindings-sampler2D.shader_test
@@ -0,0 +1,53 @@
+/* The GLSL 4.20 spec, v11, says:
+ *
+ *     "A link error will result if two compilation units in a program
+ *      specify different integer-constant bindings for the same
+ *      opaque-uniform name. However, it is not an error to specify a
+ *      binding on some but not all declarations for the same name, as
+ *      shown in the examples below."
+ *
+ * Although this restriction is not included in the
+ * ARB_shading_language_420pack spec, it is reasonable to believe that
+ * it applies to it too.
+ *
+ * Verify that a link error happens when using different binding
+ * points for an opaque type (sampler2D) with the same name in
+ * different compilation units.
+ */
+
+[require]
+GLSL >= 1.30
+GL_ARB_shading_language_420pack
+
+[vertex shader]
+#version 130
+#extension GL_ARB_shading_language_420pack: require
+
+layout (binding = 0) uniform sampler2D tex;
+
+in vec4 piglit_vertex;
+out vec4 vs_fs;
+
+void main()
+{
+	vs_fs = texture2D(tex, gl_Vertex.xy);
+	gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+#version 130
+#extension GL_ARB_shading_language_420pack: require
+
+layout (binding = 1) uniform sampler2D tex;
+
+uniform vec4 cst;
+in  vec4 vs_fs;
+out vec4 fs_out;
+
+void main()
+{
+	fs_out = vs_fs * texture2D(tex, cst.xy).x;
+}
+
+[test]
+link error
diff --git a/tests/spec/arb_shading_language_420pack/linker/different-bindings-shader-storage-blocks.shader_test b/tests/spec/arb_shading_language_420pack/linker/different-bindings-shader-storage-blocks.shader_test
new file mode 100644
index 000000000..2d65bae19
--- /dev/null
+++ b/tests/spec/arb_shading_language_420pack/linker/different-bindings-shader-storage-blocks.shader_test
@@ -0,0 +1,59 @@
+/* The GLSL 4.20 spec, v11, says:
+ *
+ *     "A link error will result if two compilation units in a program
+ *      specify different integer-constant bindings for the same
+ *      opaque-uniform name. However, it is not an error to specify a
+ *      binding on some but not all declarations for the same name, as
+ *      shown in the examples below."
+ *
+ * Although this restriction is not included in the
+ * ARB_shading_language_420pack spec, it is reasonable to believe that
+ * it applies to it too.
+ *
+ * Verify that no link error happens when using different binding
+ * points for Shader Storage Blocks with the same name in different
+ * compilation units.
+ */
+
+[require]
+GLSL >= 1.50
+GL_ARB_shading_language_420pack
+GL_ARB_shader_storage_buffer_object
+
+[vertex shader]
+#version 150
+#extension GL_ARB_shading_language_420pack: require
+#extension GL_ARB_shader_storage_buffer_object: require
+
+layout (binding = 0) buffer Block {
+	vec4 color;
+} buf_block;
+
+in vec4 piglit_vertex;
+out vec4 vs_fs;
+
+void main()
+{
+	vs_fs = buf_block.color;
+	gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+#version 150
+#extension GL_ARB_shading_language_420pack: require
+#extension GL_ARB_shader_storage_buffer_object: require
+
+layout (binding = 1) buffer Block {
+	vec4 color;
+} buf_block;
+
+in  vec4 vs_fs;
+out vec4 fs_out;
+
+void main()
+{
+	fs_out = vs_fs * buf_block.color.x;
+}
+
+[test]
+link success
diff --git a/tests/spec/arb_shading_language_420pack/linker/different-bindings-uniform-blocks.shader_test b/tests/spec/arb_shading_language_420pack/linker/different-bindings-uniform-blocks.shader_test
new file mode 100644
index 000000000..b8febc66d
--- /dev/null
+++ b/tests/spec/arb_shading_language_420pack/linker/different-bindings-uniform-blocks.shader_test
@@ -0,0 +1,56 @@
+/* The GLSL 4.20 spec, v11, says:
+ *
+ *     "A link error will result if two compilation units in a program
+ *      specify different integer-constant bindings for the same
+ *      opaque-uniform name. However, it is not an error to specify a
+ *      binding on some but not all declarations for the same name, as
+ *      shown in the examples below."
+ *
+ * Although this restriction is not included in the
+ * ARB_shading_language_420pack spec, it is reasonable to believe that
+ * it applies to it too.
+ *
+ * Verify that no link error happens when using different binding
+ * points for Uniform Blocks with the same name in different
+ * compilation units.
+ */
+
+[require]
+GLSL >= 1.50
+GL_ARB_shading_language_420pack
+
+[vertex shader]
+#version 150
+#extension GL_ARB_shading_language_420pack: require
+
+layout (binding = 0) uniform Block {
+	vec4 color;
+} uni_block;
+
+in vec4 piglit_vertex;
+out vec4 vs_fs;
+
+void main()
+{
+	vs_fs = uni_block.color;
+	gl_Position = piglit_vertex;
+}
+
+[fragment shader]
+#version 150
+#extension GL_ARB_shading_language_420pack: require
+
+layout (binding = 1) uniform Block {
+	vec4 color;
+} uni_block;
+
+in  vec4 vs_fs;
+out vec4 fs_out;
+
+void main()
+{
+	fs_out = vs_fs * uni_block.color.x;
+}
+
+[test]
+link success
-- 
2.11.0



More information about the Piglit mailing list