[Piglit] [PATCH] arb_enhanced_layouts: add compile and link tests for block member location
Timothy Arceri
timothy.arceri at collabora.com
Sun Nov 29 20:55:59 PST 2015
Test results:
Nvidia GeForce 840M - NVIDIA 352.41: pass
block-member-locations/block-member-mixed-order.frag
block-member-no-block-location-invaild.frag
block-member-no-block-location.frag
block-member-locations/block-member.frag
named-block-member-mixed-order.frag
named-block-member-no-block-location-invaild.frag
named-block-member-no-block-location.frag
named-block-member.frag
block-member-location-overlap.shader_test
block-member-mixed-order-overlap.shader_test
named-block-member-location-overlap.shader_test
named-block-member-mixed-order-overlap.shader_test
Nvidia GeForce 840M - NVIDIA 352.41: fail
struct-member.frag
---
.../block-member-mixed-order.frag | 25 +++++++++
.../block-member-no-block-location-invaild.frag | 26 ++++++++++
.../block-member-no-block-location.frag | 26 ++++++++++
.../block-member-locations/block-member.frag | 31 +++++++++++
.../named-block-member-mixed-order.frag | 26 ++++++++++
...med-block-member-no-block-location-invaild.frag | 26 ++++++++++
.../named-block-member-no-block-location.frag | 26 ++++++++++
.../block-member-locations/named-block-member.frag | 31 +++++++++++
.../block-member-locations/struct-member.frag | 25 +++++++++
.../block-member-location-overlap.shader_test | 59 +++++++++++++++++++++
.../block-member-mixed-order-overlap.shader_test | 52 +++++++++++++++++++
...named-block-member-location-overlap.shader_test | 60 ++++++++++++++++++++++
...ed-block-member-mixed-order-overlap.shader_test | 59 +++++++++++++++++++++
13 files changed, 472 insertions(+)
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-mixed-order.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location-invaild.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-mixed-order.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location-invaild.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member.frag
create mode 100644 tests/spec/arb_enhanced_layouts/compiler/block-member-locations/struct-member.frag
create mode 100644 tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-location-overlap.shader_test
create mode 100644 tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-mixed-order-overlap.shader_test
create mode 100644 tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-location-overlap.shader_test
create mode 100644 tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-mixed-order-overlap.shader_test
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-mixed-order.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-mixed-order.frag
new file mode 100644
index 0000000..7633088
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-mixed-order.frag
@@ -0,0 +1,25 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "The values used for locations do not have to be declared in increasing
+// order."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ vec4 a;
+ layout(location = 2) float f1;
+ float f2;
+ layout(location = 1) float f3;
+};
+
+float foo(void) {
+ return f1 + f2 + f3 + a.x + a.y + a.z + a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location-invaild.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location-invaild.frag
new file mode 100644
index 0000000..cdbc156
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location-invaild.frag
@@ -0,0 +1,26 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "If a block has no block-level location layout qualifier, it is required
+// that either all or none of its members have a location layout qualifier,
+// or a compile-time error results."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+in block {
+ vec4 a;
+ layout(location = 1) float f1;
+ float f2;
+ layout(location = 3) float f3;
+};
+
+float foo(void) {
+ return f1 + f2 + f3 + a.x + a.y + a.z + a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location.frag
new file mode 100644
index 0000000..99ac9cd
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member-no-block-location.frag
@@ -0,0 +1,26 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "If a block has no block-level location layout qualifier, it is required
+// that either all or none of its members have a location layout qualifier,
+// or a compile-time error results."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+in block {
+ layout(location = 0) vec4 a;
+ layout(location = 1) float f1;
+ layout(location = 2) float f2;
+ layout(location = 3) float f3;
+};
+
+float foo(void) {
+ return f1 + f2 + f3 + a.x + a.y + a.z + a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member.frag
new file mode 100644
index 0000000..3e17733
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/block-member.frag
@@ -0,0 +1,31 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "If the declared input is a structure or block, its members will be
+// assigned consecutive locations in their order of declaration, with the
+// first member assigned the location provided in the layout qualifier. For
+// a structure, this process applies to the entire structure. It is a
+// compile-time error to use a location qualifier on a member of a
+// structure. For a block, this process applies to the entire block, or
+// until the first member is reached that has a location layout qualifier.
+// When a block member is declared with a location qualifier, its location
+// comes from that qualifier: The member's location qualifier overrides the
+// block-level declaration."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ float f1;
+ layout(location = 1) float f2;
+};
+
+float foo(void) {
+ return f1 + f2;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-mixed-order.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-mixed-order.frag
new file mode 100644
index 0000000..c91bb50
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-mixed-order.frag
@@ -0,0 +1,26 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "The values used for locations do not have to be declared in increasing
+// order."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ vec4 a;
+ layout(location = 2) float f1;
+ float f2;
+ layout(location = 1) float f3;
+} name;
+
+float foo(void) {
+ return name.f1 + name.f2 + name.f3 + name.a.x +
+ name.a.y + name.a.z + name.a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location-invaild.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location-invaild.frag
new file mode 100644
index 0000000..cdbc156
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location-invaild.frag
@@ -0,0 +1,26 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "If a block has no block-level location layout qualifier, it is required
+// that either all or none of its members have a location layout qualifier,
+// or a compile-time error results."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+in block {
+ vec4 a;
+ layout(location = 1) float f1;
+ float f2;
+ layout(location = 3) float f3;
+};
+
+float foo(void) {
+ return f1 + f2 + f3 + a.x + a.y + a.z + a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location.frag
new file mode 100644
index 0000000..99ac9cd
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member-no-block-location.frag
@@ -0,0 +1,26 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "If a block has no block-level location layout qualifier, it is required
+// that either all or none of its members have a location layout qualifier,
+// or a compile-time error results."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+in block {
+ layout(location = 0) vec4 a;
+ layout(location = 1) float f1;
+ layout(location = 2) float f2;
+ layout(location = 3) float f3;
+};
+
+float foo(void) {
+ return f1 + f2 + f3 + a.x + a.y + a.z + a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member.frag
new file mode 100644
index 0000000..2425ca0
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/named-block-member.frag
@@ -0,0 +1,31 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "If the declared input is a structure or block, its members will be
+// assigned consecutive locations in their order of declaration, with the
+// first member assigned the location provided in the layout qualifier. For
+// a structure, this process applies to the entire structure. It is a
+// compile-time error to use a location qualifier on a member of a
+// structure. For a block, this process applies to the entire block, or
+// until the first member is reached that has a location layout qualifier.
+// When a block member is declared with a location qualifier, its location
+// comes from that qualifier: The member's location qualifier overrides the
+// block-level declaration."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ float f1;
+ layout(location = 1) float f2;
+} name;
+
+float foo(void) {
+ return name.f1 + name.f2;
+}
diff --git a/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/struct-member.frag b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/struct-member.frag
new file mode 100644
index 0000000..286d987
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/compiler/block-member-locations/struct-member.frag
@@ -0,0 +1,25 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "It is a compile-time error to use a location qualifier on a member of
+// a structure."
+
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in struct S {
+ vec4 a;
+ float f1;
+ layout(location=1) float f2; // Error: can't use location on struct member
+ float f3;
+} s;
+
+float foo(void) {
+ return s.f1 + s.f2 + s.f3 + s.a.x + s.a.y + s.a.z + s.a.w;
+}
diff --git a/tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-location-overlap.shader_test b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-location-overlap.shader_test
new file mode 100644
index 0000000..ae87844
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-location-overlap.shader_test
@@ -0,0 +1,59 @@
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "Location aliasing is causing two variables or block members to have the
+// same location number. Component aliasing is assigning the same (or
+// overlapping) component numbers for two location aliases. (Recall if
+// component is not used, components are assigned starting with 0.) With
+// one exception, location aliasing is allowed only if it does not cause
+// component aliasing; it is a compile-time or link-time error to cause
+// component aliasing. Further, when location aliasing, the aliases
+// sharing the location must have the same underlying numerical type
+// (floating-point or integer) and the same auxiliary storage and
+// interpolation qualification."
+
+[require]
+GLSL >= 1.50
+GL_ARB_enhanced_layouts
+GL_ARB_separate_shader_objects
+
+[vertex shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) out block {
+ vec4 a;
+ layout(location = 1) float f1;
+ float f2;
+ layout(location = 2) float f3; // ERROR: Location 2 used by f2
+};
+
+void main()
+{
+ a = vec4(1.0);
+ f1 = 0.0;
+ f2 = 1.0;
+ f3 = 1.0;
+}
+
+[fragment shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ vec4 a;
+ layout(location = 1) float f1;
+ float f2;
+ layout(location = 2) float f3; // ERROR: Location 2 used by f2
+};
+
+out vec4 color;
+
+void main()
+{
+ color = vec4(f1 + a.x, f2 + a.y, f3 + a.z, a.w);
+}
+
+[test]
+link error
diff --git a/tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-mixed-order-overlap.shader_test b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-mixed-order-overlap.shader_test
new file mode 100644
index 0000000..c70699e
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/block-member-mixed-order-overlap.shader_test
@@ -0,0 +1,52 @@
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "Subsequent members are again assigned consecutive locations, based on
+// the newest location, until the next member declared with a location
+// qualifier."
+
+[require]
+GLSL >= 1.50
+GL_ARB_enhanced_layouts
+GL_ARB_separate_shader_objects
+
+[vertex shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) out block {
+ layout(location = 3) vec4 a;
+ layout(location = 2) float f1;
+ float f2; // Error: Location 3 used by a
+ layout(location = 1) float f3;
+};
+
+void main()
+{
+ a = vec4(1.0);
+ f1 = 0.0;
+ f2 = 1.0;
+ f3 = 1.0;
+}
+
+[fragment shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ layout(location = 3) vec4 a;
+ layout(location = 2) float f1;
+ float f2; // Error: Location 3 used by a
+ layout(location = 1) float f3;
+};
+
+out vec4 color;
+
+void main()
+{
+ color = vec4(f1 + a.x, f2 + a.y, f3 + a.z, a.w);
+}
+
+[test]
+link error
diff --git a/tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-location-overlap.shader_test b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-location-overlap.shader_test
new file mode 100644
index 0000000..1cd45b6
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-location-overlap.shader_test
@@ -0,0 +1,60 @@
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "Location aliasing is causing two variables or block members to have the
+// same location number. Component aliasing is assigning the same (or
+// overlapping) component numbers for two location aliases. (Recall if
+// component is not used, components are assigned starting with 0.) With
+// one exception, location aliasing is allowed only if it does not cause
+// component aliasing; it is a compile-time or link-time error to cause
+// component aliasing. Further, when location aliasing, the aliases
+// sharing the location must have the same underlying numerical type
+// (floating-point or integer) and the same auxiliary storage and
+// interpolation qualification."
+
+[require]
+GLSL >= 1.50
+GL_ARB_enhanced_layouts
+GL_ARB_separate_shader_objects
+
+[vertex shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) out block {
+ vec4 a;
+ layout(location = 1) float f1;
+ float f2;
+ layout(location = 2) float f3; // ERROR: Location 2 used by f2
+} name;
+
+void main()
+{
+ name.a = vec4(1.0);
+ name.f1 = 0.0;
+ name.f2 = 1.0;
+ name.f3 = 1.0;
+}
+
+[fragment shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ vec4 a;
+ layout(location = 1) float f1;
+ float f2;
+ layout(location = 2) float f3; // ERROR: Location 2 used by f2
+} name;
+
+out vec4 color;
+
+void main()
+{
+ color = vec4(name.f1 + name.a.x, name.f2 + name.a.y,
+ name.f3 + name.a.z, name.a.w);
+}
+
+[test]
+link error
diff --git a/tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-mixed-order-overlap.shader_test b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-mixed-order-overlap.shader_test
new file mode 100644
index 0000000..f1cefcc
--- /dev/null
+++ b/tests/spec/arb_enhanced_layouts/linker/block-member-locations/named-block-member-mixed-order-overlap.shader_test
@@ -0,0 +1,59 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_enhanced_layouts GL_ARB_separate_shader_objects
+// [end config]
+//
+// From Section 4.4.1 (Input Layout Qualifiers) of the GLSL 4.50 spec:
+//
+// "Subsequent members are again assigned consecutive locations, based on
+// the newest location, until the next member declared with a location
+// qualifier."
+
+[require]
+GLSL >= 1.50
+GL_ARB_enhanced_layouts
+GL_ARB_separate_shader_objects
+
+[vertex shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) out block {
+ layout(location = 3) vec4 a;
+ layout(location = 2) float f1;
+ float f2; // Error: Location 3 used by a
+ layout(location = 1) float f3;
+} name;
+
+void main()
+{
+ name.a = vec4(1.0);
+ name.f1 = 0.0;
+ name.f2 = 1.0;
+ name.f3 = 1.0;
+}
+
+[fragment shader]
+#version 150
+#extension GL_ARB_enhanced_layouts: require
+#extension GL_ARB_separate_shader_objects: require
+
+layout(location = 0) in block {
+ layout(location = 3) vec4 a;
+ layout(location = 2) float f1;
+ float f2; // Error: Location 3 used by a
+ layout(location = 1) float f3;
+} name;
+
+out vec4 color;
+
+void main()
+{
+ color = vec4(name.f1 + name.a.x, name.f2 + name.a.y,
+ name.f3 + name.a.z, name.a.w);
+}
+
+[test]
+link error
--
2.4.3
More information about the Piglit
mailing list