UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ShaderCore.cpp File Reference
#include "ShaderCore.h"
#include "Algo/Find.h"
#include "Async/ParallelFor.h"
#include "Compression/OodleDataCompression.h"
#include "DataDrivenShaderPlatformInfo.h"
#include "HAL/FileManager.h"
#include "HAL/PlatformStackWalk.h"
#include "Interfaces/IShaderFormat.h"
#include "Interfaces/IShaderFormatModule.h"
#include "Interfaces/ITargetPlatform.h"
#include "Interfaces/ITargetPlatformManagerModule.h"
#include "Math/BigInt.h"
#include "Misc/CommandLine.h"
#include "Misc/FileHelper.h"
#include "Misc/Compression.h"
#include "Misc/CoreMisc.h"
#include "Misc/Paths.h"
#include "Misc/PathViews.h"
#include "Misc/ScopeLock.h"
#include "Misc/ScopeRWLock.h"
#include "Misc/ScopedSlowTask.h"
#include "Misc/StringBuilder.h"
#include "Containers/StripedMap.h"
#include "Modules/ModuleManager.h"
#include "RHIShaderFormatDefinitions.inl"
#include "Serialization/MemoryHasher.h"
#include "Serialization/MemoryWriter.h"
#include "Serialization/ShaderKeyGenerator.h"
#include "Shader.h"
#include "ShaderSerialization.h"
#include "ShaderCompilerCore.h"
#include "ShaderCompilerDefinitions.h"
#include "ShaderCompilerJobTypes.h"
#include "ShaderCompileWorkerUtil.h"
#include "ShaderDiagnostics.h"
#include "Stats/StatsMisc.h"
#include "String/Find.h"
#include "Tasks/Task.h"
#include "Templates/UniquePtr.h"
#include "VertexFactory.h"
#include "ShaderCompilerFlags.inl"

Classes

struct  FShaderFileCacheEntry
 
class  FMissingShaderFileCacheGuard
 
class  FShaderHashCache
 
struct  FShaderSettingHelper
 
struct  FShaderSymbolSettingHelper
 
class  FInternalShaderCompilerFunctions
 
struct  FShaderVirtualFileContents
 

Namespaces

namespace  FShaderStatTagNames
 

Macros

#define UE_ALLOW_SHADER_COMPILING   1
 
#define UE_ALLOW_SHADER_COMPILING_BASED_ON_SHADER_DIRECTORY_EXISTENCE   0
 
#define SHADER_COMPILER_FLAGS_ENTRY(Name)   { TEXT(#Name), CFLAG_##Name },
 

Functions

bool operator== (const FShaderStatVariant &LHS, const FShaderStatVariant &RHS)
 
bool operator< (const FShaderStatVariant &LHS, const FShaderStatVariant &RHS)
 
FStringBuilderBaseoperator<< (FStringBuilderBase &Builder, const FShaderStatVariant &Variant)
 
FStringBuilderBaseoperator<< (FStringBuilderBase &Builder, const FGenericShaderStat &Stat)
 
void UpdateShaderDevelopmentMode ()
 
 DEFINE_STAT (STAT_ShaderCompiling_NiagaraShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumTotalNiagaraShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_OpenColorIOShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumTotalOpenColorIOShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_MaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_GlobalShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_RHI)
 
 DEFINE_STAT (STAT_ShaderCompiling_HashingShaderFiles)
 
 DEFINE_STAT (STAT_ShaderCompiling_LoadingShaderFiles)
 
 DEFINE_STAT (STAT_ShaderCompiling_HLSLTranslation)
 
 DEFINE_STAT (STAT_ShaderCompiling_DDCLoading)
 
 DEFINE_STAT (STAT_ShaderCompiling_MaterialLoading)
 
 DEFINE_STAT (STAT_ShaderCompiling_MaterialCompiling)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumTotalMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumSpecialMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumParticleMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumSkinnedMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumLitMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumUnlitMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumTransparentMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumOpaqueMaterialShaders)
 
 DEFINE_STAT (STAT_ShaderCompiling_NumMaskedMaterialShaders)
 
 DEFINE_STAT (STAT_Shaders_NumShadersLoaded)
 
 DEFINE_STAT (STAT_Shaders_NumShadersCreated)
 
 DEFINE_STAT (STAT_Shaders_NumShaderMaps)
 
 DEFINE_STAT (STAT_Shaders_NumShaderMapsUsedForRendering)
 
 DEFINE_STAT (STAT_Shaders_RTShaderLoadTime)
 
 DEFINE_STAT (STAT_Shaders_ShaderMemory)
 
 DEFINE_STAT (STAT_Shaders_ShaderResourceMemory)
 
 DEFINE_STAT (STAT_Shaders_ShaderPreloadMemory)
 
 CSV_DEFINE_CATEGORY (Shaders,(!UE_BUILD_SHIPPING))
 
