[Piglit] [PATCH 4/6] gl_ClipDistance: Add better max size checks.

Paul Berry stereotype441 at gmail.com
Tue Sep 6 09:06:32 PDT 2011


On 4 September 2011 11:34, Paul Berry <stereotype441 at gmail.com> wrote:

> These new tests validate that an appropriate error is generated when:
> - attempting to access beyond the end of gl_ClipDistance when explicitly
> sized
>  to 3.
> - attempting to access beyond the end of gl_ClipDistance when explicitly
> sized
>  to gl_MaxClipDistances.
> - attempting to explicitly size gl_ClipDistance beyond gl_MaxClipDistances.
> - same as above, but without accessing gl_ClipDistance.
> - attempting to access beyond the end of gl_ClipDistance when implicitly
> sized.
>
> These tests replace clip-distance-not-sizeable-above-max.c, which was less
> thorough, and more unweildy since it was a straight C program.
> ---
>  tests/all.tests                                    |    1 -
>  .../clipping/clip-distance-explicit-access-3.frag  |   30 +++++
>  .../clipping/clip-distance-explicit-access-3.vert  |   37 ++++++
>  .../clip-distance-explicit-access-max.frag         |   31 +++++
>  .../clip-distance-explicit-access-max.vert         |   38 ++++++
>  ...ip-distance-explicit-too-large-with-access.frag |   30 +++++
>  ...ip-distance-explicit-too-large-with-access.vert |   37 ++++++
>  .../clipping/clip-distance-explicit-too-large.frag |   28 +++++
>  .../clipping/clip-distance-explicit-too-large.vert |   35 ++++++
>  .../clip-distance-implicit-access-max.frag         |   28 +++++
>  .../clip-distance-implicit-access-max.vert         |   35 ++++++
>  .../glsl-1.30/linker/clipping/CMakeLists.gl.txt    |    1 -
>  .../clip-distance-not-sizeable-above-max.c         |  123
> --------------------
>  13 files changed, 329 insertions(+), 125 deletions(-)
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-3.frag
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-3.vert
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-max.frag
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-max.vert
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-too-large-with-access.frag
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-too-large-with-access.vert
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-too-large.frag
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-too-large.vert
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-implicit-access-max.frag
>  create mode 100644
> tests/spec/glsl-1.30/compiler/clipping/clip-distance-implicit-access-max.vert
>  delete mode 100644
> tests/spec/glsl-1.30/linker/clipping/clip-distance-not-sizeable-above-max.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 931e0d3..9958c66 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -811,7 +811,6 @@ add_shader_test_dir(spec['glsl-1.30']['execution'],
>                    recursive=True)
>  spec['glsl-1.30']['linker'] = Group()
>  spec['glsl-1.30']['linker']['clipping'] = Group()
> -add_plain_test(spec['glsl-1.30']['linker']['clipping'],
> 'clip-distance-not-sizeable-above-max')
>  add_plain_test(spec['glsl-1.30']['linker']['clipping'],
> 'mixing-clip-distance-and-clip-vertex-disallowed')
>
>  # Group AMD_conservative_depth
> diff --git
> a/tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-3.frag
> b/tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-3.frag
> new file mode 100644
> index 0000000..19c10cd
> --- /dev/null
> +++
> b/tests/spec/glsl-1.30/compiler/clipping/clip-distance-explicit-access-3.frag
> @@ -0,0 +1,30 @@
> +/* [config]
> + * expect_result: fail
> + * glsl_version: 1.30
> + * check_link: true
> + * [end config]
> + *
> + * From the GLSL 1.30 spec section 7.2 (Fragment Shader Special
> + * Variables):
> + *
> + *   The built-in input variable gl_ClipDistance array contains
> + *   linearly interpolated values for the vertex values written by the
> + *   vertex shader to the gl_ClipDistance vertex output variable. This
> + *   array must be sized in the fragment shader either implicitly or
> + *   explicitly to be the same size as it was sized in the vertex
> + *   shader.
> + *
> + * This test checks that the an error occurs when explicitly setting
> + * the size of gl_ClipDistance to 3 (which should be ok) and trying to
> + * access a non-existent element (gl_ClipDistance[3]) using an
> + * integral constant expression, which should generate an error.
> + */
> +#version 130
> +
> +out float gl_ClipDistance[3];
> +
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +  gl_FragColor = vec4(gl_ClipDistance[3]);
> +}
>

Whoops, all the .frag programs in this patch have an extra bogus line saying
"gl_Position = gl_Vertex;".  This causes the test to pass, but for the wrong
reason (it passes because "gl_Vertex" and "gl_Position" are not defined for
fragment shaders, not because of the gl_ClipDistance sizing rules that these
tests are intended to check).  I'll remove these bogus lines before pushing
the patches.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20110906/c33f8313/attachment-0001.htm>


More information about the Piglit mailing list