From 654aead8a1014d095331986a32690920b6d8464a Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Wed, 9 Aug 2017 18:19:28 +0300 Subject: SL-684 Improve cache version guard --- indra/newview/lltexturecache.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'indra/newview/lltexturecache.cpp') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index a541273621..5561fddb9d 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -31,6 +31,7 @@ #include "llapr.h" #include "lldir.h" #include "llimage.h" +#include "llimagej2c.h" // for version control #include "lllfsthread.h" #include "llviewercontrol.h" @@ -938,6 +939,14 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id) F32 LLTextureCache::sHeaderCacheVersion = 1.7f; U32 LLTextureCache::sCacheMaxEntries = 1024 * 1024; //~1 million textures. S64 LLTextureCache::sCacheMaxTexturesSize = 0; // no limit +std::string LLTextureCache::sHeaderCacheEncoderVersion = LLImageJ2C::getEngineInfo(); + +#if defined(ADDRESS_SIZE) +U32 LLTextureCache::sHeaderCacheAddressSize = ADDRESS_SIZE; +#else +U32 LLTextureCache::sHeaderCacheAddressSize = 32; +#endif + const char* entries_filename = "texture.entries"; const char* cache_filename = "texture.cache"; const char* old_textures_dirname = "textures"; @@ -1080,12 +1089,28 @@ void LLTextureCache::readEntriesHeader() } else //create an empty entries header. { - mHeaderEntriesInfo.mVersion = sHeaderCacheVersion ; - mHeaderEntriesInfo.mEntries = 0 ; + setEntriesHeader(); writeEntriesHeader() ; } } +void LLTextureCache::setEntriesHeader() +{ + if (sHeaderEncoderStringSize < sHeaderCacheEncoderVersion.size() + 1) + { + // For simplicity we use predefined size of header, so if version string + // doesn't fit, either getEngineInfo() returned malformed string or + // sHeaderEncoderStringSize need to be increased. + // Also take into accout that c_str() returns additional null character + LL_ERRS() << "Version string doesn't fit in header" << LL_ENDL; + } + + mHeaderEntriesInfo.mVersion = sHeaderCacheVersion; + mHeaderEntriesInfo.mAdressSize = sHeaderCacheAddressSize; + strcpy(mHeaderEntriesInfo.mEncoderVersion, sHeaderCacheEncoderVersion.c_str()); + mHeaderEntriesInfo.mEntries = 0; +} + void LLTextureCache::writeEntriesHeader() { llassert_always(mHeaderAPRFile == NULL); @@ -1439,7 +1464,9 @@ void LLTextureCache::readHeaderCache() readEntriesHeader(); - if (mHeaderEntriesInfo.mVersion != sHeaderCacheVersion) + if (mHeaderEntriesInfo.mVersion != sHeaderCacheVersion + || mHeaderEntriesInfo.mAdressSize != sHeaderCacheAddressSize + || strcmp(mHeaderEntriesInfo.mEncoderVersion, sHeaderCacheEncoderVersion.c_str()) != 0) { if (!mReadOnly) { @@ -1601,8 +1628,7 @@ void LLTextureCache::purgeAllTextures(bool purge_directories) mUpdatedEntryMap.clear(); // Info with 0 entries - mHeaderEntriesInfo.mVersion = sHeaderCacheVersion; - mHeaderEntriesInfo.mEntries = 0; + setEntriesHeader(); writeEntriesHeader(); LL_INFOS() << "The entire texture cache is cleared." << LL_ENDL ; -- cgit v1.2.3 From d290f2c512a3bdbb526fc0fc00e17a9c8bdc0693 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 21 Aug 2017 17:41:41 +0300 Subject: BUG-134134 Additional logging --- indra/newview/lltexturecache.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/lltexturecache.cpp') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 5561fddb9d..8b90a0a737 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1470,6 +1470,7 @@ void LLTextureCache::readHeaderCache() { if (!mReadOnly) { + LL_INFOS() << "Texture Cache version mismatch, Purging." << LL_ENDL; purgeAllTextures(false); } } -- cgit v1.2.3 From a0b57c0cd7621fa8575d8f05eaa958323aa106fc Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 29 Aug 2017 16:45:29 +0300 Subject: SL-776 Disk cache purge not purging headers if headers are corrupt or on version mismatch --- indra/newview/lltexturecache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lltexturecache.cpp') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 8b90a0a737..e8b3842ae5 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1615,9 +1615,9 @@ void LLTextureCache::purgeAllTextures(bool purge_directories) gDirUtilp->deleteFilesInDir(dirname, mask); } } + gDirUtilp->deleteFilesInDir(mTexturesDirName, mask); // headers, fast cache if (purge_directories) { - gDirUtilp->deleteFilesInDir(mTexturesDirName, mask); LLFile::rmdir(mTexturesDirName); } } -- cgit v1.2.3 From 6dcde6469d03b96260b1d00c22a90d76357a28ae Mon Sep 17 00:00:00 2001 From: ruslantproductengine Date: Tue, 6 Jun 2017 15:30:03 +0300 Subject: [SL-711] - Eliminate some overheads in texturecache. - Eliminate memory overhead when need duplicated scaled image. - Small improvement in LLImageBase::getCodecFromExtension() --- indra/newview/lltexturecache.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'indra/newview/lltexturecache.cpp') diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index e8b3842ae5..f0c28041d1 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1987,15 +1987,13 @@ bool LLTextureCache::writeToFastCache(S32 id, LLPointer raw, S32 dis if(w * h *c > 0) //valid { //make a duplicate to keep the original raw image untouched. - raw = raw->duplicate(); + raw = raw->scaled(w, h); if (raw->isBufferInvalid()) { LL_WARNS() << "Invalid image duplicate buffer" << LL_ENDL; return false; } - raw->scale(w, h) ; - discardlevel += i ; } } -- cgit v1.2.3