diff options
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
-rw-r--r-- | indra/newview/lltexturecache.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index e5af47ab6c..2e54d3de39 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -39,6 +39,10 @@ #include "llappviewer.h" #include "llmemory.h" +#if LL_WINDOWS +#pragma optimize("", off) +#endif + // Cache organization: // cache/texture.entries // Unordered array of Entry structs @@ -1225,7 +1229,8 @@ S32 LLTextureCache::openAndReadEntry(const LLUUID& id, Entry& entry, bool create { readEntryFromHeaderImmediately(idx, entry) ; } - if(entry.mImageSize <= entry.mBodySize)//it happens on 64-bit systems, do not know why + llassert(entry.mImageSize < 0 || entry.mImageSize > entry.mBodySize); + /*if(entry.mImageSize <= entry.mBodySize)//it happens on 64-bit systems, do not know why { LL_WARNS() << "corrupted entry: " << id << " entry image size: " << entry.mImageSize << " entry body size: " << entry.mBodySize << LL_ENDL ; @@ -1234,7 +1239,7 @@ S32 LLTextureCache::openAndReadEntry(const LLUUID& id, Entry& entry, bool create removeEntry(idx, entry, tex_filename) ; mUpdatedEntryMap.erase(idx) ; idx = -1 ; - } + }*/ } return idx; } @@ -1262,12 +1267,12 @@ void LLTextureCache::writeEntryToHeaderImmediately(S32& idx, Entry& entry, bool { aprfile = openHeaderEntriesFile(false, offset); } + llassert(entry.mImageSize > entry.mBodySize); bytes_written = aprfile->write((void*)&entry, (S32)sizeof(Entry)); if(bytes_written != sizeof(Entry)) { clearCorruptedCache() ; //clear the cache. idx = -1 ;//mark the idx invalid. - return ; } @@ -1314,6 +1319,8 @@ void LLTextureCache::updateEntryTimeStamp(S32 idx, Entry& entry) //update an existing entry, write to header file immediately. bool LLTextureCache::updateEntry(S32& idx, Entry& entry, S32 new_image_size, S32 new_data_size) { + llassert(new_image_size >= new_data_size); + S32 new_body_size = llmax(0, new_data_size - TEXTURE_CACHE_ENTRY_SIZE) ; if(new_image_size == entry.mImageSize && new_body_size == entry.mBodySize) @@ -1402,6 +1409,10 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) } entries.push_back(entry); // LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL; + if(entry.mImageSize < 0) + { + mFreeList.insert(idx); + } if(entry.mImageSize > entry.mBodySize) { mHeaderIDMap[entry.mID] = idx; @@ -1733,28 +1744,27 @@ void LLTextureCache::purgeTextures(bool validate) iter != time_idx_set.end(); ++iter) { S32 idx = iter->second; - bool purge_entry = false; - std::string filename = getTextureFileName(entries[idx].mID); - if (cache_size >= purged_cache_size) - { - purge_entry = true; - } - else if (validate) + bool purge_entry = false; + if (validate) { // make sure file exists and is the correct size U32 uuididx = entries[idx].mID.mData[0]; if (uuididx == validate_idx) { + std::string filename = getTextureFileName(entries[idx].mID); LL_DEBUGS("TextureCache") << "Validating: " << filename << "Size: " << entries[idx].mBodySize << LL_ENDL; S32 bodysize = LLAPRFile::size(filename, getLocalAPRFilePool()); if (bodysize != entries[idx].mBodySize) { - LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mBodySize - << filename << LL_ENDL; + LL_WARNS("TextureCache") << "TEXTURE CACHE BODY HAS BAD SIZE: " << bodysize << " != " << entries[idx].mBodySize << filename << LL_ENDL; purge_entry = true; } } } + else if (cache_size >= purged_cache_size) + { + purge_entry = true; + } else { break; @@ -1763,6 +1773,7 @@ void LLTextureCache::purgeTextures(bool validate) if (purge_entry) { purge_count++; + std::string filename = getTextureFileName(entries[idx].mID); LL_DEBUGS("TextureCache") << "PURGING: " << filename << LL_ENDL; cache_size -= entries[idx].mBodySize; removeEntry(idx, entries[idx], filename) ; @@ -1826,6 +1837,8 @@ S32 LLTextureCache::getHeaderCacheEntry(const LLUUID& id, Entry& entry) // Writes imagesize to the header, updates timestamp S32 LLTextureCache::setHeaderCacheEntry(const LLUUID& id, Entry& entry, S32 imagesize, S32 datasize) { + llassert(imagesize >= datasize); + mHeaderMutex.lock(); S32 idx = openAndReadEntry(id, entry, true); // read or create mHeaderMutex.unlock(); |