UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ShaderCompilerCore.h File Reference
#include "CoreMinimal.h"
#include "HAL/FileManager.h"
#include "Hash/Blake3.h"
#include "Hash/xxhash.h"
#include "Stats/Stats.h"
#include "Templates/RefCounting.h"
#include "Misc/EnumClassFlags.h"
#include "Misc/SecureHash.h"
#include "Misc/Paths.h"
#include "Misc/PathViews.h"
#include "Misc/CoreStats.h"
#include "ShaderCore.h"
#include "ShaderParameterMetadata.h"
#include "ShaderCompilerFlags.inl"

Go to the source code of this file.

Classes

struct  FShaderCompilerResourceTable
 
struct  FExtraShaderCompilerSettings
 
struct  FShaderDebugDataContext
 
struct  FShaderCompilerInput
 
struct  FShaderCompilerError
 
struct  FShaderCompilerOutput
 
struct  FShaderCompileWorkerDiagnostics
 
struct  FShaderPreprocessDependency
 
struct  FShaderPreprocessDependencies
 

Namespaces

namespace  UE
 
namespace  UE::ShaderCompiler
 
namespace  FOodleDataCompression
 

Macros

#define SHADER_COMPILER_FLAGS_ENTRY(Name)   CFLAG_##Name,
 
#define SHADER_COMPILER_FLAGS_ENTRY_DEPRECATED(Name, Version, Message)   CFLAG_##Name UE_DEPRECATED(Version, Message),
 

Typedefs

using FShaderSharedStringPtr = TSharedPtr< FString, ESPMode::ThreadSafe >
 
typedef TSharedPtr< TArray< ANSICHAR >, ESPMode::ThreadSafeFShaderSharedAnsiStringPtr
 
using FShaderCompilerInputHash = FBlake3Hash
 
typedef TSharedPtr< FShaderPreprocessDependencies, ESPMode::ThreadSafeFShaderPreprocessDependenciesShared
 

Enumerations

enum class  EWriteShaderSymbols : uint8 { Disable = 0 , UnCompress = 1 , Compress = 2 }
 
enum  ECompilerFlags { CFLAG_Max }
 
enum class  EOfflineShaderCompilerType : uint8 { Mali , Adreno , Num }
 
enum class  EShaderDebugInfoFlags : uint8 {
  Default = 0 , UE_DEPRECATED =(5.7, "DirectCompile has been renamed DebugCompile and DebugCompileArgs.txt is dumped by default") = 1 << 0 , InputHash = 1 << 1 , Diagnostics = 1 << 2 ,
  ShaderCodeBinary = 1 << 3 , DetailedSource = 1 << 4 , CompileFromDebugUSF = 1 << 5 , ShaderCodePlatformHashes = 1 << 6
}
 
enum class  EConvertAndStripFlags : uint8 { None = 0 , NoSimdPadding = 1 << 0 }
 
enum class  EShaderCompilerWorkerType : uint8 { None , LocalThread , Distributed }
 
enum class  EShaderCompileJobType : uint8 { Single , Pipeline , Num }
 

Functions

RENDERCORE_API ERHIBindlessConfiguration UE::ShaderCompiler::GetBindlessConfiguration (EShaderPlatform ShaderPlatform)
 
RENDERCORE_API bool UE::ShaderCompiler::ShouldCompileWithBindlessEnabled (EShaderPlatform ShaderPlatform, const FShaderCompilerInput &Input)
 
RENDERCORE_API ERHIBindlessConfiguration UE::ShaderCompiler::GetBindlessResourcesConfiguration (FName ShaderFormat)
 
RENDERCORE_API ERHIBindlessConfiguration UE::ShaderCompiler::GetBindlessSamplersConfiguration (FName ShaderFormat)
 
RENDERCORE_API const FString & GetBuildMachineArtifactBasePath ()
 
RENDERCORE_API const FString & GetShaderDebugInfoPath ()
 
RENDERCORE_API bool ShouldGenerateShaderSymbols (FName ShaderFormat)
 
RENDERCORE_API bool ShouldGenerateShaderSymbolsInfo (FName ShaderFormat)
 
RENDERCORE_API bool ShouldWriteShaderSymbols (FName ShaderFormat)
 
RENDERCORE_API bool GetShaderSymbolPathOverride (FString &OutPathOverride, FName ShaderFormat)
 
RENDERCORE_API bool GetShaderFileNameOverride (FString &OutFileNameOverride, const TCHAR *Cvar, FName ShaderFormat, FName PlatformName)
 
RENDERCORE_API bool ShouldAllowUniqueShaderSymbols (FName ShaderFormat)
 
