Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

VR Major VR Performance Issue: OculusWaitForGPU running on CPU?

Discussion in '5.1 Beta' started by vvander, May 26, 2015.

  1. vvander

    vvander

    Joined:
    Jan 18, 2011
    Posts:
    72
    Anyone else having serious performance problems with VR enabled? I'm seeing 500+ fps in a pretty basic scene without VR, but I'm only getting 10 fps with VR enabled - both in the editor and a build. Profiler is pegging the issue as "OculusWaitForGPU" and it's showing up under the CPU instead of the GPU. I think the only way this makes sense is if VR mode somehow is swapping all the rendering to the CPU instead. Or maybe something completely different is going on and I'm an idiot. It's a distinct possibility.

    I submitted a bug report (699605), but I would be surprised if I was the first to encounter this since it's happening on both of my machines with very different specs.

    Admittedly, this is on 5.1.0.f1 and not f2, but I'm downloading it right now to see. Given the fairly small release notes for this version my guess is that it will still be an issue. I remember it happening before the RC cycle started up, too, but I haven't had a chance to document it until now.
     
    Last edited: May 27, 2015
    JonDadley likes this.
  2. JonDadley

    JonDadley

    Joined:
    Sep 2, 2013
    Posts:
    139
    I've also been noticing some major performance issues with VR. As you've noted, I have scenes that run at +150fps with VR disabled. As soon as I enable VR it drops to around 39fps. I'm also seeing OculusWaitForGPU taking a lot of time on the profiler.

    I've noticed other VR performance issues - another scene runs at +1000fps without VR enabled. If I enable VR in the editor it keeps a high frame rate and is very smooth when viewed in the HMD. However, when I build this scene and run the build, it is extremely 'juddery' in the HMD. It's quite sickening.

    I've also seen weird differences between direct and extended mode when testing VR scenes (documented here).

    Unfortunately these issues are making the native VR unusable for me at the moment which is a shame because, apart from the performance bugs, it is excellent. Really hoping these issues get patched quickly after 5.1 is released.
     
  3. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    OculusWaitForGPU is happening on the CPU. The CPU is not continuing because it is waiting for the GPU to return. If every frame on the GPU is taking longer than expected, you will see OculusWaitForGPU taking up a large amount of time. When running in the Editor, the GPU takes time to render all of the Editor windows as well as the game scene. To get the most accurate profiling results in the Editor, make sure that you have Maximize on play turned on for the Game view. This will prevent the rendering of all other editor windows and show a more accurate GPU time for your scene.
     
    Datadazer, yoyyoffg and Psyco92 like this.
  4. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I'm getting terrible results with 5.1.0f2 as well. I've got a scene that runs 400 fps normally but I'm lucky to get 40 or 50 on the Rift. It's not even usable now.

    With version 0f1 Unity stats show a solid 79 or 80 with Rift as expected with VSynch (probably should be 75?), but in forward rendering mode the right eye flickers like crazy showing only part of the scene most of the time. Left eye flickers occasionally too but it's not nearly as bad there. In deferred mode (maybe linear too, but with the flickering it's hard to tell) the head tracking stutters like crazy. In both versions the Rift is unusable in my application.
     
    Last edited: May 28, 2015
  5. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    What is taking up the most time on your CPU and GPU? Are you also seeing OculusWaitForGPU taking up a majority of the CPU time?
     
  6. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Yeah, it's the same thing vvander reported, but not as severe in my case. 62.4% OculusWaitForGPU (7.3ms) versus 21.9% Camera Render (2.56ms). There are spikes that go much higher than that (~75% 18ms) OculusWaitForGPU.

    Just now when I ran it in 0f2 to get these numbers, it ran at 75-80 fps. I'm not sure what the numbers were when it was only running 40-50 fps earlier. I have not seen it go clear down to 10 fps like vvander though.

    Head tracking stutters: I have a sneaking suspicion that the little stutters in head tracking are coming from those spikes up to ~18ms in the OculusWaitForGPU. The stutters look identical to what you get when the frame rate drops to 37 very briefly. If I had to guess I'd say the long pauses during those spikes are goofing up the time warping so you see the display jump and then snap back when your head is panning. Don't really know though.
     
  7. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Here's a grab. Full size version here: http://www.performancesimulations.com/wp/wp-content/uploads/2015/05/profiler1.png




    Ignore the huge plateau in the beginning, that's caused by something dumb I do with particles at the beginning of the scene that I need to fix yet.

    The rest of the graph where the values are lower with periodic spikes is more typical. Take away the spikes and that data point shown here would be a normal frame. I'm not sure if the head tracking stutters correspond to the spikes because I can't watch the Rift and the profiler at the same time.

    Anyway, most of the time indeed is spent in that OculusWaitForGPU function which is taking two or three times as long as the rendering in a "no spike" case. I saw that in 0f1 too, so I don't know that this is really new to 0f2.
     
  8. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Come to think of it, somewhere in the middle of all this I deleted a bunch of thick grass. I might have done that when the 0f2 results were really slow which would explain why I'm back up to 75-80 fps on that last test. 0f1 didn't have problems running it with the thick grass (aside from the head tracking stutters and spikes), but 0f2 couldn't handle it.
     
  9. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    It sounds like your GPU is taking up most of the time. So, the CPU is waiting for the GPU to return, but this is taking ~6.5ms each frame. What does your GPU usage look like?
     
  10. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Which info are you asking for, exactly? The rendering section with batches and SetPass calls and so forth?

    If memory serves me correctly, batches during these tests were in the neighborhood of 800-1000 with about 100 saved by batching. If you want something else, let me know what data and where to find it and I'll try this again.
     
  11. vvander

    vvander

    Joined:
    Jan 18, 2011
    Posts:
    72
    I apologize for the late response, I've been on vacation. Thanks for this explanation, that definitely makes more sense than CPU rendering while in VR mode. Don't have my DK2 to test right now, but my suspicion is that the maximize on play option will only help a little. I am also experiencing the stutter that Todd mentioned, but it's hard to say if that's a framerate issue since I can't even get high enough fps in an empty scene with just a cube to even test it comfortably - regardless of whether it's in the editor or a build.

    The last thing I tested before the vacation was whether f2 was going to help or not, and I can echo Todd's report that it does not at all. My expectations were that the fps would drop to 25% of non-VR mode at the max (~50% for 2x rendering with some extra headroom for the Oculus SDK), but I couldn't even achieve that low benchmark. It's not just unusable for an end user, it's impossible to develop with the VR performance as it is for me right now (hence the vacation).

    If UT wants to release 5.1 soon, you're going to have to fix this issue or push native VR to 5.2 :-/ Total showstopper for VR dev at the moment.

    I'm happy to provide any additional info you guys need to fix this - just let me know.
     
  12. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    I've also had the flickering (mostly one eye) going on really badly. The Rift isn't usable really with f1 or f2 for me because of it.
     
  13. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    @Todd Wasson @vvander

    I think I have failed to fully explain how OculusWaitForGPU works, so here is another shot.

    When Profiling Applications that use Oculus Native VR, you will see OculusWaitForGPU in the CPU Usage tab. This function call can take up anywhere from 100% of your CPU time to 0% of your CPU time. The amount of time that it takes on the CPU depends on the total time the current scene spends in both the CPU and GPU combined.

    With Oculus VR, your application will always be set to render at 75fps. Meaning that you have ~13.3ms per frame to spend between the CPU and the GPU. However, if in a single frame, you take more or less than 13.3ms, you will have to wait for the next opportunity. This is where OculusWaitForGPU gets involved.

    OculusWaitForGPU is called once we finish work on the CPU and we are now waiting for the GPU to do it's work. So, OculusWaitForGPU, should be at least the same amount of time as the GPU Usage, but it will be more if we have finished all of our CPU and GPU work for the frame and we still have to wait until 13.3 total ms have passed in the frame.

    If we miss the draw at 13.3ms, we have to wait until the next opportunity to draw 13.3ms later. So if your frame takes a total of 16.5ms spending 10ms on the CPU and 6.5ms on the GPU, we won't draw until 26.6ms have passed and OculusWaitForGPU will be 16.6ms. So if each frame of the game misses the draw window, we will end up with ~37fps.

    So when looking at your application and trying to see what is the cause of less than 75fps in VR mode, you need to look at both the CPU usage in the profiler and the GPU usage in the profiler. If you are in the Editor you should also toggle the Profiler editor option to see how much time the Editor is spending on the CPU and GPU each frame. As this small amount of time could cause your application to miss the draw window in the Editor, but standalone builds would make the window.

    If you are unsure what I mean by any of this information, please message me and I will break it down as best as I can. Also to enable the GPU usage tab in the Profiler, use the Add Profiler->GPU button.
     
    Alverik, Psyco92, VirtualDawn and 4 others like this.
  14. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    That makes sense, Ed. Thanks for the excellent explanation.

    I'm in the middle of other stuff right now, but when I get time to run the Rift again on it, I'll report GPU info as you've described.