Merge git://github.com/AlericInglewood/SingularityViewer

Conflicts:
	indra/cmake/Boost.cmake
This commit is contained in:
Siana Gearz
2011-06-09 15:30:19 +02:00
46 changed files with 855 additions and 883 deletions

View File

@@ -178,6 +178,7 @@
#include "llviewerthrottle.h"
#include "llparcel.h"
#include "lldiriterator.h"
#include "llavatarnamecache.h"
#include "llinventoryview.h"
@@ -2951,8 +2952,10 @@ void LLAppViewer::migrateCacheDirectory()
// Migrate inventory cache to avoid pain to inventory database after mass update
S32 file_count = 0;
std::string file_name;
std::string mask = delimiter + "*.*";
while (gDirUtilp->getNextFileInDir(old_cache_dir, mask, file_name, false))
std::string mask = "*.*";
LLDirIterator iter(old_cache_dir, mask);
while (iter.next(file_name))
{
if (file_name == "." || file_name == "..") continue;
std::string source_path = old_cache_dir + delimiter + file_name;
@@ -2986,6 +2989,44 @@ void LLAppViewer::migrateCacheDirectory()
#endif // LL_WINDOWS || LL_DARWIN
}
void dumpVFSCaches()
{
llinfos << "======= Static VFS ========" << llendl;
gStaticVFS->listFiles();
#if LL_WINDOWS
llinfos << "======= Dumping static VFS to StaticVFSDump ========" << llendl;
WCHAR w_str[MAX_PATH];
GetCurrentDirectory(MAX_PATH, w_str);
S32 res = LLFile::mkdir("StaticVFSDump");
if (res == -1)
{
if (errno != EEXIST)
{
llwarns << "Couldn't create dir StaticVFSDump" << llendl;
}
}
SetCurrentDirectory(utf8str_to_utf16str("StaticVFSDump").c_str());
gStaticVFS->dumpFiles();
SetCurrentDirectory(w_str);
#endif
llinfos << "========= Dynamic VFS ====" << llendl;
gVFS->listFiles();
#if LL_WINDOWS
llinfos << "========= Dumping dynamic VFS to VFSDump ====" << llendl;
res = LLFile::mkdir("VFSDump");
if (res == -1)
{
if (errno != EEXIST)
{
llwarns << "Couldn't create dir VFSDump" << llendl;
}
}
SetCurrentDirectory(utf8str_to_utf16str("VFSDump").c_str());
gVFS->dumpFiles();
SetCurrentDirectory(w_str);
#endif
}
//static
U32 LLAppViewer::getTextureCacheVersion()
{
@@ -3016,11 +3057,12 @@ bool LLAppViewer::initCache()
if (gSavedSettings.getBOOL("PurgeCacheOnStartup") ||
gSavedSettings.getBOOL("PurgeCacheOnNextStartup"))
{
gSavedSettings.setBOOL("PurgeCacheOnNextStartup", false);
mPurgeCache = true;
gSavedSettings.setBOOL("PurgeCacheOnNextStartup", false);
mPurgeCache = true;
// STORM-1141 force purgeAllTextures to get called to prevent a crash here. -brad
texture_cache_mismatch = true;
}
// Bullshit, mPurgeCache already causes the same and doing it twice just leads to loads of warnings. --Aleric
//texture_cache_mismatch = true;
}
// We have moved the location of the cache directory over time.
migrateCacheDirectory();
@@ -3046,38 +3088,53 @@ bool LLAppViewer::initCache()
{
LLSplashScreen::update("Clearing cache...");
purgeCache();
// <edit>
texture_cache_mismatch = false;
// </edit>
}
LLSplashScreen::update("Initializing Texture Cache...");
// Init the texture cache
// Allocate 80% of the cache size for textures
const S32 MB = 1024*1024;
const S32 MB = 1024 * 1024;
const S64 MIN_CACHE_SIZE = 64 * MB;
const S64 MAX_CACHE_SIZE = 9984ll * MB;
const S64 MAX_VFS_SIZE = 1024 * MB; // 1 GB
S64 cache_size = (S64)(gSavedSettings.getU32("CacheSize")) * MB;
const S64 MAX_CACHE_SIZE = 1024*MB;
cache_size = llmin(cache_size, MAX_CACHE_SIZE);
S64 texture_cache_size = ((cache_size * 8)/10);
cache_size = llclamp(cache_size, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
S64 texture_cache_size = ((cache_size * 8) / 10);
S64 vfs_size = cache_size - texture_cache_size;
if (vfs_size > MAX_VFS_SIZE)
{
// Give the texture cache more space, since the VFS can't be bigger than 1GB.
// This happens when the user's CacheSize setting is greater than 5GB.
vfs_size = MAX_VFS_SIZE;
texture_cache_size = cache_size - MAX_VFS_SIZE;
}
S64 extra = LLAppViewer::getTextureCache()->initCache(LL_PATH_CACHE, texture_cache_size, texture_cache_mismatch);
texture_cache_size -= extra;
LLSplashScreen::update("Initializing VFS...");
// Init the VFS
S64 vfs_size = cache_size - texture_cache_size;
const S64 MAX_VFS_SIZE = 1024 * MB; // 1 GB
vfs_size = llmin(vfs_size, MAX_VFS_SIZE);
vfs_size = llmin(vfs_size + extra, MAX_VFS_SIZE);
vfs_size = (vfs_size / MB) * MB; // make sure it is MB aligned
U32 vfs_size_u32 = (U32)vfs_size;
U32 old_vfs_size = gSavedSettings.getU32("VFSOldSize") * MB;
bool resize_vfs = (vfs_size_u32 != old_vfs_size);
if (resize_vfs)
{
gSavedSettings.setU32("VFSOldSize", vfs_size_u32/MB);
gSavedSettings.setU32("VFSOldSize", vfs_size_u32 / MB);
}
LL_INFOS("AppCache") << "VFS CACHE SIZE: " << vfs_size/(1024*1024) << " MB" << LL_ENDL;
LL_INFOS("AppCache") << "VFS CACHE SIZE: " << vfs_size / (1024*1024) << " MB" << LL_ENDL;
// This has to happen BEFORE starting the vfs
//time_t ltime;
// time_t ltime;
srand(time(NULL)); // Flawfinder: ignore
U32 old_salt = gSavedSettings.getU32("VFSSalt");
U32 new_salt;
@@ -3098,10 +3155,10 @@ bool LLAppViewer::initCache()
do
{
new_salt = rand();
} while( new_salt == old_salt );
} while(new_salt == old_salt);
}
old_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_DATA_FILE_BASE) + llformat("%u",old_salt);
old_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_DATA_FILE_BASE) + llformat("%u",old_salt);
// make sure this file exists
llstat s;
@@ -3110,15 +3167,15 @@ bool LLAppViewer::initCache()
{
// doesn't exist, look for a data file
std::string mask;
mask = gDirUtilp->getDirDelimiter();
mask += VFS_DATA_FILE_BASE;
mask = VFS_DATA_FILE_BASE;
mask += "*";
std::string dir;
dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"");
dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
std::string found_file;
if (gDirUtilp->getNextFileInDir(dir, mask, found_file, false))
LLDirIterator iter(dir, mask);
if (iter.next(found_file))
{
old_vfs_data_file = dir + gDirUtilp->getDirDelimiter() + found_file;
@@ -3131,7 +3188,7 @@ bool LLAppViewer::initCache()
}
}
old_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_INDEX_FILE_BASE) + llformat("%u",old_salt);
old_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_INDEX_FILE_BASE) + llformat("%u",old_salt);
stat_result = LLFile::stat(old_vfs_index_file, &s);
if (stat_result)
@@ -3144,27 +3201,25 @@ bool LLAppViewer::initCache()
// Just in case, nuke any other old cache files in the directory.
std::string dir;
dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,"");
dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
std::string mask;
mask = gDirUtilp->getDirDelimiter();
mask += VFS_DATA_FILE_BASE;
mask = VFS_DATA_FILE_BASE;
mask += "*";
gDirUtilp->deleteFilesInDir(dir, mask);
mask = gDirUtilp->getDirDelimiter();
mask += VFS_INDEX_FILE_BASE;
mask = VFS_INDEX_FILE_BASE;
mask += "*";
gDirUtilp->deleteFilesInDir(dir, mask);
}
new_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,VFS_DATA_FILE_BASE) + llformat("%u",new_salt);
new_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_INDEX_FILE_BASE) + llformat("%u",new_salt);
new_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_DATA_FILE_BASE) + llformat("%u", new_salt);
new_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, VFS_INDEX_FILE_BASE) + llformat("%u", new_salt);
static_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"static_data.db2");
static_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"static_index.db2");
static_vfs_data_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "static_data.db2");
static_vfs_index_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "static_index.db2");
if (resize_vfs)
{
@@ -3186,36 +3241,44 @@ bool LLAppViewer::initCache()
gSavedSettings.setU32("VFSSalt", new_salt);
// Don't remove VFS after viewer crashes. If user has corrupt data, they can reinstall. JC
gVFS = new LLVFS(new_vfs_index_file, new_vfs_data_file, false, vfs_size_u32, false);
if( VFSVALID_BAD_CORRUPT == gVFS->getValidState() )
gVFS = LLVFS::createLLVFS(new_vfs_index_file, new_vfs_data_file, false, vfs_size_u32, false);
if (!gVFS)
{
// Try again with fresh files
// (The constructor deletes corrupt files when it finds them.)
LL_WARNS("AppCache") << "VFS corrupt, deleted. Making new VFS." << LL_ENDL;
delete gVFS;
gVFS = new LLVFS(new_vfs_index_file, new_vfs_data_file, false, vfs_size_u32, false);
return false;
}
gStaticVFS = new LLVFS(static_vfs_index_file, static_vfs_data_file, true, 0, false);
gStaticVFS = LLVFS::createLLVFS(static_vfs_index_file, static_vfs_data_file, true, 0, false);
if (!gStaticVFS)
{
return false;
}
BOOL success = gVFS->isValid() && gStaticVFS->isValid();
if( !success )
if (!success)
{
return false;
}
else
{
LLVFile::initClass();
#ifndef LL_RELEASE_FOR_DOWNLOAD
if (gSavedSettings.getBOOL("DumpVFSCaches"))
{
dumpVFSCaches();
}
#endif
return true;
}
}
void LLAppViewer::purgeCache()
{
LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << llendl;
LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << LL_ENDL;
LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE);
std::string mask = gDirUtilp->getDirDelimiter() + "*.*";
gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""),mask);
std::string mask = "*.*";
gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), mask);
}
const std::string& LLAppViewer::getSecondLifeTitle() const