UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ShaderCompiler.h File Reference
#include "Templates/RefCounting.h"
#include "HAL/PlatformProcess.h"
#include "ShaderCore.h"
#include "ShaderCompilerCore.h"
#include "ShaderCompilerJobTypes.h"
#include "Shader.h"
#include "HAL/RunnableThread.h"
#include "HAL/Runnable.h"
#include "Templates/Atomic.h"
#include "Templates/UniquePtr.h"
#include "HAL/ThreadSafeCounter.h"
#include "RHIDefinitions.h"
#include "GBufferInfo.h"
#include "ShaderMaterial.h"
#include "Misc/ScopeRWLock.h"
#include "IAssetCompilingManager.h"
#include "Containers/HashTable.h"
#include "Containers/List.h"
#include "Containers/Deque.h"
#include "Hash/Blake3.h"
#include "Hash/CityHash.h"
#include "SceneTypes.h"
#include "UObject/StrongObjectPtr.h"
#include "ShaderCompiler.generated.h"

Go to the source code of this file.

Classes

class  FShaderCompileJobCollection
 
struct  FShaderCompileMemoryUsage
 
class  FShaderCompileThreadRunnableBase
 
class  FShaderCompileThreadRunnable
 
class  FShaderCompileUtilities
 
class  FShaderCompileDistributedThreadRunnable_Interface
 
struct  FShaderCompilerCounters
 
struct  FShaderCompilerMaterialCounters
 
struct  FShaderTimings
 
struct  FShaderCompilerSinglePermutationStat
 
struct  FShaderStats
 
struct  FShaderCompilerStats
 
struct  FShaderCompilerStats::FWorkerDiagnosticsInfo
 
struct  FShaderCompilerMemoryLimits
 
class  FShaderCompilingManager
 
struct  FODSCRequestPayload
 
struct  FShaderRecompileData
 

Typedefs

using FShaderCompileJobCallback = TFunction< bool(FShaderCommonCompileJob *)>
 
using FShaderMapFinalizeResults = FShaderMapCompileResults
 

Enumerations

enum class  ODSCRecompileCommand {
  None , Changed , Global , Material ,
  SingleShader , ResetMaterialCache
}
 

Functions

 DECLARE_LOG_CATEGORY_EXTERN (LogShaderCompilers, Log, All)
 
bool AreShaderErrorsFatal ()
 
bool CreateShadersOnLoad ()
 
ENGINE_API bool IsShaderJobCacheDDCEnabled ()
 
ENGINE_API bool IsMaterialMapDDCEnabled ()
 
ENGINE_API void GetShaderCompilerCurrentMemoryLimits (FShaderCompilerMemoryLimits &limits)
 
ENGINE_API void SetShaderCompilerTargetMemoryLimitInMiB (int32 NewLimit)
 
ENGINE_API bool ShouldCompileODSCOnlyShaders ()
 
void GetOutdatedShaderTypes (TArray< const FShaderType * > &OutdatedShaderTypes, TArray< const FShaderPipelineType * > &OutdatedShaderPipelineTypes, TArray< const FVertexFactoryType * > &OutdatedFactoryTypes)
 
bool RecompileShaders (const TCHAR *Cmd, FOutputDevice &Ar)
 
ENGINE_API bool IsGlobalShaderMapComplete (const TCHAR *TypeNameSubstring=nullptr)
 
ENGINE_API void VerifyGlobalShaders (EShaderPlatform Platform, bool bLoadedFromCacheFile, const TArray< const FShaderType * > *OutdatedShaderTypes=nullptr, const TArray< const FShaderPipelineType * > *OutdatedShaderPipelineTypes=nullptr)
 
ENGINE_API void VerifyGlobalShaders (EShaderPlatform Platform, const ITargetPlatform *TargetPlatform, bool bLoadedFromCacheFile, const TArray< const FShaderType * > *OutdatedShaderTypes=nullptr, const TArray< const FShaderPipelineType * > *OutdatedShaderPipelineTypes=nullptr, const FShaderCompilerFlags &InExtraCompilerFlags={})
 
