[Piglit] [PATCH] glsl-1.10: test loop unrolling when induction variable is inside if branch

Eric Anholt eric at anholt.net
Mon Jun 4 22:25:54 UTC 2018


Timothy Arceri <tarceri at itsqueeze.com> writes:

> ---
>  ...induction-variable-inside-if-branch.shader_test | 61 ++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
>  create mode 100644 tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-induction-variable-inside-if-branch.shader_test
>
> diff --git a/tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-induction-variable-inside-if-branch.shader_test b/tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-induction-variable-inside-if-branch.shader_test
> new file mode 100644
> index 000000000..1990db8ea
> --- /dev/null
> +++ b/tests/spec/glsl-1.10/execution/vs-loop-simple-unroll-induction-variable-inside-if-branch.shader_test
> @@ -0,0 +1,61 @@
> +# This tests unrolling of a loop with a single exit point.
> +#
> +# Here we test that loop is correctly unrolled when the induction variable is
> +# inside an if branch.
> +[require]
> +GLSL >= 1.10
> +
> +[vertex shader]
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +
> +  vec4 colour = vec4(1.0, 0.0, 0.0, 1.0);
> +
> +  int i = 1;
> +  int j = 0; // we use this so the if doesn't get reduced to a series of bcsel
> +  do {
> +
> +    j++;
> +
> +    if (i >= 3) {
> +      if (i == 3) {
> +         colour = vec4(0.0, 1.0, 0.0, 1.0);
> +         j++;
> +         if (j != 6)
> +           colour = vec4(1.0, 0.0, 1.0, 1.0);
> +      } else {
> +        colour = vec4(1.0, 1.0, 0.0, 1.0);
> +      }
> +      break;
> +    } else {
> +      if (i != 1) {
> +         j++;
> +      }
> +    }
> +
> +   if (i >= 5) {
> +      j++; // unreachable
> +      break;
> +    } else {

mismatched indentation

> +      if (i != 1) {
> +         j++;
> +      }
> +      i++;
> +    }
> +  } while (i < 4);
> +
> +  gl_FrontColor = colour;
> +}

Thanks for making tests for bugs like this!

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20180604/2568ca82/attachment-0001.sig>


More information about the Piglit mailing list