summaryrefslogtreecommitdiff
path: root/indra/llrender/llrendertarget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llrendertarget.cpp')
-rwxr-xr-xindra/llrender/llrendertarget.cpp64
1 files changed, 24 insertions, 40 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index c0602d79bd..d7f141bd92 100755
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -262,7 +262,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
}
#endif
-
+
return true;
}
@@ -364,56 +364,36 @@ void LLRenderTarget::release()
sBytesAllocated -= mResX*mResY*4;
}
- else if (mFBO)
- {
+ else if (mUseDepth && mFBO)
+ { //detach shared depth buffer
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
-
- 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;
+ 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;
}
- }
-
- // 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);
+ else
+ { //attached as a texture
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, LLTexUnit::getInternalType(mUsage), 0, 0);
}
+ mUseDepth = false;
}
if (mFBO)
{
glDeleteFramebuffers(1, (GLuint *) &mFBO);
- stop_glerror();
mFBO = 0;
}
if (mTex.size() > 0)
{
- sBytesAllocated -= mResX*mResY*4;
- LLImageGL::deleteTextures(mUsage, mInternalFormat[0], 0, 1, &mTex[0], true);
+ sBytesAllocated -= mResX*mResY*4*mTex.size();
+ LLImageGL::deleteTextures(mUsage, mInternalFormat[0], 0, mTex.size(), &mTex[0], true);
+ mTex.clear();
+ mInternalFormat.clear();
}
-
- mTex.clear();
- mInternalFormat.clear();
-
+
mResX = mResY = 0;
sBoundTarget = NULL;
@@ -495,6 +475,12 @@ U32 LLRenderTarget::getTexture(U32 attachment) const
return mTex[attachment];
}
+U32 LLRenderTarget::getNumTextures() const
+{
+ return mTex.size();
+}
+
+
void LLRenderTarget::bindTexture(U32 index, S32 channel)
{
gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index));
@@ -597,10 +583,8 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0
{
if (!source.mFBO)
{
- llwarns << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
- return;
+ llerrs << "Cannot copy framebuffer contents for non FBO render targets." << llendl;
}
-
{
GLboolean write_depth = mask & GL_DEPTH_BUFFER_BIT ? TRUE : FALSE;