Skip to content

Commit

Permalink
Fix opengl OVR texture lifetime issues
Browse files Browse the repository at this point in the history
Clear mirror and eye textures of OVRRenderI at startup
instead of in the individual renderer interfaces
  • Loading branch information
mendsley committed Sep 16, 2016
1 parent 37f00de commit fd6ed06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/hmd_ovr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
{
}
Expand Down
6 changes: 0 additions & 6 deletions src/renderer_d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/renderer_d3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) );
Expand Down

0 comments on commit fd6ed06

Please sign in to comment.