UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GlobalShader.h File Reference
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "Containers/UnrealString.h"
#include "CoreMinimal.h"
#include "HAL/Platform.h"
#include "Misc/AssertionMacros.h"
#include "Misc/Paths.h"
#include "RHI.h"
#include "RHIDefinitions.h"
#include "RHIResources.h"
#include "Serialization/MemoryImage.h"
#include "Serialization/MemoryLayout.h"
#include "Shader.h"
#include "ShaderParameterUtils.h"
#include "Templates/Tuple.h"
#include "Templates/UniquePtr.h"
#include "UObject/NameTypes.h"
#include "UObject/UnrealNames.h"

Go to the source code of this file.

Classes

class  FGlobalShaderMapId
 
struct  FGlobalShaderPermutationParameters
 
class  FGlobalShaderType
 
class  FGlobalShaderMapContent
 
class  FGlobalShaderMapSection
 
class  FGlobalShaderMap
 
class  FGlobalShader
 
class  FNULLPS
 

Macros

#define DECLARE_GLOBAL_SHADER(ShaderClass)   DECLARE_SHADER_TYPE(ShaderClass, Global)
 
#define DECLARE_EXPORTED_GLOBAL_SHADER(ShaderClass, RequiredAPI)   DECLARE_EXPORTED_SHADER_TYPE(ShaderClass, Global, RequiredAPI)
 
#define IMPLEMENT_GLOBAL_SHADER(ShaderClass, SourceFilename, FunctionName, Frequency)   IMPLEMENT_SHADER_TYPE(,ShaderClass,TEXT(SourceFilename),TEXT(FunctionName),Frequency)
 

Enumerations

enum class  ERecursiveShader { None = 0 , Resolve = 1 << 0 , Clear = 1 << 1 , Null = 1 << 2 }
 

Functions

RENDERCORE_API FGlobalShaderMapGetGlobalShaderMap (EShaderPlatform Platform)
 
FGlobalShaderMapGetGlobalShaderMap (ERHIFeatureLevel::Type FeatureLevel)
 
RENDERCORE_API void CreateRecursiveShaders ()
 
void ForceInitGlobalShaderType (FShaderType &ShaderType)
 
template<typename TShaderType >
void ForceInitGlobalShaderType ()
 

Variables

RENDERCORE_API const int32 GlobalShaderMapId
 
RENDERCORE_API FGlobalShaderMapGGlobalShaderMap [SP_NumPlatforms]
 
RENDERCORE_API ERecursiveShader GRequiredRecursiveShaders
 

Macro Definition Documentation

◆ DECLARE_EXPORTED_GLOBAL_SHADER

#define DECLARE_EXPORTED_GLOBAL_SHADER (   ShaderClass,
  RequiredAPI 
)    DECLARE_EXPORTED_SHADER_TYPE(ShaderClass, Global, RequiredAPI)

◆ DECLARE_GLOBAL_SHADER

#define DECLARE_GLOBAL_SHADER (   ShaderClass)    DECLARE_SHADER_TYPE(ShaderClass, Global)

DECLARE_GLOBAL_SHADER and IMPLEMENT_GLOBAL_SHADER setup a global shader class's boiler plate. They are meant to be used like so:

class FMyGlobalShaderPS : public FGlobalShader { // Setup the shader's boiler plate. DECLARE_GLOBAL_SHADER(FMyGlobalShaderPS);

// Setup the shader's permutation domain. If no dimensions, can do FPermutationDomain = FShaderPermutationNone. using FPermutationDomain = TShaderPermutationDomain<DIMENSIONS...>;

// ... };

// Instantiates global shader's global variable that will take care of compilation process of the shader. This needs imperatively to be done in a .cpp file regardless of whether FMyGlobalShaderPS is in a header or not. IMPLEMENT_GLOBAL_SHADER(FMyGlobalShaderPS, "/Engine/Private/MyShaderFile.usf", "MainPS", SF_Pixel);

When the shader class is a public header, let say in RenderCore module public header, the class declaration macro then should have the RENDERCORE_API like this:

class FMyGlobalShaderPS : public FGlobalShader { // Setup the shader's boiler plate. DECLARE_EXPORTED_GLOBAL_SHADER(FMyGlobalShaderPS, RENDERCORE_API);

// ... };

◆ IMPLEMENT_GLOBAL_SHADER

#define IMPLEMENT_GLOBAL_SHADER (   ShaderClass,
  SourceFilename,
  FunctionName,
  Frequency 
)    IMPLEMENT_SHADER_TYPE(,ShaderClass,TEXT(SourceFilename),TEXT(FunctionName),Frequency)

Enumeration Type Documentation

◆ ERecursiveShader

enum class ERecursiveShader
strong

Groups of global shaders which can be used in recursive RHI command lists by platform RHI implementations.

Enumerator
None 
Resolve 
Clear 
Null 

Function Documentation

◆ CreateRecursiveShaders()

RENDERCORE_API void CreateRecursiveShaders ( )
extern

◆ ForceInitGlobalShaderType() [1/2]

template<typename TShaderType >
void ForceInitGlobalShaderType ( )
inline

◆ ForceInitGlobalShaderType() [2/2]

void ForceInitGlobalShaderType ( FShaderType ShaderType)

◆ GetGlobalShaderMap() [1/2]

FGlobalShaderMap * GetGlobalShaderMap ( ERHIFeatureLevel::Type  FeatureLevel)
inline

Overload for the above GetGlobalShaderMap which takes a feature level and translates to the appropriate shader platform

Parameters
FeatureLevel- Which feature levels shader map to use
bRefreshShaderMapIf true, the existing global shader map will be tossed first
Returns
A reference to the global shader map.

◆ GetGlobalShaderMap() [2/2]

RENDERCORE_API FGlobalShaderMap * GetGlobalShaderMap ( EShaderPlatform  Platform)
extern

Accesses the global shader map. This is a global FGlobalShaderMap which contains an instance of each global shader type.

Parameters
PlatformWhich platform's global shader map to use
bRefreshShaderMapIf true, the existing global shader map will be tossed first
Returns
A reference to the global shader map.

Variable Documentation

◆ GGlobalShaderMap

RENDERCORE_API FGlobalShaderMap* GGlobalShaderMap[SP_NumPlatforms]
extern

The global shader map.

◆ GlobalShaderMapId

RENDERCORE_API const int32 GlobalShaderMapId
extern

Used to identify the global shader map in compile queues.

◆ GRequiredRecursiveShaders

RENDERCORE_API ERecursiveShader GRequiredRecursiveShaders
extern