From fd6ed06968f6ed24fc57f929a7d47b3d06fed126 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Fri, 16 Sep 2016 14:58:43 -0700 Subject: [PATCH] Fix opengl OVR texture lifetime issues Clear mirror and eye textures of OVRRenderI at startup instead of in the individual renderer interfaces --- src/hmd_ovr.h | 7 +++++++ src/renderer_d3d11.cpp | 6 ------ src/renderer_d3d11.h | 1 - src/renderer_gl.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hmd_ovr.h b/src/hmd_ovr.h index 9184713e0..eb275c4ea 100644 --- a/src/hmd_ovr.h +++ b/src/hmd_ovr.h @@ -30,6 +30,7 @@ namespace bgfx // render data for both eyes and mirrored output struct BX_NO_VTABLE OVRRenderI { + OVRRenderI(); virtual ~OVRRenderI() = 0; virtual void create(const ovrSession& _session, int _msaaSamples, int _mirrorWidth, int _mirrorHeight) = 0; virtual void destroy(const ovrSession& _session) = 0; @@ -44,6 +45,12 @@ namespace bgfx ovrMirrorTextureDesc m_mirrorTextureDesc; }; + inline OVRRenderI::OVRRenderI() + : m_mirrorTexture(NULL) + { + memset(&m_textureSwapChain, 0, sizeof(m_textureSwapChain)); + } + inline OVRRenderI::~OVRRenderI() { } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 219bb4210..f1e146328 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -3610,12 +3610,6 @@ BX_PRAGMA_DIAGNOSTIC_POP(); } #if BGFX_CONFIG_USE_OVR - OVRRenderD3D11::OVRRenderD3D11() - { - m_mirrorTexture = NULL; - memset(m_textureSwapChain, 0, sizeof(m_textureSwapChain)); - } - void OVRRenderD3D11::create(const ovrSession& _session, int _msaaSamples, int _mirrorWidth, int _mirrorHeight) { ovrHmdDesc hmdDesc = ovr_GetHmdDesc(_session); diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index 5cf52c710..f929c480e 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -63,7 +63,6 @@ namespace bgfx { namespace d3d11 #if BGFX_CONFIG_USE_OVR struct OVRRenderD3D11 : public OVRRenderI { - OVRRenderD3D11(); virtual void create(const ovrSession& _session, int _msaaSamples, int _mirrorWidth, int _mirrorHeight); virtual void destroy(const ovrSession& _session); virtual void preReset(const ovrSession& _session); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index d85b1bf63..829840ad3 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -3545,7 +3545,7 @@ namespace bgfx { namespace gl ovr_GetTextureSwapChainCurrentIndex(_session, m_textureSwapChain[_eyeIdx], &curIndex); ovr_GetTextureSwapChainBufferGL(_session, m_textureSwapChain[_eyeIdx], curIndex, &m_eyeTexId[_eyeIdx]); - if (0 != m_msaaEyeFbo) + if (0 != m_msaaEyeFbo[_eyeIdx]) { GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_msaaEyeFbo[_eyeIdx]) ); GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, m_msaaEyeTexId[_eyeIdx], 0) );