UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FShaderCompilingManager Class Reference

#include <ShaderCompiler.h>

+ Inheritance diagram for FShaderCompilingManager:

Public Types

enum class  EDumpShaderDebugInfo : int32 { Never = 0 , Always = 1 , OnError = 2 , OnErrorOrWarning = 3 }
 

Public Member Functions

ENGINE_API FShaderCompilingManager ()
 
ENGINE_API ~FShaderCompilingManager ()
 
ENGINE_API void OnMachineResourcesChanged (int32 NumberOfCores, int32 NumberOfCoresIncludingHyperthreads)
 
ENGINE_API void OnDistributedShaderCompilingChanged ()
 
ENGINE_API int32 GetNumPendingJobs () const
 
ENGINE_API int32 GetNumOutstandingJobs () const
 
ENGINE_API FShaderCompilerMemoryLimits GetCurrentMemoryLimits () const
 
ENGINE_API void SetTargetMemoryLimitInMiB (int32 NewLimit)
 
bool ShouldDisplayCompilingNotification () const
 
bool AllowAsynchronousShaderCompiling () const
 
bool IsCompiling () const
 
bool IsRemoteCompilingEnabled () const
 
bool IsExclusiveDistributedCompilingEnabled () const
 
bool IgnoreAllThrottling () const
 
bool HasShaderJobs () const
 
int32 GetNumRemainingJobs () const
 
int32 GetNumLocalWorkers () const
 
void SetExternalJobs (int32 NumJobs)
 
ENGINE_API EDumpShaderDebugInfo GetDumpShaderDebugInfo () const
 
ENGINE_API EShaderDebugInfoFlags GetDumpShaderDebugInfoFlags () const
 
ENGINE_API FString CreateShaderDebugInfoPath (const FShaderCompilerInput &ShaderCompilerInput) const
 
ENGINE_API bool ShouldRecompileToDumpShaderDebugInfo (const FShaderCompileJob &Job) const
 
ENGINE_API bool ShouldRecompileToDumpShaderDebugInfo (const FShaderCompilerInput &Input, const FShaderCompilerOutput &Output, bool bSucceeded) const
 
void IncrementNumDumpedShaderSources ()
 
const FString & GetAbsoluteShaderDebugInfoDirectory () const
 
bool AreWarningsSuppressed (const EShaderPlatform Platform) const
 
void SuppressWarnings (const EShaderPlatform Platform)
 
bool IsShaderCompilationSkipped () const
 
void SkipShaderCompilation (bool toggle)
 
void SetAllowForIncompleteShaderMaps (bool toggle)
 
ENGINE_API bool IsCompilingShaderMap (uint32 Id)
 
ENGINE_API FShaderCompileJobPrepareShaderCompileJob (uint32 Id, const FShaderCompileJobKey &Key, EShaderCompileJobPriority Priority)
 
ENGINE_API FShaderPipelineCompileJobPreparePipelineCompileJob (uint32 Id, const FShaderPipelineCompileJobKey &Key, EShaderCompileJobPriority Priority)
 
void ProcessFinishedJob (FShaderCommonCompileJob *FinishedJob)
 
ENGINE_API void ProcessFinishedJob (FShaderCommonCompileJob *FinishedJob, EShaderCompileJobStatus Status)
 
ENGINE_API void SubmitJobs (TArray< FShaderCommonCompileJobPtr > &NewJobs, const FString MaterialBasePath, FString PermutationString=FString(""))
 
ENGINE_API void CancelCompilation (const TCHAR *MaterialName, const TArray< int32 > &ShaderMapIdsToCancel)
 
ENGINE_API void FinishCompilation (const TCHAR *MaterialName, const TArray< int32 > &ShaderMapIdsToFinishCompiling)
 
ENGINE_API void FinishAllCompilation () override
 
ENGINE_API void Shutdown () override
 
ENGINE_API void PrintStats ()
 
ENGINE_API void GetLocalStats (FShaderCompilerStats &OutStats) const
 
ENGINE_API FShaderCompileMemoryUsage GetExternalMemoryUsage ()
 
ENGINE_API void ProcessAsyncResults (float TimeSlice, bool bBlockOnGlobalShaderCompletion)
 
