Navigation
API > API/Runtime > API/Runtime/Engine
Output class passed to RecordAndEmit functions for material shader data. It receives function calls that either save/load variables to compact binary or emits those variables to an FShaderKeyGenerator to construct the key. It is written to by the function RecordOrEmitMaterialShaderMapKey and its helper functions, to create the shadermap's DDC key, to hash the Material's cook dependencies for incremental cooks, and to save/load the inputs for those cook dependencies to cook metadata, with a single function definition that lists all the relevant variables. This reduces the amount of boilerplate that has to be written and maintained for each variable that can affect the DDC key and cook dependencies.
The Context additionally holds flags for which portion of data should be included in its output; these flags are set differently by the calling function depending on whether we are saving a DDC key or material dependencies, and on what kind of DDC key we are saving.
The Context additionally holds some common arguments - ShaderPlatform and ShaderFormat - that are provided to the functions from the calling functions.
| Name | FMaterialKeyGeneratorContext |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Public/MaterialKeyGeneratorContext.h |
| Include Path | #include "MaterialKeyGeneratorContext.h" |
Syntax
class FMaterialKeyGeneratorContext
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FMaterialKeyGeneratorContext
(
FString& InResultString, |
Construct a Context that is emitting variables into a text-formatted shader DDC key. | MaterialKeyGeneratorContext.h | |
FMaterialKeyGeneratorContext
(
TUniqueFunction< void(const void*Data, uint64 Size)>&& HashFunction, |
Construct a Context that is emitting variables into a binary-formatted shader DDC key or into a material dependencies hash function. | MaterialKeyGeneratorContext.h | |
FMaterialKeyGeneratorContext
(
FCbWriter& InWriter, |
Construct a Context that is saving data to compact binary. | MaterialKeyGeneratorContext.h | |
FMaterialKeyGeneratorContext
(
FCbObjectView LoadRoot, |
Construct a Context that is loading data from compact binary. | MaterialKeyGeneratorContext.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FMaterialKeyGeneratorContext() |
MaterialKeyGeneratorContext.h |
Enums
Public
| Name | Remarks |
|---|---|
| EMode | Which mode the GeneratorContext is operating in; these modes are mutually exclusive, not flags. |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| KeyGen | FShaderKeyGenerator | MaterialKeyGeneratorContext.h | ||
| ObjectStack | TArray< FCbObjectView, TInlineAllocator< 2 > > | MaterialKeyGeneratorContext.h | ||
| Writer | FCbWriter * | MaterialKeyGeneratorContext.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bHasLoadError | bool | MaterialKeyGeneratorContext.h | ||
| FMaterialKeyGeneratorContext | union FMaterialKeyGeneratorContext | MaterialKeyGeneratorContext.h | ||
| IncludeFlags | EMaterialKeyInclude | MaterialKeyGeneratorContext.h | ||
| Mode | EMode | MaterialKeyGeneratorContext.h | ||
| ShaderFormat | FName | MaterialKeyGeneratorContext.h | ||
| ShaderPlatform | EShaderPlatform | MaterialKeyGeneratorContext.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddFlags
(
EMaterialKeyInclude Flags |
Inline implementations. | MaterialKeyGeneratorContext.h | |
void Emit
(
T&& Data |
When emitting, append the given Data to the ShaderKeyGenerator, using operator<<. | MaterialKeyGeneratorContext.h | |
void EmitBoolInt
(
bool Data |
When emitting, call the ShaderKeyGenerator's AppendBoolInt. | MaterialKeyGeneratorContext.h | |
void EmitDebugText
(
FStringView Data |
When emitting, call the ShaderKeyGenerator's AppendDebugText. | MaterialKeyGeneratorContext.h | |
void EmitFunc
(
TFunctionRef< void(FShaderKeyGenerator&)> Callback |
When emitting, call Callback with the ShaderKeyGenerator. | MaterialKeyGeneratorContext.h | |
void EmitSeparator () |
When emitting, call the ShaderKeyGenerator's AppendSeparator. | MaterialKeyGeneratorContext.h | |
| Return the list of include flags. | MaterialKeyGeneratorContext.h | ||
FShaderKeyGenerator * GetKeyGenIfEmitting() |
When emitting, return pointer to the ShaderKeyGenerator. In all other modes, returns nullptr. | MaterialKeyGeneratorContext.h | |
| Must only be called when emitting; fails assertion if not. | MaterialKeyGeneratorContext.h | ||
| Return the mode the Context is operating in. | MaterialKeyGeneratorContext.h | ||
FName GetShaderFormat() |
The ShaderFormat that corresponds to the ShaderPlatform provided by the caller. | MaterialKeyGeneratorContext.h | |
EShaderPlatform GetShaderPlatform() |
The ShaderPlatform provided by the caller. | MaterialKeyGeneratorContext.h | |
bool HasAllFlags
(
EMaterialKeyInclude Flags |
Report whether all requested flags are included. | MaterialKeyGeneratorContext.h | |
bool HasLoadError () |
When loading, report whether any Record function reported an error. | MaterialKeyGeneratorContext.h | |
bool IsEmitting() |
True iff the Context is in emit mode - creating DDC key or hashing material dependencies. | MaterialKeyGeneratorContext.h | |
bool IsLoading() |
True iff the Context is loading from compact binary. | MaterialKeyGeneratorContext.h | |
bool IsRecording() |
True iff the Context is in either IsSaving or IsLoading mode. | MaterialKeyGeneratorContext.h | |
bool IsSaving() |
True iff the Context is saving to compact binary. | MaterialKeyGeneratorContext.h | |
void PostLoad
(
TFunctionRef< void()> Action |
When loading, execute the given function. In all other modes, this function is a noop. | MaterialKeyGeneratorContext.h | |
void Record
(
FUtf8StringView Name, |
When saving or loading, save the given Data with the given name. | MaterialKeyGeneratorContext.h | |
void RecordAndEmit
(
FUtf8StringView Name, |
Output function used by all three modes. | MaterialKeyGeneratorContext.h | |
void RecordObjectEnd () |
When saving or loading, end the object scope started by the last call to RecordObjectStart, and return to the parent object scope. | MaterialKeyGeneratorContext.h | |
void RecordObjectStart
(
FUtf8StringView Name |
When saving or loading, start a new object scope with the given name. | MaterialKeyGeneratorContext.h | |
void RemoveFlags
(
EMaterialKeyInclude Flags |
Remove include flags. | MaterialKeyGeneratorContext.h | |
void SetFlags
(
EMaterialKeyInclude Flags, |
Add or remove include flags, depending on the value of bIncluded. | MaterialKeyGeneratorContext.h |