[Mesa-dev] [PATCH 3/4] queryobj: Add IsQuery flag, making ISQuery() return false before BeginQuery()

Matt Turner mattst88 at gmail.com
Wed Dec 19 12:26:15 PST 2012


On Mon, Dec 17, 2012 at 2:24 PM, Carl Worth <cworth at cworth.org> wrote:
> This flag allows for the specified behavior that GenQueries reserves a name,
> but does not associate an object with it until BeginQuery. We allocate the
> object immediately with the new IsQuery flag set to false, and then set the
> flag to true at the time of BeginQuery.
>
> This allows us to implement a conformant IsQuery function by checking the
> state of the new IsQuery flag.
>
> This fixes the following es3conform tests:
>
>         occlusion_query_genqueries
>         occlusion_query_is_query_nonzero
> ---
>  src/mesa/main/mtypes.h   |    1 +
>  src/mesa/main/queryobj.c |   20 +++++++++++++++++++-
>  2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 1164fdf..5241660 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2495,6 +2495,7 @@ struct gl_query_object
>     GLuint64EXT Result; /**< the counter */
>     GLboolean Active;   /**< inside Begin/EndQuery */
>     GLboolean Ready;    /**< result is ready? */
> +   GLboolean IsQuery;  /**< query object is an actual query (see spec.) */
>  };
>
>
> diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
> index b482b15..74e8b2b 100644
> --- a/src/mesa/main/queryobj.c
> +++ b/src/mesa/main/queryobj.c
> @@ -56,6 +56,14 @@ _mesa_new_query_object(struct gl_context *ctx, GLuint id)
>         * 2.13).
>         */
>        q->Ready = GL_TRUE;
> +
> +      /* OpenGL 3.1 § 2.13 says about GenQueries, "These names are marked as
> +       * used, but no object is associated with them until the first time they
> +       * are used by BeginQuery." Since our implementation actually does
> +       * allocate an object at this point, use a flag to indicate that this
> +       * object is not (yet) a query.
> +       */
> +      q->IsQuery = GL_FALSE;
>     }
>     return q;
>  }
> @@ -257,13 +265,22 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids)
>  GLboolean GLAPIENTRY
>  _mesa_IsQuery(GLuint id)
>  {
> +   struct gl_query_object *q;
> +
>     GET_CURRENT_CONTEXT(ctx);
>     ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
>
>     if (MESA_VERBOSE & VERBOSE_API)
>        _mesa_debug(ctx, "glIsQuery(%u)\n", id);
>
> -   if (id && _mesa_lookup_query_object(ctx, id))
> +   if (id == 0)
> +      return GL_FALSE;
> +
> +   q = _mesa_lookup_query_object(ctx, id);
> +   if (q == NULL)
> +      return GL_FALSE;
> +
> +   if (q->IsQuery)
>        return GL_TRUE;
>     else
>        return GL_FALSE;

Just return q->IsQuery here? It's already declared as GLboolean.


More information about the mesa-dev mailing list