Add WiVRn-native Perfetto via Perfetto SDK

Optional server profiling built on the Perfetto SDK. Adds CPU spans
(compositor, encoder, network), GPU encode/copy slices from Vulkan timestamp
queries (Vulkan/NVENC/VAAPI), and headset feedback markers from dump_time.

WIVRN_TRACING enables tracing and selects the backend (system, inprocess, or
both); WIVRN_USE_PERFETTO gates it at build time and compiles it out otherwise.
WIVRN_TRACE_MONADO additionally drives Monado's percetto tracing from the same
switch so WiVRn and Monado land on one timeline.

Tooling: server-tracing[-monado] presets and a CI build, two Perfetto configs
(WiVRn-only and full-system), a wivrn_capture.py capture wrapper, a pftrace
summary script, and docs/profiling.md.
This commit is contained in:
Jonathan Steffan
2026-07-01 21:04:08 +02:00
committed by xytovl
parent b11655fdee
commit b9c8a54d92
34 changed files with 1968 additions and 58 deletions
+33
View File
@@ -70,6 +70,18 @@ set(BUILD_TESTING OFF)
set(XRT_HAVE_SYSTEM_CJSON OFF)
# Drive Monado's tracing from the same switch as WiVRn's: WIVRN_TRACE_MONADO builds Monado
# with percetto so its u_trace markers join the WIVRN_TRACING session (system backend).
# Monado does not fetch percetto; it must be discoverable (pkg-config / installed, or
# -DPercetto_ROOT_DIR=...). If it is missing, Monado's option_with_deps fails the configure
# with "XRT_HAVE_PERCETTO specified but not available". Linking percetto against WiVRn's own
# Perfetto SDK copy (to drop this requirement and the second runtime) is a planned follow-up.
if(WIVRN_TRACE_MONADO)
message(STATUS "WIVRN_TRACE_MONADO=ON: building Monado with percetto tracing (percetto must be available)")
set(XRT_FEATURE_TRACING ON)
set(XRT_HAVE_PERCETTO ON)
endif()
set(XRT_IPC_MSG_SOCK_FILENAME "wivrn/comp_ipc" CACHE STRING "Service socket filename")
set(XRT_IPC_SERVICE_PID_FILENAME "wivrn.pid" CACHE STRING "Service pidfile filename")
set(XRT_OXR_RUNTIME_SUFFIX "wivrn" CACHE STRING "OpenXR client library suffix")
@@ -121,6 +133,8 @@ if (WIVRN_BUILD_SERVER)
driver/xrt_cast.cpp
utils/wivrn_vk_bundle.cpp
utils/wivrn_trace.cpp
utils/gpu_timestamp_pool.cpp
)
target_compile_features(wivrn-server PRIVATE cxx_std_20)
target_compile_definitions(wivrn-server PRIVATE VULKAN_HPP_NO_CONSTRUCTORS)
@@ -171,6 +185,25 @@ if (WIVRN_BUILD_SERVER)
target_link_libraries(wivrn-server PRIVATE PkgConfig::X264)
endif()
if(WIVRN_USE_PERFETTO)
find_path(PERFETTO_SDK_DIR
NAMES perfetto.h
PATHS /usr/share/perfetto/sdk
DOC "Perfetto amalgamated SDK directory")
if(NOT PERFETTO_SDK_DIR)
message(FATAL_ERROR "WIVRN_USE_PERFETTO=ON but Perfetto SDK (perfetto.h) not found. Install perfetto-sdk.")
endif()
add_library(wivrn-perfetto-sdk STATIC ${PERFETTO_SDK_DIR}/perfetto.cc)
target_include_directories(wivrn-perfetto-sdk PUBLIC ${PERFETTO_SDK_DIR})
target_compile_options(wivrn-perfetto-sdk PRIVATE -w)
target_link_libraries(wivrn-perfetto-sdk PUBLIC pthread dl)
target_link_libraries(wivrn-server PRIVATE wivrn-perfetto-sdk)
target_compile_definitions(wivrn-server PRIVATE WIVRN_USE_PERFETTO)
if(WIVRN_TRACE_MONADO)
target_compile_definitions(wivrn-server PRIVATE WIVRN_TRACE_MONADO)
endif()
endif()
if(WIVRN_USE_SYSTEMD)
target_link_libraries(wivrn-server PRIVATE PkgConfig::SYSTEMD)
endif()