RENDERCORE_API EWriteShaderSymbols GetWriteShaderSymbolsOptions (FName ShaderFormat)
 
RENDERCORE_API bool ShouldEnableExtraShaderData (FName ShaderFormat)
 
RENDERCORE_API bool ShouldOptimizeShaders (FName ShaderFormat)
 
RENDERCORE_API bool AllowShaderCompiling ()
 
RENDERCORE_API bool AllowGlobalShaderLoad ()
 
RENDERCORE_API void LexFromString (ECompilerFlags &OutValue, const TCHAR *InString)
 
RENDERCORE_API const TCHARLexToString (ECompilerFlags InValue)
 
RENDERCORE_API const IShaderFormatFindShaderFormat (FName Format, const TArray< const IShaderFormat * > &ShaderFormats)
 
RENDERCORE_API bool PreprocessShader (FShaderCommonCompileJob *Job)
 
RENDERCORE_API void CompileShader (const TArray< const IShaderFormat * > &ShaderFormats, FShaderCompileJob &Job, const FString &WorkingDirectory, int32 *CompileCount=nullptr)
 
RENDERCORE_API void CompileShaderPipeline (const TArray< const IShaderFormat * > &ShaderFormats, FShaderPipelineCompileJob *PipelineJob, const FString &WorkingDirectory, int32 *CompileCount=nullptr)
 
RENDERCORE_API bool CheckVirtualShaderFilePath (FStringView VirtualPath, TArray< FShaderCompilerError > *CompileErrors=nullptr)
 
RENDERCORE_API void FixupShaderFilePath (FString &VirtualFilePath, EShaderPlatform ShaderPlatform, const FName *ShaderPlatformName)
 
 ENUM_CLASS_FLAGS (EConvertAndStripFlags)
 
RENDERCORE_API void ShaderConvertAndStripComments (const FString &ShaderSource, TArray< ANSICHAR > &OutStripped, EConvertAndStripFlags Flags=EConvertAndStripFlags::None)
 
RENDERCORE_API bool LoadShaderSourceFile (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform, FString *OutFileContents, TArray< FShaderCompilerError > *OutCompileErrors, const FName *ShaderPlatformName=nullptr, FShaderSharedAnsiStringPtr *OutStrippedContents=nullptr)
 
RENDERCORE_API bool LoadCachedShaderSourceFile (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform, FShaderSharedStringPtr *OutFileContents, TArray< FShaderCompilerError > *OutCompileErrors, const FName *ShaderPlatformName=nullptr, FShaderSharedAnsiStringPtr *OutStrippedContents=nullptr)
 
RENDERCORE_API bool GetShaderPreprocessDependencies (const TCHAR *VirtualFilePath, EShaderPlatform ShaderPlatform, FShaderPreprocessDependenciesShared &OutDependencies)
 

Variables

const int32 ShaderCompileWorkerInputVersion = 32
 
const int32 ShaderCompileWorkerOutputVersion = 28
 
const int32 ShaderCompileWorkerSingleJobHeader = 'S'
 
const int32 ShaderCompileWorkerPipelineJobHeader = 'P'
 
RENDERCORE_API const FGuid UE_SHADER_CACHE_VERSION
 
constexpr int32 NumShaderCompileJobTypes = (int32)EShaderCompileJobType::Num
 

Macro Definition Documentation

◆ SHADER_COMPILER_FLAGS_ENTRY

#define SHADER_COMPILER_FLAGS_ENTRY (   Name)    CFLAG_##Name,

◆ SHADER_COMPILER_FLAGS_ENTRY_DEPRECATED

#define SHADER_COMPILER_FLAGS_ENTRY_DEPRECATED (   Name,
  Version,
  Message 
)    CFLAG_##Name UE_DEPRECATED(Version, Message),

Typedef Documentation

◆ FShaderCompilerInputHash

◆ FShaderPreprocessDependenciesShared

◆ FShaderSharedAnsiStringPtr

◆ FShaderSharedStringPtr

Enumeration Type Documentation

◆ ECompilerFlags

Enumerator
CFLAG_Max 

◆ EConvertAndStripFlags

Enumerator
None 
NoSimdPadding 

◆ EOfflineShaderCompilerType

enumeration of offline shader compiler for the material editor

Enumerator
Mali 
Adreno 
Num 

◆ EShaderCompileJobType

Enumerator
Single 
Pipeline 
Num 

◆ EShaderCompilerWorkerType

Enumerator
None 
LocalThread 
Distributed 

◆ EShaderDebugInfoFlags

Enumerator
Default 
UE_DEPRECATED 
InputHash 
Diagnostics 
ShaderCodeBinary 
DetailedSource 
CompileFromDebugUSF 
ShaderCodePlatformHashes 

