[Piglit] [PATCH 03/11] arb_transform_feedback2: Misc. API error checks

Paul Berry stereotype441 at gmail.com
Fri Oct 4 11:16:30 PDT 2013


On 21 August 2013 09:07, Ian Romanick <idr at freedesktop.org> wrote:

> From: Ian Romanick <ian.d.romanick at intel.com>
>
> This covers most of the errors mentioned in the spec that aren't
> already covered in cannot-bind-when-active.c and gen-names-only.c.
> Most of the other errors should be covered by existing
> EXT_transform_feedback tests.
>
> Mesa currently fails three of the subtests (TransformFeedbackVaryings
> only when inactive; Link program only when inactive; and Resume with
> the same program only).
>
> NVIDIA (304.64 on GTX 260) fails several subtests.
>
>     Pause active feedback only: Incorrectly generates error in
>     glEndTransformFeedback.  Later subtests have a work-around for
>     this bug.  Without the work-around, every test would fail.
>
>     TransformFeedbackVaryings only when inactive: Doesn't generate any
>     errors when it should.
>
>     Draw only from "ended" object: Generates GL_INVALID_VALUE instead
>     of GL_INVALID_OPERATION.
>
> AMD has not been tested.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> Cc: James Jones <jajones at nvidia.com>
>

I would prefer to see this transformed into a piglit test that takes a
command line argument specifying which sub-test to run (as we do in a lot
of other piglit tests--see .  That way (a) we won't have to go to extra
effort to workaround the NVIDIA bug with glEndTransformFeedback, (b) if one
subtest fails, we won't lose the ability to notice regressions in the other
subtests, and (c) we won't have to worry about subtest ordering (see the
comment above the call to delete_inactive_only()).

Other comments below.


