[Piglit] [PATCH] Porting Arb Occlusion Query tests from Glean to Piglit

Ilia Mirkin imirkin at alum.mit.edu
Tue Sep 8 07:20:53 PDT 2015


On Tue, Sep 8, 2015 at 3:35 AM, Juliet Fru <julietfru at gmail.com> wrote:
> ---
>  tests/spec/arb_occlusion_query/CMakeLists.gl.txt   |   1 +
>  .../arb_occlusion_query/occlusion_query_conform.c  | 676 +++++++++++++++++++++
>  2 files changed, 677 insertions(+)
>  create mode 100644 tests/spec/arb_occlusion_query/occlusion_query_conform.c
>
> diff --git a/tests/spec/arb_occlusion_query/CMakeLists.gl.txt b/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
> index 01a499d..23a19e4 100644
> --- a/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
> +++ b/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
> @@ -10,6 +10,7 @@ link_libraries (
>  )
>
>  piglit_add_executable (occlusion_query occlusion_query.c)
> +piglit_add_executable (occlusion_query_conformance occlusion_query_conform.c)
>  piglit_add_executable (occlusion_query_lifetime occlusion_query_lifetime.c)
>  piglit_add_executable (occlusion_query_meta_no_fragments occlusion_query_meta_no_fragments.c)
>  piglit_add_executable (occlusion_query_meta_fragments occlusion_query_meta_fragments.c)
> diff --git a/tests/spec/arb_occlusion_query/occlusion_query_conform.c b/tests/spec/arb_occlusion_query/occlusion_query_conform.c
> new file mode 100644
> index 0000000..1d1f1e3
> --- /dev/null
> +++ b/tests/spec/arb_occlusion_query/occlusion_query_conform.c
> @@ -0,0 +1,676 @@
> +/*  BEGIN_COPYRIGHT -*- glean -*-
> + *
> + *  Copyright (C) 1999  Allen Akin   All Rights Reserved.
> + *  Copyright (C) 2015  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.
> + *
> + * END_COPYRIGHT
> + */
> +
> +/** @file occlusion_query_conform.c
> + *
> + *     Conformance test on ARB_occlusion_query extension.
> + *
> + *     Authors:
> + *     Wei Wang <wei.z.wang at intel.com>
> + *     Adapted to Piglit by Juliet Fru <julietfru at gmail.com>, September 2015
> + */
> +
> +#include "piglit-util-gl.h"
> +#include <stdlib.h>
> +#include <assert.h>
> +#include <string.h>
> +#include <stdio.h>
> +#include <math.h>
> +#include <time.h>
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN config.supports_gl_compat_version = 10;

missing newline?

> +
> +config.window_width = 180;
> +config.window_height = 100;

This will cause annoyance for some version of windows... min window
size there is 160x160.

> +config.window_visual =
> +       PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE |
> +       PIGLIT_GL_VISUAL_DEPTH;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +#define GL_GLEXT_PROTOTYPES
> +#define START_QUERY(id)\
> +       glBeginQueryARB(GL_SAMPLES_PASSED_ARB, id);
> +#define TERM_QUERY()\
> +       glEndQueryARB(GL_SAMPLES_PASSED_ARB);

Please get rid of these.

> +/* Generate a box which will be occluded by the occluder */
> +       void
> +gen_box(GLfloat left, GLfloat right, GLfloat top, GLfloat btm)
> +{
> +       glBegin(GL_POLYGON);
> +       glVertex3f(left, top, 0);
> +       glVertex3f(right, top, 0);
> +       glVertex3f(right, btm, 0);
> +       glVertex3f(left, btm, 0);
> +       glEnd();
> +}

Use piglit_draw_rect

> +
> +bool
> +chk_ext()
> +{
> +       const char *ext = (const char *) glGetString(GL_EXTENSIONS);
> +
> +       if (!strstr(ext, "GL_ARB _occlusion_query")) {
> +               printf(" %s Warning: Extension GL_ARB_occlusion_query is missing.\n", ext);
> +               return false;
> +       }
> +
> +       return true;
> +}

Use piglit_require_extension

> +
> +GLuint
> +find_unused_id()
> +{
> +       /* used the regular random number generator. */
> +       srand((unsigned) time(NULL));
> +       unsigned int id;
> +       int counter = 0;
> +
> +#define MAX_FIND_ID_ROUND 256
> +
> +       while (1) {
> +               /* assuming that at least 2^32-1 <id> can be generated */
> +               id = rand();
> +               if (id != 0 && glIsQueryARB(id) == GL_FALSE)
> +                       return id;
> +               if (++counter >= MAX_FIND_ID_ROUND) {
> +                       char str[1000];
> +                       sprintf(str,
> +                               "Cannot find the unused id after [%d] tries.",
> +                               MAX_FIND_ID_ROUND);
> +                       printf("Warning: %s\n", str);
> +                       return 0;
> +               }
> +       }
> +}

Errrr.... huh? What is this for? Shouldn't one always just use
glGenQueries? I looked at some of the uses and am definitely very
confused.

  -ilia


More information about the Piglit mailing list