bool AllowDebugViewmodes ()
 
bool AllowDebugViewmodes (EShaderPlatform Platform)
 
ERHIBindlessConfiguration GetBindlessConfiguration (EShaderPlatform ShaderPlatform, const TCHAR *SettingName, IConsoleVariable *CVar)
 
bool ShouldGenerateShaderSymbols (FName ShaderFormat)
 
bool ShouldGenerateShaderSymbolsInfo (FName ShaderFormat)
 
bool ShouldWriteShaderSymbols (FName ShaderFormat)
 
bool ShouldAllowUniqueShaderSymbols (FName ShaderFormat)
 
const FString & GetBuildMachineArtifactBasePath ()
 
const FString & GetShaderDebugInfoPath ()
 
bool GetShaderSymbolPathOverride (FString &OutPathOverride, FName ShaderFormat)
 
bool GetShaderFileNameOverride (FString &OutFileNameOverride, const TCHAR *Cvar, FName ShaderFormat, FName PlatformName)
 
EWriteShaderSymbols GetWriteShaderSymbolsOptions (FName ShaderFormat)
 
bool ShouldEnableExtraShaderData (FName ShaderFormat)
 
bool ShouldOptimizeShaders (FName ShaderFormat)
 
bool AllowShaderCompiling ()
 
bool AllowGlobalShaderLoad ()
 
bool CheckVirtualShaderFilePath (FStringView VirtualFilePath, TArray< FShaderCompilerError > *CompileErrors)
 
const IShaderFormatFindShaderFormat (FName Format, const TArray< const IShaderFormat * > &ShaderFormats)
 
bool ConditionalPreprocessShader (FShaderCommonCompileJob *Job)
 
bool PreprocessShader (FShaderCommonCompileJob *Job)
 
void CompileShader (const TArray< const IShaderFormat * > &ShaderFormats, FShaderCompilerInput &Input, FShaderCompilerOutput &Output, const FString &WorkingDirectory, int32 *CompileCount)
 
void CompileShader (const TArray< const IShaderFormat * > &ShaderFormats, FShaderCompileJob &Job, const FString &WorkingDirectory, int32 *CompileCount)
 
void CompileShaderPipeline (const TArray< const IShaderFormat * > &ShaderFormats, FShaderPipelineCompileJob *PipelineJob, const FString &Dir, int32 *CompileCount)
 
void AddShaderSourceFileEntry (TArray< FString > &OutVirtualFilePaths, FString VirtualFilePath, EShaderPlatform ShaderPlatform, const FName *ShaderPlatformName)
 
void GetAllVirtualShaderSourcePaths (TArray< FString > &OutVirtualFilePaths, EShaderPlatform ShaderPlatform, const FName *ShaderPlatformName)
 
void VerifyShaderSourceFiles (EShaderPlatform ShaderPlatform)
 
FString GetShaderSourceFilePath (const FString &VirtualFilePath, TArray< FShaderCompilerError > *CompileErrors)
 
FString ParseVirtualShaderFilename (const FString &InFilename)
 
bool ReplaceVirtualFilePathForShaderPlatform (FString &InOutVirtualFilePath, EShaderPlatform ShaderPlatform)
 
bool ReplaceVirtualFilePathForShaderAutogen (FString &InOutVirtualFilePath, EShaderPlatform ShaderPlatform, const FName *InShaderPlatformName)
 
