[Piglit] [PATCH] glsl-1.20: better test indirect indexing of literal array of structs

Brian Paul brianp at vmware.com
Fri Jun 30 13:12:58 UTC 2017


Reviewed-by: Brian Paul <brianp at vmware.com>


On 06/29/2017 10:25 PM, Timothy Arceri wrote:
> This exposes some existing bugs in gallium and also provides more
> coverage for when we start packing uniforms.
> ---
>   ...iteral-array-of-structs-vec4-member.shader_test | 39 +++++++++++++++
>   ...s-with-multiple-members-large-array.shader_test | 57 ++++++++++++++++++++++
>   ...ay-of-structs-with-multiple-members.shader_test | 44 +++++++++++++++++
>   3 files changed, 140 insertions(+)
>   create mode 100644 tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test
>   create mode 100644 tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test
>   create mode 100644 tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test
>
> diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test
> new file mode 100644
> index 0000000..a403f6f
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-vec4-member.shader_test
> @@ -0,0 +1,39 @@
> +# Verify that an array of structs appearing in the shader as a literal
> +# can be successfully dereferenced to access the values inside the
> +# structs.
> +
> +[require]
> +GLSL >= 1.20
> +
> +[vertex shader]
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +struct Foo {
> +  ivec4 value;
> +};
> +
> +uniform int i;
> +uniform ivec4 expected_value;
> +
> +void main()
> +{
> +  ivec4 actual_value = Foo[2](Foo(ivec4(100, 200, 300, 400)),
> +                              Foo(ivec4(500, 600, 700, 800)))[i].value;
> +  if (actual_value == expected_value)
> +    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +uniform int i 0
> +uniform ivec4 expected_value 100 200 300 400
> +draw rect -1 -1 2 1
> +uniform int i 1
> +uniform ivec4 expected_value 500 600 700 800
> +draw rect -1 0 2 1
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test
> new file mode 100644
> index 0000000..ff2b34d
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members-large-array.shader_test
> @@ -0,0 +1,57 @@
> +# Verify that an array of structs appearing in the shader as a literal
> +# can be successfully dereferenced to access the values inside the
> +# structs.
> +#
> +# This test has a slightly larger array to better check that we calculate
> +# offsets correctly. This exposed a bug in the glsl to tgsi pass in gallium
> +# based drivers.
> +
> +[require]
> +GLSL >= 1.20
> +
> +[vertex shader]
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +struct Foo {
> +  int value;
> +
> +  /* A second member of a differnt size ensures we calculate member offsets
> +   * correctly.
> +   */
> +  ivec2 value2;
> +};
> +
> +uniform int i;
> +uniform ivec2 expected_value;
> +
> +void main()
> +{
> +  ivec2 actual_value = Foo[4](Foo(100, ivec2(200, 300)),
> +                              Foo(400, ivec2(500, 600)),
> +                              Foo(700, ivec2(800, 900)),
> +                              Foo(1000, ivec2(1100, 1200)))[i].value2;
> +  if (actual_value == expected_value)
> +    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +uniform int i 0
> +uniform ivec2 expected_value 200 300
> +draw rect -1 -1 1 1
> +uniform int i 1
> +uniform ivec2 expected_value 500 600
> +draw rect 0 -1 1 1
> +probe all rgba 0.0 1.0 0.0 1.0
> +uniform int i 0
> +uniform ivec2 expected_value 800 900
> +draw rect -1 0 1 1
> +uniform int i 1
> +uniform ivec2 expected_value 1100 1200
> +draw rect 0 0 1 1
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test
> new file mode 100644
> index 0000000..c7d0e3a
> --- /dev/null
> +++ b/tests/spec/glsl-1.20/execution/fs-deref-literal-array-of-structs-with-multiple-members.shader_test
> @@ -0,0 +1,44 @@
> +# Verify that an array of structs appearing in the shader as a literal
> +# can be successfully dereferenced to access the values inside the
> +# structs.
> +
> +[require]
> +GLSL >= 1.20
> +
> +[vertex shader]
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +struct Foo {
> +  int value;
> +
> +  /* A second member of a differnt size helps ensures we calculate member
> +   * offsets correctly.
> +   */
> +  ivec2 value2;
> +};
> +
> +uniform int i;
> +uniform ivec2 expected_value;
> +
> +void main()
> +{
> +  ivec2 actual_value = Foo[2](Foo(100, ivec2(200, 300)),
> +                              Foo(400, ivec2(500, 600)))[i].value2;
> +  if (actual_value == expected_value)
> +    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
> +  else
> +    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +uniform int i 0
> +uniform ivec2 expected_value 200 300
> +draw rect -1 -1 2 1
> +uniform int i 1
> +uniform ivec2 expected_value 500 600
> +draw rect -1 0 2 1
> +probe all rgba 0.0 1.0 0.0 1.0
>



More information about the Piglit mailing list