ENGINE_API void ProcessAsyncResults (bool bLimitExecutionTime, bool bBlockOnGlobalShaderCompletion)
 
ENGINE_API void DumpDebugInfoForEachPendingJob (const FShaderCompileJobCallback &PendingJobCallback) const
 

Static Public Member Functions

static ENGINE_API FName GetStaticAssetTypeName ()
 
static bool IsShaderCompilerWorkerRunning (FProcHandle &WorkerHandle)
 

Friends

class FShaderCompileThreadRunnableBase
 
class FShaderCompileThreadRunnable
 
class FShaderCompileDistributedThreadRunnable_Interface
 
class FShaderCompileFASTBuildThreadRunnable
 

Detailed Description

Manager of asynchronous and parallel shader compilation. This class contains an interface to enqueue and retreive asynchronous shader jobs, and manages a FShaderCompileThreadRunnable.

Member Enumeration Documentation

◆ EDumpShaderDebugInfo

Enumerator
Never 
Always 
OnError 
OnErrorOrWarning 

Constructor & Destructor Documentation

◆ FShaderCompilingManager()

FShaderCompilingManager::FShaderCompilingManager ( )

◆ ~FShaderCompilingManager()

FShaderCompilingManager::~FShaderCompilingManager ( )

Member Function Documentation

◆ AllowAsynchronousShaderCompiling()

bool FShaderCompilingManager::AllowAsynchronousShaderCompiling ( ) const
inline

◆ AreWarningsSuppressed()

bool FShaderCompilingManager::AreWarningsSuppressed ( const EShaderPlatform  Platform) const
inline

◆ CancelCompilation()

void FShaderCompilingManager::CancelCompilation ( const TCHAR MaterialName,
const TArray< int32 > &  ShaderMapIdsToCancel 
)

Removes all outstanding compile jobs for the passed shader maps.

◆ CreateShaderDebugInfoPath()

FString FShaderCompilingManager::CreateShaderDebugInfoPath ( const FShaderCompilerInput ShaderCompilerInput) const

◆ DumpDebugInfoForEachPendingJob()

void FShaderCompilingManager::DumpDebugInfoForEachPendingJob ( const FShaderCompileJobCallback PendingJobCallback) const

Dumps the debug information for each pending job for which PendingJobCallback returns true.

◆ FinishAllCompilation()

void FShaderCompilingManager::FinishAllCompilation ( )
overridevirtual

Blocks until completion of all async shader compiling, and assigns shader maps to relevant materials. This should be called before exit if the DDC needs to be made up to date.

Implements IAssetCompilingManager.

◆ FinishCompilation()

void FShaderCompilingManager::FinishCompilation ( const TCHAR MaterialName,
const TArray< int32 > &  ShaderMapIdsToFinishCompiling 
)

Blocks until completion of the requested shader maps.
This will not assign the shader map to any materials, the caller is responsible for that.

◆ GetAbsoluteShaderDebugInfoDirectory()

const FString & FShaderCompilingManager::GetAbsoluteShaderDebugInfoDirectory ( ) const
inline

◆ GetCurrentMemoryLimits()

ENGINE_API FShaderCompilerMemoryLimits FShaderCompilingManager::GetCurrentMemoryLimits ( ) const

◆ GetDumpShaderDebugInfo()

FShaderCompilingManager::EDumpShaderDebugInfo FShaderCompilingManager::GetDumpShaderDebugInfo ( ) const

◆ GetDumpShaderDebugInfoFlags()

EShaderDebugInfoFlags FShaderCompilingManager::GetDumpShaderDebugInfoFlags ( ) const

◆ GetExternalMemoryUsage()

FShaderCompileMemoryUsage FShaderCompilingManager::GetExternalMemoryUsage ( )

Returns the current memory usage of external local compilation processes in bytes.

◆ GetLocalStats()

void FShaderCompilingManager::GetLocalStats ( FShaderCompilerStats OutStats) const

Retrieve compiler statistics for all compilation done in this process. Note that this will not include stats for any compilation that occurs in worker processes in a multiprocess cook.

◆ GetNumLocalWorkers()

int32 FShaderCompilingManager::GetNumLocalWorkers ( ) const
inline

