[Piglit] [PATCH 3/4] glslparsertest: Add tests for bit shifts in GLSL 1.30

Ian Romanick idr at freedesktop.org
Mon Oct 11 17:50:58 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chad Versace wrote:
> From: Chad Versace <chad.versace at intel.com>
> 
> ---
>  tests/glslparser.tests                       |    9 +++
>  tests/glslparsertest/glsl2/bit-shift-01.frag |   14 +++++
>  tests/glslparsertest/glsl2/bit-shift-02.frag |   14 +++++
>  tests/glslparsertest/glsl2/bit-shift-03.frag |   23 ++++++++
>  tests/glslparsertest/glsl2/bit-shift-04.frag |   23 ++++++++
>  tests/glslparsertest/glsl2/bit-shift-05.frag |   39 ++++++++++++++
>  tests/glslparsertest/glsl2/bit-shift-06.frag |   71 ++++++++++++++++++++++++++
>  tests/glslparsertest/glsl2/bit-shift-07.frag |   17 ++++++
>  tests/glslparsertest/glsl2/bit-shift-08.frag |   12 ++++
>  tests/glslparsertest/glsl2/bit-shift-09.frag |   11 ++++
>  10 files changed, 233 insertions(+), 0 deletions(-)
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-01.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-02.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-03.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-04.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-05.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-06.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-07.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-08.frag
>  create mode 100644 tests/glslparsertest/glsl2/bit-shift-09.frag
> 
> diff --git a/tests/glslparser.tests b/tests/glslparser.tests
> index b258da4..ff48780 100644
> --- a/tests/glslparser.tests
> +++ b/tests/glslparser.tests
> @@ -227,6 +227,15 @@ add_otherglslparsertest('glsl2/bit-not-03.frag', 'pass', '1.30')
>  add_otherglslparsertest('glsl2/bit-not-04.frag', 'pass', '1.30')
>  add_otherglslparsertest('glsl2/bit-not-05.frag', 'fail', '1.30')
>  add_otherglslparsertest('glsl2/bit-not-06.frag', 'fail', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-01.frag', 'pass', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-02.frag', 'pass', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-03.frag', 'pass', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-04.frag', 'pass', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-05.frag', 'pass', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-06.frag', 'pass', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-07.frag', 'fail', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-08.frag', 'fail', '1.30')
> +add_otherglslparsertest('glsl2/bit-shift-09.frag', 'fail', '1.30')
>  add_otherglslparsertest('glsl2/builtin-functions-110.vert', 'pass')
>  add_otherglslparsertest('glsl2/builtin-functions-110.frag', 'pass')
>  add_otherglslparsertest('glsl2/builtin-functions-120.vert', 'pass', '1.20')
> diff --git a/tests/glslparsertest/glsl2/bit-shift-01.frag b/tests/glslparsertest/glsl2/bit-shift-01.frag
> new file mode 100644
> index 0000000..4bfd6d4
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-01.frag
> @@ -0,0 +1,14 @@
> +// Expected: PASS, glsl == 1.30
> +//
> +// Description: bit-shift with argument type (int, int)
> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "the operands must be signed or unsigned integers or integer vectors. [...]
> +// In all cases, the resulting type will be the same type as the left
> +// operand."
> +
> +#version 130
> +void main() {
> +    int x0 = 4 << 1;
> +    int x1 = 4 >> 1;
> +}
> diff --git a/tests/glslparsertest/glsl2/bit-shift-02.frag b/tests/glslparsertest/glsl2/bit-shift-02.frag
> new file mode 100644
> index 0000000..240798c
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-02.frag
> @@ -0,0 +1,14 @@
> +// Expected: PASS, glsl == 1.30
> +//
> +// Description: bit-shift with argument type (uint, uint)
> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "the operands must be signed or unsigned integers or integer vectors. [...]
> +// In all cases, the resulting type will be the same type as the left
> +// operand."
> +
> +#version 130
> +void main() {
> +    uint x0 = uint(4) << uint(1);
> +    uint x1 = uint(4) >> uint(1);

This should also work as 'uint(4) << 1'.  Likewise, int(4) << uint(1)
should work.  Maybe change the x1 assignment in this and the previous
case to have / not have the cast on the shift count?  I see that these
cases are covered in the vectored tests below.

> +}
> diff --git a/tests/glslparsertest/glsl2/bit-shift-03.frag b/tests/glslparsertest/glsl2/bit-shift-03.frag
> new file mode 100644
> index 0000000..20bea35
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-03.frag
> @@ -0,0 +1,23 @@
> +// Expected: PASS, glsl == 1.30
> +//
> +// Description: bit-shift with argument type (ivecN, ivecN)
> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "the operands must be signed or unsigned integers or integer vectors. [...]
> +// In all cases, the resulting type will be the same type as the left
> +// operand."
> +
> +#version 130
> +void main() {
> +    // ivec2
> +    ivec2 v00 = ivec2(0, 1) << ivec2(0, 1);
> +    ivec2 v01 = ivec2(0, 1) >> ivec2(0, 1);
> +
> +    // ivec3
> +    ivec3 v02 = ivec3(0, 1, 2) << ivec3(0, 1, 2);
> +    ivec3 v03 = ivec3(0, 1, 2) >> ivec3(0, 1, 2);
> +
> +    // ivec4
> +    ivec4 v04 = ivec4(0, 1, 2, 3) << ivec4(0, 1, 2, 3);
> +    ivec4 v05 = ivec4(0, 1, 2, 3) >> ivec4(0, 1, 2, 3);
> +}
> diff --git a/tests/glslparsertest/glsl2/bit-shift-04.frag b/tests/glslparsertest/glsl2/bit-shift-04.frag
> new file mode 100644
> index 0000000..f14d2bc
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-04.frag
> @@ -0,0 +1,23 @@
> +// Expected: PASS, glsl == 1.30
> +//
> +// Description: bit-shift with argument type (uvecN, uvecN)
> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "the operands must be signed or unsigned integers or integer vectors. [...]
> +// In all cases, the resulting type will be the same type as the left
> +// operand."
> +
> +#version 130
> +void main() {
> +    // uvec2
> +    uvec2 v00 = uvec2(0, 1) << uvec2(0, 1);
> +    uvec2 v01 = uvec2(0, 1) >> uvec2(0, 1);
> +
> +    // uvec3
> +    uvec3 v02 = uvec3(0, 1, 2) << uvec3(0, 1, 2);
> +    uvec3 v03 = uvec3(0, 1, 2) >> uvec3(0, 1, 2);
> +
> +    // uvec4
> +    uvec4 v04 = uvec4(0, 1, 2, 3) << uvec4(0, 1, 2, 3);
> +    uvec4 v05 = uvec4(0, 1, 2, 3) >> uvec4(0, 1, 2, 3);
> +}
> diff --git a/tests/glslparsertest/glsl2/bit-shift-05.frag b/tests/glslparsertest/glsl2/bit-shift-05.frag
> new file mode 100644
> index 0000000..8047de3
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-05.frag
> @@ -0,0 +1,39 @@
> +// Expected: PASS, glsl == 1.30
> +//
> +// Description: bit-shift with argument types:
> +//     - (ivecN, uvecN)
> +//     - (uvecN, ivecN)
> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "One operand can be signed while the other is unsigned."
> +
> +#version 130
> +void main() {
> +    // ivecN = ivecN << uvecN -----------------
> +
> +    // ivec2 = ivec2 << uvec2
> +    ivec2 v00 = ivec2(0, 1) << uvec2(0, 1);
> +    ivec2 v01 = ivec2(0, 1) >> uvec2(0, 1);
> +
> +    // ivec3 = ivec3 << uvec3
> +    ivec3 v02 = ivec3(0, 1, 2) << uvec3(0, 1, 2);
> +    ivec3 v03 = ivec3(0, 1, 2) >> uvec3(0, 1, 2);
> +
> +    // ivec4 = ivec4 << uvec4
> +    ivec4 v04 = ivec4(0, 1, 2, 3) << uvec4(0, 1, 2, 3);
> +    ivec4 v05 = ivec4(0, 1, 2, 3) >> uvec4(0, 1, 2, 3);
> +
> +    // uvecN = uvecN << ivecN -----------------
> +
> +    // uvec2 = uvec2 << ivec2
> +    ivec2 v06 = ivec2(0, 1) << uvec2(0, 1);
> +    ivec2 v07 = ivec2(0, 1) >> uvec2(0, 1);
> +
> +    // uvec3 = uvec3 << ivec3
> +    ivec3 v08 = ivec3(0, 1, 2) << uvec3(0, 1, 2);
> +    ivec3 v09 = ivec3(0, 1, 2) >> uvec3(0, 1, 2);
> +
> +    // uvec4 = uvec4 << ivec4
> +    ivec4 v10 = ivec4(0, 1, 2, 3) << uvec4(0, 1, 2, 3);
> +    ivec4 v11 = ivec4(0, 1, 2, 3) >> uvec4(0, 1, 2, 3);
> +}
> diff --git a/tests/glslparsertest/glsl2/bit-shift-06.frag b/tests/glslparsertest/glsl2/bit-shift-06.frag
> new file mode 100644
> index 0000000..3094e58
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-06.frag
> @@ -0,0 +1,71 @@
> +// Expected: PASS, glsl == 1.30
> +//
> +// Description: bit-shift with argument types:
> +//     - (ivecN, int)
> +//     - (uvecN, int)
> +//     - (ivecN, uint)
> +//     - (uvecN, uint)
> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "One operand can be signed while the other is unsigned. [...] If the first
> +// operand is a vector, the second operand must be a scalar or a vector,"
> +
> +
> +#version 130
> +void main() {
> +    // (ivecN, int) --------------------------
> +
> +    // (ivec2, int)
> +    ivec2 v00 = ivec2(0, 1) << 7;
> +    ivec2 v01 = ivec2(0, 1) >> 7;
> +
> +    // (ivec3, int)
> +    ivec3 v02 = ivec3(0, 1, 2) << 7;
> +    ivec3 v03 = ivec3(0, 1, 2) >> 7;
> +
> +    // (ivec4, int)
> +    ivec4 v04 = ivec4(0, 1, 2, 3) << 7;
> +    ivec4 v05 = ivec4(0, 1, 2, 3) >> 7;
> +
> +    // (uvecN, int) --------------------------
> +
> +    // (uvec2, int)
> +    uvec2 v10 = uvec2(0, 1) << 7;
> +    uvec2 v11 = uvec2(0, 1) >> 7;
> +
> +    // (uvec3, int)
> +    uvec3 v12 = uvec3(0, 1, 2) << 7;
> +    uvec3 v13 = uvec3(0, 1, 2) >> 7;
> +
> +    // (uvec4, int)
> +    uvec4 v14 = uvec4(0, 1, 2, 3) << 7;
> +    uvec4 v15 = uvec4(0, 1, 2, 3) >> 7;
> +
> +    // (ivecN, uint) --------------------------
> +
> +    // (ivec2, uint)
> +    ivec2 v20 = ivec2(0, 1) << uint(7);
> +    ivec2 v21 = ivec2(0, 1) >> uint(7);
> +
> +    // (ivec3, uint)
> +    ivec3 v22 = ivec3(0, 1, 2) << uint(7);
> +    ivec3 v23 = ivec3(0, 1, 2) >> uint(7);
> +
> +    // (ivec4, uint)
> +    ivec4 v24 = ivec4(0, 1, 2, 3) << uint(7);
> +    ivec4 v25 = ivec4(0, 1, 2, 3) >> uint(7);
> +
> +    // (uvecN, uint) --------------------------
> +
> +    // (uvec2, uint)
> +    uvec2 v30 = uvec2(0, 1) << uint(7);
> +    uvec2 v31 = uvec2(0, 1) >> uint(7);
> +
> +    // (uvec3, uint)
> +    uvec3 v32 = uvec3(0, 1, 2) << uint(7);
> +    uvec3 v33 = uvec3(0, 1, 2) >> uint(7);
> +
> +    // (uvec4, uint)
> +    uvec4 v34 = uvec4(0, 1, 2, 3) << uint(7);
> +    uvec4 v35 = uvec4(0, 1, 2, 3) >> uint(7);
> +}
> diff --git a/tests/glslparsertest/glsl2/bit-shift-07.frag b/tests/glslparsertest/glsl2/bit-shift-07.frag
> new file mode 100644
> index 0000000..6f335d6
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-07.frag
> @@ -0,0 +1,17 @@
> +// Expected: FAIL, glsl == 1.30
> +//
> +// Description: bit-shift with argument types (int, ivec2)
> +//     - (ivecN, int)
> +//     - (uvecN, int)
> +//     - (ivecN, uint)
> +//     - (uvecN, uint)