> ---
>  tests/all.tests                                    |   1 +
>  .../spec/arb_transform_feedback2/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_transform_feedback2/api-errors.c    | 634
> +++++++++++++++++++++
>  3 files changed, 636 insertions(+)
>  create mode 100644 tests/spec/arb_transform_feedback2/api-errors.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index a12fdb4..d548e58 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -2181,6 +2181,7 @@ arb_transform_feedback2['draw-auto'] =
> PlainExecTest(['arb_transform_feedback2-d
>  arb_transform_feedback2['istranformfeedback'] =
> PlainExecTest(['arb_transform_feedback2-istransformfeedback', '-auto'])
>  arb_transform_feedback2['glGenTransformFeedbacks names only'] =
> concurrent_test('arb_transform_feedback2-gen-names-only')
>  arb_transform_feedback2['cannot bind when another object is active'] =
> concurrent_test('arb_transform_feedback2-cannot-bind-when-active')
> +arb_transform_feedback2['misc. API error checks'] =
> concurrent_test('arb_transform_feedback2-api-errors')
>
>  arb_transform_feedback_instanced = Group()
>  spec['ARB_transform_feedback_instanced'] =
> arb_transform_feedback_instanced
> diff --git a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
> b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
> index db708e0..f9d53ad 100644
> --- a/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
> +++ b/tests/spec/arb_transform_feedback2/CMakeLists.gl.txt
> @@ -9,6 +9,7 @@ link_libraries (
>         ${OPENGL_glu_LIBRARY}
>  )
>
> +piglit_add_executable (arb_transform_feedback2-api-errors api-errors.c)
>  piglit_add_executable (arb_transform_feedback2-cannot-bind-when-active
> cannot-bind-when-active.c)
>  piglit_add_executable (arb_transform_feedback2-draw-auto draw-auto.c)
>  piglit_add_executable (arb_transform_feedback2-gen-names-only
> gen-names-only.c)
> diff --git a/tests/spec/arb_transform_feedback2/api-errors.c
> b/tests/spec/arb_transform_feedback2/api-errors.c
> new file mode 100644
> index 0000000..f1b2f41
> --- /dev/null
> +++ b/tests/spec/arb_transform_feedback2/api-errors.c
> @@ -0,0 +1,634 @@
> +/*
> + * Copyright © 2012 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.
> + */
> +
> +/**
> + * \file api-errors.c
> + * Verify a handful of error conditions required by the spec.
> + *
> + * None of these subtests is large enough to warrant a separate test case.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_compat_version = 10;
> +       config.window_visual = PIGLIT_GL_VISUAL_RGB;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       return PIGLIT_FAIL;
> +}
> +
> +static const char vstext[] =
> +       "varying vec4 x;\n"
> +       "varying vec4 y;\n"
> +       "void main()\n"
> +       "{\n"
> +       "    gl_Position = vec4(0);\n"
> +       "    x = vec4(0);\n"
> +       "    y = vec4(0);\n"
> +       "}"
> +       ;
> +
> +static const char fstext[] =
> +       "void main() { gl_FragColor = vec4(0); }";
> +
> +static const char *varyings[] = {"x"};
> +static GLuint id;
> +static GLuint prog;
> +static GLuint fs_only_prog;
> +static GLuint buf;
> +
> +static bool delete_inactive_only(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Cannot delete while active...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated by
> +        *     DeleteTransformFeedbacks if the transform feedback operation
> +        *     for any object named by <ids> is currently active."
> +        *
> +        * However, shortly before that it also says,
> +        *
> +        *     "If an active transform feedback object is deleted its name
> +        *     immediately becomes unused, but the underlying object is not
> +        *     deleted until it is no longer active."
> +        *
> +        * So, that seems a bit contradictory.
>

When referencing contradictory specs, we should include a comment saying
how we've chosen to resolve the contradiction.  Please add a comment saying
something like: "in this test we assume that an attempt to delete an active
transform feedback object will fail with INVALID_OPERATION."


> +        */
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glDeleteTransformFeedbacks(1, &id);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool paired_begin_end(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Paired begin / end check...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "Transform feedback commands must be paired; the error
> +        *     INVALID_OPERATION is generated by BeginTransformFeedback if
> +        *     transform feedback is active, and by EndTransformFeedback if
> +        *     transform feedback is inactive. Transform feedback is
> initially
> +        *     inactive."
> +        *
> +        * The first case is already tested by the cannot-bind-when-active
> +        * test.
> +        */
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
>

This subtest only verifies that it is invalid to call EndTransformFeedback
on an inactive transform feedback object.  We should also test (either in
this subtest or another one) that it's invalid to call
BeginTransformFeedback on an active transform feedback object.


> +}
> +
> +static bool pause_active_only(void)
> +{
> +       bool pass = true;
> +       bool end_success;
> +
> +       if (!piglit_automatic)
> +               printf("Pause active feedback only...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated by
> +        *     PauseTransformFeedback if the currently bound transform
> +        *     feedback is not active or is paused."
> +        */
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       /* There is no need for an explicit resume here.  Page 162
> +        * (page 179 of the PDF) of the OpenGL 4.2 spec says:
> +        *
> +        *     "EndTransformFeedback first performs an implicit
> +        *     ResumeTransformFeedback (see blow) if transform feedback is
> +        *     active and not paused."
> +        *
> +        * This appears to be a typo.  If feedback is active and *not*
> paused
> +        * ResumeTransformFeedback is supposed to generate an
> +        * INVALID_OPERATION.  I'll assume that the 'not' should be
> removed in
> +        * the spec.
> +        */
> +       glEndTransformFeedback();
> +       end_success = piglit_check_gl_error(0);
> +       if (!end_success) {
> +               glResumeTransformFeedback();
> +               glEndTransformFeedback();
> +               piglit_reset_gl_error();
> +       }
> +
> +       pass = end_success && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool resume_paused_only(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Resume paused feedback only...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated by
> +        *     ResumeTransformFeedback if the currently bound transform
> +        *     feedback is not active or is not paused."
> +        */
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool vertex_shader_required(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Vertex shader required...\n");
> +
> +       if (piglit_is_extension_supported("GL_NV_transform_feedback2")) {
> +               if (!piglit_automatic)
> +                       printf("skip (GL_NV_transform_feedback2)\n");
> +
> +               return true;
> +       }
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated by
> +        *     BeginTransformFeedback if no vertex or geometry shader is
> +        *     active."
> +        */
> +       glUseProgram(fs_only_prog);
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glUseProgram(prog);
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool change_varyings_inactive_only(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("TransformFeedbackVaryings only when
> inactive...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated:
> +        *
> +        *         * by TransformFeedbackVaryings if the current transform
> +        *           feedback object is active, even if paused;"
> +        */
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glTransformFeedbackVaryings(prog, 1, varyings,
> +                                   GL_INTERLEAVED_ATTRIBS);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glTransformFeedbackVaryings(prog, 1, varyings,
> +                                   GL_INTERLEAVED_ATTRIBS);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool change_program_inactive_or_paused(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Change program only when inactive or paused...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated:
> +        *
> +        *         * by UseProgram if the current transform feedback
> object is
> +        *           active and not paused;"
> +        */
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glUseProgram(fs_only_prog);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glUseProgram(fs_only_prog);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       /* Restore the program or glResumeTransformFeedback will generate
> an
> +        * error.
> +        */
> +       glUseProgram(prog);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       /* Work-around drivers with glEndTransformFeedback bugs.  See
> +        * pause_active_only above.
> +        */
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glUseProgram(prog);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool link_program_inactive_only(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Link program only when inactive...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated:
> +        *
> +        *         * by LinkProgram if <program> is the name of a program
> +        *           being used by one or more transform feedback objects,
> +        *           even if the objects are not currently bound or are
> +        *           paused;"
> +        */
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glLinkProgram(prog);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glLinkProgram(prog);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glLinkProgram(prog);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glUseProgram(0);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glLinkProgram(prog);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glUseProgram(prog);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       /* Work-around drivers with glEndTransformFeedback bugs.  See
> +        * pause_active_only above.
> +        */
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool resume_same_program_only(void)
> +{
> +       bool pass = true;
> +
> +       if (!piglit_automatic)
> +               printf("Resume with the same program only...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated:
> +        *
> +        *         * by ResumeTransformFeedback if the program object being
> +        *           used by the current transform feedback object is not
> +        *           active."
> +        */
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glUseProgram(0);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
>

Since program number 0 is special, we should also make sure
ResumeTransformFeedback produces the proper error if a different
user-defined program is active.  Can we add:

glUseProgram(fs_only_prog);
pass = piglit_check_gl_error(0) && pass;
glResumeTransformFeedback();
pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;


> +
> +       glUseProgram(prog);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       /* Work-around drivers with glEndTransformFeedback bugs.  See
> +        * pause_active_only above.
> +        */
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool draw_from_valid_object_only(void)
> +{
> +       bool pass = true;
> +       GLuint bad_id;
> +
> +       if (!piglit_automatic)
> +               printf("Draw only from valid object...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_VALUE is generated if <id> is not the
> name
> +        *     of a transform feedback object."
>

Some context would be helpful here.  Please mention that this text is under
the description of DrawTransformFeedback().


> +        */
> +       glGenTransformFeedbacks(1, &bad_id);
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, bad_id);
> +       glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
> +
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glDeleteTransformFeedbacks(1, &bad_id);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glDrawTransformFeedback(GL_TRIANGLES, bad_id);
> +       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +static bool draw_from_ended_object_only(void)
> +{
> +       bool pass = true;
> +       GLuint bad_id;
> +
> +       if (!piglit_automatic)
> +               printf("Draw only from \"ended\" object...\n");
> +
> +       /* The ARB_transform_feedback2 spec says:
> +        *
> +        *     "The error INVALID_OPERATION is generated if
> +        *     EndTransformFeedback has never been called while the object
> +        *     named by <id> was bound."
> +        */
> +       glGenTransformFeedbacks(1, &bad_id);
> +
> +       glDrawTransformFeedback(GL_TRIANGLES, bad_id);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, bad_id);
> +       glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
> +
> +       glBeginTransformFeedback(GL_TRIANGLES);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glPauseTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glDrawTransformFeedback(GL_TRIANGLES, bad_id);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, bad_id);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       /* Work-around drivers with glEndTransformFeedback bugs.  See
> +        * pause_active_only above.
> +        */
> +       glResumeTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glEndTransformFeedback();
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glDeleteTransformFeedbacks(1, &bad_id);
> +       pass = piglit_check_gl_error(0) && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
> +
> +       if (!piglit_automatic)
> +               printf("%s\n", pass ? "pass" : "fail");
> +
> +       return pass;
> +}
> +
> +void piglit_init(int argc, char **argv)
> +{
> +       GLuint vs;
> +       GLuint fs;
> +       bool pass = true;
> +
> +       piglit_require_transform_feedback();
> +       piglit_require_GLSL();
> +       piglit_require_extension("GL_ARB_transform_feedback2");
> +
> +       /* This is all just the boot-strap work for the test.
> +        */
> +       glGenBuffers(1, &buf);
> +       glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buf);
> +       glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, NULL,
> GL_STREAM_READ);
> +
> +       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
> +       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext);
> +       prog = glCreateProgram();
> +       glAttachShader(prog, vs);
> +       glAttachShader(prog, fs);
> +
> +       glTransformFeedbackVaryings(prog, 1, varyings,
> +                                   GL_INTERLEAVED_ATTRIBS);
> +       glLinkProgram(prog);
> +       if (!piglit_link_check_status(prog)) {
> +               pass = false;
> +               goto done;
> +       }
> +
> +       fs_only_prog = piglit_link_simple_program(vs, fs);
> +       if (fs_only_prog == 0) {
> +               pass = false;
> +               goto done;
> +       }
> +
> +       glUseProgram(prog);
> +
> +       glGenTransformFeedbacks(1, &id);
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
> +       glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buf);
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
> +
> +       pass = paired_begin_end() && pass;
> +       pass = pause_active_only() && pass;
> +       pass = resume_paused_only() && pass;
> +       pass = vertex_shader_required() && pass;
> +       pass = change_varyings_inactive_only() && pass;
> +       pass = change_program_inactive_or_paused() && pass;
> +       pass = link_program_inactive_only() && pass;
> +       pass = resume_same_program_only() && pass;
> +       pass = draw_from_valid_object_only() && pass;
> +       pass = draw_from_ended_object_only() && pass;
> +
> +       /* Do this one last.  If it fails, it will delete the object and
> cause
> +        * all of the othere subtests to fail.
> +        */
> +       pass = delete_inactive_only() && pass;
> +
> +       glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
> +
> +done:
> +       glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
> +       glDeleteBuffers(1, &buf);
> +
> +       glDeleteTransformFeedbacks(1, &id);
> +
> +       glUseProgram(0);
> +       glDeleteShader(vs);
> +       glDeleteShader(fs);
> +       glDeleteProgram(prog);
> +       glDeleteProgram(fs_only_prog);
> +
> +       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> --
> 1.8.1.4
>
> _______________________________________________
> 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/20131004/3dedf546/attachment-0001.html>


More information about the Piglit mailing list