[Mesa-dev] [PATCH 10/10] i965: Pull query BO reallocation out into a helper function.

Eric Anholt eric at anholt.net
Thu Feb 28 09:48:45 PST 2013


Kenneth Graunke <kenneth at whitecape.org> writes:

> We'll want to reuse this for non-occlusion queries in the future.
>
> Plus, it's a single logical task, so having it as a helper function
> clarifies the code somewhat.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/mesa/drivers/dri/i965/brw_queryobj.c | 56 +++++++++++++++++++-------------
>  1 file changed, 33 insertions(+), 23 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
> index d80f624..9a38be1 100644
> --- a/src/mesa/drivers/dri/i965/brw_queryobj.c
> +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
> @@ -489,6 +489,38 @@ static void brw_check_query(struct gl_context *ctx, struct gl_query_object *q)
>  }
>  
>  /**
> + * Ensure there query's BO has enough space to store a new pair of values.
> + *
> + * If not, gather the existing BO's results and create a new buffer of the
> + * same size.
> + */
> +static void
> +ensure_bo_has_space(struct gl_context *ctx, struct brw_query_object *query)
> +{
> +   struct intel_context *intel = intel_context(ctx);
> +
> +   if (!query->bo || query->last_index * 2 + 1 >= 4096 / sizeof(uint64_t)) {
> +
> +      if (query->bo != NULL) {
> +         /* The old query BO did not have enough space, so we allocated a new
> +          * one.  Gather the results so far (adding up the differences) and
> +          * release the old BO.
> +          */
> +	 brw_queryobj_get_results(ctx, query);
> +      }
> +
> +      query->bo = drm_intel_bo_alloc(intel->bufmgr, "query", 4096, 1);
> +
> +      /* Fill the buffer with zeroes.  This is probably superfluous. */
> +      drm_intel_bo_map(query->bo, true);
> +      memset((char *) query->bo->virtual, 0, 4096);
> +      drm_intel_bo_unmap(query->bo);

Pretty sure the char * is totally superfluous.  This isn't c++ here.
That and the tab comment I'd be happy to see just resolved in this
commit.

I've now reviewed the rest of the series, and I'm looking forward to it
landing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130228/a96faa76/attachment.pgp>


More information about the mesa-dev mailing list