Merge branch 'develop' of https://github.com/secondlife/viewer
# Conflicts: # indra/newview/installers/windows/installer_template.nsimaster
commit
a601715860
|
|
@ -995,16 +995,17 @@ bool LLShaderMgr::validateProgramObject(GLuint obj)
|
|||
return success;
|
||||
}
|
||||
|
||||
void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version, const LLUUID& current_cache_version)
|
||||
void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version, const LLUUID& current_cache_version, bool second_instance)
|
||||
{
|
||||
LL_INFOS() << "Initializing shader cache" << LL_ENDL;
|
||||
LL_PROFILE_ZONE_SCOPED;
|
||||
LL_INFOS("ShaderMgr") << "Initializing shader cache" << LL_ENDL;
|
||||
|
||||
mShaderCacheEnabled = gGLManager.mGLVersion >= 4.09 && enabled;
|
||||
|
||||
if(!mShaderCacheEnabled || mShaderCacheInitialized)
|
||||
if(!mShaderCacheEnabled || mShaderCacheVersion.notNull())
|
||||
return;
|
||||
|
||||
mShaderCacheInitialized = true;
|
||||
mShaderCacheVersion = current_cache_version;
|
||||
|
||||
mShaderCacheDir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "shader_cache");
|
||||
LLFile::mkdir(mShaderCacheDir);
|
||||
|
|
@ -1013,16 +1014,19 @@ void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version,
|
|||
std::string meta_out_path = gDirUtilp->add(mShaderCacheDir, "shaderdata.llsd");
|
||||
if (gDirUtilp->fileExists(meta_out_path))
|
||||
{
|
||||
LL_INFOS() << "Loading shader cache metadata" << LL_ENDL;
|
||||
LL_PROFILE_ZONE_NAMED("shader_cache");
|
||||
LL_INFOS("ShaderMgr") << "Loading shader cache metadata" << LL_ENDL;
|
||||
|
||||
llifstream instream(meta_out_path);
|
||||
llifstream instream(meta_out_path, std::ifstream::in | std::ifstream::binary);
|
||||
LLSD in_data;
|
||||
LLSDSerialize::fromNotation(in_data, instream, LLSDSerialize::SIZE_UNLIMITED);
|
||||
// todo: this is likely very expensive to parse, should use binary
|
||||
LLSDSerialize::fromBinary(in_data, instream, LLSDSerialize::SIZE_UNLIMITED);
|
||||
instream.close();
|
||||
|
||||
if (old_cache_version == current_cache_version)
|
||||
if (old_cache_version == current_cache_version
|
||||
&& in_data["version"].asUUID() == current_cache_version)
|
||||
{
|
||||
for (const auto& data_pair : llsd::inMap(in_data))
|
||||
for (const auto& data_pair : llsd::inMap(in_data["shaders"]))
|
||||
{
|
||||
ProgramBinaryData binary_info = ProgramBinaryData();
|
||||
binary_info.mBinaryFormat = data_pair.second["binary_format"].asInteger();
|
||||
|
|
@ -1031,10 +1035,14 @@ void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version,
|
|||
mShaderBinaryCache.insert_or_assign(LLUUID(data_pair.first), binary_info);
|
||||
}
|
||||
}
|
||||
else if (!second_instance)
|
||||
{
|
||||
LL_INFOS("ShaderMgr") << "Shader cache version mismatch detected. Purging." << LL_ENDL;
|
||||
clearShaderCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_INFOS() << "Shader cache version mismatch detected. Purging." << LL_ENDL;
|
||||
clearShaderCache();
|
||||
LL_INFOS("ShaderMgr") << "Shader cache version mismatch detected." << LL_ENDL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1043,7 +1051,7 @@ void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version,
|
|||
void LLShaderMgr::clearShaderCache()
|
||||
{
|
||||
std::string shader_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "shader_cache");
|
||||
LL_INFOS() << "Removing shader cache at " << shader_cache << LL_ENDL;
|
||||
LL_INFOS("ShaderMgr") << "Removing shader cache at " << shader_cache << LL_ENDL;
|
||||
const std::string mask = "*";
|
||||
gDirUtilp->deleteFilesInDir(shader_cache, mask);
|
||||
mShaderBinaryCache.clear();
|
||||
|
|
@ -1052,10 +1060,22 @@ void LLShaderMgr::clearShaderCache()
|
|||
void LLShaderMgr::persistShaderCacheMetadata()
|
||||
{
|
||||
if(!mShaderCacheEnabled) return;
|
||||
if (mShaderCacheVersion.isNull())
|
||||
{
|
||||
LL_WARNS("ShaderMgr") << "Attempted to save shader cache with no version set" << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
LL_INFOS() << "Persisting shader cache metadata to disk" << LL_ENDL;
|
||||
LL_INFOS("ShaderMgr") << "Persisting shader cache metadata to disk" << LL_ENDL;
|
||||
|
||||
LLSD out = LLSD::emptyMap();
|
||||
LLSD out;
|
||||
// Settings and shader cache get saved at different time, thus making
|
||||
// RenderShaderCacheVersion unreliable when running multiple viewer
|
||||
// instances, or for cases where viewer crashes before saving settings.
|
||||
// Dupplicate version to the cache itself.
|
||||
out["version"] = mShaderCacheVersion;
|
||||
out["shaders"] = LLSD::emptyMap();
|
||||
LLSD &shaders = out["shaders"];
|
||||
|
||||
static const F32 LRU_TIME = (60.f * 60.f) * 24.f * 7.f; // 14 days
|
||||
const F32 current_time = (F32)LLTimer::getTotalSeconds();
|
||||
|
|
@ -1074,14 +1094,19 @@ void LLShaderMgr::persistShaderCacheMetadata()
|
|||
data["binary_format"] = LLSD::Integer(shader_metadata.mBinaryFormat);
|
||||
data["binary_size"] = LLSD::Integer(shader_metadata.mBinaryLength);
|
||||
data["last_used"] = LLSD::Real(shader_metadata.mLastUsedTime);
|
||||
out[it->first.asString()] = data;
|
||||
shaders[it->first.asString()] = data;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
std::string meta_out_path = gDirUtilp->add(mShaderCacheDir, "shaderdata.llsd");
|
||||
llofstream outstream(meta_out_path);
|
||||
LLSDSerialize::toNotation(out, outstream);
|
||||
llofstream outstream(meta_out_path, std::ios_base::out | std::ios_base::binary);
|
||||
if (!outstream.is_open())
|
||||
{
|
||||
LL_WARNS("ShaderMgr") << "Failed to open file. Unable to save shader cache to: " << mShaderCacheDir << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
LLSDSerialize::toBinary(out, outstream);
|
||||
outstream.close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ public:
|
|||
// Implemented in the application to actually update out of date uniforms for a particular shader
|
||||
virtual void updateShaderUniforms(LLGLSLShader * shader) = 0; // Pure Virtual
|
||||
|
||||
void initShaderCache(bool enabled, const LLUUID& old_cache_version, const LLUUID& current_cache_version);
|
||||
void initShaderCache(bool enabled, const LLUUID& old_cache_version, const LLUUID& current_cache_version, bool second_instance);
|
||||
void clearShaderCache();
|
||||
void persistShaderCacheMetadata();
|
||||
|
||||
|
|
@ -408,7 +408,7 @@ public:
|
|||
F32 mLastUsedTime = 0.0;
|
||||
};
|
||||
std::map<LLUUID, ProgramBinaryData> mShaderBinaryCache;
|
||||
bool mShaderCacheInitialized = false;
|
||||
LLUUID mShaderCacheVersion;
|
||||
bool mShaderCacheEnabled = false;
|
||||
std::string mShaderCacheDir;
|
||||
|
||||
|
|
|
|||
|
|
@ -174,6 +174,74 @@ Var FRIENDLY_APP_NAME # <FS:Ansariel> FIRE-30446: Set FriendlyAppName for prot
|
|||
!include "x64.nsh" # for 64bit detection
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Substring function
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
!define StrStr "!insertmacro StrStr"
|
||||
|
||||
!macro StrStr ResultVar String SubString
|
||||
Push `${String}`
|
||||
Push `${SubString}`
|
||||
Call StrStr
|
||||
Pop `${ResultVar}`
|
||||
!macroend
|
||||
|
||||
Function StrStr
|
||||
|
||||
# After this point:
|
||||
# ------------------------------------------
|
||||
# $R0 = SubString (input)
|
||||
# $R1 = String (input)
|
||||
# $R2 = SubStringLen (temp)
|
||||
# $R3 = StrLen (temp)
|
||||
# $R4 = StartCharPos (temp)
|
||||
# $R5 = TempStr (temp)
|
||||
# function from nsis.sourceforge.io/StrStr
|
||||
|
||||
;Get input from user
|
||||
Exch $R0
|
||||
Exch
|
||||
Exch $R1
|
||||
Push $R2
|
||||
Push $R3
|
||||
Push $R4
|
||||
Push $R5
|
||||
|
||||
;Get "String" and "SubString" length
|
||||
StrLen $R2 $R0
|
||||
StrLen $R3 $R1
|
||||
;Start "StartCharPos" counter
|
||||
StrCpy $R4 0
|
||||
|
||||
;Loop until "SubString" is found or "String" reaches its end
|
||||
${Do}
|
||||
;Remove everything before and after the searched part ("TempStr")
|
||||
StrCpy $R5 $R1 $R2 $R4
|
||||
|
||||
;Compare "TempStr" with "SubString"
|
||||
${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|}
|
||||
;If not "SubString", this could be "String"'s end
|
||||
${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|}
|
||||
;If not, continue the loop
|
||||
IntOp $R4 $R4 + 1
|
||||
${Loop}
|
||||
|
||||
# After this point:
|
||||
# ------------------------------------------
|
||||
# $R0 = ResultVar (output)
|
||||
|
||||
;Remove part before "SubString" on "String" (if there has one)
|
||||
StrCpy $R0 $R1 `` $R4
|
||||
|
||||
;Return output to user
|
||||
Pop $R5
|
||||
Pop $R4
|
||||
Pop $R3
|
||||
Pop $R2
|
||||
Pop $R1
|
||||
Exch $R0
|
||||
FunctionEnd
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Pre-directory page callback
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
Function dirPre
|
||||
|
|
@ -316,15 +384,31 @@ Function .onInit
|
|||
# However, SL-10506 complains about the resulting behavior, so the logic below
|
||||
# is adapted from before we introduced MultiUser.nsh.
|
||||
|
||||
# Check if user specified /D= on the command line
|
||||
System::Call 'kernel32::GetCommandLine()t .r0'
|
||||
Push $0
|
||||
Push " /D="
|
||||
Call StrStr
|
||||
Pop $1
|
||||
${If} $1 != ""
|
||||
# /D= was specified, extract the path
|
||||
# spaces are allowed in path after /D=, it's expected to be the last parameter
|
||||
StrLen $2 $1
|
||||
StrCpy $INSTDIR $1 $2 4 # Skip over " /D="
|
||||
Goto after_instdir
|
||||
${EndIf}
|
||||
|
||||
# if $0 is empty, this is the first time for this viewer name
|
||||
ReadRegStr $0 SHELL_CONTEXT "${INSTNAME_KEY}" ""
|
||||
|
||||
# viewer with this name was installed before
|
||||
${If} $0 != ""
|
||||
# use the value we got from registry as install location
|
||||
# use the value we got from registry as install location
|
||||
StrCpy $INSTDIR $0
|
||||
${EndIf}
|
||||
|
||||
after_instdir:
|
||||
|
||||
Call CheckCPUFlags # Make sure we have SSE2 support
|
||||
|
||||
# Two checks here, if we are an AVX2 build we want to abort if no AVX2 support on this CPU.
|
||||
|
|
|
|||
|
|
@ -650,6 +650,7 @@ bool idle_startup()
|
|||
LL_WARNS_ONCE() << "gViewerWindow is not initialized" << LL_ENDL;
|
||||
return false; // No world yet
|
||||
}
|
||||
LL_PROFILE_ZONE_SCOPED;
|
||||
|
||||
const F32 PRECACHING_DELAY = gSavedSettings.getF32("PrecachingDelay");
|
||||
static LLTimer timeout;
|
||||
|
|
|
|||
|
|
@ -550,7 +550,11 @@ void LLViewerShaderMgr::setShaders()
|
|||
gSavedSettings.setString("RenderShaderCacheVersion", current_cache_version.asString());
|
||||
}
|
||||
|
||||
initShaderCache(shader_cache_enabled, old_cache_version, current_cache_version);
|
||||
initShaderCache(
|
||||
shader_cache_enabled,
|
||||
old_cache_version,
|
||||
current_cache_version,
|
||||
LLAppViewer::instance()->isSecondInstance());
|
||||
}
|
||||
|
||||
static LLCachedControl<U32> max_texture_index(gSavedSettings, "RenderMaxTextureIndex", 16);
|
||||
|
|
@ -708,7 +712,10 @@ void LLViewerShaderMgr::setShaders()
|
|||
loaded = loaded && loadShadersDeferred();
|
||||
llassert(loaded);
|
||||
|
||||
persistShaderCacheMetadata();
|
||||
if (!LLAppViewer::instance()->isSecondInstance())
|
||||
{
|
||||
persistShaderCacheMetadata();
|
||||
}
|
||||
|
||||
if (gViewerWindow)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue