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
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);
/* 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
}
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);
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];
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];
#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.
* 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
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) {
}
/* 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
* 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