In-engine profiler (CPU/GPU frame stats, Tracy integration)

Motivation

AAA studios live by profiler data. Without per-frame CPU/GPU stats available inside the editor and the running game, every optimisation step is blind guessing. Profiling must be a first-class citizen, not an afterthought.

Goal

Ship an integrated profiler that shows CPU frame breakdown, GPU timings, draw-call counts, memory, and entity/component stats — in both the Studio viewport and the built game — with an optional Tracy open-telemetry export for deep dives.

Tasks

In-process profiling API

  • PROFILE_SCOPE(name) macro / Zig comptime helper that records begin/end timestamps on a per-thread ring buffer
  • GPU timer queries (SDL3 GPU timestamp queries) for render passes and draw calls
  • Stats counters: draw calls, triangles, material switches, texture binds, allocs/frame

Studio profiler panel

  • Flame graph / timeline view of the last N frames (CPU + GPU lanes)
  • Stats bar in the viewport HUD: FPS, frame ms, GPU ms, draw calls
  • Memory profiler tab: heap breakdown by allocator/system
  • Per-system update time breakdown (scene, physics, audio, render)

Built-game profiler

  • Toggle via CLI flag or debug server command (#2 (closed)) — zero overhead when disabled
  • Overlay HUD mode (FPS + stats, toggled at runtime via a key)
  • Export frame data as JSON/CSV for CI regression detection

Tracy integration

  • Conditional Tracy client linkage (-Dtracy=true build option)
  • Map PROFILE_SCOPE and GPU queries to Tracy zones
  • Document Tracy server setup + capturing a profile

Acceptance Criteria

  • Studio shows a profiler panel with CPU/GPU flame graph for the last frame.
  • Built game can display an overlay HUD and export frame data.
  • Tracy integration works when opted in at build time.
  • Profiler adds zero runtime cost when disabled.
  • #2 (closed) (Debug server exposes perf endpoints), #31 (closed) (Play Mode where profiler runs live), (built game infra).
Edited by Bruno Massa