Add new shader_runner tests that include a dynamic variable so the tests aren't constant folded away.
These tests are sourced from the const versions, and are only slightly modified. With debug build, the driver aborts. With release build, the test fails cleanly. This will be fixed with the following patch sent to mesa-dev: glsl: Fix aggregates with dynamic initializers. Signed-off-by: Cody Northrop <[email protected]> Reviewed-by: Courtney Goeltzenleuchter <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79373 --- ...ggregate-dynamic-initializer-matrix.shader_test | 54 ++++++++++++++ ...ate-dynamic-initializer-sized-array.shader_test | 61 ++++++++++++++++ ...ggregate-dynamic-initializer-struct.shader_test | 83 ++++++++++++++++++++++ ...e-dynamic-initializer-unsized-array.shader_test | 63 ++++++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-matrix.shader_test create mode 100644 tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-sized-array.shader_test create mode 100644 tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-struct.shader_test create mode 100644 tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-unsized-array.shader_test diff --git a/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-matrix.shader_test b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-matrix.shader_test new file mode 100644 index 0000000..7b923e8 --- /dev/null +++ b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-matrix.shader_test @@ -0,0 +1,54 @@ +/* The ARB_shading_language_420pack suggests: + * + * Verify that the following three matrices are identical: + * + * mat2x2 a = mat2( vec2( 1.0, 0.0 ), vec2( 0.0, 1.0 ) ); + * mat2x2 b = { vec2( 1.0, 0.0 ), vec2( 0.0, 1.0 ) }; + * mat2x2 c = { { 1.0, 0.0 }, { 0.0, 1.0 } }; + * + * This test differs from aggregate-initializer-matrix.shader_test + * in that it includes one dynamic variable, to further test the + * compiler. Otherwise, the initializer is constant folded away. + * The matrices should still be identical. + */ + +[require] +GLSL >= 1.30 +GL_ARB_shading_language_420pack + +[vertex shader] +#extension GL_ARB_shading_language_420pack: enable + +in vec4 vertex; +out vec4 color; + +void main() +{ + mat2x2 a = mat2( vec2( 1.0, vertex.x ), vec2( 0.0, 1.0 ) ); + mat2x2 b = { vec2( 1.0, vertex.x ), vec2( 0.0, 1.0 ) }; + mat2x2 c = { { 1.0, vertex.x }, { 0.0, 1.0 } }; + + color = vec4(0.0, 1.0, 0.0, 1.0); + + if (a.length() != b.length() || a.length() != c.length()) { + color = vec4(0.0, 0.0, 1.0, 1.0); + } else { + for (int i = 0; i < a.length(); i++) { + if (a[i] != b[i] || a[i] != c[i]) { + color = vec4(1.0, 0.0, 0.0, 1.0); + } + } + } + gl_Position = vertex; +} + +[fragment shader] +in vec4 color; + +void main() { + gl_FragColor = color;; +} + +[test] +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-sized-array.shader_test b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-sized-array.shader_test new file mode 100644 index 0000000..8191ceb --- /dev/null +++ b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-sized-array.shader_test @@ -0,0 +1,61 @@ +/* The ARB_shading_language_420pack suggests: + * + * Verify that the following two arrays are identical: + * + * vec4 a[12] = vec4 [] (vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0)); + * vec4 b[12] = { vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4) }; [sic] + * + * Of course, it means to include a final row of four vec4(0.0) in the initializer + * of b[12]. + * + * This test differs from aggregate-initializer-sized-array.shader_test in that + * it specifies one dynamic variable, to further test the compiler. Otherwise, + * the initializer is constant folded away. The arrays should still be identical. + */ + +[require] +GLSL >= 1.30 +GL_ARB_shading_language_420pack + +[vertex shader] +#extension GL_ARB_shading_language_420pack: enable + +in vec4 vertex; +out vec4 color; + +void main() +{ + vec4 a[12] = vec4 [] (vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + vec4(vertex.x), vec4(0.0), vec4(0.0), vec4(0.0)); + vec4 b[12] = { vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + vec4(vertex.x), vec4(0.0), vec4(0.0), vec4(0.0) }; + + color = vec4(0.0, 1.0, 0.0, 1.0); + + if (a.length() != b.length()) { + color = vec4(0.0, 0.0, 1.0, 1.0); + } else { + for (int i = 0; i < a.length(); i++) { + if (a[i] != b[i]) { + color = vec4(1.0, 0.0, 0.0, 1.0); + } + } + } + gl_Position = vertex; +} + +[fragment shader] +in vec4 color; + +void main() { + gl_FragColor = color;; +} + +[test] +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-struct.shader_test b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-struct.shader_test new file mode 100644 index 0000000..a04a2fa --- /dev/null +++ b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-struct.shader_test @@ -0,0 +1,83 @@ +/* + * This test differs from aggregate-initializer-struct.shader_test + * in that it includes one dynamic variable, to further test the + * compiler. Otherwise, the initializer is constant folded away. + * The structs should still be identical. + */ + +[require] +GLSL >= 1.30 +GL_ARB_shading_language_420pack + +[vertex shader] +#extension GL_ARB_shading_language_420pack: enable + +in vec4 vertex; +out vec4 color; + +void main() +{ + struct S { + vec4 v[2]; + }; + + struct T { + S a[2], b; + int c; + } + s1 = T( + S[2]( + S(vec4[2](vec4(vertex.x, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0))), + S(vec4[2](vec4(vertex.x, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0))) + ), // a + S(vec4[2](vec4(vertex.x, 2.0, 3.0, 4.0), vec4(5.0, 6.0, 7.0, 8.0))), // b + 4 // c + ), + s2 = { + { + { + { + {vertex.x, 2.0, 3.0, 4.0}, // a[0].v[0] + {5.0, 6.0, 7.0, 8.0} // a[0].v[1] + } // a[0].v + }, // a[0] + { + { + {vertex.x, 2.0, 3.0, 4.0}, // a[1].v[0] + {5.0, 6.0, 7.0, 8.0} // a[1].v[1] + } // a[1].v + } // a[1] + }, // a + { + { + {vertex.x, 2.0, 3.0, 4.0}, // b.v[0] + {5.0, 6.0, 7.0, 8.0} // b.v[1] + } // b.v + }, // b + 4 // c + }; + + color = vec4(0.0, 1.0, 0.0, 1.0); + + if (s1.a[0].v[0] != s2.a[0].v[0] || + s1.a[0].v[1] != s2.a[0].v[1] || + s1.a[1].v[0] != s2.a[1].v[0] || + s1.a[1].v[1] != s2.a[1].v[1] || + s1.b.v[0] != s2.b.v[0] || + s1.b.v[1] != s2.b.v[1] || + s1.c != s2.c) { + color = vec4(1.0, 0.0, 0.0, 1.0); + } + gl_Position = vertex; +} + +[fragment shader] +in vec4 color; + +void main() { + gl_FragColor = color;; +} + +[test] +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-unsized-array.shader_test b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-unsized-array.shader_test new file mode 100644 index 0000000..5300f49 --- /dev/null +++ b/tests/spec/arb_shading_language_420pack/execution/aggregate-dynamic-initializer-unsized-array.shader_test @@ -0,0 +1,63 @@ +/* The ARB_shading_language_420pack suggests: + * + * Verify that the following two arrays are identical: + * + * vec4 a[] = vec4 [] (vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(3.6)); + * vec4 b[] = { vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(0.0), + * vec4(0.0), vec4(0.0), vec4(0.0), vec4(3.6) }; + * + * This test differs from aggregate-initializer-unsized-array.shader_test in that + * it specifies one dynamic variable, to further test the compiler. Otherwise, + * the initializer is constant folded away. The arrays should still be identical. + */ + +[require] +GLSL >= 1.30 +GL_ARB_shading_language_420pack + +[vertex shader] +#extension GL_ARB_shading_language_420pack: enable + +in vec4 vertex; +out vec4 color; + +void main() +{ + vec4 a[] = vec4 [] (vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + vec4(vertex.x), vec4(0.0), vec4(0.0), vec4(0.0), + vec4(0.0), vec4(0.0), vec4(0.0), vec4(3.6)); + vec4 b[] = { vec4(1.2), vec4(0.0), vec4(0.0), vec4(0.0), + vec4(0.0), vec4(0.0), vec4(0.0), vec4(2.4), + vec4(vertex.x), vec4(0.0), vec4(0.0), vec4(0.0), + vec4(0.0), vec4(0.0), vec4(0.0), vec4(3.6) }; + + color = vec4(0.0, 1.0, 0.0, 1.0); + + if (a.length() != b.length()) { + color = vec4(0.0, 0.0, 1.0, 1.0); + } else { + for (int i = 0; i < a.length(); i++) { + if (a[i] != b[i]) { + color = vec4(1.0, 0.0, 0.0, 1.0); + } + } + } + gl_Position = vertex; +} + +[fragment shader] +in vec4 color; + +void main() { + gl_FragColor = color;; +} + +[test] +draw rect -1 -1 2 2 +probe all rgba 0.0 1.0 0.0 1.0 -- 1.9.1 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
