diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 6f3deba0c..2e0531263 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -299,10 +299,15 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components) ++sRawImageCount; } -LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components) +LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_copy) : LLImageBase(), mCacheEntries(0) { - if(allocateDataSize(width, height, components) && data) + + if(no_copy) + { + setDataAndSize(data, width, height, components); + } + else if(allocateDataSize(width, height, components) && data) { memcpy(getData(), data, width*height*components); } @@ -762,8 +767,17 @@ void LLImageRaw::fill( const LLColor4U& color ) } } +LLPointer LLImageRaw::duplicate() +{ + if(getNumRefs() < 2) + { + return this; //nobody else refences to this image, no need to duplicate. + } - + //make a duplicate + LLPointer dup = new LLImageRaw(getData(), getWidth(), getHeight(), getComponents()); + return dup; +} // Src and dst can be any size. Src and dst can each have 3 or 4 components. void LLImageRaw::copy(LLImageRaw* src) diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 012031338..1e94f49f4 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -173,7 +173,7 @@ protected: public: LLImageRaw(); LLImageRaw(U16 width, U16 height, S8 components); - LLImageRaw(U8 *data, U16 width, U16 height, S8 components); + LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_copy = false); LLImageRaw(LLImageRaw const* src, U16 width, U16 height, U16 crop_offset, bool crop_vertically); // Construct using createFromFile (used by tools) //LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only = false); @@ -204,6 +204,9 @@ public: // Copy operations + //duplicate this raw image if refCount > 1. + LLPointer duplicate(); + // Src and dst can be any size. Src and dst can each have 3 or 4 components. void copy( LLImageRaw* src ); diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp index e8f3fafbe..b88da4041 100644 --- a/indra/newview/lldynamictexture.cpp +++ b/indra/newview/lldynamictexture.cpp @@ -131,7 +131,7 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth) llassert(mFullHeight <= 512); llassert(mFullWidth <= 512); - if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete()) + if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI) { //using offscreen render target, just use the bottom left corner mOrigin.set(0, 0); } @@ -218,13 +218,12 @@ BOOL LLViewerDynamicTexture::updateAllInstances() return TRUE; } -#if 0 //THIS CAUSES MAINT-1092 - bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete(); + bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI; + if (use_fbo) { gPipeline.mWaterDis.bindTarget(); } -#endif LLGLSLShader::bindNoShader(); LLVertexBuffer::unbind(); @@ -259,12 +258,10 @@ BOOL LLViewerDynamicTexture::updateAllInstances() } } -#if 0 //THIS CAUSES MAINT-1092 if (use_fbo) { gPipeline.mWaterDis.flush(); } -#endif return ret; } diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index f8e0f43ee..d14a47fa9 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -1208,7 +1208,12 @@ void LLViewerFetchedTexture::addToCreateTexture() destroyRawImage(); return ; } - mRawImage->scale(w >> i, h >> i) ; + + { + //make a duplicate in case somebody else is using this raw image + mRawImage = mRawImage->duplicate(); + mRawImage->scale(w >> i, h >> i) ; + } } } } @@ -2540,7 +2545,11 @@ void LLViewerFetchedTexture::setCachedRawImage() mIsRawImageValid = 0; return; } - mRawImage->scale(w >> i, h >> i) ; + { + //make a duplicate in case somebody else is using this raw image + mRawImage = mRawImage->duplicate(); + mRawImage->scale(w >> i, h >> i) ; + } } if(mCachedRawImage.notNull()) mCachedRawImage->setInCache(false);