[Piglit] [PATCH 05/18] arb_geometry_shader4: Test valid input primitives.
Paul Berry
stereotype441 at gmail.com
Thu Jun 13 12:00:31 PDT 2013
On 7 June 2013 11:12, Fabian Bieler <fabianbieler at fastmail.fm> wrote:
> Test that glProgramParameter() triggers the required errors.
>
> The geometry shader input primitive type is limited to a subset
> of OpenGL primitive types.
>
> >From the ARB_geometry_shader4 spec (section Errors):
> "The error INVALID_VALUE is generated by ProgramParameteriARB if <pname> is
> GEOMETRY_INPUT_TYPE_ARB and <value> is not one of POINTS, LINES,
> LINES_ADJACENCY_ARB, TRIANGLES or TRIANGLES_ADJACENCY_ARB."
> ---
> tests/all.tests | 1 +
> tests/spec/CMakeLists.txt | 1 +
> tests/spec/arb_geometry_shader4/CMakeLists.txt | 1 +
> .../arb_geometry_shader4/execution/CMakeLists.txt | 1 +
> .../execution/program-parameter/CMakeLists.gl.txt | 13 +++
> .../execution/program-parameter/CMakeLists.txt | 1 +
> .../execution/program-parameter/common.h | 117
> +++++++++++++++++++++
> .../execution/program-parameter/input-type.c | 69 ++++++++++++
> 8 files changed, 204 insertions(+)
> create mode 100644 tests/spec/arb_geometry_shader4/CMakeLists.txt
> create mode 100644
> tests/spec/arb_geometry_shader4/execution/CMakeLists.txt
> create mode 100644
> tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.gl.txt
> create mode 100644
> tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.txt
> create mode 100644
> tests/spec/arb_geometry_shader4/execution/program-parameter/common.h
> create mode 100644
> tests/spec/arb_geometry_shader4/execution/program-parameter/input-type.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 73f08f4..897542e 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -2297,6 +2297,7 @@ spec['ARB_map_buffer_alignment'] =
> arb_map_buffer_alignment
> add_plain_test(arb_map_buffer_alignment,
> 'arb_map_buffer_alignment-sanity_test')
>
> arb_geometry_shader4 = Group()
> +add_concurrent_test(arb_geometry_shader4, 'program-parameter-input-type')
> spec['ARB_geometry_shader4'] = arb_geometry_shader4
> add_shader_test_dir(spec['ARB_geometry_shader4'],
> os.path.join(testsDir, 'spec',
> 'arb_geometry_shader4'),
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 690f463..e6cd6d2 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -5,6 +5,7 @@ add_subdirectory (arb_draw_instanced)
> add_subdirectory (arb_es2_compatibility)
> add_subdirectory (arb_framebuffer_object)
> add_subdirectory (arb_framebuffer_srgb)
> +add_subdirectory (arb_geometry_shader4)
> add_subdirectory (arb_instanced_arrays)
> add_subdirectory (arb_internalformat_query)
> add_subdirectory (arb_map_buffer_alignment)
> diff --git a/tests/spec/arb_geometry_shader4/CMakeLists.txt
> b/tests/spec/arb_geometry_shader4/CMakeLists.txt
> new file mode 100644
> index 0000000..bb76f08
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/CMakeLists.txt
> @@ -0,0 +1 @@
> +add_subdirectory (execution)
> diff --git a/tests/spec/arb_geometry_shader4/execution/CMakeLists.txt
> b/tests/spec/arb_geometry_shader4/execution/CMakeLists.txt
> new file mode 100644
> index 0000000..872db20
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/execution/CMakeLists.txt
> @@ -0,0 +1 @@
> +add_subdirectory (program-parameter)
> diff --git
> a/tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.gl.txt
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..786eb31
> --- /dev/null
> +++
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.gl.txt
> @@ -0,0 +1,13 @@
> +include_directories(
> + ${GLEXT_INCLUDE_DIR}
> + ${OPENGL_INCLUDE_PATH}
> + ${piglit_SOURCE_DIR}/tests/util
> +)
> +
> +link_libraries (
> + piglitutil_${piglit_target_api}
> + ${OPENGL_gl_LIBRARY}
> + ${OPENGL_glu_LIBRARY}
> +)
> +
> +piglit_add_executable (program-parameter-input-type input-type.c)
> diff --git
> a/tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.txt
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git
> a/tests/spec/arb_geometry_shader4/execution/program-parameter/common.h
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/common.h
> new file mode 100644
> index 0000000..7504591
> --- /dev/null
> +++ b/tests/spec/arb_geometry_shader4/execution/program-parameter/common.h
> @@ -0,0 +1,117 @@
> +/*
> + * Copyright © 2013 The Piglit project
> + *
> + * 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 common.h
> + *
> + * Common code for glProgramParameter testing.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +
> +struct primitive_geom_info {
> + GLenum type;
> + GLenum error;
> +};
> +
> +
> +static const struct primitive_geom_info primitives_in[] = {
> + {GL_POINTS, GL_NO_ERROR},
> +
> + {GL_LINES, GL_NO_ERROR},
> + {GL_LINE_STRIP, GL_INVALID_VALUE},
> + {GL_LINE_LOOP, GL_INVALID_VALUE},
> +
> + {GL_TRIANGLES, GL_NO_ERROR},
> + {GL_TRIANGLE_STRIP, GL_INVALID_VALUE},
> + {GL_TRIANGLE_FAN, GL_INVALID_VALUE},
> +
> + {GL_LINES_ADJACENCY, GL_NO_ERROR},
> + {GL_LINE_STRIP_ADJACENCY, GL_INVALID_VALUE},
> +
> + {GL_TRIANGLES_ADJACENCY, GL_NO_ERROR},
> + {GL_TRIANGLE_STRIP_ADJACENCY, GL_INVALID_VALUE},
> +
> + {GL_QUADS, GL_INVALID_VALUE},
> + {GL_QUAD_STRIP, GL_INVALID_VALUE},
> + {GL_POLYGON, GL_INVALID_VALUE},
> +};
> +
> +
> +/* Primitive types passed to glBegin (or equivalent) and matching geometry
> + * shader input type; */
>
This comment seems out of place. Is it meant to go above "static const
struct primitive_geom_info primitives_in[] = {"?
Also, our usual style for formatting comments is to put "*/" on a line by
itself for multi-line comments. For example:
/* Here is a
* multiline
* comment
*/
For single-line comments, we put the "*/" on the same line as the comment:
/* Like this */
> +
> +static const char vs_text[] =
> + "void main()\n"
> + "{\n"
> + " gl_Position = vec4(0);\n"
> + "}\n";
> +
> +static const char gs_text4[] =
> + "#extension GL_ARB_geometry_shader4: enable\n"
> + "uniform int vertex_count;\n"
> + "void main()\n"
> + "{\n"
> + " for (int i = 0; i < vertex_count; i++) {\n"
> + " gl_Position = vec4(0.0);\n"
> + " EmitVertex();\n"
> + " }\n"
> + "}\n";
> +
> +static const char fs_text4[] =
> + "void main()\n"
> + "{\n"
> + " gl_FragColor = vec4(1.0);\n"
> + "}\n";
> +
> +
> +static GLuint
> +create_shader(const char *const vs_text, const char *const gs_text,
> + const char *const fs_text)
> +{
> + const char *const varying = "var";
> + GLuint vs, gs, fs, prog;
> +
> + prog = glCreateProgram();
> + vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
> + glAttachShader(prog, vs);
> + glDeleteShader(vs);
> + gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_text);
> + glAttachShader(prog, gs);
> + glDeleteShader(gs);
> + if (fs_text) {
> + fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER,
> fs_text);
> + glAttachShader(prog, fs);
> + glDeleteShader(fs);
> + } else {
> + glTransformFeedbackVaryings(prog, 1, &varying,
> + GL_INTERLEAVED_ATTRIBS);
> + }
> +
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + piglit_report_result(PIGLIT_FAIL);
> +
> + return prog;
> +}
> +
> diff --git
> a/tests/spec/arb_geometry_shader4/execution/program-parameter/input-type.c
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/input-type.c
> new file mode 100644
> index 0000000..fcc4223
> --- /dev/null
> +++
> b/tests/spec/arb_geometry_shader4/execution/program-parameter/input-type.c
> @@ -0,0 +1,69 @@
> +/*
> + * Copyright © 2013 The Piglit project
> + *
> + * 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 input-type.c
> + *
> + * Test required errors for wrong GL_GEOMETRY_INPUT_TYPE parameters.
> + */
> +
> +#include "common.h"
> +
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> + config.supports_gl_compat_version = 20;
> + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE |
> PIGLIT_GL_VISUAL_RGBA;
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + bool pass = true;
> + GLuint prog;
> + int i;
> +
> + /* NV_geometry_shader4 relaxes some restrictions on valid program
> + * parameters.
> + */
> + piglit_require_not_extension("GL_NV_geometry_shader4");
>
Need to also add:
piglit_require_extension("GL_ARB_geometry_shader4");
With those fixes, this patch is:
Reviewed-by: Paul Berry <stereotype441 at gmail.com>
> +
> + /* Create shader. */
> + prog = create_shader(vs_text, gs_text4, fs_text4);
> +
> + for (i = 0; i < ARRAY_SIZE(primitives_in); i++) {
> + const struct primitive_geom_info p = primitives_in[i];
> + printf("Testing %s.\n", piglit_get_prim_name(p.type));
> + glProgramParameteri(prog, GL_GEOMETRY_INPUT_TYPE_ARB,
> p.type);
> + pass = piglit_check_gl_error(p.error) && pass;
> + }
> +
> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + /* Should never be reached */
> + return PIGLIT_FAIL;
> +}
> --
> 1.8.1.2
>
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130613/48247922/attachment.html>
More information about the Piglit
mailing list