[Mesa-dev] [PATCH] i965: fix timer query on gen6+

Zou, Nanhai nanhai.zou at intel.com
Wed Jul 20 18:57:30 PDT 2011


For ILK, It is vol 1.18.11.2, 
		This register has the contents from TIMESTAMP_HI (0x70070) display register. This field gets incremented every 1 uS of time.

Thanks
Zou Nanhai		


-----Original Message-----
From: mesa-dev-bounces+nanhai.zou=intel.com at lists.freedesktop.org [mailto:mesa-dev-bounces+nanhai.zou=intel.com at lists.freedesktop.org] On Behalf Of Kenneth Graunke
Sent: 2011年7月21日 2:13
To: mesa-dev at lists.freedesktop.org
Subject: Re: [Mesa-dev] [PATCH] i965: fix timer query on gen6+

On 07/20/2011 09:12 AM, Zou Nan hai wrote:
> 	on gen6+, PIPE_CONTROL reported time stamp are 64 bits
> 	value (high 32 bits MBZ on snb), toggles every 80 ns.
> 
> 	Signed-off-by: Zou Nan hai <nanhai.zou at intel.com>

This seems correct to me.  The Sandybridge PRM, Volume 1, Part 3,
section 1.1.10.10 "TIMESTAMP - Reported Timestamp Count", does seem to
agree with your code.  The Ironlake PRM seems to have inaccurate info
(it lists the SNB field as Project: All), but the G45 PRM, Volume 1a,
section 8.16.10 does have the old U64 version.

That said, I haven't found the justification for the * 1000, nor why
we're only using 32-bits of the U64 counter (in the pre-gen6 code).

Please include spec references for things like this, it makes it a lot
easier to verify the changes.

--Kenneth

> ---
>  src/mesa/drivers/dri/i965/brw_queryobj.c |   17 ++++++++++++-----
>  1 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c
> index b41d05d..2e04fc2 100644
> --- a/src/mesa/drivers/dri/i965/brw_queryobj.c
> +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c
> @@ -47,7 +47,7 @@
>  
>  /** Waits on the query object's BO and totals the results for this query */
>  static void
> -brw_queryobj_get_results(struct brw_query_object *query)
> +brw_queryobj_get_results(struct brw_query_object *query, int gen)
>  {
>     int i;
>     uint64_t *results;
> @@ -58,7 +58,10 @@ brw_queryobj_get_results(struct brw_query_object *query)
>     drm_intel_bo_map(query->bo, GL_FALSE);
>     results = query->bo->virtual;
>     if (query->Base.Target == GL_TIME_ELAPSED_EXT) {
> -      query->Base.Result += 1000 * ((results[1] >> 32) - (results[0] >> 32));
> +      if (gen >= 6)
> +         query->Base.Result += 80 * (results[1] - results[0]);
> +      else
> +         query->Base.Result += 1000 * ((results[1] >> 32) - (results[0] >> 32));
>     } else {
>        /* Map and count the pixels from the current query BO */
>        for (i = query->first_index; i <= query->last_index; i++) {
> @@ -200,17 +203,21 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q)
>  static void brw_wait_query(struct gl_context *ctx, struct gl_query_object *q)
>  {
>     struct brw_query_object *query = (struct brw_query_object *)q;
> +   struct brw_context *brw = brw_context(ctx);
> +   struct intel_context *intel = intel_context(ctx);
>  
> -   brw_queryobj_get_results(query);
> +   brw_queryobj_get_results(query, intel->gen);
>     query->Base.Ready = GL_TRUE;
>  }
>  
>  static void brw_check_query(struct gl_context *ctx, struct gl_query_object *q)
>  {
>     struct brw_query_object *query = (struct brw_query_object *)q;
> +   struct brw_context *brw = brw_context(ctx);
> +   struct intel_context *intel = intel_context(ctx);
>  
>     if (query->bo == NULL || !drm_intel_bo_busy(query->bo)) {
> -      brw_queryobj_get_results(query);
> +      brw_queryobj_get_results(query, intel->gen);
>        query->Base.Ready = GL_TRUE;
>     }
>  }
> @@ -295,7 +302,7 @@ brw_emit_query_begin(struct brw_context *brw)
>  
>     if (query->bo != brw->query.bo) {
>        if (query->bo != NULL)
> -	 brw_queryobj_get_results(query);
> +	 brw_queryobj_get_results(query, intel->gen);
>        drm_intel_bo_reference(brw->query.bo);
>        query->bo = brw->query.bo;
>        query->first_index = brw->query.index;

_______________________________________________
mesa-dev mailing list
mesa-dev at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list