Search Unity

GPU Frame Timing on IOS/Android 2019

Discussion in 'AR/VR (XR) Discussion' started by FrankvHoof, May 13, 2019.

  1. FrankvHoof

    FrankvHoof

    Joined:
    Nov 3, 2014
    Posts:
    104
    I'm trying to implement Dynamic Resolution Scaling using XRSettings.renderViewportScale to get a smoother framerate on a cardboard-enabled project in Unity 2019.1.0f2.

    However, I'm not getting any GPU-Timings.
    Tried:
    - XRStats.gpuTimeLastFrame (deprecated, returns 0)
    - XRStats.TryGetGPUTimeLastFrame (returns 0)
    - FrameTimingManager.GetGpuTimerFrequency (returns 0)
    - FrameTimingManager.GetLatestTimings() (returns 0)
    - XRDevice.refreshRate (returns screen refresh-rate, not current speed/fps).

    I've tried this in builds on both Vulkan and OpenGL 3, on a Mali GPU (Oppo F7), and an Adreno one (Galaxy S8), but I'm not getting ANY results anywhere..
    Is this a bug in Unity 2019? The docs clearly state that the FrameTimingManager should be working for Android (Vulkan) and IOS (Metal) right now.
     
  2. florianpenzkofer

    florianpenzkofer

    Unity Technologies

    Joined:
    Sep 2, 2014
    Posts:
    195
    The Vulkan implementation of FrameTimingManager is known to be broken. Sorry for this.
    The issue (1152859) is not in the public issue tracker yet. We have a fix ready and we will backport to 2019.1 once QA confirms that it's affected.

    We currently don't support OpenGL ES for dynamic resolution.
    We are probably going to ship an OpenGL ES implementation of FramerTimingManager, but there are no plans for complete support of dynamic resolution (changing framebuffer resolution is expensive with OpenGL ES).
     
  3. FrankvHoof

    FrankvHoof

    Joined:
    Nov 3, 2014
    Posts:
    104
    I'm not actually looking to change the framebuffer resolution, just the section of the buffer that's used (which is why I'm looking at XRSettings.renderViewportScale https://docs.unity3d.com/ScriptReference/XR.XRSettings-renderViewportScale.html )..
    Currently, my CPU-frame is taking about 5-8 ms.
    However, my GPU (on the Oppo) is taking anywhere from 16.5 to 18ms (narrowly missing VSync, thereby limiting to 30fps). I have narrowed this down to fill-rate, but since I have near-zero overdraw (I'm rendering 1000's of quads using ECS), I'm looking at scaling down the resolution just a tiny bit, in order to cut my render-time by just enough so that I can stay at 60fps throughout.
    As the GPU differs per device, I'm trying to implement a system which can scale from 0.7 (for a poor device) to about 1.4 (for e.g. an IPhone X). In order to do this, I'd need the GPU-Timings to check how close I am to getting that <16ms render, to prevent the VSync.

    As Vulkan isn't currently supported with XR, and OpenGL doesn't have FrameTimingManager, is there any way I can get the duration for Rendering? (Aside from strictly relying on FPS-count?)
     
  4. FrankvHoof

    FrankvHoof

    Joined:
    Nov 3, 2014
    Posts:
    104
unityunity