summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2013-09-11 20:40:11 -0700
committerGraham Linden <graham@lindenlab.com>2013-09-11 20:40:11 -0700
commit63757692b60362cd55919edb142d132d5b26fe12 (patch)
tree44beb606e7898ce37668a68b5545c97bf4dcc572 /indra
parente8bd9afbe6fab36bb7016cee8c3f3a745e9bd02d (diff)
NORSPEC-362 Fix leak of deferred color attachments
Diffstat (limited to 'indra')
-rwxr-xr-xindra/llrender/llrendertarget.cpp52
1 files changed, 36 insertions, 16 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index ed9134c938..c0602d79bd 100755
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -364,36 +364,56 @@ void LLRenderTarget::release()
sBytesAllocated -= mResX*mResY*4;
}
- else if (mUseDepth && mFBO)
- { //detach shared depth buffer
+ else if (mFBO)
+ {
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
- if (mStencil)
- { //attached as a renderbuffer
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
- mStencil = false;
+
+ if (mUseDepth)
+ { //detach shared depth buffer
+ if (mStencil)
+ { //attached as a renderbuffer
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
+ mStencil = false;
+ }
+ else
+ { //attached as a texture
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), 0, 0);
+ }
+ mUseDepth = false;
}
- else
- { //attached as a texture
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), 0, 0);
+ }
+
+ // Detach any extra color buffers (e.g. SRGB spec buffers)
+ //
+ if (mFBO && (mTex.size() > 1))
+ {
+ 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);
+ stop_glerror();
+ LLImageGL::deleteTextures(mUsage, mInternalFormat[z], 0, 1, &mTex[z], true);
}
- mUseDepth = false;
}
if (mFBO)
{
glDeleteFramebuffers(1, (GLuint *) &mFBO);
+ stop_glerror();
mFBO = 0;
}
if (mTex.size() > 0)
{
- sBytesAllocated -= mResX*mResY*4*mTex.size();
- LLImageGL::deleteTextures(mUsage, mInternalFormat[0], 0, mTex.size(), &mTex[0], true);
- mTex.clear();
- mInternalFormat.clear();
+ sBytesAllocated -= mResX*mResY*4;
+ LLImageGL::deleteTextures(mUsage, mInternalFormat[0], 0, 1, &mTex[0], true);
}
-
+
+ mTex.clear();
+ mInternalFormat.clear();
+
mResX = mResY = 0;
sBoundTarget = NULL;