diff options
Diffstat (limited to 'indra/llrender/llrendertarget.cpp')
-rw-r--r-- | indra/llrender/llrendertarget.cpp | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index d9520b3bf6..f0df3bcf90 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -61,8 +61,11 @@ BOOL LLRenderTarget::sUseFBO = FALSE; LLRenderTarget::LLRenderTarget() : mResX(0), mResY(0), + mViewportWidth(0), + mViewportHeight(0), mTex(0), mFBO(0), + mColorFmt(0), mDepth(0), mStencil(0), mUseDepth(FALSE), @@ -86,13 +89,31 @@ void LLRenderTarget::setSampleBuffer(LLMultisampleBuffer* buffer) void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, BOOL stencil, LLTexUnit::eTextureType usage, BOOL use_fbo) { + // only reallocate if something changed + if (mResX == resx + && mResY == resy + && mUseDepth == depth + && mStencil == stencil + && mUsage == usage + && (mFBO != 0) == ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) + && mColorFmt == color_fmt) + { + // nothing to do + return; + } + stop_glerror(); mResX = resx; mResY = resy; + // default viewport to entire texture + mViewportWidth = mResX; + mViewportHeight = mResY; mStencil = stencil; mUsage = usage; mUseDepth = depth; + mFBO = 0; + mColorFmt = color_fmt; release(); @@ -312,7 +333,7 @@ void LLRenderTarget::bindTarget() } } - glViewport(0, 0, mResX, mResY); + glViewport(0, 0, mViewportWidth, mViewportHeight); sBoundTarget = this; } @@ -515,12 +536,18 @@ BOOL LLRenderTarget::isComplete() const return (!mTex.empty() || mDepth) ? TRUE : FALSE; } +void LLRenderTarget::setViewport(U32 width, U32 height) +{ + mViewportWidth = llmin(width, mResX); + mViewportHeight = llmin(height, mResY); +} + void LLRenderTarget::getViewport(S32* viewport) { viewport[0] = 0; viewport[1] = 0; - viewport[2] = mResX; - viewport[3] = mResY; + viewport[2] = mViewportWidth; + viewport[3] = mViewportHeight; } //================================================== @@ -581,7 +608,7 @@ void LLMultisampleBuffer::bindTarget(LLRenderTarget* ref) check_framebuffer_status(); - glViewport(0, 0, mResX, mResY); + glViewport(0, 0, mViewportWidth, mViewportHeight); sBoundTarget = this; } @@ -593,13 +620,30 @@ void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth void LLMultisampleBuffer::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, BOOL stencil, LLTexUnit::eTextureType usage, BOOL use_fbo, U32 samples ) { + if (mResX == resx + && mResY == resy + && mUseDepth == depth + && mStencil == stencil + && mUsage == usage + && (mFBO != 0) == ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) + && mColorFmt == color_fmt + && mSamples == samples) + { + // nothing to do + return; + } + stop_glerror(); mResX = resx; mResY = resy; + mViewportWidth = mResX; + mViewportHeight = mResY; mUsage = usage; mUseDepth = depth; mStencil = stencil; + mFBO = 0; + mColorFmt = color_fmt; releaseSampleBuffer(); |