i965: move brw_timebase_scale to device info
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 8 Jun 2018 16:51:33 +0000 (17:51 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 17 Apr 2019 13:10:42 +0000 (14:10 +0100)
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Mark Janes <mark.a.janes@intel.com>
src/intel/dev/gen_device_info.h
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_performance_query.c
src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c
src/mesa/drivers/dri/i965/brw_queryobj.c
src/mesa/drivers/dri/i965/gen6_queryobj.c

index a5ab14b36631ffdf2e0513a92cd2b9d4e18e9c4c..af13615be2b7ee695913018f45c1096dc5e0d500 100644 (file)
@@ -275,6 +275,13 @@ void gen_device_info_update_from_masks(struct gen_device_info *devinfo,
 void gen_device_info_update_from_topology(struct gen_device_info *devinfo,
                                           const struct drm_i915_query_topology_info *topology);
 
+static inline uint64_t
+gen_device_info_timebase_scale(const struct gen_device_info *devinfo,
+                               uint64_t gpu_timestamp)
+{
+   return (1000000000ull * gpu_timestamp) / devinfo->timestamp_frequency;
+}
+
 #ifdef __cplusplus
 }
 #endif
index 23048428f3edf388a07e6fcb8abd5da64a33d5e9..46791c7d2c808a3b5311b2391ff79e0fa57d1bc6 100644 (file)
@@ -1333,7 +1333,6 @@ void brw_emit_query_begin(struct brw_context *brw);
 void brw_emit_query_end(struct brw_context *brw);
 void brw_query_counter(struct gl_context *ctx, struct gl_query_object *q);
 bool brw_is_query_pipelined(struct brw_query_object *query);
-uint64_t brw_timebase_scale(struct brw_context *brw, uint64_t gpu_timestamp);
 uint64_t brw_raw_timestamp_delta(struct brw_context *brw,
                                  uint64_t time0, uint64_t time1);
 
index d3ae3c114f8e14be077da647da8a6e892931ee54..b3b34a82da78e6ef163af7b0902b8d102245cb3a 100644 (file)
@@ -786,14 +786,18 @@ accumulate_oa_reports(struct brw_context *brw,
             /* Ignore reports that come before the start marker.
              * (Note: takes care to allow overflow of 32bit timestamps)
              */
-            if (brw_timebase_scale(brw, report[1] - start[1]) > 5000000000)
+            if (gen_device_info_timebase_scale(devinfo,
+                                               report[1] - start[1]) > 5000000000) {
                continue;
+            }
 
             /* Ignore reports that come after the end marker.
              * (Note: takes care to allow overflow of 32bit timestamps)
              */
-            if (brw_timebase_scale(brw, report[1] - end[1]) <= 5000000000)
+            if (gen_device_info_timebase_scale(devinfo,
+                                               report[1] - end[1]) <= 5000000000) {
                goto end;
+            }
 
             /* For Gen8+ since the counters continue while other
              * contexts are running we need to discount any unrelated
index 159f31441c5628065b1f9209d472d98b9ca213c3..919069f9e39766d0db0cb3edbc1ec0a0b4c476cf 100644 (file)
@@ -54,7 +54,7 @@ brw_perf_query_get_mdapi_oa_data(struct brw_context *brw,
       }
 
       mdapi_data->ReportsCount = result->reports_accumulated;
-      mdapi_data->TotalTime = brw_timebase_scale(brw, result->accumulator[0]);
+      mdapi_data->TotalTime = gen_device_info_timebase_scale(devinfo, result->accumulator[0]);
       mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
       mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
       return sizeof(*mdapi_data);
@@ -74,7 +74,7 @@ brw_perf_query_get_mdapi_oa_data(struct brw_context *brw,
 
       mdapi_data->ReportId = result->hw_id;
       mdapi_data->ReportsCount = result->reports_accumulated;
-      mdapi_data->TotalTime = brw_timebase_scale(brw, result->accumulator[0]);
+      mdapi_data->TotalTime = gen_device_info_timebase_scale(devinfo, result->accumulator[0]);
       mdapi_data->GPUTicks = result->accumulator[1];
       mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
       mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
@@ -100,7 +100,7 @@ brw_perf_query_get_mdapi_oa_data(struct brw_context *brw,
 
       mdapi_data->ReportId = result->hw_id;
       mdapi_data->ReportsCount = result->reports_accumulated;
-      mdapi_data->TotalTime = brw_timebase_scale(brw, result->accumulator[0]);
+      mdapi_data->TotalTime = gen_device_info_timebase_scale(devinfo, result->accumulator[0]);
       mdapi_data->GPUTicks = result->accumulator[1];
       mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
       mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
index bc4b8c43e7b669330a1edba5041ee56380d56337..1fb809cab8f19c871a45842d6d7c9c4f2f67f5a5 100644 (file)
 #include "brw_state.h"
 #include "intel_batchbuffer.h"
 
-uint64_t
-brw_timebase_scale(struct brw_context *brw, uint64_t gpu_timestamp)
-{
-   const struct gen_device_info *devinfo = &brw->screen->devinfo;
-
-   return (1000000000ull * gpu_timestamp) / devinfo->timestamp_frequency;
-}
-
 /* As best we know currently, the Gen HW timestamps are 36bits across
  * all platforms, which we need to account for when calculating a
  * delta to measure elapsed time.
@@ -164,12 +156,12 @@ brw_queryobj_get_results(struct gl_context *ctx,
        * Subtract the two and convert to nanoseconds.
        */
       query->Base.Result = brw_raw_timestamp_delta(brw, results[0], results[1]);
-      query->Base.Result = brw_timebase_scale(brw, query->Base.Result);
+      query->Base.Result = gen_device_info_timebase_scale(devinfo, query->Base.Result);
       break;
 
    case GL_TIMESTAMP:
       /* The query BO contains a single timestamp value in results[0]. */
-      query->Base.Result = brw_timebase_scale(brw, results[0]);
+      query->Base.Result = gen_device_info_timebase_scale(devinfo, results[0]);
 
       /* Ensure the scaled timestamp overflows according to
        * GL_QUERY_COUNTER_BITS
@@ -547,6 +539,7 @@ static uint64_t
 brw_get_timestamp(struct gl_context *ctx)
 {
    struct brw_context *brw = brw_context(ctx);
+   const struct gen_device_info *devinfo = &brw->screen->devinfo;
    uint64_t result = 0;
 
    switch (brw->screen->hw_has_timestamp) {
@@ -563,7 +556,7 @@ brw_get_timestamp(struct gl_context *ctx)
    }
 
    /* Scale to nanosecond units */
-   result = brw_timebase_scale(brw, result);
+   result = gen_device_info_timebase_scale(devinfo, result);
 
    /* Ensure the scaled timestamp overflows according to
     * GL_QUERY_COUNTER_BITS.  Technically this isn't required if
index ce9bb474e181a8263de73bdc964d56decf4b8382..ada28a4a8241bf672c094472f2b78f55564726a2 100644 (file)
@@ -236,12 +236,12 @@ gen6_queryobj_get_results(struct gl_context *ctx,
        * Subtract the two and convert to nanoseconds.
        */
       query->Base.Result = brw_raw_timestamp_delta(brw, results[0], results[1]);
-      query->Base.Result = brw_timebase_scale(brw, query->Base.Result);
+      query->Base.Result = gen_device_info_timebase_scale(devinfo, query->Base.Result);
       break;
 
    case GL_TIMESTAMP:
       /* The query BO contains a single timestamp value in results[0]. */
-      query->Base.Result = brw_timebase_scale(brw, results[0]);
+      query->Base.Result = gen_device_info_timebase_scale(devinfo, results[0]);
 
       /* Ensure the scaled timestamp overflows according to
        * GL_QUERY_COUNTER_BITS