void FixupShaderFilePath (FString &VirtualFilePath, EShaderPlatform ShaderPlatform, const FName *ShaderPlatformName)
 
bool IsEndOfLine (TCHAR C)
 
bool CommentStripNeedsHandling (TCHAR C)
 
int NewlineCharCount (TCHAR First, TCHAR Second)
 
void ShaderConvertAndStripComments (const FString &ShaderSource, TArray< ANSICHAR > &OutStripped, EConvertAndStripFlags Flags)
 
bool LoadCachedShaderSourceFile (const TCHAR *InVirtualFilePath, EShaderPlatform ShaderPlatform, FShaderSharedStringPtr *OutFileContents, TArray< FShaderCompilerError > *OutCompileErrors, const FName *ShaderPlatformName, FShaderSharedAnsiStringPtr *OutStrippedContents)
 
bool LoadShaderSourceFile (const TCHAR *InVirtualFilePath, EShaderPlatform ShaderPlatform, FString *OutFileContents, TArray< FShaderCompilerError > *OutCompileErrors, const FName *ShaderPlatformName, FShaderSharedAnsiStringPtr *OutStrippedContents)
 
void LoadShaderSourceFileChecked (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform, FString &OutFileContents, const FName *ShaderPlatformName)
 
const TCHARSkipToCharOnCurrentLine (const TCHAR *InStr, TCHAR TargetChar)
 
bool GetShaderPreprocessDependencies (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform, FShaderPreprocessDependenciesShared &OutDependencies)
 
void GetShaderIncludes (const TCHAR *EntryPointVirtualFilePath, const TCHAR *VirtualFilePath, TArray< FString > &IncludeVirtualFilePaths, EShaderPlatform ShaderPlatform, uint32 DepthLimit, const FName *ShaderPlatformName)
 
void GetShaderIncludes (const TCHAR *EntryPointVirtualFilePath, const TCHAR *VirtualFilePath, const FString &FileContents, TArray< FString > &IncludeVirtualFilePaths, EShaderPlatform ShaderPlatform, uint32 DepthLimit, const FName *ShaderPlatformName)
 
void HashShaderFileWithIncludes (FArchive &HashingArchive, const TCHAR *VirtualFilePath, const FString &FileContents, EShaderPlatform ShaderPlatform, bool bOnlyHashIncludedFiles)
 
const FSHAHashGetShaderFileHash (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform)
 
const FSHAHashTryGetShaderFileHash (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform, FString *OutErrorMessage)
 
const FSHAHashGetShaderFilesHash (const TArray< FString > &VirtualFilePaths, EShaderPlatform ShaderPlatform)
 
void InitializeShaderHashCache ()
 
void UpdateIncludeDirectoryForPreviewPlatform (EShaderPlatform PreviewPlatform, EShaderPlatform ActualPlatform)
 
void CheckShaderHashCacheInclude (const FString &VirtualFilePath, EShaderPlatform ShaderPlatform, const FString &ShaderFormatName)
 
void InitializeShaderTypes ()
 
void FlushShaderFileCache ()
 
void InvalidateShaderFileCacheEntry (const TCHAR *InVirtualFilePath, EShaderPlatform InShaderPlatform, const FName *InShaderPlatformName)
 
FString MakeInjectedShaderCodeBlock (const TCHAR *BlockName, const FString &CodeToInject)
 
const TMap< FString, FString > & AllShaderSourceDirectoryMappings ()
 
void ResetAllShaderSourceDirectoryMappings ()
 
void AddShaderSourceDirectoryMapping (const FString &VirtualShaderDirectory, const FString &RealShaderDirectory)
 
void AddShaderSourceSharedVirtualDirectory (const FString &VirtualShaderDirectory)
 
FArchiveoperator<< (FArchive &Ar, FSharedBuffer &Buffer)
 
FArchiveoperator<< (FArchive &Ar, FShaderCodeResource &Resource)
 
FArchiveoperator<< (FArchive &Ar, FShaderCode &Output)
 
FArchiveoperator<< (FArchive &Ar, FShaderCompilerInput &Input)
 
