[Piglit] [PATCH] Test bad interaction with optimizer and a uniform array as a function argument.

Dominik Behr dbehr at chromium.org
Tue Sep 3 15:48:15 PDT 2013


Hi,
It could be also useful to have a test that actually verifies the value
written to uniform from host is read used by GPU. This uniform array
problem causes assert in debug builds of Mesa but it would pass the compile
in release mode. Also, there is potential for out-of-bounds access for
array on stack in brw::vec4_visitor::pack_uniform_registers in Mesa.


On Tue, Sep 3, 2013 at 2:51 PM, Matt Turner <mattst88 at gmail.com> wrote:

> These test that a uniform array used only as a function argument is not
> improperly optimized out or has its length reduced.
>
> Cc: Dominik Behr <dbehr at chromium.org>
> Reported-by: Dominik Behr <dbehr at chromium.org>
> ---
>  .../glsl-fs-max-array-access-forward-declaration.frag    | 16
> ++++++++++++++++
>  tests/shaders/glsl-fs-max-array-access-function.frag     | 14
> ++++++++++++++
>  .../glsl-vs-max-array-access-forward-declaration.vert    | 16
> ++++++++++++++++
>  tests/shaders/glsl-vs-max-array-access-function.vert     | 15
> +++++++++++++++
>  4 files changed, 61 insertions(+)
>  create mode 100644
> tests/shaders/glsl-fs-max-array-access-forward-declaration.frag
>  create mode 100644 tests/shaders/glsl-fs-max-array-access-function.frag
>  create mode 100644
> tests/shaders/glsl-vs-max-array-access-forward-declaration.vert
>  create mode 100644 tests/shaders/glsl-vs-max-array-access-function.vert
>
> diff --git
> a/tests/shaders/glsl-fs-max-array-access-forward-declaration.frag
> b/tests/shaders/glsl-fs-max-array-access-forward-declaration.frag
> new file mode 100644
> index 0000000..e92859b
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-max-array-access-forward-declaration.frag
> @@ -0,0 +1,16 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.10
> +// [end config]
> +
> +uniform float a[3];
> +
> +float func(float array[3]);
> +
> +void main() {
> +       gl_FragColor = vec4(func(a), vec3(1.0));
> +}
> +
> +float func(float array[3]) {
> +       return array[2];
> +}
> diff --git a/tests/shaders/glsl-fs-max-array-access-function.frag
> b/tests/shaders/glsl-fs-max-array-access-function.frag
> new file mode 100644
> index 0000000..a3208dc
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-max-array-access-function.frag
> @@ -0,0 +1,14 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.10
> +// [end config]
> +
> +uniform float a[3];
> +
> +float func(float array[3]) {
> +       return array[2];
> +}
> +
> +void main() {
> +       gl_FragColor = vec4(func(a), vec3(1.0));
> +}
> diff --git
> a/tests/shaders/glsl-vs-max-array-access-forward-declaration.vert
> b/tests/shaders/glsl-vs-max-array-access-forward-declaration.vert
> new file mode 100644
> index 0000000..4306e78
> --- /dev/null
> +++ b/tests/shaders/glsl-vs-max-array-access-forward-declaration.vert
> @@ -0,0 +1,16 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.10
> +// [end config]
> +
> +uniform float a[3];
> +
> +float func(float array[3]);
> +
> +void main() {
> +       gl_Position = vec4(func(a), vec3(1.0));
> +}
> +
> +float func(float array[3]) {
> +       return array[2];
> +}
> diff --git a/tests/shaders/glsl-vs-max-array-access-function.vert
> b/tests/shaders/glsl-vs-max-array-access-function.vert
> new file mode 100644
> index 0000000..45592c5
> --- /dev/null
> +++ b/tests/shaders/glsl-vs-max-array-access-function.vert
> @@ -0,0 +1,15 @@
> +// [config]
> +// expect_result: pass
> +// glsl_version: 1.10
> +// [end config]
> +
> +uniform float a[3];
> +
> +float func(float array[3]) {
> +       return array[2];
> +}
> +
> +void main()
> +{
> +       gl_Position = vec4(func(a), vec3(1.0));
> +}
> --
> 1.8.3.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130903/346c86f9/attachment-0001.html>


More information about the Piglit mailing list