[Piglit] [PATCH v2] Add tests for arb_cull_distance

Dylan Baker baker.dylan.c at gmail.com
Fri Jan 16 16:13:37 PST 2015


On Saturday, January 17, 2015 12:01:56 AM Tobias Klausmann wrote:
> Testing for:
> - new <pname> entrys supported by GetIntegerv and others
> - new constants
> - new array gl_CullDistance:
>   explicit size, max. size and max. size while interfering with gl_ClipDistance
> 
> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
> ---
> V2: Add a missing semicolon in 
>     fs-cull-and-clip-distance-sizeable-to-max.shader_test
> 
>  tests/all.py                                       |   7 +
>  tests/spec/CMakeLists.txt                          |   1 +
>  tests/spec/arb_cull_distance/CMakeLists.gl.txt     |  14 ++
>  tests/spec/arb_cull_distance/CMakeLists.txt        |   1 +
>  ...fs-cull-and-clip-distance-different.shader_test |  47 ++++++
>  ...s-cull-and-clip-distance-exceed-max.shader_test |  38 +++++
>  ...l-and-clip-distance-sizeable-to-max.shader_test |  47 ++++++
>  .../fs-cull-distance-explicitly-sized.shader_test  |  35 +++++
>  .../fs-cull-distance-interpolated.shader_test      |  77 +++++++++
>  .../fs-cull-distance-sizeable-to-max.shader_test   |  38 +++++
>  tests/spec/arb_cull_distance/max-distances.c       | 174 +++++++++++++++++++++
>  11 files changed, 479 insertions(+)
>  create mode 100644 tests/spec/arb_cull_distance/CMakeLists.gl.txt
>  create mode 100644 tests/spec/arb_cull_distance/CMakeLists.txt
>  create mode 100644 tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/fs-cull-and-clip-distance-exceed-max.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/fs-cull-and-clip-distance-sizeable-to-max.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/fs-cull-distance-explicitly-sized.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/fs-cull-distance-interpolated.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/fs-cull-distance-sizeable-to-max.shader_test
>  create mode 100644 tests/spec/arb_cull_distance/max-distances.c
> 
> diff --git a/tests/all.py b/tests/all.py
> index f9fd238..6545cf7 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -3630,6 +3630,13 @@ add_concurrent_test(arb_copy_image, ['arb_copy_image-formats', '--samples=2'])
>  add_concurrent_test(arb_copy_image, ['arb_copy_image-formats', '--samples=4'])
>  add_concurrent_test(arb_copy_image, ['arb_copy_image-formats', '--samples=8'])
>  
> +arb_cull_distance = {}
> +spec['arb_cull_distance'] = arb_cull_distance
> +add_concurrent_test(arb_cull_distance, ['arb_cull_distance-max-distances'])
> +add_shader_test_dir(arb_cull_distance,
> +                    os.path.join(testsDir, 'spec', 'arb_cull_distance'),
> +                    recursive=True)
> +
>  arb_half_float_vertex = {}
>  spec['ARB_half_float_vertex'] = arb_half_float_vertex
>  add_plain_test(arb_half_float_vertex, ['draw-vertices-half-float'])
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 6a13f0a..890b1d2 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -6,6 +6,7 @@ add_subdirectory (arb_clear_texture)
>  add_subdirectory (arb_color_buffer_float)
>  add_subdirectory (arb_copy_image)
>  add_subdirectory (arb_compute_shader)
> +add_subdirectory (arb_cull_distance)
>  add_subdirectory (arb_debug_output)
>  add_subdirectory (khr_debug)
>  add_subdirectory (arb_depth_clamp)
> diff --git a/tests/spec/arb_cull_distance/CMakeLists.gl.txt b/tests/spec/arb_cull_distance/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..431c192
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/CMakeLists.gl.txt
> @@ -0,0 +1,14 @@
> +include_directories(
> +	${GLEXT_INCLUDE_DIR}
> +	${OPENGL_INCLUDE_PATH}
> +   ${piglit_SOURCE_DIR}/tests/mesa/util
> +)
> +
> +link_libraries (
> +	piglitutil_${piglit_target_api}
> +	${OPENGL_gl_LIBRARY}
> +	${OPENGL_glu_LIBRARY}
> +)
> +
> +piglit_add_executable (arb_cull_distance-max-distances max-distances.c)
> +
> diff --git a/tests/spec/arb_cull_distance/CMakeLists.txt b/tests/spec/arb_cull_distance/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test
> new file mode 100644
> index 0000000..387db40
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-different.shader_test
> @@ -0,0 +1,47 @@
> +# From the ARB_cull_distance spec:
> +#
> +#   The built-in output variables gl_ClipDistance and glCullDistance hold the
> +#   clip distance(s) and cull distance(s), respectively, used in the culling
> +#   stage, as described in section 13.5.
> +#
> +# This test checks that the arrays gl_ClipDistance and gl_CullDistance only
> +# interfer by gl_MaxCombinedClipAndCullDistances and not by its entrys.
> +
> +[require]
> +GLSL >= 1.30
GL_ARB_cull_distance

