Search Unity

Bug URP VR stutters due to large time spent in DXGI.WaitOnSwapChain and Gfx.WaitForRenderThread.

Discussion in 'Editor & General Support' started by Liam2349, Nov 4, 2022.

  1. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    80
    Unity Version: 2021.3.11f1
    VR Settings: Single Pass Instanced, OpenXR, Deferred renderer.
    Hardware: i7-8700k, 1080Ti, Vive 2016.
    Platform: Windows 10 21H2

    Hi, I am getting some stutters in my game. I connected the profiler to a build to investigate. The screenshots are in order.

    First, you can see that the CPU graph hovers around 90FPS, as my HMD is 90Hz. However, there are spikes above this. When investigating one of these spikes, I see that the excess time is spent in DXGI.WaitOnSwapChain.

    I have 11.11ms to make frame rate, and the frame took 15.29ms, with 4.16ms spent in DXGI.WaitOnSwapChain. 11.11 + 4.16 = 15.27. So from my perspective, the CPU is waiting, for some reason, causing a stutter. According to MSI Afterburner and the RivaTuner overlay, GPU usage is 40 to 70%, so should not be bottlenecking. VRAM usage is 9 of 11GB.

    Is this because the CPU was slightly too slow? If so, why wait specifically 4.16ms extra?

    I then disabled graphics jobs so that I could use the GPU profiler, and tested another spike. Now I see time spent in Gfx.WaitForRenderThread, and we can see that the GPU finishes its work in time.

    Draw calls (batches) can be up to 2700 with 3.8M triangles.

    I am unsure whether this is a bug or something I misunderstand. I've read about issues with URP VR performance but I think that was specifically for Quest.
     

    Attached Files:

    thisismyweakarm likes this.
  2. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    80
    I just tested another spike - here you can see the CPU took 12.11ms, with 4.14ms spent in DXGI.WaitOnSwapChain. 12.11 - 4.14 = 7.97ms, well within the 11.11ms budget - but this additional wait causes a stutter, apparently for no reason?
     

    Attached Files:

  3. georgestpds

    georgestpds

    Joined:
    Jun 29, 2021
    Posts:
    6
    I have the same issue in Built-In RP, not VR.
    When in the Editor everything's fine, but when I build the game the CPU is overworking and the profiler shows DXGI.WaitOnSwapChain as taking all the processing power...

    If anyone could help that would be great
     
  4. zwave00

    zwave00

    Joined:
    Jan 28, 2023
    Posts:
    3
    Did you find the fix on this? Been working for the past week and can't find a solution anywhere