Search Unity

Question Random spikes

Discussion in 'VR' started by Max-om, Dec 21, 2022.

  1. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Hey guys. We have random spikes in our StreamVR game. I cant for the life of me find out why, it never occurs on the same spot in the scene so its not scene related it seems. Our scripts takes almost nothing so its not that

    upload_2022-12-21_12-20-1.png


    Hardware:
    AMD 5950x
    Nvidia 3090 drivers: 526.98
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,063
    The highlighted frames GPU seems to take up the most. Can be anything from drivers, to nvidia settings, etc
    If it's not noticable in-game I wouldn't worry too much about it
     
  3. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    It's any thing from a slight lag to a spike with reprojection :/
     
  4. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    I have read there are problems with 30xx series and VR, maybe that's what I am experiencing?
     
  5. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    In the upper left you can enable the gpu profiler module - it might give you some more details on what's going on.
     
  6. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Looks broken? Says 14.080 ms is spent in Device.Present but if I expand that node the children says 0? Does this tell you anything?

    upload_2022-12-22_20-14-18.png
     
  7. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    What it's doing during that time period is blitting eye texture to the main window (the one that shows up on your 2d monitor), and presenting that. It's strange to me that that's stalling at all - it's like vsync is on.. the syncing should be coming from steamvr not d3d present. What render pipeline are you using? can you try to disable vsync somehow (should automatically be disabled when VR is on but maybe there is a bug)? can you repro this in an empty project?
     
  8. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Is your monitor refresh rate 120hz (looks ~8ms in above image)? another thing to try to confirm/disprove vsync suspicion is switch your monitor to 60hz and see if the device.present time grows.
     
  9. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    My main monitor is a 144hz screen. And the valve Index runs in 90hz. The spikes magnitude is pretty much random. It doesn't seem to be tied to a fixed refresh rate.

    Edit: i will try to see if I can repro.
     
  10. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Here is a example of a less severe lag

    upload_2022-12-22_21-5-1.png

    And here is another example of a more severe lag

    upload_2022-12-22_21-6-41.png

    This is with 144hz display rate on main monitor. Will try to lower refrshrate now.
     
  11. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Here with my monitor at 60hz

    upload_2022-12-22_21-10-24.png
     
  12. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    We are on built in forward rendering
     
  13. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Same thing in an empty project with onlyxr and steamvr xr plugin

    upload_2022-12-22_21-18-52.png

    edit: by mistake did this in 2021 LTS while our game for now uses 2020 LTS
     
  14. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    The highest I'm seeing for Device.Present is 1.5ms , usually < .7ms on OpenXR plugin. I'll try with SteamVR plugin in a bit.
     

    Attached Files:

  15. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    With steamVR I was able to reproduce high Device.Present times, like you're seeing (~27ms in my case). I used the superluminal profiler to see what's happening deeper in those cases - it turns out it's related to capturing the extra GPU profiler data (d3d timer queries) - steam VR adds a bunch of these so I think that's why it's looking worse on steamVR vs other runtimes.

    When the profiler isn't attached, superluminal capture looks good.

    Perhaps it's a red herring then?
     

    Attached Files:

  16. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    Thanks for taking your time. Thing is if i just run the game without profiling i get these spikes to, i can both see them in. SteamVR frametime window in headset and I can observe the actual lag.
     
  17. Max-om

    Max-om

    Joined:
    Aug 9, 2017
    Posts:
    499
    I recorded this little demo without profiling, though recording with OBS which skews the result a little bit.



    You can see both pink spikes (reprojection) and the smaller yellow spikes thats just a smal lag but still noticble.

    edit: Funny enough my benchmarking thats going on in the background (this is a precorded path) does not notice a big impact on the perf, though I do remove the top and min 1% frames from the result and those spikes are probably not in the statstics because of that

    With OBS:
    Highest Frametime: 2.7177
    Lowest Frametime: 1.3324
    Avg framerate: 1.832094

    Without OBS:
    Highest Frametime: 2.6185
    Lowest Frametime: 1.2623
    Avg framerate: 1.75618

    Though I must give you guys credit that GFX jobs finally does a difference, above is with gfx jobs and below without. A 10% increase in perf!

    Without OBS and without GFX jobs:
    Highest Frametime: 2.8731
    Lowest Frametime: 1.3738
    Avg framerate: 1.937669
     
    Last edited: Dec 23, 2022