diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index c07b3591f13f29cb941b5b2a614ee1c99ac864a4..88c48e51660b80ee53bc67a04889e2600cb69306 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -373,33 +373,31 @@ void LLRenderTarget::release() glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); } - if (mFBO) - { - // Detach any extra color buffers (e.g. SRGB spec buffers) - // - if (mTex.size() > 1) - { - glBindFramebuffer(GL_FRAMEBUFFER, mFBO); - S32 z; - for (z = mTex.size() - 1; z >= 1; z--) - { - sBytesAllocated -= mResX * mResY * 4; - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + z, LLTexUnit::getInternalType(mUsage), 0, 0); - LLImageGL::deleteTextures(1, &mTex[z]); - } - glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); - } - - if (mFBO == sCurFBO) - { - sCurFBO = 0; - glBindFramebuffer(GL_FRAMEBUFFER, 0); - } - - { - glDeleteFramebuffers(1, (GLuint*)&mFBO); - mFBO = 0; - } + // Detach any extra color buffers (e.g. SRGB spec buffers) + // + if (mFBO && (mTex.size() > 1)) + { + glBindFramebuffer(GL_FRAMEBUFFER, mFBO); + S32 z; + for (z = mTex.size() - 1; z >= 1; z--) + { + sBytesAllocated -= mResX*mResY*4; + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+z, LLTexUnit::getInternalType(mUsage), 0, 0); + LLImageGL::deleteTextures(1, &mTex[z]); + } + glBindFramebuffer(GL_FRAMEBUFFER, sCurFBO); + } + + if (mFBO) + { + if (mFBO == sCurFBO) + { + sCurFBO = 0; + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } + + glDeleteFramebuffers(1, (GLuint *) &mFBO); + mFBO = 0; } if (mTex.size() > 0)