Skip to content

Commit

Permalink
GL: Recreate VAO on swap chain switch. Fixed issue #209.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Feb 2, 2024
1 parent d9e1845 commit 6286da0
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,7 @@ namespace bgfx { namespace gl
if (m_vaoSupport)
{
GL_CHECK(glGenVertexArrays(1, &m_vao) );
GL_CHECK(glBindVertexArray(m_vao) );
}

m_samplerObjectSupport = false
Expand Down Expand Up @@ -3659,13 +3660,9 @@ namespace bgfx { namespace gl
void submitBlit(BlitState& _bs, uint16_t _view);

void submit(Frame* _render, ClearQuad& _clearQuad, TextVideoMemBlitter& _textVideoMemBlitter) override;

void blitSetup(TextVideoMemBlitter& _blitter) override
{
if (0 != m_vao)
{
GL_CHECK(glBindVertexArray(m_vao) );
}

uint32_t width = m_resolution.width;
uint32_t height = m_resolution.height;

Expand Down Expand Up @@ -3842,6 +3839,13 @@ namespace bgfx { namespace gl
}
}

if (0 != m_vao)
{
GL_CHECK(glDeleteVertexArrays(1, &m_vao) );
GL_CHECK(glGenVertexArrays(1, &m_vao) );
GL_CHECK(glBindVertexArray(m_vao) );
}

if (m_srgbWriteControlSupport)
{
if (0 == m_currentFbo)
Expand Down Expand Up @@ -4543,10 +4547,9 @@ namespace bgfx { namespace gl
}
else
{
const GLuint defaultVao = m_vao;
if (0 != defaultVao)
if (0 != m_vao)
{
GL_CHECK(glBindVertexArray(defaultVao) );
GL_CHECK(glBindVertexArray(m_vao) );
}

GL_CHECK(glDisable(GL_SCISSOR_TEST) );
Expand Down Expand Up @@ -7456,19 +7459,9 @@ namespace bgfx { namespace gl

BGFX_GL_PROFILER_BEGIN_LITERAL("rendererSubmit", kColorView);

if (1 < m_numWindows
&& m_vaoSupport)
if (0 != m_vao)
{
m_vaoSupport = false;
GL_CHECK(glBindVertexArray(0) );
GL_CHECK(glDeleteVertexArrays(1, &m_vao) );
m_vao = 0;
}

const GLuint defaultVao = m_vao;
if (0 != defaultVao)
{
GL_CHECK(glBindVertexArray(defaultVao) );
GL_CHECK(glBindVertexArray(m_vao) );
}

GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_backBufferFbo) );
Expand Down Expand Up @@ -8556,11 +8549,6 @@ namespace bgfx { namespace gl

blitMsaaFbo();

if (m_vaoSupport)
{
GL_CHECK(glBindVertexArray(m_vao) );
}

if (0 < _render->m_numRenderItems)
{
if (0 != (m_resolution.reset & BGFX_RESET_FLUSH_AFTER_RENDER) )
Expand Down Expand Up @@ -8818,6 +8806,11 @@ namespace bgfx { namespace gl

BGFX_GL_PROFILER_END();
}

if (0 != m_vao)
{
GL_CHECK(glBindVertexArray(0) );
}
}
} } // namespace bgfx

Expand Down

0 comments on commit 6286da0

Please sign in to comment.