ENGINE_API void PrecacheComputePipelineStatesForGlobalShaders (ERHIFeatureLevel::Type FeatureLevel, const ITargetPlatform *TargetPlatform)
 
ENGINE_API void RecompileGlobalShaders ()
 
ENGINE_API bool RecompileChangedShadersForPlatform (const FString &PlatformName)
 
ENGINE_API void BeginRecompileGlobalShaders (const TArray< const FShaderType * > &OutdatedShaderTypes, const TArray< const FShaderPipelineType * > &OutdatedShaderPipelineTypes, EShaderPlatform ShaderPlatform, const ITargetPlatform *TargetPlatform=nullptr, const FShaderCompilerFlags &InExtraCompilerFlags={})
 
ENGINE_API void FinishRecompileGlobalShaders ()
 
ENGINE_API void LoadGlobalShadersForRemoteRecompile (FArchive &Ar, EShaderPlatform ShaderPlatform)
 
ENGINE_API FString SaveGlobalShaderFile (EShaderPlatform Platform, FString SavePath, class ITargetPlatform *TargetPlatform=nullptr)
 
ENGINE_API const TCHARODSCCmdEnumToString (ODSCRecompileCommand Cmd)
 
ENGINE_API void CompileGlobalShaderMap (bool bRefreshShaderMap=false)
 
ENGINE_API void CompileGlobalShaderMap (ERHIFeatureLevel::Type InFeatureLevel, bool bRefreshShaderMap=false)
 
ENGINE_API void CompileGlobalShaderMap (EShaderPlatform Platform, bool bRefreshShaderMap=false)
 
ENGINE_API void CompileGlobalShaderMap (EShaderPlatform Platform, const ITargetPlatform *TargetPlatform, bool bRefreshShaderMap)
 
ENGINE_API void ShutdownGlobalShaderMap ()
 
ENGINE_API const FGuidGetGlobalShaderMapDDCGuid ()
 
ENGINE_API const FGuidGetMaterialShaderMapDDCGuid ()
 
ENGINE_API bool ShouldDumpShaderDDCKeys ()
 
ENGINE_API void DumpShaderDDCKeyToFile (const EShaderPlatform InPlatform, bool bWithEditor, const TCHAR *DebugGroupName, const FString &DDCKey)
 
ENGINE_API void ProcessCookOnTheFlyShaders (bool bReloadGlobalShaders, const TArray< uint8 > &MeshMaterialMaps, const TArray< FString > &MaterialsToLoad, const TArray< uint8 > &GlobalShaderMap)
 

Variables

ENGINE_API FShaderCompilingManagerGShaderCompilingManager
 
ENGINE_API FShaderCompilerStatsGShaderCompilerStats
 

Typedef Documentation

◆ FShaderCompileJobCallback

Function signature to iterate over shader compile jobs (single and pipeline jobs).

◆ FShaderMapFinalizeResults

Results for a single compiled and finalized shader map.

Enumeration Type Documentation

◆ ODSCRecompileCommand

enum class ODSCRecompileCommand
strong
Enumerator
None 
Changed 
Global 
Material 
SingleShader 
ResetMaterialCache 

Function Documentation

◆ AreShaderErrorsFatal()

bool AreShaderErrorsFatal ( )

◆ BeginRecompileGlobalShaders()

ENGINE_API void BeginRecompileGlobalShaders ( const TArray< const FShaderType * > &  OutdatedShaderTypes,
const TArray< const FShaderPipelineType * > &  OutdatedShaderPipelineTypes,
EShaderPlatform  ShaderPlatform,
const ITargetPlatform TargetPlatform = nullptr,
const FShaderCompilerFlags InExtraCompilerFlags = {} 
)
extern

Begins recompiling the specified global shader types, and flushes their bound shader states. FinishRecompileGlobalShaders must be called after this and before using the global shaders for anything.

◆ CompileGlobalShaderMap() [1/4]

