From 2be07fc7517c624b0048e512f50280696e3f069c Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Fri, 8 Jun 2018 17:51:33 +0100 Subject: [PATCH] i965: move brw_timebase_scale to device info Signed-off-by: Lionel Landwerlin Reviewed-by: Mark Janes --- src/intel/dev/gen_device_info.h | 7 +++++++ src/mesa/drivers/dri/i965/brw_context.h | 1 - src/mesa/drivers/dri/i965/brw_performance_query.c | 8 ++++++-- .../dri/i965/brw_performance_query_mdapi.c | 6 +++--- src/mesa/drivers/dri/i965/brw_queryobj.c | 15 ++++----------- src/mesa/drivers/dri/i965/gen6_queryobj.c | 4 ++-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/intel/dev/gen_device_info.h b/src/intel/dev/gen_device_info.h index a5ab14b3663..af13615be2b 100644 --- a/src/intel/dev/gen_device_info.h +++ b/src/intel/dev/gen_device_info.h @@ -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 diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 23048428f3e..46791c7d2c8 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -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); diff --git a/src/mesa/drivers/dri/i965/brw_performance_query.c b/src/mesa/drivers/dri/i965/brw_performance_query.c index d3ae3c114f8..b3b34a82da7 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_query.c +++ b/src/mesa/drivers/dri/i965/brw_performance_query.c @@ -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 diff --git a/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c b/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c index 159f31441c5..919069f9e39 100644 --- a/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c +++ b/src/mesa/drivers/dri/i965/brw_performance_query_mdapi.c @@ -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]; diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index bc4b8c43e7b..1fb809cab8f 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -42,14 +42,6 @@ #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 diff --git a/src/mesa/drivers/dri/i965/gen6_queryobj.c b/src/mesa/drivers/dri/i965/gen6_queryobj.c index ce9bb474e18..ada28a4a824 100644 --- a/src/mesa/drivers/dri/i965/gen6_queryobj.c +++ b/src/mesa/drivers/dri/i965/gen6_queryobj.c @@ -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 -- 2.30.2