[Piglit] [PATCH v2] glsl-1.30: add tests for using immediates in common operations

Ian Romanick idr at freedesktop.org
Fri Apr 27 13:07:07 UTC 2018


On 04/27/2018 12:01 AM, Ilia Mirkin wrote:
> NVIDIA hardware has "short" immediates, and some instructions have both
> long and short immediate variants. Nouveau was picking the wrong one
> under certain conditions. This adds tests which are likely to cause
> these kinds of issues to surface in a backend.

It might be worth putting a note about this in the test scripts.
Otherwise, someone may come along later, and, thinking the tests are
redundant, try to remove them.

> Since this tests for very precise bit patterns, restrict to GLSL 1.30,
> which introduced bit operations for integers.
> 
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> Reviewed-by: Eric Anholt <eric at anholt.net>
> ---
> 
> v1 -> v2: move from GLSL 1.10 to GLSL 1.30
> 
>  .../immediates/fs-op-add-int-immed-1.shader_test   | 24 ++++++++++++++++++++++
>  .../immediates/fs-op-add-int-immed-2.shader_test   | 24 ++++++++++++++++++++++
>  .../immediates/fs-op-add-int-immed-3.shader_test   | 24 ++++++++++++++++++++++
>  .../immediates/fs-op-add-int-immed-4.shader_test   | 24 ++++++++++++++++++++++
>  .../fs-op-bitand-int-immed-1.shader_test           | 21 +++++++++++++++++++
>  .../fs-op-bitand-int-immed-2.shader_test           | 21 +++++++++++++++++++
>  .../fs-op-bitand-int-immed-3.shader_test           | 21 +++++++++++++++++++
>  .../fs-op-bitand-int-immed-4.shader_test           | 21 +++++++++++++++++++
>  .../immediates/fs-op-mul-int-immed-1.shader_test   | 24 ++++++++++++++++++++++
>  .../immediates/fs-op-mul-int-immed-2.shader_test   | 24 ++++++++++++++++++++++
>  .../immediates/fs-op-mul-int-immed-3.shader_test   | 24 ++++++++++++++++++++++
>  .../immediates/fs-op-mul-int-immed-4.shader_test   | 24 ++++++++++++++++++++++
>  12 files changed, 276 insertions(+)
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-1.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-2.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-3.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-4.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-1.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-2.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-3.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-4.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-1.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-2.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-3.shader_test
>  create mode 100644 tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-4.shader_test
> 
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-1.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-1.shader_test
> new file mode 100644
> index 000000000..d4421e613
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-1.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 + 0x80000);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 0
> +uniform int expected 0x80000
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-2.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-2.shader_test
> new file mode 100644
> index 000000000..f20b3383f
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-2.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 + 0x7ffff);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 0
> +uniform int expected 0x7ffff
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-3.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-3.shader_test
> new file mode 100644
> index 000000000..45570ba03
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-3.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 - 0x80000);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 0
> +uniform int expected -0x80000
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-4.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-4.shader_test
> new file mode 100644
> index 000000000..f14187948
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-add-int-immed-4.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 - 0x80001);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 0
> +uniform int expected -0x80001
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-1.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-1.shader_test
> new file mode 100644
> index 000000000..0f3ced422
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-1.shader_test
> @@ -0,0 +1,21 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform uint arg0 = 0xffffffffu;
> +uniform uint expected = 0x80000u;
> +
> +void main()
> +{
> +  uint result = (arg0 & 0x80000u);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-2.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-2.shader_test
> new file mode 100644
> index 000000000..1a2041237
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-2.shader_test
> @@ -0,0 +1,21 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform uint arg0 = 0xffffffffu;
> +uniform uint expected = 0x7ffffu;
> +
> +void main()
> +{
> +  uint result = (arg0 & 0x7ffffu);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-3.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-3.shader_test
> new file mode 100644
> index 000000000..883505347
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-3.shader_test
> @@ -0,0 +1,21 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform uint arg0 = 0xffffffffu;
> +uniform uint expected = -0x80000u;
> +
> +void main()
> +{
> +  uint result = (arg0 & -0x80000u);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-4.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-4.shader_test
> new file mode 100644
> index 000000000..2805991cb
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-bitand-int-immed-4.shader_test
> @@ -0,0 +1,21 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform uint arg0 = 0xffffffffu;
> +uniform uint expected = -0x80001u;
> +
> +void main()
> +{
> +  uint result = (arg0 & -0x80001u);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-1.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-1.shader_test
> new file mode 100644
> index 000000000..28ef7d1e9
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-1.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 * 0x80001);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 1
> +uniform int expected 0x80001
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-2.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-2.shader_test
> new file mode 100644
> index 000000000..5cf5e01b3
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-2.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 * 0x7ffff);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 1
> +uniform int expected 0x7ffff
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-3.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-3.shader_test
> new file mode 100644
> index 000000000..3bc00107e
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-3.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 * -0x80000);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 1
> +uniform int expected -0x80000
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> diff --git a/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-4.shader_test b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-4.shader_test
> new file mode 100644
> index 000000000..6a6b937d0
> --- /dev/null
> +++ b/tests/spec/glsl-1.30/execution/immediates/fs-op-mul-int-immed-4.shader_test
> @@ -0,0 +1,24 @@
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +uniform int arg0;
> +uniform int expected;
> +
> +void main()
> +{
> +  int result = (arg0 * -0x80001);
> +  gl_FragColor = result == expected ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +clear color 0.0 0.0 1.0 0.0
> +clear
> +
> +uniform int arg0 1
> +uniform int expected -0x80001
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0 1 0 1
> 



More information about the Piglit mailing list