From 2d1c2987ece31aa24aab62a5775240a5039a285c Mon Sep 17 00:00:00 2001 From: Dario Manesku Date: Fri, 11 May 2018 07:09:24 +0200 Subject: [PATCH] Minor fixes. (#1390) * Moved greedy generic release(Ty) below release(const Memory*). * OGL: Resolve all color attachments, not only the first one. --- src/bgfx_p.h | 18 +++++++------- src/renderer_gl.cpp | 58 ++++++++++++++++++++++++++++----------------- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 6a6e31d61..9f8fb6c76 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -454,6 +454,15 @@ namespace bgfx } }; + void setGraphicsDebuggerPresent(bool _present); + bool isGraphicsDebuggerPresent(); + void release(const Memory* _mem); + const char* getAttribName(Attrib::Enum _attr); + void getTextureSizeFromRatio(BackbufferRatio::Enum _ratio, uint16_t& _width, uint16_t& _height); + TextureFormat::Enum getViableTextureFormat(const bimg::ImageContainer& _imageContainer); + const char* getName(TextureFormat::Enum _fmt); + const char* getName(UniformHandle _handle); + template inline void release(Ty) { @@ -465,15 +474,6 @@ namespace bgfx release( (const Memory*)_mem); } - void setGraphicsDebuggerPresent(bool _present); - bool isGraphicsDebuggerPresent(); - void release(const Memory* _mem); - const char* getAttribName(Attrib::Enum _attr); - void getTextureSizeFromRatio(BackbufferRatio::Enum _ratio, uint16_t& _width, uint16_t& _height); - TextureFormat::Enum getViableTextureFormat(const bimg::ImageContainer& _imageContainer); - const char* getName(TextureFormat::Enum _fmt); - const char* getName(UniformHandle _handle); - inline uint32_t castfu(float _value) { union { float fl; uint32_t ui; } un; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index a7f25edd0..0b8eed2e1 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -6343,36 +6343,50 @@ BX_TRACE("%d, %d, %d, %s", _array, _srgb, _mipAutogen, getName(_format) ); { if (0 != m_fbo[1]) { - GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo[0]) ); - GL_CHECK(glReadBuffer(GL_COLOR_ATTACHMENT0) ); - GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo[1]) ); - GL_CHECK(glBlitFramebuffer(0 - , 0 - , m_width - , m_height - , 0 - , 0 - , m_width - , m_height - , GL_COLOR_BUFFER_BIT - , GL_LINEAR - ) ); - GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo[0]) ); - GL_CHECK(glReadBuffer(GL_NONE) ); - GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, s_renderGL->m_msaaBackBufferFbo) ); - } - - if (0 < m_numTh) - { + uint32_t colorIdx = 0; for (uint32_t ii = 0; ii < m_numTh; ++ii) { TextureHandle handle = m_attachment[ii].handle; if (isValid(handle) ) { const TextureGL& texture = s_renderGL->m_textures[handle.idx]; - texture.resolve(); + + bimg::TextureFormat::Enum format = bimg::TextureFormat::Enum(texture.m_textureFormat); + if (!bimg::isDepth(format) ) + { + GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo[0]) ); + GL_CHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo[1]) ); + GL_CHECK(glReadBuffer(GL_COLOR_ATTACHMENT0 + colorIdx) ); + GL_CHECK(glDrawBuffer(GL_COLOR_ATTACHMENT0 + colorIdx) ); + colorIdx++; + GL_CHECK(glBlitFramebuffer(0 + , 0 + , m_width + , m_height + , 0 + , 0 + , m_width + , m_height + , GL_COLOR_BUFFER_BIT + , GL_LINEAR + ) ); + } } } + + GL_CHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo[0]) ); + GL_CHECK(glReadBuffer(GL_NONE) ); + GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, s_renderGL->m_msaaBackBufferFbo) ); + } + + for (uint32_t ii = 0; ii < m_numTh; ++ii) + { + TextureHandle handle = m_attachment[ii].handle; + if (isValid(handle) ) + { + const TextureGL& texture = s_renderGL->m_textures[handle.idx]; + texture.resolve(); + } } }