diff options
author | Todd Stinson <stinson@lindenlab.com> | 2011-12-13 11:15:18 -0800 |
---|---|---|
committer | Todd Stinson <stinson@lindenlab.com> | 2011-12-13 11:15:18 -0800 |
commit | 9d1db4f19ae7ca044e47d0fe4e605e14882351c5 (patch) | |
tree | 2d499d53b60b2486f1e6666f8b9fe2063f984d22 /indra/llrender/llrendertarget.cpp | |
parent | 817c97c2f836948f210599a6f67e36a411b22c21 (diff) | |
parent | dbc91a7fac9513bdd879c5c2dc82208e08eaad2d (diff) |
Pull and merge from https://bitbucket.org/lindenlab/viewer-development.
Diffstat (limited to 'indra/llrender/llrendertarget.cpp')
-rw-r--r-- | indra/llrender/llrendertarget.cpp | 112 |
1 files changed, 37 insertions, 75 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 8c0d3592df..1aa12614ea 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -31,8 +31,7 @@ #include "llgl.h" LLRenderTarget* LLRenderTarget::sBoundTarget = NULL; - - +U32 LLRenderTarget::sBytesAllocated = 0; void check_framebuffer_status() { @@ -62,8 +61,7 @@ LLRenderTarget::LLRenderTarget() : mStencil(0), mUseDepth(false), mRenderDepth(false), - mUsage(LLTexUnit::TT_TEXTURE), - mSamples(0) + mUsage(LLTexUnit::TT_TEXTURE) { } @@ -84,20 +82,6 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, boo mStencil = stencil; mUsage = usage; mUseDepth = depth; - mSamples = samples; - - mSamples = gGLManager.getNumFBOFSAASamples(mSamples); - - if (mSamples > 1 && gGLManager.mHasTextureMultisample) - { - mUsage = LLTexUnit::TT_MULTISAMPLE_TEXTURE; - //no support for multisampled stencil targets yet - mStencil = false; - } - else - { - mSamples = 0; - } if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) { @@ -157,21 +141,6 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) stop_glerror(); -#ifdef GL_ARB_texture_multisample - if (mSamples > 1) - { - clear_glerror(); - glTexImage2DMultisample(LLTexUnit::getInternalType(mUsage), mSamples, color_fmt, mResX, mResY, GL_TRUE); - if (glGetError() != GL_NO_ERROR) - { - llwarns << "Could not allocate multisample color buffer for render target." << llendl; - return false; - } - } - else -#else - llassert_always(mSamples <= 1); -#endif { clear_glerror(); LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL); @@ -182,32 +151,32 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt) } } + sBytesAllocated += mResX*mResY*4; + stop_glerror(); - if (mSamples == 0) - { - if (offset == 0) - { //use bilinear filtering on single texture render targets that aren't multisampled - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - stop_glerror(); - } - else - { //don't filter data attachments - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - stop_glerror(); - } + + if (offset == 0) + { //use bilinear filtering on single texture render targets that aren't multisampled + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + stop_glerror(); + } + else + { //don't filter data attachments + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + stop_glerror(); + } - if (mUsage != LLTexUnit::TT_RECT_TEXTURE) - { - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR); - stop_glerror(); - } - else - { - // ATI doesn't support mirrored repeat for rectangular textures. - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - } + if (mUsage != LLTexUnit::TT_RECT_TEXTURE) + { + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_MIRROR); + stop_glerror(); + } + else + { + // ATI doesn't support mirrored repeat for rectangular textures. + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); } if (mFBO) @@ -250,26 +219,16 @@ bool LLRenderTarget::allocateDepth() { LLImageGL::generateTextures(1, &mDepth); gGL.getTexUnit(0)->bindManual(mUsage, mDepth); - if (mSamples == 0) - { - U32 internal_type = LLTexUnit::getInternalType(mUsage); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - stop_glerror(); - clear_glerror(); - LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT32, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - } -#ifdef GL_ARB_texture_multisample - else - { - stop_glerror(); - clear_glerror(); - glTexImage2DMultisample(LLTexUnit::getInternalType(mUsage), mSamples, GL_DEPTH_COMPONENT32, mResX, mResY, GL_TRUE); - } -#else - llassert_always(mSamples <= 1); -#endif + + U32 internal_type = LLTexUnit::getInternalType(mUsage); + stop_glerror(); + clear_glerror(); + LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } + sBytesAllocated += mResX*mResY*4; + if (glGetError() != GL_NO_ERROR) { llwarns << "Unable to allocate depth buffer for render target." << llendl; @@ -339,14 +298,16 @@ void LLRenderTarget::release() stop_glerror(); } mDepth = 0; + + sBytesAllocated -= mResX*mResY*4; } else if (mUseDepth && mFBO) { //detach shared depth buffer glBindFramebuffer(GL_FRAMEBUFFER, mFBO); if (mStencil) { //attached as a renderbuffer - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); mStencil = false; } else @@ -364,6 +325,7 @@ void LLRenderTarget::release() if (mTex.size() > 0) { + sBytesAllocated -= mResX*mResY*4*mTex.size(); LLImageGL::deleteTextures(mTex.size(), &mTex[0], true); mTex.clear(); } |