[GL] Fix sRGB framebuffer write (#3032)

This commit is contained in:
Christophe Dehais 2023-02-02 18:16:32 +01:00 committed by GitHub
parent 10ec8e8882
commit cd3a1ea7f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 12 deletions

View File

@ -3821,18 +3821,6 @@ namespace bgfx { namespace gl
m_needPresent |= true;
m_currentFbo = m_msaaBackBufferFbo;
if (m_srgbWriteControlSupport)
{
if (0 != (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER) )
{
GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB) );
}
else
{
GL_CHECK(glDisable(GL_FRAMEBUFFER_SRGB) );
}
}
}
else
{
@ -3853,6 +3841,26 @@ namespace bgfx { namespace gl
}
}
if (m_srgbWriteControlSupport)
{
if (0 == m_currentFbo)
{
if (0 != (m_resolution.reset & BGFX_RESET_SRGB_BACKBUFFER) )
{
GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB) );
}
else
{
GL_CHECK(glDisable(GL_FRAMEBUFFER_SRGB) );
}
}
else
{
// actual sRGB write/blending determined by FBO's color attachments format
GL_CHECK(glEnable(GL_FRAMEBUFFER_SRGB) );
}
}
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_currentFbo) );
m_fbh = _fbh;
@ -8579,6 +8587,12 @@ namespace bgfx { namespace gl
profiler.end();
}
if (m_srgbWriteControlSupport)
{
// switch state back to default for cases when the on-screen draw is done externally
GL_CHECK(glDisable(GL_FRAMEBUFFER_SRGB) );
}
}
BGFX_GL_PROFILER_END();