Cut-and-paste comment fail?

> +//
> +// From page 50 (page 56 of PDF) of the GLSL 1.30 spec:
> +// "If the first operand is a scalar, the second operand has to be a scalar as
> +// well."
> +
> +#version 130
> +void main() {
> +    int x = 7 << ivec2(0, 1);
> +}
> +
> diff --git a/tests/glslparsertest/glsl2/bit-shift-08.frag b/tests/glslparsertest/glsl2/bit-shift-08.frag
> new file mode 100644
> index 0000000..4d7e87e
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-08.frag
> @@ -0,0 +1,12 @@
> +// Expected: FAIL, glsl <= 1.30
> +//
> +// Description: bit-shift with arguments (mat4, int)
> +//
> +// From page 50 (page 56 of the PDF) of the GLSL 1.30 spec:
> +// "the operands must be signed or unsigned integers or integer vectors."
> +
> +#version 130
> +void main() {
> +    bool b = true << 0;
> +}
> +
> diff --git a/tests/glslparsertest/glsl2/bit-shift-09.frag b/tests/glslparsertest/glsl2/bit-shift-09.frag
> new file mode 100644
> index 0000000..a1f39c2
> --- /dev/null
> +++ b/tests/glslparsertest/glsl2/bit-shift-09.frag
> @@ -0,0 +1,11 @@
> +// Expected: FAIL, glsl == 1.30
> +//
> +// Description: bit-shift with unequally sized vectors
> +//
> +// See page 50 (page 56 of the PDF) of the GLSL 1.30 spec.
> +
> +#version 130
> +void main() {
> +    ivec2 v = ivec2(0, 1) << ivec3(0, 1, 2);
> +}
> +

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyzsPAACgkQX1gOwKyEAw9uygCeOOuCGpiO6k4AiFZLmzs9mtHA
2hkAnAqqj4nvCxTAd/6CMa5vB+yiSMhD
=31Bb
-----END PGP SIGNATURE-----


More information about the Piglit mailing list