◆ EWriteShaderSymbols

enum class EWriteShaderSymbols : uint8
strong
Enumerator
Disable 
UnCompress 
Compress 

Function Documentation

◆ AllowGlobalShaderLoad()

RENDERCORE_API bool AllowGlobalShaderLoad ( )
extern

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

◆ AllowShaderCompiling()

RENDERCORE_API bool AllowShaderCompiling ( )
extern

Returns true is shader compiling is allowed

◆ CheckVirtualShaderFilePath()

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

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.

◆ CompileShader()

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

◆ CompileShaderPipeline()

RENDERCORE_API void CompileShaderPipeline ( const TArray< const IShaderFormat * > &  ShaderFormats,
FShaderPipelineCompileJob PipelineJob,
const FString &  WorkingDirectory,
int32 CompileCount = nullptr 
)
extern

◆ ENUM_CLASS_FLAGS()

ENUM_CLASS_FLAGS ( EConvertAndStripFlags  )

◆ FindShaderFormat()

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

◆ FixupShaderFilePath()

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

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

◆ GetBuildMachineArtifactBasePath()

RENDERCORE_API const FString & GetBuildMachineArtifactBasePath ( )
extern

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

◆ GetShaderDebugInfoPath()

RENDERCORE_API const FString & GetShaderDebugInfoPath ( )
extern

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

◆ GetShaderFileNameOverride()

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

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

◆ GetShaderPreprocessDependencies()

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

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

◆ GetShaderSymbolPathOverride()

RENDERCORE_API bool GetShaderSymbolPathOverride ( FString &  OutPathOverride,
FName  ShaderFormat 
)
extern

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

◆ GetWriteShaderSymbolsOptions()

RENDERCORE_API EWriteShaderSymbols GetWriteShaderSymbolsOptions ( FName  ShaderFormat)
extern

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

◆ LexFromString()

RENDERCORE_API void LexFromString ( ECompilerFlags OutValue,
const TCHAR InString 
)
extern

◆ LexToString()

RENDERCORE_API const TCHAR * LexToString ( ECompilerFlags  InValue)
extern

◆ LoadCachedShaderSourceFile()

RENDERCORE_API bool LoadCachedShaderSourceFile ( const TCHAR VirtualFilePath,
EShaderPlatform  ShaderPlatform,
FShaderSharedStringPtr OutFileContents,
TArray< FShaderCompilerError > *  OutCompileErrors,
const FName ShaderPlatformName = nullptr,
FShaderSharedAnsiStringPtr OutStrippedContents = nullptr 
)
extern

◆ LoadShaderSourceFile()

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

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.

◆ PreprocessShader()

RENDERCORE_API bool PreprocessShader ( FShaderCommonCompileJob Job)
extern

◆ ShaderConvertAndStripComments()

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

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

◆ ShouldAllowUniqueShaderSymbols()

RENDERCORE_API bool ShouldAllowUniqueShaderSymbols ( FName  ShaderFormat)
extern

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

◆ ShouldEnableExtraShaderData()

RENDERCORE_API bool ShouldEnableExtraShaderData ( FName  ShaderFormat)
extern

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

◆ ShouldGenerateShaderSymbols()

RENDERCORE_API bool ShouldGenerateShaderSymbols ( FName  ShaderFormat)
extern

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

◆ ShouldGenerateShaderSymbolsInfo()

RENDERCORE_API bool ShouldGenerateShaderSymbolsInfo ( FName  ShaderFormat)
extern

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

◆ ShouldOptimizeShaders()

RENDERCORE_API bool ShouldOptimizeShaders ( FName  ShaderFormat)
extern

◆ ShouldWriteShaderSymbols()

RENDERCORE_API bool ShouldWriteShaderSymbols ( FName  ShaderFormat)
extern

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

Variable Documentation

◆ NumShaderCompileJobTypes

constexpr int32 NumShaderCompileJobTypes = (int32)EShaderCompileJobType::Num
inlineconstexpr

◆ ShaderCompileWorkerInputVersion

const int32 ShaderCompileWorkerInputVersion = 32
inline

◆ ShaderCompileWorkerOutputVersion

const int32 ShaderCompileWorkerOutputVersion = 28
inline

◆ ShaderCompileWorkerPipelineJobHeader

const int32 ShaderCompileWorkerPipelineJobHeader = 'P'
inline

◆ ShaderCompileWorkerSingleJobHeader

const int32 ShaderCompileWorkerSingleJobHeader = 'S'
inline

◆ UE_SHADER_CACHE_VERSION

RENDERCORE_API const FGuid UE_SHADER_CACHE_VERSION
extern