[Piglit] [WIP 2/4] tests/spec: ARB_transform_feedback3 interleaved in two buffers
Ian Romanick
idr at freedesktop.org
Fri Sep 27 16:18:45 PDT 2013
There are some other comments below, but there is a bunch of mixing of
tabs and spaces in the file. Piglit generally uses only tabs.
On 09/16/2013 07:54 AM, Topi Pohjolainen wrote:
> Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
> tests/all.tests | 3 +
> tests/spec/CMakeLists.txt | 1 +
> .../spec/arb_transform_feedback3/CMakeLists.gl.txt | 13 ++
> tests/spec/arb_transform_feedback3/CMakeLists.txt | 1 +
> .../ext_interleaved_two_bufs.c | 223 +++++++++++++++++++++
> 5 files changed, 241 insertions(+)
> create mode 100644 tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
> create mode 100644 tests/spec/arb_transform_feedback3/CMakeLists.txt
> create mode 100644 tests/spec/arb_transform_feedback3/ext_interleaved_two_bufs.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index dc36841..bdebd17 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -2256,6 +2256,9 @@ for param in ['gl_NextBuffer-1', 'gl_NextBuffer-2', 'gl_SkipComponents1-1',
> arb_transform_feedback3[param] = concurrent_test(
> 'ext_transform_feedback-output-type {0}'.format(param))
>
> +arb_transform_feedback3['arb_transform_feedback3-ext_interleaved_two_bufs_vs'] = PlainExecTest(['arb_transform_feedback3-ext_interleaved_two_bufs', '-auto', 'vs'])
> +arb_transform_feedback3['arb_transform_feedback3-ext_interleaved_two_bufs_gs'] = PlainExecTest(['arb_transform_feedback3-ext_interleaved_two_bufs', '-auto', 'gs'])
> +
> arb_uniform_buffer_object = Group()
> spec['ARB_uniform_buffer_object'] = arb_uniform_buffer_object
> import_glsl_parser_tests(spec['ARB_uniform_buffer_object'],
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 3bd8e9c..fd21b84 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -38,6 +38,7 @@ add_subdirectory (arb_texture_storage_multisample)
> add_subdirectory (arb_texture_view)
> add_subdirectory (arb_timer_query)
> add_subdirectory (arb_transform_feedback2)
> +add_subdirectory (arb_transform_feedback3)
> add_subdirectory (ati_envmap_bumpmap)
> add_subdirectory (ext_fog_coord)
> add_subdirectory (ext_framebuffer_multisample)
> diff --git a/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt b/tests/spec/arb_transform_feedback3/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..614ccd6
> --- /dev/null
> +++ b/tests/spec/arb_transform_feedback3/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 (arb_transform_feedback3-ext_interleaved_two_bufs ext_interleaved_two_bufs.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/arb_transform_feedback3/CMakeLists.txt b/tests/spec/arb_transform_feedback3/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_transform_feedback3/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_transform_feedback3/ext_interleaved_two_bufs.c b/tests/spec/arb_transform_feedback3/ext_interleaved_two_bufs.c
> new file mode 100644
> index 0000000..7b43dca
> --- /dev/null
> +++ b/tests/spec/arb_transform_feedback3/ext_interleaved_two_bufs.c
> @@ -0,0 +1,223 @@
> +/*
> + * Copyright © 2013 Intel Corporation
> + *
> + * 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.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +/**
> + * @file ext_interleaved_two_bufs.c
> + *
> + * Record two interleaved sets of attributes, one holding two attributes and the
> + * other holding three, into two separate buffers. The test can be executed in
> + * two different ways: both sets originating from vertex shader or both sets
> + * originating from geometry shader.
> + *
> + * Recording both vertex shader and geometry shader outputs in parallel is not
> + * supported by the extension. The spec says:
> + *
> + * "When a geometry shader is active (see section 2.12), transform feedback
> + * records the values of the selected geometry shader output variables from the
> + * emitted vertices. Otherwise, the values of the selected vertex shader output
> + * variables are recorded."
> + *
> + * This test uses the "EXT"-style GLSL transform feedback.
> + */
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 10;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static const char vs_text_two_sets[] =
> + "#version 150\n"
> + "out float x1_out;\n"
> + "out vec2 x2_out;\n"
> + "out vec3 x3_out;\n"
> + "out float y1_out;\n"
> + "out vec4 y2_out;\n"
> + "void main() {\n"
> + " gl_Position = vec4(0.0);\n"
> + " x1_out = 0.1;\n"
> + " x2_out = vec2(0.2, 0.3);\n"
> + " x3_out = vec3(0.4, 0.5, 0.6);\n"
> + " y1_out = 0.7;\n"
> + " y2_out = vec4(0.75, 0.80, 0.85, 0.90);\n"
> + "}";
> +
> +static const char vs_text_no_set[] =
> + "#version 150\n"
> + "void main() {\n"
> + " gl_Position = vec4(0.0);\n"
> + "}";
> +
> +static const char gs_text_two_sets[] =
> + "#version 150\n"
> + "layout(points) in;\n"
> + "layout(points, max_vertices = 1) out;\n"
> + "out float x1_out;\n"
> + "out vec2 x2_out;\n"
> + "out vec3 x3_out;\n"
> + "out float y1_out;\n"
> + "out vec4 y2_out;\n"
> + "void main() {\n"
> + " gl_Position = gl_in[0].gl_Position;\n"
> + " x1_out = 0.1;\n"
> + " x2_out = vec2(0.2, 0.3);\n"
> + " x3_out = vec3(0.4, 0.5, 0.6);\n"
> + " y1_out = 0.7;\n"
> + " y2_out = vec4(0.75, 0.80, 0.85, 0.90);\n"
> + " EmitVertex();\n"
> + "}";
> +
> +/**
> + * The spec for ARB_transform_feedback3 says:
> + *
> + * If a string in <varyings> is "gl_NextBuffer", it does not identify a
> + * varying variable, but instead serves as a buffer separator value to
> + * direct subsequent varyings at the next transform feedback binding point.
> + */
> +static const char *varyings[] = { "x1_out", "x2_out", "x3_out", "gl_NextBuffer",
> + "y1_out", "y2_out" };
> +
> +/* Expected transform feedback results in the first buffer: */
> +static const float expected_xfb_result_1[] = {
> + 0.1, /* x1 */
> + 0.2, 0.3, /* x2 */
> + 0.4, 0.5, 0.6 /* x3 */
> +};
> +
> +/* Expected transform feedback results in the second buffer: */
> +static const float expected_xfb_result_2[] = {
> + 0.7, /* y1 */
> + 0.75, 0.80, 0.85, 0.90 /* y2 */
> +};
> +
> +static void
> +print_usage_and_exit(const char *prog_name)
> +{
> + printf("Usage: %s <subtest>\n"
> + " where <subtest> is one of the following:\n"
> + " gs\n"
> + " vs\n", prog_name);
> + piglit_report_result(PIGLIT_FAIL);
> +}
> +
> +static void
> +build_and_use_program(const char *vs_text, const char *gs_text)
> +{
> + GLuint vs, gs, prog;
> +
> + prog = glCreateProgram();
> + vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_text);
> + glAttachShader(prog, vs);
> +
> + if (gs_text) {
> + gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_text);
> + glAttachShader(prog, gs);
> + }
> +
> + /**
> + * In the EXT-style the recorded varyings need to be set before
> + * linking.
> + * Also it should be noticed that when mixed mode is used, i.e., where
> + * one records multiple attributes per buffer but also uses separate
> + * buffers, the mode must be set to interleaved.
> + */
> + glTransformFeedbackVaryings(prog, ARRAY_SIZE(varyings), varyings,
> + GL_INTERLEAVED_ATTRIBS_EXT);
Drop _EXT from all the enums that have core names.
> +
> + glLinkProgram(prog);
> + if (!piglit_link_check_status(prog))
> + piglit_report_result(PIGLIT_FAIL);
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + piglit_report_result(PIGLIT_FAIL);
> +
> + glUseProgram(prog);
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + int pass;
> + GLuint xfb[2];
> + const char *vs_text;
> + const char *gs_text;
> +
> + if (argc != 2)
> + print_usage_and_exit(argv[0]);
> + if (strcmp(argv[1], "vs") == 0) {
> + vs_text = vs_text_two_sets;
> + gs_text = 0;
> + } else if (strcmp(argv[1], "gs") == 0) {
> + vs_text = vs_text_no_set;
> + gs_text = gs_text_two_sets;
> + } else
> + print_usage_and_exit(argv[0]);
> +
> + piglit_require_GLSL_version(130);
> + piglit_require_extension("GL_ARB_geometry_shader4");
Mesa isn't going to implement GL_ARB_geometry_shader4, so this test
should use OpenGL 3.2 instead. This means you can remove both the above
piglit_require_ checks and do
config.supports_gl_compat_version = 32;
config.supports_gl_core_version = 32;
above.
> + piglit_require_extension("GL_ARB_transform_feedback3");
> +
> + build_and_use_program(vs_text, gs_text);
> +
> + /* Set up the transform feedback buffers. */
> + glGenBuffers(2, xfb);
> + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, xfb[0]);
> + glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
> + sizeof(expected_xfb_result_1), NULL, GL_STREAM_READ);
> + glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 1, xfb[1]);
> + glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
> + sizeof(expected_xfb_result_2), NULL, GL_STREAM_READ);
> +
> + /* Use GL_RASTERIZER_DISCARD, since we are going to use
> + * transform feedback for this test.
> + */
> + glEnable(GL_RASTERIZER_DISCARD);
> +
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + piglit_report_result(PIGLIT_FAIL);
> +
> + /* Draw and record */
> + glBeginTransformFeedback(GL_POINTS);
> + glDrawArrays(GL_POINTS, 0, 1);
> + glEndTransformFeedback();
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + piglit_report_result(PIGLIT_FAIL);
> +
> + /* Check the recordings against expectations */
> + pass = piglit_probe_buffer(xfb[0], GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
> + "first", 1, ARRAY_SIZE(expected_xfb_result_1),
> + expected_xfb_result_1);
> + pass = piglit_probe_buffer(xfb[1], GL_TRANSFORM_FEEDBACK_BUFFER_EXT,
> + "second", 1, ARRAY_SIZE(expected_xfb_result_2),
> + expected_xfb_result_2) && pass;
> +
> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + /* Should never be reached */
> + return PIGLIT_FAIL;
> +}
>
More information about the Piglit
mailing list