i965: move brw_timebase_scale to device info
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Mark Janes <mark.a.janes@intel.com>
This commit is contained in:
@@ -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,
|
void gen_device_info_update_from_topology(struct gen_device_info *devinfo,
|
||||||
const struct drm_i915_query_topology_info *topology);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1333,7 +1333,6 @@ void brw_emit_query_begin(struct brw_context *brw);
|
|||||||
void brw_emit_query_end(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);
|
void brw_query_counter(struct gl_context *ctx, struct gl_query_object *q);
|
||||||
bool brw_is_query_pipelined(struct brw_query_object *query);
|
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 brw_raw_timestamp_delta(struct brw_context *brw,
|
||||||
uint64_t time0, uint64_t time1);
|
uint64_t time0, uint64_t time1);
|
||||||
|
|
||||||
|
@@ -786,14 +786,18 @@ accumulate_oa_reports(struct brw_context *brw,
|
|||||||
/* Ignore reports that come before the start marker.
|
/* Ignore reports that come before the start marker.
|
||||||
* (Note: takes care to allow overflow of 32bit timestamps)
|
* (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;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ignore reports that come after the end marker.
|
/* Ignore reports that come after the end marker.
|
||||||
* (Note: takes care to allow overflow of 32bit timestamps)
|
* (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;
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
/* For Gen8+ since the counters continue while other
|
/* For Gen8+ since the counters continue while other
|
||||||
* contexts are running we need to discount any unrelated
|
* contexts are running we need to discount any unrelated
|
||||||
|
@@ -54,7 +54,7 @@ brw_perf_query_get_mdapi_oa_data(struct brw_context *brw,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mdapi_data->ReportsCount = result->reports_accumulated;
|
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->CoreFrequency = obj->oa.gt_frequency[1];
|
||||||
mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
|
mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
|
||||||
return sizeof(*mdapi_data);
|
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->ReportId = result->hw_id;
|
||||||
mdapi_data->ReportsCount = result->reports_accumulated;
|
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->GPUTicks = result->accumulator[1];
|
||||||
mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
|
mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
|
||||||
mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != 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->ReportId = result->hw_id;
|
||||||
mdapi_data->ReportsCount = result->reports_accumulated;
|
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->GPUTicks = result->accumulator[1];
|
||||||
mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
|
mdapi_data->CoreFrequency = obj->oa.gt_frequency[1];
|
||||||
mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
|
mdapi_data->CoreFrequencyChanged = obj->oa.gt_frequency[0] != obj->oa.gt_frequency[1];
|
||||||
|
@@ -42,14 +42,6 @@
|
|||||||
#include "brw_state.h"
|
#include "brw_state.h"
|
||||||
#include "intel_batchbuffer.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
|
/* As best we know currently, the Gen HW timestamps are 36bits across
|
||||||
* all platforms, which we need to account for when calculating a
|
* all platforms, which we need to account for when calculating a
|
||||||
* delta to measure elapsed time.
|
* delta to measure elapsed time.
|
||||||
@@ -164,12 +156,12 @@ brw_queryobj_get_results(struct gl_context *ctx,
|
|||||||
* Subtract the two and convert to nanoseconds.
|
* Subtract the two and convert to nanoseconds.
|
||||||
*/
|
*/
|
||||||
query->Base.Result = brw_raw_timestamp_delta(brw, results[0], results[1]);
|
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;
|
break;
|
||||||
|
|
||||||
case GL_TIMESTAMP:
|
case GL_TIMESTAMP:
|
||||||
/* The query BO contains a single timestamp value in results[0]. */
|
/* 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
|
/* Ensure the scaled timestamp overflows according to
|
||||||
* GL_QUERY_COUNTER_BITS
|
* GL_QUERY_COUNTER_BITS
|
||||||
@@ -547,6 +539,7 @@ static uint64_t
|
|||||||
brw_get_timestamp(struct gl_context *ctx)
|
brw_get_timestamp(struct gl_context *ctx)
|
||||||
{
|
{
|
||||||
struct brw_context *brw = brw_context(ctx);
|
struct brw_context *brw = brw_context(ctx);
|
||||||
|
const struct gen_device_info *devinfo = &brw->screen->devinfo;
|
||||||
uint64_t result = 0;
|
uint64_t result = 0;
|
||||||
|
|
||||||
switch (brw->screen->hw_has_timestamp) {
|
switch (brw->screen->hw_has_timestamp) {
|
||||||
@@ -563,7 +556,7 @@ brw_get_timestamp(struct gl_context *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Scale to nanosecond units */
|
/* 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
|
/* Ensure the scaled timestamp overflows according to
|
||||||
* GL_QUERY_COUNTER_BITS. Technically this isn't required if
|
* GL_QUERY_COUNTER_BITS. Technically this isn't required if
|
||||||
|
@@ -236,12 +236,12 @@ gen6_queryobj_get_results(struct gl_context *ctx,
|
|||||||
* Subtract the two and convert to nanoseconds.
|
* Subtract the two and convert to nanoseconds.
|
||||||
*/
|
*/
|
||||||
query->Base.Result = brw_raw_timestamp_delta(brw, results[0], results[1]);
|
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;
|
break;
|
||||||
|
|
||||||
case GL_TIMESTAMP:
|
case GL_TIMESTAMP:
|
||||||
/* The query BO contains a single timestamp value in results[0]. */
|
/* 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
|
/* Ensure the scaled timestamp overflows according to
|
||||||
* GL_QUERY_COUNTER_BITS
|
* GL_QUERY_COUNTER_BITS
|
||||||
|
Reference in New Issue
Block a user