ENGINE_API void CompileGlobalShaderMap ( bool  bRefreshShaderMap = false)
extern

◆ CompileGlobalShaderMap() [2/4]

ENGINE_API void CompileGlobalShaderMap ( ERHIFeatureLevel::Type  InFeatureLevel,
bool  bRefreshShaderMap = false 
)
extern

◆ CompileGlobalShaderMap() [3/4]

ENGINE_API void CompileGlobalShaderMap ( EShaderPlatform  Platform,
bool  bRefreshShaderMap = false 
)
extern

◆ CompileGlobalShaderMap() [4/4]

ENGINE_API void CompileGlobalShaderMap ( EShaderPlatform  Platform,
const ITargetPlatform TargetPlatform,
bool  bRefreshShaderMap 
)
extern

◆ CreateShadersOnLoad()

bool CreateShadersOnLoad ( )

◆ DECLARE_LOG_CATEGORY_EXTERN()

DECLARE_LOG_CATEGORY_EXTERN ( LogShaderCompilers  ,
Log  ,
All   
)

◆ DumpShaderDDCKeyToFile()

ENGINE_API void DumpShaderDDCKeyToFile ( const EShaderPlatform  InPlatform,
bool  bWithEditor,
const TCHAR DebugGroupName,
const FString &  DDCKey 
)
extern

◆ FinishRecompileGlobalShaders()

ENGINE_API void FinishRecompileGlobalShaders ( )
extern

Finishes recompiling global shaders. Must be called after BeginRecompileGlobalShaders.

◆ GetGlobalShaderMapDDCGuid()

ENGINE_API const FGuid & GetGlobalShaderMapDDCGuid ( )
extern

◆ GetMaterialShaderMapDDCGuid()

ENGINE_API const FGuid & GetMaterialShaderMapDDCGuid ( )
extern

◆ GetOutdatedShaderTypes()

void GetOutdatedShaderTypes ( TArray< const FShaderType * > &  OutdatedShaderTypes,
TArray< const FShaderPipelineType * > &  OutdatedShaderPipelineTypes,
TArray< const FVertexFactoryType * > &  OutdatedFactoryTypes 
)
extern

◆ GetShaderCompilerCurrentMemoryLimits()

ENGINE_API void GetShaderCompilerCurrentMemoryLimits ( FShaderCompilerMemoryLimits limits)
extern

◆ IsGlobalShaderMapComplete()

ENGINE_API bool IsGlobalShaderMapComplete ( const TCHAR TypeNameSubstring = nullptr)
extern

Returns whether all global shader types containing the substring are complete and ready for rendering. if type name is null, check everything

◆ IsMaterialMapDDCEnabled()

ENGINE_API bool IsMaterialMapDDCEnabled ( )
extern

◆ IsShaderJobCacheDDCEnabled()

ENGINE_API bool IsShaderJobCacheDDCEnabled ( )
extern

◆ LoadGlobalShadersForRemoteRecompile()

ENGINE_API void LoadGlobalShadersForRemoteRecompile ( FArchive Ar,
EShaderPlatform  ShaderPlatform 
)
extern

Serializes a global shader map to an archive (used with recompiling shaders for a remote console)

◆ ODSCCmdEnumToString()

ENGINE_API const TCHAR * ODSCCmdEnumToString ( ODSCRecompileCommand  Cmd)
extern

◆ PrecacheComputePipelineStatesForGlobalShaders()

ENGINE_API void PrecacheComputePipelineStatesForGlobalShaders ( ERHIFeatureLevel::Type  FeatureLevel,
const ITargetPlatform TargetPlatform 
)
extern

Precreates compute PSOs for global shaders. Separate from Compile/VerifyGlobalShaders to avoid blocking loads.

◆ ProcessCookOnTheFlyShaders()

ENGINE_API void ProcessCookOnTheFlyShaders ( bool  bReloadGlobalShaders,
const TArray< uint8 > &  MeshMaterialMaps,
const TArray< FString > &  MaterialsToLoad,
const TArray< uint8 > &  GlobalShaderMap 
)
extern

