mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-09-23 10:54:43 +00:00
Fix MSAA blit into a multisampled destination and stale MSAA resolve. (#3921)
This commit is contained in:
committed by
GitHub
parent
dd961560d5
commit
780f7bf00a
@@ -7605,6 +7605,51 @@ namespace bgfx { namespace gl
|
||||
return true;
|
||||
}
|
||||
|
||||
static void resolveMsaaRbo(const TextureGL& _src, GLuint _currentFbo)
|
||||
{
|
||||
if (0 == _src.m_rbo
|
||||
|| NULL == glBlitFramebuffer
|
||||
|| bimg::isDepth(bimg::TextureFormat::Enum(_src.m_textureFormat) ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GLuint fbo[2];
|
||||
GL_CHECK(glGenFramebuffers(BX_COUNTOF(fbo), fbo) );
|
||||
|
||||
GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo[0]) );
|
||||
GL_CHECK(glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER
|
||||
, GL_COLOR_ATTACHMENT0
|
||||
, GL_RENDERBUFFER
|
||||
, _src.m_rbo
|
||||
) );
|
||||
|
||||
GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo[1]) );
|
||||
GL_CHECK(glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER
|
||||
, GL_COLOR_ATTACHMENT0
|
||||
, _src.m_target
|
||||
, _src.m_id
|
||||
, 0
|
||||
) );
|
||||
|
||||
GL_CHECK(glDisable(GL_SCISSOR_TEST) );
|
||||
GL_CHECK(glBlitFramebuffer(
|
||||
0
|
||||
, 0
|
||||
, _src.m_width
|
||||
, _src.m_height
|
||||
, 0
|
||||
, 0
|
||||
, _src.m_width
|
||||
, _src.m_height
|
||||
, GL_COLOR_BUFFER_BIT
|
||||
, GL_NEAREST
|
||||
) );
|
||||
|
||||
GL_CHECK(glDeleteFramebuffers(BX_COUNTOF(fbo), fbo) );
|
||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, _currentFbo) );
|
||||
}
|
||||
|
||||
static bool blitCompressed2D(
|
||||
const BlitItem& _bi
|
||||
, const TextureGL& _src
|
||||
@@ -7742,13 +7787,21 @@ namespace bgfx { namespace gl
|
||||
continue;
|
||||
}
|
||||
|
||||
const bool srcReadsMsaaRbo = 0 != src.m_rbo && dst.isMsaaSurface();
|
||||
|
||||
if (!srcReadsMsaaRbo
|
||||
&& 0 == bi.m_srcMip)
|
||||
{
|
||||
resolveMsaaRbo(src, m_currentFbo);
|
||||
}
|
||||
|
||||
GL_CHECK(glCopyImageSubData(
|
||||
src.m_id
|
||||
, src.m_target
|
||||
, bi.m_srcMip
|
||||
srcReadsMsaaRbo ? src.m_rbo : src.m_id
|
||||
, srcReadsMsaaRbo ? GL_RENDERBUFFER : src.m_target
|
||||
, srcReadsMsaaRbo ? 0 : bi.m_srcMip
|
||||
, bi.m_srcX
|
||||
, bi.m_srcY
|
||||
, bi.m_srcZ
|
||||
, srcReadsMsaaRbo ? 0 : bi.m_srcZ
|
||||
, dst.m_id
|
||||
, dst.m_target
|
||||
, bi.m_dstMip
|
||||
@@ -7774,6 +7827,11 @@ namespace bgfx { namespace gl
|
||||
, "Blitting 3D regions is not supported"
|
||||
);
|
||||
|
||||
if (0 == bi.m_srcMip)
|
||||
{
|
||||
resolveMsaaRbo(src, m_currentFbo);
|
||||
}
|
||||
|
||||
GLuint fbo;
|
||||
GL_CHECK(glGenFramebuffers(1, &fbo) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user