For the other tests too.
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +out float gl_ClipDistance[4];
> +out float gl_CullDistance[4];
> +
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +  for (int i = 1; i <= 4; ++i) {
> +    gl_ClipDistance[i-1] = i;
> +    gl_CullDistance[i-1] = i*5;
> +  }
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +in float gl_ClipDistance[4];
> +in float gl_CullDistance[4];
> +
> +void main()
> +{
> +  gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
> +  for (int i = 1; i <= 4; ++i) {
> +    if (gl_ClipDistance[i-1] != i)
> +      gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
> +    if (gl_CullDistance[i-1] != (i*5))
> +      gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> +  }
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-exceed-max.shader_test b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-exceed-max.shader_test
> new file mode 100644
> index 0000000..591bf5f
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-exceed-max.shader_test
> @@ -0,0 +1,38 @@
> +# From the ARB_cull_distance spec:
> +#
> +#   It is a compile-time or link-time error for the set of shaders forming
> +#   a program to have the sum of the sizes of the gl_ClipDistance and
> +#   gl_CullDistance arrays to be larger than
> +#   gl_MaxCombinedClipAndCullDistances.
> +#
> +# This test checks that the combined size of gl_CullDistance and
> +# gl_ClipDistance causes an error when exceeding
> +# gl_MaxCombinedClipAndCullDistances.
> +
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +out float gl_ClipDistance[gl_MaxCombinedClipAndCullDistances];
> +out float gl_CullDistance[gl_MaxCombinedClipAndCullDistances];
> +
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +in float gl_ClipDistance[gl_MaxCombinedClipAndCullDistances];
> +in float gl_CullDistance[gl_MaxCombinedClipAndCullDistances];
> +
> +void main()
> +{
> +  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +link error
> diff --git a/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-sizeable-to-max.shader_test b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-sizeable-to-max.shader_test
> new file mode 100644
> index 0000000..ca177b2
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/fs-cull-and-clip-distance-sizeable-to-max.shader_test
> @@ -0,0 +1,47 @@
> +# From the ARB_cull_distance spec:
> +#
> +#    It is a compile-time or link-time error for the set of shaders forming
> +#    a program to have the sum of the sizes of the gl_ClipDistance and
> +#    gl_CullDistance arrays to be larger than
> +#    gl_MaxCombinedClipAndCullDistances.
> +#
> +# This test checks that the size of gl_CullDistance and gl_ClipDistance can be
> +# set to gl_MaxCombinedClipAndCullDistances without error, and that this
> +# actually causes the size of the arrays to be set properly.
> +
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +out float gl_ClipDistance[gl_MaxCombinedClipAndCullDistances/2];
> +out float gl_CullDistance[gl_MaxCombinedClipAndCullDistances/2];
> +
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +in float gl_ClipDistance[gl_MaxCombinedClipAndCullDistances/2];
> +in float gl_CullDistance[gl_MaxCombinedClipAndCullDistances/2];
> +
> +void main()
> +{
> +  gl_FragColor =
> +  (gl_CullDistance.length() == gl_MaxCombinedClipAndCullDistances/2)
> +  ? vec4(0.0, 0.0, 1.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +
> +  if (gl_CullDistance.length() == gl_MaxCombinedClipAndCullDistances/2) {
> +    gl_FragColor =
> +    (gl_ClipDistance.length() == gl_MaxCombinedClipAndCullDistances/2)
> +    ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +  }
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/fs-cull-distance-explicitly-sized.shader_test b/tests/spec/arb_cull_distance/fs-cull-distance-explicitly-sized.shader_test
> new file mode 100644
> index 0000000..de641b4
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/fs-cull-distance-explicitly-sized.shader_test
> @@ -0,0 +1,35 @@
> +# From the ARB_cull_distance spec:
> +#
> +# If either shader redeclares the built-in array gl_CullDistance[] or
> +# gl_ClipDistance[], the array must have the same size in both shaders.
> +#
> +# This test checks that the GLSL compiler respects the size of
> +# gl_CullDistance when it is explicitly declared in the fragment shader.
> +
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +out float gl_CullDistance[3];
> +
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +in float gl_CullDistance[3];
> +
> +void main()
> +{
> +  gl_FragColor = (gl_CullDistance.length() == 3) ? vec4(0.0, 1.0, 0.0, 1.0)
> +                                                 : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/fs-cull-distance-interpolated.shader_test b/tests/spec/arb_cull_distance/fs-cull-distance-interpolated.shader_test
> new file mode 100644
> index 0000000..1cb53f8
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/fs-cull-distance-interpolated.shader_test
> @@ -0,0 +1,77 @@
> +# From the ARB_cull_distance spec:
> +#
> +#   In the fragment language, gl_CullDistance array contains linearly
> +#   interpolated values for the vertex values written by a shader to the
> +#   gl_CullDistance vertex output variable.
> +#
> +# This test checks proper operation of gl_CullDistance in fragment
> +# shaders by setting each element of gl_CullDistance to simple linear
> +# function of gl_Vertex (computed by taking the dot product of
> +# gl_Vertex with a uniform vector, and dividing the result by
> +# gl_Vertex's homogeneous coordinate).  gl_Vertex is also passed
> +# through to the fragment shader, which uses the same dot product to
> +# verify that gl_CullDistance has been properly interpolated.
> +
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +uniform vec4 transform[6];
> +out vec4 vertex;
> +out float gl_CullDistance[6];
> +
> +void main()
> +{
> +  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
> +
> +  // Set each value of gl_CullDistance to a linear transformation of
> +  // gl_Vertex.
> +  for (int i = 0; i < 6; ++i) {
> +    gl_CullDistance[i] = dot(transform[i], gl_Vertex) / gl_Vertex.w;
> +  }
> +
> +  // Pass through gl_Vertex to the fragment shader so that it can
> +  // verify the interpolated values of gl_CullDistance.
> +  vertex = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +uniform vec4 transform[6];
> +in vec4 vertex;
> +in float gl_CullDistance[6];
> +
> +void main()
> +{
> +  bool test_passed = true;
> +
> +  // Check that each value of gl_CullDistance matches the value
> +  // computed in the vertex shader.
> +  for (int i = 0; i < 6; ++i) {
> +    float expected_distance = dot(transform[i], vertex) / vertex.w;
> +    float deviation = distance(gl_CullDistance[i], expected_distance);
> +    if (deviation > 1.0e-5) {
> +      test_passed = false;
> +    }
> +  }
> +
> +  // Report pass/fail as a red or green pixel.
> +  gl_FragColor = test_passed ? vec4(0.0, 1.0, 0.0, 1.0)
> +                             : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +ortho 0 1 0 1
> +
> +uniform vec4 transform[0]  1.0  1.0 0.0 0.0 # cullDistance[0] = x + y
> +uniform vec4 transform[1]  1.0  2.0 0.0 0.0 # cullDistance[1] = x + 2*y
> +uniform vec4 transform[2]  2.0  1.0 0.0 0.0 # cullDistance[2] = 2*x + y
> +uniform vec4 transform[3]  2.0  2.0 0.0 0.0 # cullDistance[3] = 2*x + 2*y
> +uniform vec4 transform[4] -1.0 -1.0 0.0 2.0 # cullDistance[4] = 2.0 - x - y
> +uniform vec4 transform[5] -1.0  1.0 0.0 1.0 # cullDistance[5] = 1.0 - x + y
> +
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/fs-cull-distance-sizeable-to-max.shader_test b/tests/spec/arb_cull_distance/fs-cull-distance-sizeable-to-max.shader_test
> new file mode 100644
> index 0000000..95e06c7
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/fs-cull-distance-sizeable-to-max.shader_test
> @@ -0,0 +1,38 @@
> +# From the ARB_cull_distance spec:
> +#
> +#    The gl_CullDistance array is predeclared as unsized and must be sized by
> +#    the shader either redeclaring it with a size or indexing it only with
> +#    integral constant expressions. The size determines the number and set of
> +#    enabled cull distances and can be at most gl_MaxCullDistances.
> +#
> +# This test checks that the size of gl_CullDistance can be set to
> +# gl_MaxCullDistances without error, and that this actually causes the
> +# size of the array to be set properly.
> +
> +[require]
> +GLSL >= 1.30
> +
> +[vertex shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +out float gl_CullDistance[gl_MaxCullDistances];
> +
> +void main()
> +{
> +  gl_Position = gl_Vertex;
> +}
> +
> +[fragment shader]
> +#version 130
> +#extension GL_ARB_cull_distance: enable
> +in float gl_CullDistance[gl_MaxCullDistances];
> +
> +void main()
> +{
> +  gl_FragColor = (gl_CullDistance.length() == gl_MaxCullDistances)
> +    ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0);
> +}
> +
> +[test]
> +draw rect -1 -1 2 2
> +probe all rgba 0.0 1.0 0.0 1.0
> diff --git a/tests/spec/arb_cull_distance/max-distances.c b/tests/spec/arb_cull_distance/max-distances.c
> new file mode 100644
> index 0000000..5814291
> --- /dev/null
> +++ b/tests/spec/arb_cull_distance/max-distances.c
> @@ -0,0 +1,174 @@
> +/*
> + * Copyright © 2015 Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +/**
> + * \file max-distances.c
> + *
> + * From the ARB_cull_distance spec:
> + *
> + * Modify Section 7.3, Built-In Constants
> + *
> + * (add to the list of implementation-dependent constants after
> + *  gl_MaxClipDistances on p. 132)
> + *
> + *  const int  gl_MaxCullDistances = 8;
> + *  const int  gl_MaxCombinedClipAndCullDistances = 8;
> + *
> + *
> + * New Implementation Dependent State
> + *
> + * (add to table 23.53, Implementation Dependent Values)
> + *
> + * Get Value                             Type  Get Command  Min. value  Description
> + * ------------------------------------  ----  -----------  ----------  ------------------------------
> + * MAX_CULL_DISTANCES                     Z+   GetIntegerv      8       Max no. of user culling planes
> + * MAX_COMBINED_CLIP_AND_CULL_DISTANCES   Z+   GetIntegerv      8       Max combined no. of user
> + *                                                                      clipping and culling planes
> + *
> + * This test verifies that glGetIntegerv() returns the appropriate values for
> + * the tokens MAX_CULL_DISTANCES and MAX_COMBINED_CLIP_AND_CULL_DISTANCES, that
> + * these values matches the values of gl_MaxCullDistances, respectively
> + * gl_MaxCombinedClipAndCullDistances defined in the vertex and fragment shader
> + * and that these values are at least 8.
> + */
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +   config.supports_gl_compat_version = 10;
> +   config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static const char vert[] =
> +   "#version 130\n"
> +   "#extension GL_ARB_cull_distance: enable\n"
> +   "uniform int expected_value;\n"
> +   "uniform bool test_distances;\n"
> +   "uniform bool test_in_vs;\n"
> +   "void main()\n"
> +   "{\n"
> +   "  gl_Position = gl_Vertex;\n"
> +   "  if (test_in_vs) {\n"
> +   "    int value = test_distances ? gl_MaxCullDistances\n"
> +   "                               : gl_MaxCombinedClipAndCullDistances;\n"
> +   "    gl_FrontColor = (value == expected_value)\n"
> +   "                     ? vec4(0.0, 1.0, 0.0, 1.0)\n"
> +   "                     : vec4(1.0, 0.0, 0.0, 1.0);\n"
> +   "  }\n"
> +   "}\n";
> +
> +static const char frag[] =
> +   "#version 130\n"
> +   "#extension GL_ARB_cull_distance: enable\n"
> +   "uniform int expected_value;\n"
> +   "uniform bool test_distances;\n"
> +   "uniform bool test_in_vs;\n"
> +   "void main()\n"
> +   "{\n"
> +   "  if (test_in_vs) {\n"
> +   "    gl_FragColor = gl_Color;\n"
> +   "  } else {\n"
> +   "    int value = test_distances ? gl_MaxCullDistances\n"
> +   "                               : gl_MaxCombinedClipAndCullDistances;\n"
> +   "    gl_FragColor = (value == expected_value)\n"
> +   "                    ? vec4(0.0, 1.0, 0.0, 1.0)\n"
> +   "                    : vec4(1.0, 0.0, 0.0, 1.0);\n"
> +   "  }\n"
> +   "}\n";
> +
> +GLuint prog;
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +   GLint max_cull_distances;
> +   GLint max_combined_clip_and_cull_distances;
> +   GLint expected_value;
> +   GLint test_distances, test_in_vs;
> +   float green[] = { 0.0, 1.0, 0.0, 1.0 };
> +   GLint loc;
> +
> +   enum piglit_result result = PIGLIT_PASS;
> +
> +   glGetIntegerv(GL_MAX_CULL_DISTANCES, &max_cull_distances);
> +   printf("GL_MAX_CULL_DISTANCES = %d\n", max_cull_distances);
> +   if (max_cull_distances < 8) {
> +      printf("GL_MAX_CULL_DISTANCES < 8\n");
> +      piglit_report_result(PIGLIT_FAIL);
> +   }
> +
> +   glGetIntegerv(GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES,
> +                 &max_combined_clip_and_cull_distances);
> +   printf("GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES = %d\n",
> +          max_combined_clip_and_cull_distances);
> +   if (max_combined_clip_and_cull_distances < 8) {
> +      printf("GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES < 8\n");
> +      piglit_report_result(PIGLIT_FAIL);
> +   }
> +
> +   expected_value = max_cull_distances;
> +   loc = glGetUniformLocation(prog, "expected_value");
> +   glUniform1i(loc, expected_value);
> +
> +   for (test_distances = 0; test_distances <= 1; ++test_distances) {
> +      loc = glGetUniformLocation(prog, "test_distances");
> +      glUniform1i(loc, test_distances);
> +      for (test_in_vs = 0; test_in_vs <= 1; ++test_in_vs) {
> +         bool pass;
> +         loc = glGetUniformLocation(prog, "test_in_vs");
> +         glUniform1i(loc, test_in_vs);
> +         piglit_draw_rect(-1, -1, 2, 2);
> +         pass = piglit_probe_rect_rgba(0, 0, piglit_width,
> +                                       piglit_height, green);
> +         if (test_distances) {
> +            printf("Checking that gl_MaxCullDistances == %d in %s: %s\n",
> +                   expected_value,
> +                   test_in_vs ? "VS" : "FS",
> +                   pass ? "pass" : "fail");
> +         }
> +         else {
> +            printf("Checking that gl_MaxCombinedClipAndCullDistances "
> +                   "== %d in %s: %s\n",
> +                   expected_value,
> +                   test_in_vs ? "VS" : "FS",
> +                   pass ? "pass" : "fail");
> +         }
> +         if (!pass) {
> +            result = PIGLIT_FAIL;
> +         }
> +      }
> +   }
> +   return result;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	piglit_require_gl_version(30);
> +	piglit_require_GLSL();
> +	piglit_require_GLSL_version(130);
> +	piglit_require_extension("GL_ARB_cull_distance");
> +	prog = piglit_build_simple_program(vert, frag);
> +	glUseProgram(prog);
> +}
> -- 
> 2.2.1
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150116/61c85057/attachment.sig>


More information about the Piglit mailing list