Handles serializing in MeshMaterialMaps or GlobalShaderMap from a CookOnTheFly command and applying them to the in-memory shadermaps.

Parameters
MeshMaterialMapsByte array that contains the serialized material shadermap from across the network.
MaterialsToLoadThe materials contained in the MeshMaterialMaps
GlobalShaderMapByte array that contains the serialized global shadermap from across the network.

◆ RecompileChangedShadersForPlatform()

ENGINE_API bool RecompileChangedShadersForPlatform ( const FString &  PlatformName)
extern

Recompiles global shaders and material shaders rebuilds global shaders and also clears the cooked platform data for all materials if there is a global shader change detected can be slow

◆ RecompileGlobalShaders()

ENGINE_API void RecompileGlobalShaders ( )
extern

Forces a recompile of the global shaders.

◆ RecompileShaders()

bool RecompileShaders ( const TCHAR Cmd,
FOutputDevice Ar 
)
extern

Implementation of the 'recompileshaders' console command. Recompiles shaders at runtime based on various criteria.

◆ SaveGlobalShaderFile()

ENGINE_API FString SaveGlobalShaderFile ( EShaderPlatform  Platform,
FString  SavePath,
class ITargetPlatform TargetPlatform 
)
extern

Saves the global shader map as a file for the target platform.

Returns
the name of the file written

Saves the global shader map as a file for the target platform.

◆ SetShaderCompilerTargetMemoryLimitInMiB()

ENGINE_API void SetShaderCompilerTargetMemoryLimitInMiB ( int32  NewLimit)
extern

◆ ShouldCompileODSCOnlyShaders()

ENGINE_API bool ShouldCompileODSCOnlyShaders ( )
extern

Returns true if we should compile shaders that are only compiled in on demand shader compilation modes and not stored in cooked shader maps. This can be useful for debug shaders.

◆ ShouldDumpShaderDDCKeys()

ENGINE_API bool ShouldDumpShaderDDCKeys ( )
extern

◆ ShutdownGlobalShaderMap()

ENGINE_API void ShutdownGlobalShaderMap ( )
extern

◆ VerifyGlobalShaders() [1/2]

ENGINE_API void VerifyGlobalShaders ( EShaderPlatform  Platform,
bool  bLoadedFromCacheFile,
const TArray< const FShaderType * > *  OutdatedShaderTypes = nullptr,
const TArray< const FShaderPipelineType * > *  OutdatedShaderPipelineTypes = nullptr 
)
extern

Makes sure all global shaders are loaded and/or compiled for the passed in platform. Note: if compilation is needed, this only kicks off the compile.

Parameters
PlatformPlatform to verify global shaders for
bLoadedFromCacheFileLoad the shaders from cache, will error out and not compile shaders if missing
OutdatedShaderTypesOptional list of shader types, will trigger compilation job for shader types found in this list even if the map already has the shader.
OutdatedShaderPipelineTypesOptional list of shader pipeline types, will trigger compilation job for shader pipeline types found in this list even if the map already has the pipeline.

◆ VerifyGlobalShaders() [2/2]

ENGINE_API void VerifyGlobalShaders ( EShaderPlatform  Platform,
const ITargetPlatform TargetPlatform,
bool  bLoadedFromCacheFile,
const TArray< const FShaderType * > *  OutdatedShaderTypes,
const TArray< const FShaderPipelineType * > *  OutdatedShaderPipelineTypes,
const FShaderCompilerFlags InExtraCompilerFlags 
)
extern

Makes sure all global shaders are loaded and/or compiled for the passed in platform. Note: if compilation is needed, this only kicks off the compile.

Parameters
PlatformPlatform to verify global shaders for

Variable Documentation

◆ GShaderCompilerStats

ENGINE_API FShaderCompilerStats* GShaderCompilerStats
extern

The global shader compiling stats

◆ GShaderCompilingManager

ENGINE_API FShaderCompilingManager* GShaderCompilingManager
extern

The global shader compiling thread manager.