VR: Fix big performance bottleneck for simple scenes

Blender's main loop puts the main thread to sleep for 5ms if no user input was
received from the OS. We never want that to happen while the VR session is
running, which runs on the main thread too.

For simpler scenes, where the viewport already draws fast, this may have quite
some impact. E.g. in my tests, the classroom scene went from ~55 to quite
stable 90 FPS in solid mode (total render time as measured and averaged by
Windows Mixed Reality utilities). With Eevee, it only went from 41 to 47 FPS.
In complex files, there's barely a difference. E.g. less than 1 FPS increase in
a Spring file (both Solid mode and Eevee).
This commit is contained in:
Julian Eisel 2020-05-24 17:26:31 +02:00
parent 8e4c74292a
commit 6b8555e01c
1 changed files with 6 additions and 1 deletions

View File

@ -126,7 +126,12 @@ void wm_xr_exit(wmWindowManager *wm)
bool wm_xr_events_handle(wmWindowManager *wm)
{
if (wm->xr.runtime && wm->xr.runtime->context) {
return GHOST_XrEventsHandle(wm->xr.runtime->context);
GHOST_XrEventsHandle(wm->xr.runtime->context);
/* wm_window_process_events() uses the return value to determine if it can put the main thread
* to sleep for some milliseconds. We never want that to happen while the VR session runs on
* the main thread. So always return true. */
return true;
}
return false;
}