diff --git a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp index 6e7381193..80fdbe9af 100644 --- a/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp +++ b/3rdparty/glsl-optimizer/src/glsl/standalone_scaffolding.cpp @@ -44,13 +44,13 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, } void -_mesa_shader_debug(struct gl_context *, GLenum, GLuint *id, +_mesa_shader_debug(struct gl_context *, GLenum, GLuint *, const char *, int) { } extern "C" void -_mesa_error_no_memory(const char *caller) +_mesa_error_no_memory(const char *) { } diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 5b3941d80..e11d6aac6 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -118,6 +118,7 @@ namespace entry { entry::Key::F3, entry::Modifier::None, 1, cmd, "graphics wireframe" }, { entry::Key::F4, entry::Modifier::None, 1, cmd, "graphics hmd" }, { entry::Key::F4, entry::Modifier::LeftShift, 1, cmd, "graphics hmdrecenter" }, + { entry::Key::F4, entry::Modifier::LeftCtrl, 1, cmd, "graphics hmddbg" }, { entry::Key::F7, entry::Modifier::None, 1, cmd, "graphics vsync" }, { entry::Key::F8, entry::Modifier::None, 1, cmd, "graphics msaa" }, { entry::Key::Print, entry::Modifier::None, 1, cmd, "graphics screenshot" }, diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index 49f1eb514..543100be6 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -157,7 +157,11 @@ struct Input void removeBindings(const char* _name) { - m_inputBindingsMap.erase(m_inputBindingsMap.find(_name)); + InputBindingMap::iterator it = m_inputBindingsMap.find(_name); + if (it != m_inputBindingsMap.end() ) + { + m_inputBindingsMap.erase(it); + } } void process(const InputBinding* _bindings) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index da52055b8..9de97a3d9 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -2223,7 +2223,12 @@ namespace bgfx && BGFX_CHUNK_MAGIC_FSH != magic && BGFX_CHUNK_MAGIC_VSH != magic) { - BX_WARN(false, "Invalid shader signature! 0x%08x.", magic); + BX_WARN(false, "Invalid shader signature! %c%c%c%d." + , ( (uint8_t*)&magic)[0] + , ( (uint8_t*)&magic)[1] + , ( (uint8_t*)&magic)[2] + , ( (uint8_t*)&magic)[3] + ); ShaderHandle invalid = BGFX_INVALID_HANDLE; return invalid; } diff --git a/src/ovr.cpp b/src/ovr.cpp index 52255fb38..f70f3e5d0 100644 --- a/src/ovr.cpp +++ b/src/ovr.cpp @@ -12,6 +12,7 @@ namespace bgfx OVR::OVR() : m_hmd(NULL) , m_initialized(false) + , m_debug(false) { } @@ -39,6 +40,46 @@ namespace bgfx return false; } + if (_debug) + { + switch (_config->Header.API) + { +#if BGFX_CONFIG_RENDERER_DIRECT3D9 + case ovrRenderAPI_D3D9: + { + ovrD3D9ConfigData* data = (ovrD3D9ConfigData*)_config; + m_rtSize = data->Header.RTSize; + } + break; +#endif // BGFX_CONFIG_RENDERER_DIRECT3D9 + +#if BGFX_CONFIG_RENDERER_DIRECT3D11 + case ovrRenderAPI_D3D11: + { + ovrD3D11ConfigData* data = (ovrD3D11ConfigData*)_config; + m_rtSize = data->Header.RTSize; + } + break; +#endif // BGFX_CONFIG_RENDERER_DIRECT3D11 + +#if BGFX_CONFIG_RENDERER_OPENGL + case ovrRenderAPI_OpenGL: + { + ovrGLConfigData* data = (ovrGLConfigData*)_config; + m_rtSize = data->Header.RTSize; + } + break; +#endif // BGFX_CONFIG_RENDERER_OPENGL + + default: + BX_CHECK(false, "You should not be here!"); + break; + } + + m_debug = true; + return false; + } + if (!_debug) { m_hmd = ovrHmd_Create(0); @@ -67,6 +108,7 @@ namespace bgfx | ovrDistortionCap_Vignette | ovrDistortionCap_TimeWarp | ovrDistortionCap_Overdrive + | ovrDistortionCap_NoRestore , eyeFov , m_erd ); @@ -135,6 +177,8 @@ ovrError: ovrHmd_Destroy(m_hmd); m_hmd = NULL; } + + m_debug = false; } bool OVR::swap() @@ -197,15 +241,32 @@ ovrError: eye.pixelsPerTanAngle[0] = erd.PixelsPerTanAngleAtCenter.x; eye.pixelsPerTanAngle[1] = erd.PixelsPerTanAngleAtCenter.y; } - - _hmd.width = uint16_t(m_rtSize.w); - _hmd.height = uint16_t(m_rtSize.h); } else { - _hmd.width = 0; - _hmd.height = 0; + for (int ii = 0; ii < 2; ++ii) + { + _hmd.eye[ii].rotation[0] = 0.0f; + _hmd.eye[ii].rotation[1] = 0.0f; + _hmd.eye[ii].rotation[2] = 0.0f; + _hmd.eye[ii].rotation[3] = 1.0f; + _hmd.eye[ii].translation[0] = 0.0f; + _hmd.eye[ii].translation[1] = 0.0f; + _hmd.eye[ii].translation[2] = 0.0f; + _hmd.eye[ii].fov[0] = 1.32928634f; + _hmd.eye[ii].fov[1] = 1.32928634f; + _hmd.eye[ii].fov[2] = 0 == ii ? 1.05865765f : 1.09236801f; + _hmd.eye[ii].fov[3] = 0 == ii ? 1.09236801f : 1.05865765f; + _hmd.eye[ii].viewOffset[0] = 0 == ii ? 0.0355070010f : -0.0375000015f; + _hmd.eye[ii].viewOffset[1] = 0.0f; + _hmd.eye[ii].viewOffset[2] = 0 == ii ? 0.00150949787f : -0.00150949787f; + _hmd.eye[ii].pixelsPerTanAngle[0] = 1; + _hmd.eye[ii].pixelsPerTanAngle[1] = 1; + } } + + _hmd.width = uint16_t(m_rtSize.w); + _hmd.height = uint16_t(m_rtSize.h); } } // namespace bgfx diff --git a/src/ovr.h b/src/ovr.h index 5fc18ef6c..e08da30f1 100644 --- a/src/ovr.h +++ b/src/ovr.h @@ -44,6 +44,11 @@ namespace bgfx return NULL != m_hmd; } + bool isDebug() const + { + return m_debug; + } + void init(); void shutdown(); @@ -68,6 +73,7 @@ namespace bgfx ovrSizei m_rtSize; bool m_warning; bool m_initialized; + bool m_debug; }; } // namespace bgfx @@ -104,6 +110,11 @@ namespace bgfx return false; } + bool isDebug() const + { + return false; + } + bool swap() { return false; diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 288dfcdbc..e935f8c45 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1833,9 +1833,9 @@ RENDERDOC_IMPORT void ovrPreReset() { #if BGFX_CONFIG_USE_OVR + m_ovr.preReset(); if (NULL != m_ovrRtv) { - m_ovr.preReset(); std::swap(m_ovrRtv, m_backBufferColor); std::swap(m_ovrDsv, m_backBufferDepthStencil); BX_CHECK(NULL == m_backBufferDepthStencil, ""); @@ -2952,7 +2952,7 @@ RENDERDOC_IMPORT Matrix4* mtxView[2] = { _render->m_view, mtxViewTmp[1] }; Matrix4 mtxViewProj[2][BGFX_CONFIG_MAX_VIEWS]; - const bool hmdEnabled = m_ovr.isEnabled(); + const bool hmdEnabled = m_ovr.isEnabled() || m_ovr.isDebug(); _render->m_hmdEnabled = hmdEnabled; if (hmdEnabled) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index d988eeea1..ae9bae096 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2017,9 +2017,9 @@ namespace bgfx void ovrPreReset() { #if BGFX_CONFIG_USE_OVR + m_ovr.preReset(); if (m_ovr.isEnabled() ) { - m_ovr.preReset(); GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0) ); GL_CHECK(glDeleteFramebuffers(1, &m_msaaBackBufferFbo) ); m_msaaBackBufferFbo = m_ovrFbo; @@ -4121,7 +4121,7 @@ namespace bgfx Matrix4* mtxView[2] = { _render->m_view, mtxViewTmp[1] }; Matrix4 mtxViewProj[2][BGFX_CONFIG_MAX_VIEWS]; - const bool hmdEnabled = m_ovr.isEnabled(); + const bool hmdEnabled = m_ovr.isEnabled() || m_ovr.isDebug(); _render->m_hmdEnabled = hmdEnabled; if (hmdEnabled)