Blender Git Loki

Git Commits -> Revision b961b3f

Revision b961b3f by Julian Eisel (temp-vr-draw-thread)
July 30, 2019, 11:28 (GMT)
Initial, mostly broken VR viewport drawing on own thread

Spawns a separate thread to do any VR session drawing on. There are
four reasons for this:
* VR session doesn't need the usual main loop procedure for drawing.
With the drawing on a separate thread, the session doesn't have the
overhead of the other parts of the main loop.
* OpenXR performs thread blocking operations to synchronize rendering
with the device refresh rate. This would conflict with the rest of
Blender, causing lags on event handling, drawing, etc.
* With an own thread, we can keep a single OpenGL context alive,
avoiding expensive context switches. This should improve performance
significantly.
* With a bit more work, viewports can draw entirely in parallel (at
least the CPU side of it), pushing performance even further.

Drawing the viewport on a separate thread shouldn't be much of an
issue. The draw-manager is already thread safe (mutex guarded). Not much
seems needed to get it entirely concurrent, allowing viewport drawing
from separate threads without any synchronization (i.e. only one at a
time).
I had to create an own depsgraph for the VR draw thread so the viewport
gets its own buffers for its own OpenGL context.

Right now this is utterly broken, but at least an empty viewport is
drawn for the VR session in a separate thread. Issues are:
* VR viewport doesn't draw any objects, just background + overlays
(apparently the VR session depsgraph isn't built correctly).
* OpenGL context of the main thread seems messed up when drawing the VR
view. Result is drawing glitches and eventually Blender crashes.
* Exiting the VR session causes failed assertions and memory leaks.

Commit Details:

Full Hash: b961b3f0c91ac091f0d74b24f75f48f62b039f11
Parent Commit: 091cc94
Lines Changed: +128, -48

10 Modified Paths:

/intern/ghost/GHOST_C-api.h (+2, -1) (Diff)
/intern/ghost/GHOST_IXrContext.h (+1, -0) (Diff)
/intern/ghost/intern/GHOST_C-api.cpp (+7, -0) (Diff)
/intern/ghost/intern/GHOST_XrContext.cpp (+5, -0) (Diff)
/intern/ghost/intern/GHOST_XrContext.h (+1, -0) (Diff)
/source/blender/draw/intern/draw_manager.c (+1, -1) (Diff)
/source/blender/gpu/intern/gpu_viewport.c (+0, -3) (Diff)
/source/blender/windowmanager/intern/wm_draw.c (+21, -27) (Diff)
/source/blender/windowmanager/intern/wm_surface.c (+7, -5) (Diff)
/source/blender/windowmanager/intern/wm_xr.c (+83, -11) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021