[Piglit] [PATCH] ext_transform_feedback: Test Tranform Feedback with Primitive Restart

Jordan Justen jljusten at gmail.com
Sat Jun 30 18:24:08 PDT 2012


On Fri, Jun 29, 2012 at 4:59 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 06/29/2012 10:13 AM, Jordan Justen wrote:
>>
>> Signed-off-by: Jordan Justen<jordan.l.justen at intel.com>
>
>
> It seems like this test should massively fail on Mesa because
> EXT_transform_feedback only works with shaders.  In order to get transform
> feedback from fixed-function, you need NV_transform_feedback.  That is the
> primary difference between the two extensions.

It worked with i965, but it still sounds like I should add a shader.
I'll update it.

>> ---
>>   tests/all.tests                                    |    1 +
>>   .../spec/ext_transform_feedback/CMakeLists.gl.txt  |    1 +
>>   .../ext_transform_feedback/primitive-restart.c     |  111
>> ++++++++++++++++++++
>>   3 files changed, 113 insertions(+)
>>   create mode 100644 tests/spec/ext_transform_feedback/primitive-restart.c
>>
>> diff --git a/tests/all.tests b/tests/all.tests
>> index 63937b9..6e9b92e 100644
>> --- a/tests/all.tests
>> +++ b/tests/all.tests
>> @@ -1762,6 +1762,7 @@ for mode in ['discard', 'buffer', 'prims_generated',
>> 'prims_written']:
>>           test_name = 'generatemipmap {0}'.format(mode)
>>           ext_transform_feedback[test_name] = concurrent_test(
>>                   'ext_transform_feedback-{0}'.format(test_name))
>> +ext_transform_feedback['primitive-restart'] =
>> concurrent_test('ext_transform_feedback-primitive-restart')
>>
>>   arb_transform_feedback2 = Group()
>>   spec['ARB_transform_feedback2'] = arb_transform_feedback2
>> diff --git a/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
>> b/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
>> index b8c2693..a24fa5a 100644
>> --- a/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
>> +++ b/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
>> @@ -32,5 +32,6 @@ piglit_add_executable
>> (ext_transform_feedback-output-type output-type.c)
>>   piglit_add_executable (ext_transform_feedback-order order.c)
>>   piglit_add_executable (ext_transform_feedback-overflow-edge-cases
>> overflow-edge-cases.c)
>>   piglit_add_executable (ext_transform_feedback-tessellation
>> tessellation.c)
>> +piglit_add_executable (ext_transform_feedback-primitive-restart
>> primitive-restart.c)
>>
>>   # vim: ft=cmake:
>> diff --git a/tests/spec/ext_transform_feedback/primitive-restart.c
>> b/tests/spec/ext_transform_feedback/primitive-restart.c
>> new file mode 100644
>> index 0000000..7213cbc
>> --- /dev/null
>> +++ b/tests/spec/ext_transform_feedback/primitive-restart.c
>> @@ -0,0 +1,111 @@
>> +/*
>> + * Copyright 2010 VMware, Inc.
>> + * Copyright (c) 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 primitive-restart.c
>> + *
>> + * Tests for a bug in the i965 driver where transform feedback would
>> + * return an invalid value when primitive restart was used.
>> + */
>> +
>> +#include "piglit-util.h"
>> +
>> +PIGLIT_GL_TEST_MAIN(
>> +    20 /*window_width*/,
>> +    20 /*window_height*/,
>> +    GLUT_RGB | GLUT_DOUBLE)
>> +
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +   GLfloat verts[][2] = {
>> +      {  0,  0 },
>> +      {  0, 20 },
>> +      { 20,  0 },
>> +   };
>> +   GLubyte indices[4] = {
>> +      0,
>> +      1,
>> +      2,
>> +      0xff
>> +   };
>> +   enum piglit_result result = PIGLIT_PASS;
>> +   GLuint num_generated_primitives;
>> +   GLuint generated_query;
>> +
>> +   glGenQueries(1,&generated_query);
>> +
>> +   piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
>> +
>> +   glClear(GL_COLOR_BUFFER_BIT);
>> +
>> +   glVertexPointer(2, GL_FLOAT, 0, (void *)verts);
>> +
>> +   glEnableClientState(GL_VERTEX_ARRAY);
>> +
>> +   glBeginQuery(GL_PRIMITIVES_GENERATED, generated_query);
>> +
>> +   assert(glGetError()==0);
>
>
> Use piglit_check_gl_error(0) instead.
>
>
>> +
>> +   glEnableClientState(GL_PRIMITIVE_RESTART_NV);
>> +   glPrimitiveRestartIndexNV(0xff);
>> +
>> +   /* Draw */
>> +   glDrawElements(GL_TRIANGLE_STRIP, ARRAY_SIZE(indices),
>> +                  GL_UNSIGNED_BYTE, indices);
>> +
>> +   glDisableClientState(GL_PRIMITIVE_RESTART_NV);
>> +   glDisableClientState(GL_VERTEX_ARRAY);
>> +
>> +   glEndQuery(GL_PRIMITIVES_GENERATED);
>> +   glGetQueryObjectuiv(generated_query, GL_QUERY_RESULT,
>> +&num_generated_primitives);
>> +   glDeleteQueries(1,&generated_query);
>> +
>> +   assert(glGetError()==0);
>
>
> Ditto.
>
>
>> +
>> +   if (num_generated_primitives != 1) {
>> +      fprintf(stderr, "GL_PRIMITIVES_GENERATED: expected=1, got=%u\n",
>> +              num_generated_primitives);
>> +      result = PIGLIT_FAIL;
>> +   }
>> +
>> +   piglit_present_results();
>> +
>> +   return result;
>> +}
>> +
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +   if ((piglit_get_gl_version()<  31)&&
>> +       !piglit_is_extension_supported("GL_NV_primitive_restart")) {
>> +      printf("Primitive restart not supported.\n");
>> +      piglit_report_result(PIGLIT_SKIP);
>> +      exit(1);
>
> Is this correct?  I know a bunch of stuff in the piglit framework changed
> while I was on vacation...

I based this on piglit_require_transform_feedback.

Which part looks bad?

-Jordan

>
>> +   }
>> +   piglit_require_transform_feedback();
>> +}
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list