VR: Add device resolution to HMD. Init at startup.

BREAKING: bgfx::getHMD() now returns a valid pointer
if the VR runtime was initialized. This is different
from existing behavior where getHMD returned NULL until
a bgfx::reset(... BGFX_RESET_HMD) was issued. Applications
must now check HMD::flags for the current state of the VR
runtime. The following code has the code change required:

`const bgfx::HMD* hmd = bgfx::getHMD()
if (NULL != hmd)`
becomes:
`const bgfx::HMD* hmd = bgfx::getHMD()
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDRERING))
{
	// rendering logic
}`

See the updated examples for details.

This allows applications to create the appropriately
sized back buffer for the HMD device by using the new device
resolution fields HMD::deviceHeight and HMD::deviceWidth.
These values report the pixel resolution of the attached
HMD hardware.

This also allows applications to query the reported HMD
resolution immediately after bgfx::init. This prevents
the device from being cycled which generates rendring
artifacts on startup - namely flashing back to a black
screen and reseting the Health+Warning disaply.

This involves initialization the ovrHmd device on
initialization, but deferring rendering until
postReset has been called. This adds an addiional
memory overhead of 32k to builds defining BGFX_CONFIG_USE_OVR.
The overhead for current builds is ~1.9MB for calls to
ovr_Initialize, so the additional overhead is pretty
trivial (+1.8%)
This commit is contained in:
Matthew Endsley
2015-06-02 17:00:36 -07:00
parent ce3eded6a3
commit 1e604e8f38
19 changed files with 88 additions and 63 deletions

View File

@@ -195,7 +195,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
// Set view and projection matrix for view 0.
const bgfx::HMD* hmd = bgfx::getHMD();
if (NULL != hmd)
if (NULL != hmd && 0 != (hmd->flags & BGFX_HMD_RENDERING))
{
float view[16];
bx::mtxQuatTranslationHMD(view, hmd->eye[0].rotation, eye);