Initial HMD viewport rendering (DirectX only first)
authorJulian Eisel <eiseljulian@gmail.com>
Mon, 1 Jul 2019 13:57:32 +0000 (15:57 +0200)
committerJulian Eisel <eiseljulian@gmail.com>
Mon, 1 Jul 2019 13:57:32 +0000 (15:57 +0200)
commit2cedad990a975185fc8a24efbd827c7fd93f650d
treea6ab0b702d50adf048d8e295f3bcf2c7b40ce2fd
parent109be29e42bbea92fa1c993833ffd40af75ab8af
Initial HMD viewport rendering (DirectX only first)

Finally: This makes it possible to render a viewport to an HMD via
OpenXR. Pure OpenGL rendering will need some more tweaks to work.
To my great delight, performance is quite good for reasonably sized
scenes.

Had to do some hacks and marked some TODOs. Nothing too bad though.

Here are a couple of notes:
* Current initial pose is pretty useless, think it just looks downwards
  from world origin. Will change that soon.
* The rendered viewport has some issues: Too dark (bad lighting?), grid
  doesn't show up even though I told it to, lighting seems to change with
  view position/rotation, etc. Needs some polish.
* Ideally we'd just use the D3D11 Texture given to us via the OpenXR
  swapchain and blit the OpenGL framebuffer into that. However the
  NV_DX_interop extension fails doing this. Seems like this is a NVidia
  Optimus only issue, but I'm missing the hardware to confirm.
  So instead, we blit into the D3D11 back buffer first and then into the
  Texture.
* The draw-manager uses its own offscreen context so we have to get the
  render result from the draw-manager context to the VR session's
  context first. Luckily I've already added code to support blitting from
  one OpenGL context into another. But it requires blitting twice.
  Blitting should be very cheap, but still...
  Draw-manager could get a context to use passed instead.
20 files changed:
intern/ghost/GHOST_C-api.h
intern/ghost/GHOST_IContext.h
intern/ghost/intern/GHOST_C-api.cpp
intern/ghost/intern/GHOST_Context.cpp
intern/ghost/intern/GHOST_Context.h
intern/ghost/intern/GHOST_ContextD3D.cpp
intern/ghost/intern/GHOST_ContextD3D.h
intern/ghost/intern/GHOST_ContextWGL.cpp
intern/ghost/intern/GHOST_IXrGraphicsBinding.h
intern/ghost/intern/GHOST_SystemWin32.cpp
intern/ghost/intern/GHOST_XrGraphicsBinding.cpp
intern/ghost/intern/GHOST_XrSession.cpp
source/blender/draw/DRW_engine.h
source/blender/draw/intern/draw_manager.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_surface.c
source/blender/windowmanager/intern/wm_xr.c
source/blender/windowmanager/wm_surface.h