Skip to content

turnip: implement basic perfetto support

Danylo Piliaiev requested to merge Danil/mesa:turnip/feature/perfetto into main

This moved u_trace from gallium to the common utils and with a little modification it could be usable for Vulkan drivers.

The notable changes to u_trace are:

  • Addition of fence parameter to u_trace_flush - because drivers need to have something to wait on in u_trace_read_ts callback and u_trace_flush is the first place where drivers would reasonably be able to obtain a fence or other sync object.
  • Passing of opaque flush_data pointer via u_trace_flush. There is data which becomes available only at this point which other drivers may want to pass. For example Vulkan drivers would want to pass at least submission id (for perfetto) and a sync object to wait on in u_trace_read_ts.

As for Turnip, I duplicated the tracepoints definitions and RenderpassDataSource implementation.

  • Not everything useful is timestamped at the moment and probably not all useful info is added to tracepoints
  • There is no per-draw tracing, only per tile. Tracing every drawcall incurred too big overhead. As a middle ground only gmem load/store/clears are traces per tile.

Changelog:

  • Payload's serialization is now auto-generated
  • Reduced the tu_start_/tu_end_ callback duplication via macro
  • Re-usable command buffers are supported via CP_MEMCPY fallback - at submission time for every reusable command buffer CP_MEMCPY is added to copy all timestamps
  • GMEM load/stores/clears are traced per tile, also sysmem clears traced

: Better support of re-usage and simultaneous command buffer would require being able to write gpu time (with CP_EVENT_WRITE_0_TIMESTAMP) at indirect offset, which would require fw patching (see #4789), or we would have to copy the timestamp buffer after the each commandstream.

On the other hand I don't know any real games using other than VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT command buffers and DXVK/VKD3D don't use other types either. However, vkcube and Vulkan samples do use reusable command buffers...

It does hang my a650 board with a bit dated 5.10 kernel, there are no iova faults, nothing in dmesg, just total hangs from time to time. On the other hand that board loves to hang on any minor inconvenience... RB3 with a630 works without any hangs/faults though.

Secondary command buffer are not supported, no one uses them...

KGSL is not supported


Note: at the moment this requires a fairly new kernel, in my case for 5.10 kernel I had to cherry-pick:

  • 9fbd3088351b92e8c2cef6e37a39decb12a8d5bb "drm/msm: Fix a5xx/a6xx timestamps"
  • 3ab1c5cc3939b3322ebd27a44b8ee6a16eccc9f5 "drm/msm: Add param for userspace to query suspend count"

Example of VkQuake trace:

image

Edited by Danylo Piliaiev

Merge request reports