05-11-2022 03:04 AM - edited 05-11-2022 04:21 AM
I'm trying to implement Unity's Dynamic Resolution as a quick fix for the remaining GPU-bound scenarios in our game, but I'm running into the issue that I can't seem to get the last GPU frametime no matter what API I use. Neither FrameTimingManager.GetLatestTimings, XRStats.TryGetGPUTimeLastFrame, nor XRDisplaySubsystem.TryGetAppGPUTimeLastFrame seem to work on my Quest 2 (but do in-editor via Link). What is the preferred method to get the GPU frametime on Quest?
To clarify, the game is using Vulkan and the VRAPI (not OpenXR).
10-17-2022 10:25 AM
I'm having this exact issue. Did you ever find a solution? I've tried no less than 6 different API calls to try and get this information, yet they all fail or return 0.
10-18-2022 01:27 AM - edited 10-18-2022 01:27 AM
I got it.
You need this in your Start/Awake function (or whenever you want to start tracking the GPU App time)
void OnEnable()
{
Unity.XR.Oculus.Stats.PerfMetrics.EnablePerfMetrics(true);
}
void OnDisable()
{
Unity.XR.Oculus.Stats.PerfMetrics.EnablePerfMetrics(false);
}
Then, in your Update...
float appGPUTime = Unity.XR.Oculus.Stats.PerfMetrics.AppGPUTime;
That got it for me.
Hope that helps!