Returns the (current) number of local workers.

◆ GetNumOutstandingJobs()

int32 FShaderCompilingManager::GetNumOutstandingJobs ( ) const

◆ GetNumPendingJobs()

int32 FShaderCompilingManager::GetNumPendingJobs ( ) const

◆ GetNumRemainingJobs()

int32 FShaderCompilingManager::GetNumRemainingJobs ( ) const
inline

Returns the number of outstanding compile jobs. Note: This is dependent on NumOutstandingJobs which is updated from another thread, so the results are non-deterministic.

◆ GetStaticAssetTypeName()

FName FShaderCompilingManager::GetStaticAssetTypeName ( )
static

Get the name of the asset type this compiler handles

◆ HasShaderJobs()

bool FShaderCompilingManager::HasShaderJobs ( ) const
inline

return true if we have shader jobs in any state shader jobs are removed when they are applied to the gamethreadshadermap accessable from gamethread

◆ IgnoreAllThrottling()

bool FShaderCompilingManager::IgnoreAllThrottling ( ) const
inline

Returns whether normal throttling settings should be ignored because shader compilation is at the moment the only action blocking the critical path. An example of such situation is startup compilation of global shaders and default materials, but there may be more cases like that.

◆ IncrementNumDumpedShaderSources()

void FShaderCompilingManager::IncrementNumDumpedShaderSources ( )
inline

◆ IsCompiling()

bool FShaderCompilingManager::IsCompiling ( ) const
inline

Returns whether async compiling is happening. Note: This is dependent on NumOutstandingJobs which is updated from another thread, so the results are non-deterministic.

◆ IsCompilingShaderMap()

bool FShaderCompilingManager::IsCompilingShaderMap ( uint32  Id)

◆ IsExclusiveDistributedCompilingEnabled()

bool FShaderCompilingManager::IsExclusiveDistributedCompilingEnabled ( ) const
inline

Returns whether shaders are exclusively compiled through distributed controller, i.e. no local shader compiling thread is allocated. If this is true, the distributed controller must not refuse job batches below a minimum threshold, otherwise those jobs will never get picked up.

◆ IsRemoteCompilingEnabled()

bool FShaderCompilingManager::IsRemoteCompilingEnabled ( ) const
inline

Returns whether remote compiling is enabled. Otherwise, only the local machine is used for shader compilation. This depends on command line argument '-NoRemoteShaderCompile', CVar 'r.ShaderCompiler.AllowDistributedCompilation', and whether the target platform supports remote compilin; see ITargetPlatform::CanSupportRemoteShaderCompile().

◆ IsShaderCompilationSkipped()

bool FShaderCompilingManager::IsShaderCompilationSkipped ( ) const
inline

◆ IsShaderCompilerWorkerRunning()

bool FShaderCompilingManager::IsShaderCompilerWorkerRunning ( FProcHandle WorkerHandle)
static

Returns true if the given shader compile worker is still running.

◆ OnDistributedShaderCompilingChanged()

void FShaderCompilingManager::OnDistributedShaderCompilingChanged ( )

Called when CVars are changed at runtime that determine whether or not the distributed shader compiler supports local workers (e.g. 'r.XGEController.AvoidUsingLocalMachine' can be changed at runtime).

◆ OnMachineResourcesChanged()

void FShaderCompilingManager::OnMachineResourcesChanged ( int32  NumberOfCores,
int32  NumberOfCoresIncludingHyperthreads 
)

Called by external systems that have updated the number of worker threads available.

◆ PreparePipelineCompileJob()

FShaderPipelineCompileJob * FShaderCompilingManager::PreparePipelineCompileJob ( uint32  Id,
const FShaderPipelineCompileJobKey Key,
EShaderCompileJobPriority  Priority 
)

◆ PrepareShaderCompileJob()

FShaderCompileJob * FShaderCompilingManager::PrepareShaderCompileJob ( uint32  Id,
const FShaderCompileJobKey Key,
EShaderCompileJobPriority  Priority 
)

Prepares a job of the given type for compilation. If a job with the given Id/Key already exists, it will attempt to adjust to the higher priority if possible, and nullptr will be returned. If a non-nullptr is returned, the given job should be filled out with relevant information, then passed to SubmitJobs() when ready

