UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Shader.cpp File Reference
#include "Shader.h"
#include "Misc/CoreMisc.h"
#include "Misc/StringBuilder.h"
#include "VertexFactory.h"
#include "ProfilingDebugging/DiagnosticTable.h"
#include "Interfaces/ITargetPlatform.h"
#include "Interfaces/ITargetPlatformManagerModule.h"
#include "Interfaces/IShaderFormat.h"
#include "Internationalization/Regex.h"
#include "Serialization/ShaderKeyGenerator.h"
#include "ShaderCodeLibrary.h"
#include "ShaderCore.h"
#include "ShaderCompilerCore.h"
#include "RenderUtils.h"
#include "StereoRenderUtils.h"
#include "Misc/ConfigCacheIni.h"
#include "Misc/ScopeLock.h"
#include "UObject/RenderingObjectVersion.h"
#include "ProfilingDebugging/LoadTimeTracker.h"
#include "Misc/LargeWorldRenderPosition.h"
#include "DataDrivenShaderPlatformInfo.h"
#include "ShaderPlatformCachedIniValue.h"
#include "ColorManagement/ColorSpace.h"

Functions

 DEFINE_LOG_CATEGORY (LogShaders)
 
 IMPLEMENT_TYPE_LAYOUT (FShader)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderParameterBindings)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderMapContent)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderTypeDependency)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderPipeline)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderUniformBufferParameterInfo)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderResourceParameterInfo)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderLooseParameterInfo)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderLooseParameterBufferInfo)
 
 IMPLEMENT_TYPE_LAYOUT (FShaderParameterMapInfo)
 
 IMPLEMENT_EXPORTED_INTRINSIC_TYPE_LAYOUT (TIndexedPtr< FShaderType >)
 
 IMPLEMENT_EXPORTED_INTRINSIC_TYPE_LAYOUT (TIndexedPtr< FVertexFactoryType >)
 
const FShaderPipelineTypeFindShaderPipelineType (FName TypeName)
 
FArchiveoperator<< (FArchive &Ar, const FShaderPipelineType *&TypeRef)
 
FArchiveoperator<< (FArchive &Ar, FShaderType *&Ref)
 
const FTypeLayoutDescGetTypeLayoutDesc (const FPointerTableBase *PtrTable, const FShader &Shader)
 
void DumpShaderStats (EShaderPlatform Platform, EShaderFrequency Frequency)
 
void DumpShaderPipelineStats (EShaderPlatform Platform)
 
FShaderTypeFindShaderTypeByName (const FHashedName &ShaderTypeName)
 
void DispatchComputeShader (FRHIComputeCommandList &RHICmdList, FShader *Shader, uint32 ThreadGroupCountX, uint32 ThreadGroupCountY, uint32 ThreadGroupCountZ)
 
void DispatchIndirectComputeShader (FRHIComputeCommandList &RHICmdList, FShader *Shader, FRHIBuffer *ArgumentBuffer, uint32 ArgumentOffset)
 
bool IsDxcEnabledForPlatform (EShaderPlatform Platform, bool bHlslVersion2021)
 
bool IsUsingEmulatedUniformBuffers (EShaderPlatform Platform)
 
void ShaderMapAppendKeyString (EShaderPlatform Platform, FString &KeyString)
 
void ShaderMapAppendKey (EShaderPlatform Platform, FShaderKeyGenerator &KeyGen)
 
void SetAdditionalShaderPermutationFlags (EShaderPermutationFlags AdditionalFlags)
 
EShaderPermutationFlags GetShaderPermutationFlags (const FPlatformTypeLayoutParameters &LayoutParams)
 
void RegisterRayTracingPayloadType (ERayTracingPayloadType PayloadType, uint32 PayloadSize, TRaytracingPayloadSizeFunction PayloadSizeFunction)
 
uint32 GetRayTracingPayloadTypeMaxSize (ERayTracingPayloadType PayloadType)
 

Function Documentation

◆ DEFINE_LOG_CATEGORY()

DEFINE_LOG_CATEGORY ( LogShaders  )

◆ DispatchComputeShader()

void DispatchComputeShader ( FRHIComputeCommandList RHICmdList,
FShader Shader,
uint32  ThreadGroupCountX,
uint32  ThreadGroupCountY,
uint32  ThreadGroupCountZ 
)

Helper function to dispatch a compute shader while checking that parameters have been set correctly.

◆ DispatchIndirectComputeShader()

void DispatchIndirectComputeShader ( FRHIComputeCommandList RHICmdList,
FShader Shader,
FRHIBuffer ArgumentBuffer,
uint32  ArgumentOffset 
)

Helper function to dispatch a compute shader indirectly while checking that parameters have been set correctly.

◆ DumpShaderPipelineStats()

void DumpShaderPipelineStats ( EShaderPlatform  Platform)

Dumps shader pipeline stats to the log. Does not include material (eg shader pipeline instance) information.

