From e039d996fdd67c216e7d8e795668fff4df1ac639 Mon Sep 17 00:00:00 2001 From: Patrik Minder Date: Tue, 23 Oct 2018 22:07:01 +0200 Subject: [PATCH] Changed so that isFramebufferFormatValid checks the format even if it is not supported as a normal texture. Changed so that isTextureValid passes check if format is only supported as FrameBuffer and flags match that. (#1530) --- src/bgfx.cpp | 10 +++++++++- src/renderer_gl.cpp | 29 ++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index aacd99f1a..245c35ba4 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -3941,11 +3941,19 @@ namespace bgfx return; } - bool formatSupported = 0 != (g_caps.formats[_format] & (0 + bool formatSupported; + if (0 != (_flags & (BGFX_TEXTURE_RT | BGFX_TEXTURE_RT_WRITE_ONLY)) ) + { + formatSupported = 0 != (g_caps.formats[_format] & BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER); + } + else + { + formatSupported = 0 != (g_caps.formats[_format] & (0 | BGFX_CAPS_FORMAT_TEXTURE_2D | BGFX_CAPS_FORMAT_TEXTURE_2D_EMULATED | BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ) ); + } uint16_t srgbCaps = BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB; if (_cubeMap) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 2e1dc0c40..94d0f3677 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1571,8 +1571,7 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); ? tfi.m_internalFmtSrgb : tfi.m_internalFmt ; - if (GL_ZERO == internalFmt - || !tfi.m_supported) + if (GL_ZERO == internalFmt) { return false; } @@ -5911,11 +5910,27 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); if (0 != texture.m_rbo) { - GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER - , attachment - , GL_RENDERBUFFER - , texture.m_rbo - ) ); +#if !(BGFX_CONFIG_RENDERER_OPENGL >= 30 || BGFX_CONFIG_RENDERER_OPENGLES >= 30) + if (GL_DEPTH_STENCIL_ATTACHMENT == attachment) + { + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER + , GL_DEPTH_ATTACHMENT + , GL_RENDERBUFFER + , texture.m_rbo + ) ); + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER + , GL_STENCIL_ATTACHMENT + , GL_RENDERBUFFER + , texture.m_rbo + ) ); + } + else +#endif + GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER + , attachment + , GL_RENDERBUFFER + , texture.m_rbo + ) ); } else {