bDeterministicShaderCodeOrder
bDeterministicShaderCodeOrder
#Overview
name: bDeterministicShaderCodeOrder
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bDeterministicShaderCodeOrder is to control the order in which shader code is processed and stored during packaging and shader compilation. This setting is primarily used in the rendering system, specifically for shader code management.
This setting variable is relied upon by the Unreal Engine’s packaging system, shader compilation system, and cooking process. It is used in the following modules:
- DeveloperToolSettings
- UnrealEd
- RenderCore
The value of this variable is set in the project’s packaging settings, specifically in the “ProjectPackagingSettings” section of the game’s configuration file (Game.ini).
This variable interacts with other packaging and shader-related settings, such as bShareMaterialShaderCode, as evident from its placement in the ProjectPackagingSettings class.
Developers must be aware that enabling this option may impact build times and the size of shader code libraries. It ensures a consistent order of shader code, which can be beneficial for deterministic builds and debugging, but may come at the cost of increased processing time.
Best practices when using this variable include:
- Enable it when you need reproducible builds, especially for debugging shader-related issues across different machines or build environments.
- Consider the trade-off between build time and the benefits of deterministic shader code order.
- Use in conjunction with other shader-related settings like bShareMaterialShaderCode for optimal results.
- Test the impact on your project’s build time and package size before committing to using this setting in production.
- Be aware that this setting may affect the behavior of shader code libraries and could potentially impact runtime performance, so thorough testing is recommended.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultGame.ini:120, section: [/Script/UnrealEd.ProjectPackagingSettings]
- INI Section:
/Script/UnrealEd.ProjectPackagingSettings
- Raw value:
False
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Developer/DeveloperToolSettings/Classes/Settings/ProjectPackagingSettings.h:437
Scope (from outer to inner):
file
class class UProjectPackagingSettings : public UObject
Source code excerpt:
*/
UPROPERTY(config, EditAnywhere, Category = Packaging, meta = (EditCondition = "bShareMaterialShaderCode"))
bool bDeterministicShaderCodeOrder;
/**
* By default shader shader code gets saved into individual platform agnostic files,
* enabling this option will use the platform-specific library format if and only if one is available
* This will reduce overall package size but might increase loading time
*/
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/ShaderCodeLibraryToolsCommandlet.cpp:45
Scope (from outer to inner):
file
function int32 UShaderCodeLibraryToolsCommandlet::StaticMain
Source code excerpt:
bool bNeedsDeterministicOrder = false;
GConfig->GetBool(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("bDeterministicShaderCodeOrder"), bNeedsDeterministicOrder, GGameIni);
TArray<FString> OldMetaDataDirs;
OldMetaDataDirs.Add(Left);
return FShaderLibraryCooker::CreatePatchLibrary(OldMetaDataDirs, Right, Output, bNativeFormat, bNeedsDeterministicOrder) ? 0 : 1;
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/CookOnTheFlyServer.cpp:9504
Scope (from outer to inner):
file
function void UCookOnTheFlyServer::BeginCookStartShaderCodeLibrary
Source code excerpt:
PlatformIniFile.GetBool(TEXT("DevOptions.Shaders"), TEXT("bNeedsShaderStableKeys"), bNeedShaderStableKeys);
bool bNeedsDeterministicOrder = PackagingSettings->bDeterministicShaderCodeOrder;
FConfigFile PlatformGameIniFile;
FConfigCacheIni::LoadLocalIniFile(PlatformGameIniFile, TEXT("Game"), true, *TargetPlatform->IniPlatformName());
PlatformGameIniFile.GetBool(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("bDeterministicShaderCodeOrder"), bNeedsDeterministicOrder);
TArray<FName> ShaderFormats;
TargetPlatform->GetAllTargetedShaderFormats(ShaderFormats);
TArray<FShaderLibraryCooker::FShaderFormatDescriptor> ShaderFormatsWithStableKeys;
for (FName& Format : ShaderFormats)
{
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/ShaderCodeLibrary.cpp:3947
Scope (from outer to inner):
file
function bool FShaderLibraryCooker::MergeShaderCodeArchive
Source code excerpt:
bool bNeedsDeterministicOrder = false;
GConfig->GetBool(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("bDeterministicShaderCodeOrder"), bNeedsDeterministicOrder, GGameIni);
static const FRegexPattern ShaderArchivePattern(ShaderArchivePatternStr);
static const FRegexPattern StableInfoPattern(StableInfoPatternStr);
// Map of file name to the archive we are unioning
TMap<FString, FEditorShaderCodeArchive> ShaderCodeArchives;