const TCHARLexToString (EShaderCompileJobStatus Status)
 
void LexFromString (ECompilerFlags &OutValue, const TCHAR *InString)
 
const TCHARLexToString (ECompilerFlags InValue)
 

Variables

RENDERCORE_API const FName FShaderStatTagNames::AnalysisArtifactsName = TEXT("ShaderStatTags.AnalysisArtifacts")
 
TStripedMap< 31, FString, FShaderFileCacheEntryGShaderFileCache
 
FRWLock GShaderHashAccessRWLock
 
FShaderHashCache GShaderHashCache
 

Macro Definition Documentation

◆ SHADER_COMPILER_FLAGS_ENTRY

#define SHADER_COMPILER_FLAGS_ENTRY (   Name)    { TEXT(#Name), CFLAG_##Name },

◆ UE_ALLOW_SHADER_COMPILING

#define UE_ALLOW_SHADER_COMPILING   1

◆ UE_ALLOW_SHADER_COMPILING_BASED_ON_SHADER_DIRECTORY_EXISTENCE

#define UE_ALLOW_SHADER_COMPILING_BASED_ON_SHADER_DIRECTORY_EXISTENCE   0

Function Documentation

◆ AddShaderSourceDirectoryMapping()

void AddShaderSourceDirectoryMapping ( const FString &  VirtualShaderDirectory,
const FString &  RealShaderDirectory 
)

Maps a real shader directory existing on disk to a virtual shader directory.

Parameters
VirtualShaderDirectoryUnique absolute path of the virtual shader directory (ex: /Project).
RealShaderDirectoryFPlatformProcess::BaseDir() relative path of the directory map.

◆ AddShaderSourceFileEntry()

void AddShaderSourceFileEntry ( TArray< FString > &  OutVirtualFilePaths,
FString  VirtualFilePath,
EShaderPlatform  ShaderPlatform,
const FName ShaderPlatformName 
)

Add a new entry to the list of shader source files Only unique entries which can be loaded are added as well as their include files

Parameters
OutVirtualFilePaths- [out] list of shader source files to add to
ShaderFilename- shader file to add

◆ AddShaderSourceSharedVirtualDirectory()

void AddShaderSourceSharedVirtualDirectory ( const FString &  VirtualShaderDirectory)

Specifies that the virtual shader directory and all subdirectories should contain only .h files that are shared between C++ / shader

Parameters
VirtualShaderDirectoryUnique absolute path of the virtual shader directory (ex: /Project/Shared/).

◆ AllowDebugViewmodes() [1/2]

bool AllowDebugViewmodes ( )

Returns true if debug viewmodes are allowed for the current platform.

◆ AllowDebugViewmodes() [2/2]

bool AllowDebugViewmodes ( EShaderPlatform  Platform)

Returns true if debug viewmodes are allowed for the current platform.

◆ AllowGlobalShaderLoad()

bool AllowGlobalShaderLoad ( )

