API

Function setGpuTimingEnabled

  • Enable or disable per-frame GPU timing. Disabled by default and a no-op on devices where isGpuTimingSupported is false. While on, EngineContext.gpuFrameTimeMs is updated a frame or two behind via asynchronous readback. The value is an instrumented GPU interval: it includes every command recorded for the frame plus the opening and closing one-workgroup marker dispatches. It is not CPU/wall-clock time and should not be treated as a marker-free pass duration.

    Implementation: the timer module is dynamic-imported on the first enable, so engines that never call this ship none of it. Once loaded, three tiny per-frame hooks are installed on the engine; while timing is off they are undefined and renderFrame only optional-chains them (a no-op short-circuit), so scenes that never enable timing pay effectively nothing. The opening/closing timestamps are written into the frame's command encoder so the GPU runs them contiguously around that frame's passes. The first enable takes effect a microtask later (the GPU resources are created lazily, then reused); subsequent toggles are synchronous.

    Parameters

    Returns void