[Piglit] [PATCH v2 2/2] nv_fill_rectangle: add tests

Ilia Mirkin imirkin at alum.mit.edu
Thu Mar 30 21:53:37 UTC 2017


On Thu, Mar 30, 2017 at 5:38 PM, Lyude <lyude at redhat.com> wrote:
> This adds a set of basic shader tests for the GL_NV_fill_rectangle
> extension. These include:
> - Testing NV_fill_rectangle with geometry shaders, tessellation
>   evaluation shaders, and just plain tris. Also testing that it actually
>   obeys the vertex data we give it.
> - Testing that points, lines, and isolines coming from either the TES or
>   the GS, or glDraw() calls are unaffected by NV_fill_rectangle
> - Testing that we're not allowed to call glDraw() with only one of the
>   front or back polygon modes set to GL_NV_fill_rectangle
>
> Changes since v1:
> - Use GL_TRIANGLES in basic test
> - Use green for prims, 0.2 for clear
> - Fix points used for relative probe rect rgb
> - Add a lot more tests that imirkin requested
>
> Signed-off-by: Lyude <lyude at redhat.com>
> ---
>  tests/spec/CMakeLists.txt                          |  1 +
>  tests/spec/nv_fill_rectangle/CMakeLists.gl.txt     | 13 ++++
>  tests/spec/nv_fill_rectangle/CMakeLists.txt        |  1 +
>  .../gs-lines-ignore-fill-rect.shader_test          | 43 ++++++++++++
>  .../gs-points-ignore-fill-rect.shader_test         | 44 +++++++++++++
>  .../execution/gs-tris-with-fill-rect.shader_test   | 42 ++++++++++++
>  .../execution/lines-ignore-fill-rect.shader_test   | 29 ++++++++
>  .../execution/points-ignore-fill-rect.shader_test  | 35 ++++++++++
>  .../tes-isolines-ignore-fill-rect.shader_test      | 37 +++++++++++
>  ...tris-in-point-mode-ignore-fill-rect.shader_test | 43 ++++++++++++
>  .../execution/tes-tris-with-fill-rect.shader_test  | 41 ++++++++++++
>  .../execution/tris-with-fill-rect.shader_test      | 30 +++++++++
>  tests/spec/nv_fill_rectangle/invalid-draw-mode.c   | 77 ++++++++++++++++++++++
>  13 files changed, 436 insertions(+)
>  create mode 100644 tests/spec/nv_fill_rectangle/CMakeLists.gl.txt
>  create mode 100644 tests/spec/nv_fill_rectangle/CMakeLists.txt
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/gs-lines-ignore-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/gs-points-ignore-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/gs-tris-with-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/lines-ignore-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/points-ignore-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/tes-isolines-ignore-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/tes-tris-in-point-mode-ignore-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/tes-tris-with-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/execution/tris-with-fill-rect.shader_test
>  create mode 100644 tests/spec/nv_fill_rectangle/invalid-draw-mode.c
>
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 01a7935..31a57ed 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -89,6 +89,7 @@ add_subdirectory (ext_texture_swizzle)
>  add_subdirectory (ext_timer_query)
>  add_subdirectory (ext_transform_feedback)
>  add_subdirectory (nv_conditional_render)
> +add_subdirectory (nv_fill_rectangle)
>  add_subdirectory (nv_image_formats)
>  add_subdirectory (nv_texture_barrier)
>  add_subdirectory (oes_compressed_etc1_rgb8_texture)
> diff --git a/tests/spec/nv_fill_rectangle/CMakeLists.gl.txt b/tests/spec/nv_fill_rectangle/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..f9219f5
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/CMakeLists.gl.txt
> @@ -0,0 +1,13 @@
> +include_directories(
> +       ${GLEXT_INCLUDE_DIR}
> +       ${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries(
> +       piglitutil_${piglit_target_api}
> +       ${OPENGL_gl_LIBRARY}
> +)
> +
> +piglit_add_executable(nv_fill_rectangle-invalid-draw-mode invalid-draw-mode.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/nv_fill_rectangle/CMakeLists.txt b/tests/spec/nv_fill_rectangle/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/nv_fill_rectangle/execution/gs-lines-ignore-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/gs-lines-ignore-fill-rect.shader_test
> new file mode 100644
> index 0000000..e8e79a8
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/gs-lines-ignore-fill-rect.shader_test
> @@ -0,0 +1,43 @@
> +# Tests that lines output from the geometry shader are not affected by
> +# GL_NV_fill_rectangle
> +[require]
> +GLSL >= 1.50
> +GL_ARB_tessellation_shader
> +GL_NV_fill_rectangle
> +
> +[vertex shader passthrough]
> +
> +[geometry shader]
> +layout(points) in;
> +layout(line_strip, max_vertices=3) out;
> +
> +void main()
> +{
> +       for (int i = 0; i < 3; i++) {
> +               gl_Position = gl_in[i].gl_Position;

This worked? gl_in should be an array of size 1 here, so you're going
out of bounds. (I'm guessing this happens elsewhere as well.)

> +               EmitVertex();
> +       }
> +       EndPrimitive();
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> + 0.0  1.0  0.0
> + 1.0 -1.0  0.0
> +-1.0 -1.0  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_POINTS 0 3
> +
> +probe rgb  0 0 0.0 1.0 0.0
> +probe rgb 10 5 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/gs-points-ignore-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/gs-points-ignore-fill-rect.shader_test
> new file mode 100644
> index 0000000..9874b52
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/gs-points-ignore-fill-rect.shader_test
> @@ -0,0 +1,44 @@
> +# Tests that points output from the geometry shader are not effected by
> +# GL_NV_fill_rectangle
> +[require]
> +GLSL >= 1.50
> +GL_NV_fill_rectangle
> +
> +[vertex shader passthrough]
> +
> +[geometry shader]
> +layout(points) in;
> +layout(points, max_vertices=3) out;
> +
> +void main()
> +{
> +       for (int i = 0; i < 3; i++) {
> +               gl_Position = gl_in[i].gl_Position;
> +               gl_PointSize = 5.0;
> +               EmitVertex();
> +       }
> +       EndPrimitive();
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> + 0.0  1.0  0.0
> + 1.0 -1.0  0.0
> +-1.0 -1.0  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +enable GL_PROGRAM_POINT_SIZE
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_POINTS 0 3
> +
> +probe rgb  0 0 0.0 1.0 0.0
> +probe rgb 10 0 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/gs-tris-with-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/gs-tris-with-fill-rect.shader_test
> new file mode 100644
> index 0000000..decd8ab
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/gs-tris-with-fill-rect.shader_test
> @@ -0,0 +1,42 @@
> +# Tests that triangles output from the geometry shader are correctly rasterized
> +# as rectangles when GL_NV_fill_rectangle is used
> +[require]
> +GLSL >= 1.50
> +GL_NV_fill_rectangle
> +
> +[vertex shader passthrough]
> +
> +[geometry shader]
> +layout(points) in;
> +layout(triangle_strip, max_vertices=3) out;
> +
> +void main()
> +{
> +       for (int i = 0; i < 3; i++) {
> +               gl_Position = gl_in[i].gl_Position;
> +               EmitVertex();
> +       }
> +       EndPrimitive();
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> + 0.0  0.5  0.0
> + 0.5 -0.5  0.0
> +-0.5 -0.5  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_POINTS 0 3
> +
> +relative probe rect rgb (0.26, 0.26, 0.48, 0.48) (0.0, 1.0, 0.0, 1.0)
> +probe rgb 0 0 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/lines-ignore-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/lines-ignore-fill-rect.shader_test
> new file mode 100644
> index 0000000..069715f
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/lines-ignore-fill-rect.shader_test
> @@ -0,0 +1,29 @@
> +# Tests that setting the glPolygonMode to GL_FILL_RECTANGLE_NV has no effect on
> +# rasterization when the primitive to be rasterized is of type GL_LINES.
> +[require]
> +GLSL >= 1.10
> +GL_NV_fill_rectangle
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> +-1.0 -1.0  0.0
> + 1.0  1.0  0.0
> + 1.0 -1.0  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_LINES 0 3
> +
> +probe rgb  0 0 0.0 1.0 0.0
> +probe rgb 10 0 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/points-ignore-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/points-ignore-fill-rect.shader_test
> new file mode 100644
> index 0000000..2142bf4
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/points-ignore-fill-rect.shader_test
> @@ -0,0 +1,35 @@
> +# Tests that GL_NV_fill_rectangle has no effect when drawing in GL_POINTS mode
> +[require]
> +GLSL >= 1.30
> +GL_NV_fill_rectangle
> +
> +[vertex shader]
> +in vec4 vertex;
> +void main()
> +{
> +       gl_Position = vertex;
> +       gl_PointSize = 5.0; /* so the points are always inside the window */
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +vertex/float/3
> + 0.0  1.0  0.0
> + 1.0 -1.0  0.0
> +-1.0 -1.0  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +enable GL_PROGRAM_POINT_SIZE
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_POINTS 0 3
> +
> +probe rgb  0 0 0.0 1.0 0.0
> +probe rgb 10 0 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/tes-isolines-ignore-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/tes-isolines-ignore-fill-rect.shader_test
> new file mode 100644
> index 0000000..e89c9b2
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/tes-isolines-ignore-fill-rect.shader_test
> @@ -0,0 +1,37 @@
> +# Tests that isolines are not effected by GL_NV_fill_rectangle
> +[require]
> +GLSL >= 1.50
> +GL_ARB_tessellation_shader
> +GL_NV_fill_rectangle
> +
> +[vertex shader]
> +void main()
> +{
> +}
> +
> +[tessellation evaluation shader]
> +#extension GL_ARB_tessellation_shader: require
> +layout(isolines, equal_spacing) in;
> +
> +void main()
> +{
> +       gl_Position = vec4(gl_TessCoord.xy * 2.0 - 1.0, 0.0, 1.0);
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +patch parameter vertices 2
> +patch parameter default level outer 1 1 0 0
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_PATCHES 0 2
> +
> +probe rgb 0 0 0.0 1.0 0.0
> +probe rgb 5 5 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/tes-tris-in-point-mode-ignore-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/tes-tris-in-point-mode-ignore-fill-rect.shader_test
> new file mode 100644
> index 0000000..b7dac2c
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/tes-tris-in-point-mode-ignore-fill-rect.shader_test
> @@ -0,0 +1,43 @@
> +# Tests that triangles coming out of the TES in point_mode don't get rasterized
> +# as triangles when drawing in GL_NV_fill_rectangle mode
> +[require]
> +GLSL >= 1.50
> +GL_NV_fill_rectangle
> +GL_ARB_tessellation_shader
> +
> +[vertex shader passthrough]
> +
> +[tessellation evaluation shader]
> +#extension GL_ARB_tessellation_shader: require
> +layout(triangles, point_mode) in;
> +
> +void main()
> +{
> +       gl_Position = gl_in[0].gl_Position * gl_TessCoord[0]
> +                   + gl_in[1].gl_Position * gl_TessCoord[1]
> +                   + gl_in[2].gl_Position * gl_TessCoord[2];
> +       gl_PointSize = 5.0;
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> + 0.0  1.0  0.0
> + 1.0 -1.0  0.0
> +-1.0 -1.0  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +enable GL_PROGRAM_POINT_SIZE
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_PATCHES 0 3
> +
> +probe rgb  0  0 0.0 1.0 0.0
> +probe rgb 15 15 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/tes-tris-with-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/tes-tris-with-fill-rect.shader_test
> new file mode 100644
> index 0000000..efab19b
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/tes-tris-with-fill-rect.shader_test
> @@ -0,0 +1,41 @@
> +# Tests that we can output a triangle from the TES and have it rasterized as a
> +# rectangle with GL_NV_fill_rectangle
> +[require]
> +GLSL >= 1.50
> +GL_NV_fill_rectangle
> +GL_ARB_tessellation_shader
> +
> +[vertex shader passthrough]
> +
> +[tessellation evaluation shader]
> +#extension GL_ARB_tessellation_shader: require
> +layout(triangles) in;
> +
> +void main()
> +{
> +       gl_Position = gl_in[0].gl_Position * gl_TessCoord[0]
> +                   + gl_in[1].gl_Position * gl_TessCoord[1]
> +                   + gl_in[2].gl_Position * gl_TessCoord[2];
> +}
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> + 0.0  0.5  0.0
> + 0.5 -0.5  0.0
> +-0.5 -0.5  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_PATCHES 0 3
> +
> +relative probe rect rgb (0.26, 0.26, 0.48, 0.48) (0.0, 1.0, 0.0, 1.0)
> +probe rgb 0 0 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/execution/tris-with-fill-rect.shader_test b/tests/spec/nv_fill_rectangle/execution/tris-with-fill-rect.shader_test
> new file mode 100644
> index 0000000..153c9cd
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/execution/tris-with-fill-rect.shader_test
> @@ -0,0 +1,30 @@
> +# Tests whether or not we can properly rasterize triangles as rectangles using
> +# the GL_NV_fill_rectangle extension, and whether or not the rectangles obey the
> +# vertex data we use
> +[require]
> +GLSL >= 1.10
> +GL_NV_fill_rectangle
> +
> +[vertex shader passthrough]
> +
> +[fragment shader]
> +void main()
> +{
> +       gl_FragColor = vec4(0, 1, 0, 1);
> +}
> +
> +[vertex data]
> +piglit_vertex/float/3
> + 0.0  0.5  0.0
> + 0.5 -0.5  0.0
> +-0.5 -0.5  0.0
> +
> +[test]
> +clear color 0.2 0.2 0.2 0.2
> +clear
> +
> +polygon mode GL_FRONT_AND_BACK GL_FILL_RECTANGLE_NV
> +draw arrays GL_TRIANGLES 0 3
> +
> +relative probe rect rgb (0.26, 0.26, 0.48, 0.48) (0.0, 1.0, 0.0, 1.0)
> +probe rgb 0 0 0.2 0.2 0.2
> diff --git a/tests/spec/nv_fill_rectangle/invalid-draw-mode.c b/tests/spec/nv_fill_rectangle/invalid-draw-mode.c
> new file mode 100644
> index 0000000..48fffbc
> --- /dev/null
> +++ b/tests/spec/nv_fill_rectangle/invalid-draw-mode.c
> @@ -0,0 +1,77 @@
> +/*
> + * Copyright (C) 2017 Red Hat Inc.
> + *
> + * 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 invalid-draw-mode.c
> + *
> + * Additions to OpenGL 4.3 Compatibility Profile, section 14.6.4 ref:
> + *    "An INVALID_OPERATION error is generated by Begin or any Draw command if
> + *     only one of the front and back polygon mode is FILL_RECTANGLE_NV."
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +config.supports_gl_compat_version = 13;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +GLint prog;
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +        bool pass = true;
> +
> +        piglit_require_extension("GL_NV_fill_rectangle");
> +
> +        prog = piglit_build_simple_program(
> +            "#version 110\n"
> +            "attribute vec4 vertex;\n"
> +            "void main() { gl_Position = vertex; }\n",
> +            "#version 110\n"
> +            "void main() { }\n");
> +
> +        glUseProgram(prog);
> +        glViewport(0, 0, piglit_width, piglit_height);
> +        glPolygonMode(GL_FRONT, GL_FILL_RECTANGLE_NV);
> +
> +        /* Since we haven't set the mode for GL_BACK, it defaults to
> +         * GL_FILL
> +         */
> +
> +        piglit_draw_triangle(0, 0, 0, 0, 0, 0);
> +
> +        if (piglit_check_gl_error(GL_NO_ERROR))
> +                pass = false;
> +
> +        piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +        /* UNREACHED */
> +        return PIGLIT_FAIL;
> +}
> --
> 2.9.3
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list