Parameters
Platform- Platform to dump shader info for, use SP_NumPlatforms for all

◆ DumpShaderStats()

void DumpShaderStats ( EShaderPlatform  Platform,
EShaderFrequency  Frequency 
)

Dumps shader stats to the log. Will also print some shader pipeline information.

Parameters
Platform- Platform to dump shader info for, use SP_NumPlatforms for all
Frequency- Whether to dump PS or VS info, use SF_NumFrequencies to dump both

◆ FindShaderPipelineType()

const FShaderPipelineType * FindShaderPipelineType ( FName  TypeName)
inline

Find the shader pipeline type with the given name.

Returns
NULL if no type matched.

◆ FindShaderTypeByName()

FShaderType * FindShaderTypeByName ( const FHashedName ShaderTypeName)

Finds the shader type with a given name.

Parameters
ShaderTypeName- The name of the shader type to find.
Returns
The shader type, or NULL if none matched.

◆ GetRayTracingPayloadTypeMaxSize()

uint32 GetRayTracingPayloadTypeMaxSize ( ERayTracingPayloadType  PayloadType)

◆ GetShaderPermutationFlags()

EShaderPermutationFlags GetShaderPermutationFlags ( const FPlatformTypeLayoutParameters LayoutParams)

Get the shader permutation flags associated with a platform layout.

◆ GetTypeLayoutDesc()

const FTypeLayoutDesc & GetTypeLayoutDesc ( const FPointerTableBase PtrTable,
const FShader Shader 
)

◆ IMPLEMENT_EXPORTED_INTRINSIC_TYPE_LAYOUT() [1/2]

IMPLEMENT_EXPORTED_INTRINSIC_TYPE_LAYOUT ( TIndexedPtr< FShaderType )

◆ IMPLEMENT_EXPORTED_INTRINSIC_TYPE_LAYOUT() [2/2]

IMPLEMENT_EXPORTED_INTRINSIC_TYPE_LAYOUT ( TIndexedPtr< FVertexFactoryType )

◆ IMPLEMENT_TYPE_LAYOUT() [1/10]

IMPLEMENT_TYPE_LAYOUT ( FShader  )

◆ IMPLEMENT_TYPE_LAYOUT() [2/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderLooseParameterBufferInfo  )

◆ IMPLEMENT_TYPE_LAYOUT() [3/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderLooseParameterInfo  )

◆ IMPLEMENT_TYPE_LAYOUT() [4/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderMapContent  )

◆ IMPLEMENT_TYPE_LAYOUT() [5/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderParameterBindings  )

◆ IMPLEMENT_TYPE_LAYOUT() [6/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderParameterMapInfo  )

◆ IMPLEMENT_TYPE_LAYOUT() [7/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderPipeline  )

◆ IMPLEMENT_TYPE_LAYOUT() [8/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderResourceParameterInfo  )

◆ IMPLEMENT_TYPE_LAYOUT() [9/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderTypeDependency  )

◆ IMPLEMENT_TYPE_LAYOUT() [10/10]

IMPLEMENT_TYPE_LAYOUT ( FShaderUniformBufferParameterInfo  )

◆ IsDxcEnabledForPlatform()

bool IsDxcEnabledForPlatform ( EShaderPlatform  Platform,
bool  bHlslVersion2021 = false 
)

Returns whether DirectXShaderCompiler (DXC) is enabled for the specified shader platform. See console variables "r.OpenGL.ForceDXC", "r.D3D.ForceDXC".

◆ IsUsingEmulatedUniformBuffers()

bool IsUsingEmulatedUniformBuffers ( EShaderPlatform  Platform)

Returns whether the platform is using emulated uniform buffers

◆ operator<<() [1/2]

FArchive & operator<< ( FArchive Ar,
const FShaderPipelineType *&  TypeRef 
)

Serializes a reference to a shader pipeline type.

◆ operator<<() [2/2]

FArchive & operator<< ( FArchive Ar,
FShaderType *&  Ref 
)

Serializes a shader type reference by name.

◆ RegisterRayTracingPayloadType()

void RegisterRayTracingPayloadType ( ERayTracingPayloadType  PayloadType,
uint32  PayloadSize,
TRaytracingPayloadSizeFunction  PayloadSizeFunction 
)

◆ SetAdditionalShaderPermutationFlags()

void SetAdditionalShaderPermutationFlags ( EShaderPermutationFlags  AdditionalFlags)

Set global additional flags that are always added in GetShaderPermutationFlags(). Expected to be called once at startup.

◆ ShaderMapAppendKey()

void ShaderMapAppendKey ( EShaderPlatform  Platform,
FShaderKeyGenerator KeyGen 
)

◆ ShaderMapAppendKeyString()

void ShaderMapAppendKeyString ( EShaderPlatform  Platform,
FString &  KeyString 
)

Appends to KeyString for all shaders.