◆ PrintStats()

void FShaderCompilingManager::PrintStats ( )

Prints stats related to shader compilation to the log.

◆ ProcessAsyncResults() [1/2]

void FShaderCompilingManager::ProcessAsyncResults ( bool  bLimitExecutionTime,
bool  bBlockOnGlobalShaderCompletion 
)

Version of ProcessAsyncResults that specifies use of ProcessGameThreadTargetTime for the timeslice.

◆ ProcessAsyncResults() [2/2]

void FShaderCompilingManager::ProcessAsyncResults ( float  TimeSlice,
bool  bBlockOnGlobalShaderCompletion 
)

Processes completed asynchronous shader maps, and assigns them to relevant materials.

Parameters
TimeSlice- When more than 0, ProcessAsyncResults will be bandwidth throttled by the given timeslice, to limit hitching. ProcessAsyncResults will then have to be called often to finish all shader maps (eg from Tick). Otherwise, all compiled shader maps will be processed.
bBlockOnGlobalShaderCompletion- When enabled, ProcessAsyncResults will block until global shader maps are complete. This must be done before using global shaders for rendering.

◆ ProcessFinishedJob() [1/2]

void FShaderCompilingManager::ProcessFinishedJob ( FShaderCommonCompileJob FinishedJob)
inline

◆ ProcessFinishedJob() [2/2]

void FShaderCompilingManager::ProcessFinishedJob ( FShaderCommonCompileJob FinishedJob,
EShaderCompileJobStatus  Status 
)

This is an entry point for all jobs that have finished the compilation. Can be called from multiple threads.

◆ SetAllowForIncompleteShaderMaps()

void FShaderCompilingManager::SetAllowForIncompleteShaderMaps ( bool  toggle)
inline

◆ SetExternalJobs()

void FShaderCompilingManager::SetExternalJobs ( int32  NumJobs)
inline

◆ SetTargetMemoryLimitInMiB()

ENGINE_API void FShaderCompilingManager::SetTargetMemoryLimitInMiB ( int32  NewLimit)

◆ ShouldDisplayCompilingNotification()

bool FShaderCompilingManager::ShouldDisplayCompilingNotification ( ) const
inline

Returns whether to display a notification that shader compiling is happening in the background. Note: This is dependent on NumOutstandingJobs which is updated from another thread, so the results are non-deterministic.

◆ ShouldRecompileToDumpShaderDebugInfo() [1/2]

bool FShaderCompilingManager::ShouldRecompileToDumpShaderDebugInfo ( const FShaderCompileJob Job) const

◆ ShouldRecompileToDumpShaderDebugInfo() [2/2]

bool FShaderCompilingManager::ShouldRecompileToDumpShaderDebugInfo ( const FShaderCompilerInput Input,
const FShaderCompilerOutput Output,
bool  bSucceeded 
) const

◆ Shutdown()

void FShaderCompilingManager::Shutdown ( )
overridevirtual

Shutdown the shader compiler manager, this will shutdown immediately and not process any more shader compile requests.

Shutdown the shader compile manager this function should be used when ending the game to shutdown shader compile threads will not complete current pending shader compilation

Implements IAssetCompilingManager.

◆ SkipShaderCompilation()

void FShaderCompilingManager::SkipShaderCompilation ( bool  toggle)
inline

◆ SubmitJobs()

void FShaderCompilingManager::SubmitJobs ( TArray< FShaderCommonCompileJobPtr > &  NewJobs,
const FString  MaterialBasePath,
FString  PermutationString = FString("") 
)

Adds shader jobs to be asynchronously compiled. FinishCompilation or ProcessAsyncResults must be used to get the results.

◆ SuppressWarnings()

void FShaderCompilingManager::SuppressWarnings ( const EShaderPlatform  Platform)
inline

Friends And Related Symbol Documentation

◆ FShaderCompileDistributedThreadRunnable_Interface

◆ FShaderCompileFASTBuildThreadRunnable

friend class FShaderCompileFASTBuildThreadRunnable
friend

◆ FShaderCompileThreadRunnable

◆ FShaderCompileThreadRunnableBase


The documentation for this class was generated from the following files: