[Piglit] [PATCH 2/2] Transform feedback: Test error conditions.
Paul Berry
stereotype441 at gmail.com
Wed Jan 4 14:47:46 PST 2012
On 4 January 2012 13:36, Ian Romanick <idr at freedesktop.org> wrote:
> On 01/02/2012 02:32 PM, Paul Berry wrote:
>
>> This test verifies that the implementation correctly detects all of
>> the errors specified in the "Errors" section of the
>> EXT_transform_feedback spec, with the following exceptions (which seem
>> like they should be handled in separate tests):
>>
>> - Errors related to BeginQuery and EndQuery.
>>
>> - Error due to mismatch of transform feedback mode and drawing mode
>> (e.g. drawing GL_LINES when transform feedback is expecting
>> GL_TRIANGLES).
>>
>> - Errors due to exceeding MAX_TRANSFORM_FEEDBACK_**SEPARATE_ATTIBS in
>> a call to TransformFeedbackVaryings, GetTransformFeedbackVarying,
>> or
>> Get{Integer,Boolean}Indexedv(**GL_TRANSFORM_FEEDBACK_BUFFER_**BINDING).
>>
>
> Aside from one comment in the code below, the series is
>
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>
> For future tests, I think we should structure them differently. Tests
> like this can be hard to follow because you have to look in N places to see
> what each subtest actually does. I'm not sure what the right answer is, or
> I'd suggest using it for this test. :)
Yeah, I know where you're coming from. The difficulty seems to be that the
tests need to all do nearly the same thing, each with a special exception.
How do we avoid duplicating all the stuff that's nearly the same, while at
the same time making it easy to understand each subtest?
I'll try to experiment with other designs; let me know if you have any
ideas.
>
>
> ---
>> tests/all.tests | 18 +
>> .../spec/ext_transform_**feedback/CMakeLists.gl.txt | 1 +
>> tests/spec/ext_transform_**feedback/api-errors.c | 377
>> ++++++++++++++++++++
>> 3 files changed, 396 insertions(+), 0 deletions(-)
>> create mode 100644 tests/spec/ext_transform_**feedback/api-errors.c
>>
>> diff --git a/tests/all.tests b/tests/all.tests
>> index 9002ada..0290f4c 100644
>> --- a/tests/all.tests
>> +++ b/tests/all.tests
>> @@ -1392,6 +1392,24 @@ ext_timer_query['time-elapsed'**] =
>> concurrent_test('ext_timer_**query-time-elapsed'
>>
>> ext_transform_feedback = Group()
>> spec['EXT_transform_feedback'] = ext_transform_feedback
>> +for mode in ['interleaved_ok_base', 'interleaved_ok_range',
>> + 'interleaved_ok_offset', 'interleaved_unbound',
>> + 'interleaved_no_varyings', 'separate_ok_1',
>> + 'separate_unbound_0_1', 'separate_ok_2',
>> 'separate_unbound_0_2',
>> + 'separate_unbound_1_2', 'separate_no_varyings',
>> 'no_prog_active',
>> + 'begin_active', 'useprog_active', 'link_current_active',
>> + 'link_other_active', 'bind_base_active',
>> 'bind_range_active',
>> + 'bind_offset_active', 'end_inactive', 'bind_base_max',
>> + 'bind_range_max', 'bind_offset_max', 'bind_range_size_m4',
>> + 'bind_range_size_0', 'bind_range_size_1',
>> 'bind_range_size_2',
>> + 'bind_range_size_3', 'bind_range_size_5',
>> 'bind_range_offset_1',
>> + 'bind_range_offset_2', 'bind_range_offset_3',
>> + 'bind_range_offset_5', 'bind_offset_offset_1',
>> + 'bind_offset_offset_2', 'bind_offset_offset_3',
>> + 'bind_offset_offset_5', 'not_a_program']:
>> + test_name = 'api-errors {0}'.format(mode)
>> + ext_transform_feedback[test_**name] = PlainExecTest(
>> + 'ext_transform_feedback-{0} -auto'.format(test_name))
>> for varying in ['gl_Color', 'gl_SecondaryColor', 'gl_TexCoord',
>> 'gl_FogFragCoord', 'gl_Position', 'gl_PointSize',
>> 'gl_ClipVertex', 'gl_ClipDistance']:
>> diff --git a/tests/spec/ext_transform_**feedback/CMakeLists.gl.txt
>> b/tests/spec/ext_transform_**feedback/CMakeLists.gl.txt
>> index 8073a70..305f589 100644
>> --- a/tests/spec/ext_transform_**feedback/CMakeLists.gl.txt
>> +++ b/tests/spec/ext_transform_**feedback/CMakeLists.gl.txt
>> @@ -13,6 +13,7 @@ link_libraries (
>> )
>>
>> add_executable (ext_transform_feedback-**alignment alignment.c)
>> +add_executable (ext_transform_feedback-api-**errors api-errors.c)
>> add_executable (ext_transform_feedback-**builtin-varyings
>> builtin-varyings.c)
>> add_executable (ext_transform_feedback-**discard-api discard-api.c)
>> add_executable (ext_transform_feedback-**discard-bitmap
>> discard-bitmap.c)
>> diff --git a/tests/spec/ext_transform_**feedback/api-errors.c
>> b/tests/spec/ext_transform_**feedback/api-errors.c
>> new file mode 100644
>> index 0000000..486f5f4
>> --- /dev/null
>> +++ b/tests/spec/ext_transform_**feedback/api-errors.c
>> @@ -0,0 +1,377 @@
>> +/*
>> + * Copyright © 2011 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
>> + *
>> + * Test that the implementation flags various
>> + * transform-feedback-related error conditions.
>> + *
>> + * This test covers all of the error conditions as specified in the
>> + * "Errors" section of the EXT_transform_feedback spec, with the
>> + * following exceptions:
>> + *
>> + * - Errors related to BeginQuery and EndQuery.
>> + *
>> + * - Error due to mismatch of transform feedback mode and drawing mode
>> + * (e.g. drawing GL_LINES when transform feedback is expecting
>> + * GL_TRIANGLES).
>> + *
>> + * - Errors due to exceeding MAX_TRANSFORM_FEEDBACK_**SEPARATE_ATTIBS in
>> + * a call to TransformFeedbackVaryings, GetTransformFeedbackVarying,
>> + * or
>> + * Get{Integer,Boolean}Indexedv(**GL_TRANSFORM_FEEDBACK_BUFFER_**
>> BINDING).
>> + *
>> + * In addition, there are a few tests which verify that errors do not
>> + * occur during normal operation ("interleaved_ok_*", "separate_ok_*",
>> + * and "link_other_active"). These tests help to verify that the
>> + * implementation is not overly aggressive in flagging errors.
>> + */
>> +
>> +#include "piglit-util.h"
>> +
>> +int piglit_width = 16;
>> +int piglit_height = 16;
>> +int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
>> +
>> +#define XFB_BUFFER_SIZE 12
>> +#define NUM_BUFFERS 2
>> +
>> +enum test_mode {
>> + NORMAL,
>> + NO_VARYINGS,
>> + UNBOUND_BUFFER,
>> + SKIP_USE_PROGRAM,
>> + BEGIN_ACTIVE,
>> + USEPROG_ACTIVE,
>> + LINK_CURRENT_ACTIVE,
>> + LINK_OTHER_ACTIVE,
>> + BIND_ACTIVE,
>> + END_INACTIVE,
>> + BIND_MAX,
>> + BIND_BAD_SIZE,
>> + BIND_BAD_OFFSET,
>> + NOT_A_PROGRAM,
>> +};
>> +
>> +enum bind_mode {
>> + BASE,
>> + RANGE,
>> + OFFSET,
>> +};
>> +
>> +static const char *vstext =
>> + "varying vec4 foo;\n"
>> + "varying vec4 bar;\n"
>> + "\n"
>> + "void main()\n"
>> + "{\n"
>> + " foo = vec4(1.0);\n"
>> + " bar = vec4(1.0);\n"
>> + " gl_Position = vec4(1.0);\n"
>> + "}\n";
>> +
>> +static const char *varyings[] = { "foo", "bar" };
>> +
>> +static struct test_desc
>> +{
>> + const char *name;
>> + enum test_mode mode;
>> + int param;
>> + enum bind_mode bind_mode;
>> + GLenum buffer_mode;
>> + int num_buffers;
>> + GLboolean skip_use_program;
>> +} tests[] = {
>> + /* name mode param
>> num_buffers
>> + * bind_mode
>> + *
>> buffer_mode
>> + */
>> + { "interleaved_ok_base", NORMAL, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "interleaved_ok_range", NORMAL, 0, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "interleaved_ok_offset", NORMAL, 0, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "interleaved_unbound", UNBOUND_BUFFER, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "interleaved_no_varyings", NO_VARYINGS, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "separate_ok_1", NORMAL, 0, BASE,
>> GL_SEPARATE_ATTRIBS, 1 },
>> + { "separate_unbound_0_1", UNBOUND_BUFFER, 0, BASE,
>> GL_SEPARATE_ATTRIBS, 1 },
>> + { "separate_ok_2", NORMAL, 0, BASE,
>> GL_SEPARATE_ATTRIBS, 2 },
>> + { "separate_unbound_0_2", UNBOUND_BUFFER, 0, BASE,
>> GL_SEPARATE_ATTRIBS, 2 },
>> + { "separate_unbound_1_2", UNBOUND_BUFFER, 1, BASE,
>> GL_SEPARATE_ATTRIBS, 2 },
>> + { "separate_no_varyings", NO_VARYINGS, 0, BASE,
>> GL_SEPARATE_ATTRIBS, 1 },
>> + { "no_prog_active", SKIP_USE_PROGRAM, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "begin_active", BEGIN_ACTIVE, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "useprog_active", USEPROG_ACTIVE, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "link_current_active", LINK_CURRENT_ACTIVE, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "link_other_active", LINK_OTHER_ACTIVE, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_base_active", BIND_ACTIVE, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_active", BIND_ACTIVE, 0, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_offset_active", BIND_ACTIVE, 0, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "end_inactive", END_INACTIVE, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_base_max", BIND_MAX, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_max", BIND_MAX, 0, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_offset_max", BIND_MAX, 0, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_size_m4", BIND_BAD_SIZE, -4, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_size_0", BIND_BAD_SIZE, 0, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_size_1", BIND_BAD_SIZE, 1, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_size_2", BIND_BAD_SIZE, 2, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_size_3", BIND_BAD_SIZE, 3, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_size_5", BIND_BAD_SIZE, 5, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_offset_1", BIND_BAD_OFFSET, 1, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_offset_2", BIND_BAD_OFFSET, 2, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_offset_3", BIND_BAD_OFFSET, 3, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_range_offset_5", BIND_BAD_OFFSET, 5, RANGE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_offset_offset_1", BIND_BAD_OFFSET, 1, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_offset_offset_2", BIND_BAD_OFFSET, 2, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_offset_offset_3", BIND_BAD_OFFSET, 3, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "bind_offset_offset_5", BIND_BAD_OFFSET, 5, OFFSET,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> + { "not_a_program", NOT_A_PROGRAM, 0, BASE,
>> GL_INTERLEAVED_ATTRIBS, 1 },
>> +};
>> +
>> +static void
>> +do_bind(const struct test_desc *test, GLuint buf, int i)
>> +{
>> + int size = test->mode == BIND_BAD_SIZE
>> + ? test->param : sizeof(float[XFB_BUFFER_SIZE])**;
>> + int offset = test->mode == BIND_BAD_OFFSET
>> + ? test->param : 0;
>> +
>> + switch (test->bind_mode) {
>> + case BASE:
>> + printf("BindBufferBase(buffer %i)\n", i);
>> + piglit_BindBufferBase(GL_**TRANSFORM_FEEDBACK_BUFFER, i,
>> buf);
>> + break;
>> + case RANGE:
>> + printf("BindBufferRange(buffer %i, offset=%i,
>> size=%i)\n", i,
>> + offset, size);
>> + piglit_BindBufferRange(GL_**TRANSFORM_FEEDBACK_BUFFER,
>> i, buf,
>> + offset, size);
>> + break;
>> + case OFFSET:
>> + printf("BindBufferOffsetEXT(**buffer %i, offset=%i)\n",
>> i,
>> + offset);
>> + glBindBufferOffsetEXT(GL_**TRANSFORM_FEEDBACK_BUFFER, i,
>> buf,
>> + offset);
>> + break;
>> + }
>> +}
>> +
>> +static GLboolean
>> +do_test(const struct test_desc *test)
>> +{
>> + GLuint vs;
>> + GLuint progs[2];
>> + GLuint bufs[NUM_BUFFERS];
>> + float initial_xfb_buffer_contents[**XFB_BUFFER_SIZE];
>> + GLboolean pass = GL_TRUE;
>> + int i;
>> + int num_varyings = test->mode == NO_VARYINGS ? 0 :
>> test->num_buffers;
>> + GLint max_separate_attribs;
>> +
>> + glGetIntegerv(GL_MAX_**TRANSFORM_FEEDBACK_SEPARATE_**ATTRIBS,
>> + &max_separate_attribs);
>> + printf("MAX_TRANSFORM_**FEEDBACK_SEPARATE_ATTIBS=%i\n"**,
>> + max_separate_attribs);
>> +
>> + printf("Compile vertex shader\n");
>> + vs = piglit_compile_shader_text(GL_**VERTEX_SHADER, vstext);
>> + if (test->mode == NOT_A_PROGRAM) {
>> + printf("Create a buffer to use instead of a program\n");
>> + glGenBuffers(1, progs);
>> + } else {
>> + progs[0] = piglit_CreateProgram();
>> + piglit_AttachShader(progs[0], vs);
>> + }
>>
>
> This may work, but it's a bit sketchy. Each kind of object from a Gen
> function or Create function is in a separate namespace. It is conceivable
> that the name from GenBuffers and the handle from CreateProgram could have
> the same value. It should work in this case because no program has ever
> been created.
>
> A better approach is to create a program and immediately delete it. Since
> the program was never used, the delete will take effect immediately. As
> long as there are no intervening CreateProgram calls, you can be sure the
> deleted program will be invalid.
>
Ah, I didn't realize that. I'll make the fix and retest on both Mesa and
nVidia before pushing the patch.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20120104/3d24bfe9/attachment.htm>
More information about the Piglit
mailing list