intel: Print GPU timing data based on INTEL_MEASURE
authorMark Janes <markjanes@swizzler.org>
Wed, 9 Sep 2020 22:13:30 +0000 (15:13 -0700)
committerMark Janes <markjanes@swizzler.org>
Tue, 2 Feb 2021 01:24:57 +0000 (17:24 -0800)
commit0f4143ec3787ffc851feeb3ec4ee977ef46ee461
tree9abf2cc2d1d780e5503d90e4f671c5aa4cd3e426
parentf9960579c339774a3c549552f287824c0c4371d3
intel: Print GPU timing data based on INTEL_MEASURE

This infrastructure collects GPU timestamps over common intervals, and
generates a CSV report to show how long rendering took.  The overhead
of collection is limited to the flushing that is required at the
interval boundaries for accurate timestamps.

By default, timing data is sent to stderr.  To direct output to a
file:
 INTEL_MEASURE=file=/tmp/measure.csv {workload}

To begin capturing timestamps at a particular frame:
 INTEL_MEASURE=file=/tmp/measure.csv,start=15 {workload}

To capture only 23 frames:
 INTEL_MEASURE=count=23 {workload}

To capture frames 15-37, stopping before frame 38:
 INTEL_MEASURE=start=15,count=23 {workload}

Designate an asynchronous control file with:
 INTEL_MEASURE=control=path/to/control.fifo {workload}

As the workload runs, enable capture for 5 frames with:

 $ echo 5 > path/to/control.fifo

Enable unbounded capture:

 $ echo -1 > path/to/control.fifo

and disable with:

 $ echo 0 > path/to/control.fifo

Select the boundaries of each snapshot with:
 INTEL_MEASURE=draw  : DEFAULT - Collects timings for every render
 INTEL_MEASURE=rt    : Collects timings when the render target changes
 INTEL_MEASURE=batch : Collects timings when batches are submitted
 INTEL_MEASURE=frame : Collects timings at frame boundaries

With INTEL_MEASURE=interval=5, the duration of 5 events will be
combined into a single record in the output.  When possible, a single
start and end event will be submitted to the GPU to minimize
stalling.  Combined events will not span batches, except in
the case of INTEL_MEASURE=frame.

Acked-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7354>
src/intel/common/intel_measure.c [new file with mode: 0644]
src/intel/common/intel_measure.h [new file with mode: 0644]
src/intel/common/meson.build