Returns true if the global shader cache should be loaded (and potentially compiled if allowed/needed

◆ AllowShaderCompiling()

bool AllowShaderCompiling ( )

Returns true is shader compiling is allowed

◆ AllShaderSourceDirectoryMappings()

const TMap< FString, FString > & AllShaderSourceDirectoryMappings ( )

Returns the map virtual shader directory path -> real shader directory path.

◆ CheckShaderHashCacheInclude()

void CheckShaderHashCacheInclude ( const FString &  VirtualFilePath,
EShaderPlatform  ShaderPlatform,
const FString &  ShaderFormatName 
)

Checks if shader include isn't skipped by a shader hash cache.

◆ CheckVirtualShaderFilePath()

bool CheckVirtualShaderFilePath ( FStringView  VirtualPath,
TArray< FShaderCompilerError > *  CompileErrors = nullptr 
)

Validates the format of a virtual shader file path. Meant to be use as such: check(CheckVirtualShaderFilePath(VirtualFilePath)); CompileErrors output array is optional. If this is non-null, all validation errors are returned to this array instead of logging them to LogShaders.

◆ CommentStripNeedsHandling()

bool CommentStripNeedsHandling ( TCHAR  C)
inline

◆ CompileShader() [1/2]

void CompileShader ( const TArray< const IShaderFormat * > &  ShaderFormats,
FShaderCompileJob Job,
const FString &  WorkingDirectory,
int32 CompileCount 
)

◆ CompileShader() [2/2]

void CompileShader ( const TArray< const IShaderFormat * > &  ShaderFormats,
FShaderCompilerInput Input,
FShaderCompilerOutput Output,
const FString &  WorkingDirectory,
int32 CompileCount 
)

◆ CompileShaderPipeline()

void CompileShaderPipeline ( const TArray< const IShaderFormat * > &  ShaderFormats,
FShaderPipelineCompileJob PipelineJob,
const FString &  Dir,
int32 CompileCount 
)

◆ ConditionalPreprocessShader()

bool ConditionalPreprocessShader ( FShaderCommonCompileJob Job)

◆ CSV_DEFINE_CATEGORY()

CSV_DEFINE_CATEGORY ( Shaders  ,
(!UE_BUILD_SHIPPING  
)

◆ DEFINE_STAT() [1/30]

◆ DEFINE_STAT() [2/30]

◆ DEFINE_STAT() [3/30]

◆ DEFINE_STAT() [4/30]

◆ DEFINE_STAT() [5/30]

◆ DEFINE_STAT() [6/30]

◆ DEFINE_STAT() [7/30]

◆ DEFINE_STAT() [8/30]

◆ DEFINE_STAT() [9/30]

◆ DEFINE_STAT() [10/30]

◆ DEFINE_STAT() [11/30]

◆ DEFINE_STAT() [12/30]

◆ DEFINE_STAT() [13/30]

◆ DEFINE_STAT() [14/30]

◆ DEFINE_STAT() [15/30]

◆ DEFINE_STAT() [16/30]

◆ DEFINE_STAT() [17/30]

◆ DEFINE_STAT() [18/30]

◆ DEFINE_STAT() [19/30]

◆ DEFINE_STAT() [20/30]

◆ DEFINE_STAT() [21/30]

◆ DEFINE_STAT() [22/30]

DEFINE_STAT ( STAT_ShaderCompiling_RHI  )

◆ DEFINE_STAT() [23/30]

DEFINE_STAT ( STAT_Shaders_NumShaderMaps  )

◆ DEFINE_STAT() [24/30]

◆ DEFINE_STAT() [25/30]

DEFINE_STAT ( STAT_Shaders_NumShadersCreated  )

◆ DEFINE_STAT() [26/30]

DEFINE_STAT ( STAT_Shaders_NumShadersLoaded  )

◆ DEFINE_STAT() [27/30]

DEFINE_STAT ( STAT_Shaders_RTShaderLoadTime  )

◆ DEFINE_STAT() [28/30]

DEFINE_STAT ( STAT_Shaders_ShaderMemory  )

◆ DEFINE_STAT() [29/30]

◆ DEFINE_STAT() [30/30]

◆ FindShaderFormat()

const IShaderFormat * FindShaderFormat ( FName  Format,
const TArray< const IShaderFormat * > &  ShaderFormats 
)

◆ FixupShaderFilePath()

void FixupShaderFilePath ( FString &  VirtualFilePath,
EShaderPlatform  ShaderPlatform,
const FName ShaderPlatformName 
)

Fixes up the given virtual file path (substituting virtual platform path/autogen path for the given platform)

◆ FlushShaderFileCache()

void FlushShaderFileCache ( )

Flushes the shader file and CRC cache, and regenerates the binary shader files if necessary. Allows shader source files to be re-read properly even if they've been modified since startup.

◆ GetAllVirtualShaderSourcePaths()

void GetAllVirtualShaderSourcePaths ( TArray< FString > &  OutVirtualFilePaths,
EShaderPlatform  ShaderPlatform,
const FName ShaderPlatformName 
)

Generates a list of virtual paths of all shader source that engine needs to load.

Parameters
OutVirtualFilePaths- [out] list of shader source files to add to

◆ GetBindlessConfiguration()

ERHIBindlessConfiguration GetBindlessConfiguration ( EShaderPlatform  ShaderPlatform,
const TCHAR SettingName,
IConsoleVariable CVar 
)
inline

◆ GetBuildMachineArtifactBasePath()

const FString & GetBuildMachineArtifactBasePath ( )

Returns the path where shader compilation related artifacts should be stored when running on a build machine

◆ GetShaderDebugInfoPath()

const FString & GetShaderDebugInfoPath ( )

Returns the base path where any shader debug information should be written to

◆ GetShaderFileHash()

const FSHAHash & GetShaderFileHash ( const TCHAR VirtualFilePath,
EShaderPlatform  ShaderPlatform 
)

Calculates a Hash for the given filename if it does not already exist in the Hash cache.

Parameters
Filename- shader file to Hash
ShaderPlatform- shader platform to Hash
Returns
Reference to the Hash created and stored for the file, or to an empty FSHAHash if not found. Logs an error if the file is not loadable.

◆ GetShaderFileNameOverride()

bool GetShaderFileNameOverride ( FString &  OutFileNameOverride,
const TCHAR Cvar,
FName  ShaderFormat,
FName  PlatformName 
)

Returns true if the shader file name is overridden by the Cvar and OutFileNameOverride contains the override filename. ShaderFormat used for format specific cvar, PlatformName used for {Platform} string substitution, if requested. Returns false otherwise and leaves OutFileNameOverride unchanged

◆ GetShaderFilesHash()

const FSHAHash & GetShaderFilesHash ( const TArray< FString > &  VirtualFilePaths,
EShaderPlatform  ShaderPlatform 
)

Calculates a Hash for the given filename and its includes if it does not already exist in the Hash cache.

Parameters
Filename- shader file to Hash
ShaderPlatform- shader platform to Hash

◆ GetShaderIncludes() [1/2]

void GetShaderIncludes ( const TCHAR EntryPointVirtualFilePath,
const TCHAR VirtualFilePath,
const FString &  FileContents,
TArray< FString > &  IncludeVirtualFilePaths,
EShaderPlatform  ShaderPlatform,
uint32  DepthLimit,
const FName ShaderPlatformName 
)

◆ GetShaderIncludes() [2/2]

void GetShaderIncludes ( const TCHAR EntryPointVirtualFilePath,
const TCHAR VirtualFilePath,
TArray< FString > &  IncludeVirtualFilePaths,
EShaderPlatform  ShaderPlatform,
uint32  DepthLimit = 100,
const FName ShaderPlatformName = nullptr 
)

Recursively populates IncludeFilenames with the include filenames from Filename

◆ GetShaderPreprocessDependencies()

bool GetShaderPreprocessDependencies ( const TCHAR VirtualFilePath,
EShaderPlatform  ShaderPlatform,
FShaderPreprocessDependenciesShared OutDependencies 
)

Utility function that returns a root shader file plus all non-platform include dependencies in a single batch call, useful for preprocessing.

◆ GetShaderSourceFilePath()

FString GetShaderSourceFilePath ( const FString &  VirtualFilePath,
TArray< struct FShaderCompilerError > *  CompileErrors = nullptr 
)

Convert the virtual shader path to an actual file system path. CompileErrors output array is optional.

◆ GetShaderSymbolPathOverride()

bool GetShaderSymbolPathOverride ( FString &  OutPathOverride,
FName  ShaderFormat 
)

Returns true if the shader symbol path is overridden and OutPathOverride contains the override path.

◆ GetWriteShaderSymbolsOptions()

EWriteShaderSymbols GetWriteShaderSymbolsOptions ( FName  ShaderFormat)

Returns true if shaders should be combined into a single zip file instead of individual files.

◆ HashShaderFileWithIncludes()

void HashShaderFileWithIncludes ( FArchive HashingArchive,
const TCHAR VirtualFilePath,
const FString &  FileContents,
EShaderPlatform  ShaderPlatform,
bool  bOnlyHashIncludedFiles 
)

◆ InitializeShaderHashCache()

void InitializeShaderHashCache ( )

Initializes shader hash cache from IShaderFormatModules. This must be called before reading any shader include.

◆ InitializeShaderTypes()

void InitializeShaderTypes ( )

Initializes cached shader type data. This must be called before creating any FShaderType.

◆ InvalidateShaderFileCacheEntry()

void InvalidateShaderFileCacheEntry ( const TCHAR InVirtualFilePath,
EShaderPlatform  InShaderPlatform,
const FName InShaderPlatformName = nullptr 
)

Invalidates a single entry in the shader file and CRC caches.

◆ IsEndOfLine()

bool IsEndOfLine ( TCHAR  C)
inline

◆ LexFromString()

void LexFromString ( ECompilerFlags OutValue,
const TCHAR InString 
)

◆ LexToString() [1/2]

const TCHAR * LexToString ( ECompilerFlags  InValue)

◆ LexToString() [2/2]

const TCHAR * LexToString ( EShaderCompileJobStatus  Status)

◆ LoadCachedShaderSourceFile()

bool LoadCachedShaderSourceFile ( const TCHAR InVirtualFilePath,
EShaderPlatform  ShaderPlatform,
FShaderSharedStringPtr OutFileContents,
TArray< FShaderCompilerError > *  OutCompileErrors,
const FName ShaderPlatformName,
FShaderSharedAnsiStringPtr OutStrippedContents 
)

◆ LoadShaderSourceFile()

bool LoadShaderSourceFile ( const TCHAR VirtualFilePath,
EShaderPlatform  ShaderPlatform,
FString *  OutFileContents,
TArray< FShaderCompilerError > *  OutCompileErrors,
const FName ShaderPlatformName = nullptr,
FShaderSharedAnsiStringPtr OutStrippedContents = nullptr 
)

Loads the shader file with the given name.

Parameters
VirtualFilePath- The virtual path of shader file to load.
OutFileContents- If true is returned, will contain the contents of the shader file. Can be null.
Returns
True if the file was successfully loaded.

◆ LoadShaderSourceFileChecked()

void LoadShaderSourceFileChecked ( const TCHAR VirtualFilePath,
EShaderPlatform  ShaderPlatform,
FString &  OutFileContents,
const FName ShaderPlatformName = nullptr 
)

Loads the shader file with the given name. If the shader file couldn't be loaded, throws a fatal error.

◆ MakeInjectedShaderCodeBlock()

FString MakeInjectedShaderCodeBlock ( const TCHAR BlockName,
const FString &  CodeToInject 
)

Create a block of source code to be injected in the preprocessed shader code. The Block will be put into a line directive to show up in case shader compilation failures happen in this code block.

◆ NewlineCharCount()

int NewlineCharCount ( TCHAR  First,
TCHAR  Second 
)
inline

◆ operator<()

bool operator< ( const FShaderStatVariant LHS,
const FShaderStatVariant RHS 
)

◆ operator<<() [1/6]

FArchive & operator<< ( FArchive Ar,
FShaderCode Output 
)

◆ operator<<() [2/6]

FArchive & operator<< ( FArchive Ar,
FShaderCodeResource Resource 
)

◆ operator<<() [3/6]

FArchive & operator<< ( FArchive Ar,
FShaderCompilerInput Input 
)

◆ operator<<() [4/6]

FArchive & operator<< ( FArchive Ar,
FSharedBuffer Buffer 
)

◆ operator<<() [5/6]

FStringBuilderBase & operator<< ( FStringBuilderBase Builder,
const FGenericShaderStat Stat 
)

◆ operator<<() [6/6]

FStringBuilderBase & operator<< ( FStringBuilderBase Builder,
const FShaderStatVariant Variant 
)

◆ operator==()

bool operator== ( const FShaderStatVariant LHS,
const FShaderStatVariant RHS 
)

◆ ParseVirtualShaderFilename()

FString ParseVirtualShaderFilename ( const FString &  InFilename)

Converts an absolute or relative shader filename to a filename relative to the shader directory.

Parameters
InFilename- The shader filename.
Returns
a filename relative to the shaders directory.

◆ PreprocessShader()

bool PreprocessShader ( FShaderCommonCompileJob Job)

◆ ReplaceVirtualFilePathForShaderAutogen()

bool ReplaceVirtualFilePathForShaderAutogen ( FString &  InOutVirtualFilePath,
EShaderPlatform  ShaderPlatform,
const FName InShaderPlatformName = nullptr 
)

Replaces virtual platform path with appropriate autogen path for a given ShaderPlatform. Returns true if path was changed.

◆ ReplaceVirtualFilePathForShaderPlatform()

bool ReplaceVirtualFilePathForShaderPlatform ( FString &  InOutVirtualFilePath,
EShaderPlatform  ShaderPlatform 
)

Replaces virtual platform path with appropriate path for a given ShaderPlatform. Returns true if path was changed.

◆ ResetAllShaderSourceDirectoryMappings()

void ResetAllShaderSourceDirectoryMappings ( )

Hook for shader compile worker to reset the directory mappings.

◆ ShaderConvertAndStripComments()

void ShaderConvertAndStripComments ( const FString &  ShaderSource,
TArray< ANSICHAR > &  OutStripped,
EConvertAndStripFlags  Flags = EConvertAndStripFlags::None 
)

Utility function to strip comments and convert source to ANSI, useful for preprocessing

◆ ShouldAllowUniqueShaderSymbols()

bool ShouldAllowUniqueShaderSymbols ( FName  ShaderFormat)

Returns true if (external) shader symbols should be specific to each shader rather than be de-duplicated.

◆ ShouldEnableExtraShaderData()

bool ShouldEnableExtraShaderData ( FName  ShaderFormat)

Returns true if the user wants more runtime shader data (names, extra info)

◆ ShouldGenerateShaderSymbols()

bool ShouldGenerateShaderSymbols ( FName  ShaderFormat)

Returns true if shader symbols should be kept for a given platform.

◆ ShouldGenerateShaderSymbolsInfo()

bool ShouldGenerateShaderSymbolsInfo ( FName  ShaderFormat)

Returns true if shader symbol minimal info files should be generated for a given platform.

◆ ShouldOptimizeShaders()

bool ShouldOptimizeShaders ( FName  ShaderFormat)

◆ ShouldWriteShaderSymbols()

bool ShouldWriteShaderSymbols ( FName  ShaderFormat)

Returns true if shader symbols should be exported to separate files for a given platform.

◆ SkipToCharOnCurrentLine()

const TCHAR * SkipToCharOnCurrentLine ( const TCHAR InStr,
TCHAR  TargetChar 
)

Walks InStr until we find either an end-of-line or TargetChar.

◆ TryGetShaderFileHash()

const FSHAHash * TryGetShaderFileHash ( const TCHAR VirtualFilePath,
EShaderPlatform  ShaderPlatform,
FString *  OutErrorMessage = nullptr 
)

Calculates a Hash for the given filename if it does not already exist in the Hash cache.

Parameters
Filename- shader file to Hash
ShaderPlatform- shader platform to Hash
OutErrorMessage- If non-null, receives the errormessage if nullptr is returned.
Returns
Pointer to the Hash created and stored for the file, or nullptr if not found.

◆ UpdateIncludeDirectoryForPreviewPlatform()

void UpdateIncludeDirectoryForPreviewPlatform ( EShaderPlatform  PreviewPlatform,
EShaderPlatform  ActualPlatform 
)

Updates the PreviewPlatform's IncludeDirectory to match that of the Parent Platform

◆ UpdateShaderDevelopmentMode()

void UpdateShaderDevelopmentMode ( )

◆ VerifyShaderSourceFiles()

void VerifyShaderSourceFiles ( EShaderPlatform  ShaderPlatform)

Kick off SHA verification for all shader source files

Variable Documentation

◆ GShaderFileCache

TStripedMap<31, FString, FShaderFileCacheEntry> GShaderFileCache

◆ GShaderHashAccessRWLock

FRWLock GShaderHashAccessRWLock

Protects GShaderHashCache from simultaneous modification by multiple threads. Note that it can cover more than one method of the class, e.g. a block of code doing Find() then Add() can be guarded

◆ GShaderHashCache

FShaderHashCache GShaderHashCache