Navigation
API > API/Runtime > API/Runtime/Engine
References
| Module | Engine |
| Header | /Engine/Source/Runtime/Engine/Public/MaterialKeyGeneratorContext.h |
| Include | #include "MaterialKeyGeneratorContext.h" |
Syntax
class FMaterialKeyGeneratorContext
Remarks
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.
Variables
| Type | Name | Description | |
|---|---|---|---|
| FShaderKeyGenerator | KeyGen | ||
| TArray< FCbObjectView, TInlineAllocator< 2 > > | ObjectStack | ||
| FCbWriter * | Writer |
Constructors
| Type | Name | Description | |
|---|---|---|---|
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. | ||
FMaterialKeyGeneratorContext
(
FString& InResultString, |
Construct a Context that is emitting variables into a text-formatted shader DDC key. | ||
FMaterialKeyGeneratorContext
(
FCbWriter& InWriter, |
Construct a Context that is saving data to compact binary. | ||
FMaterialKeyGeneratorContext
(
FCbObjectView LoadRoot, |
Construct a Context that is loading data from compact binary. |
Destructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddFlags
(
EMaterialKeyInclude Flags |
Inline implementations. | |
| void | Emit
(
T&& Data |
When emitting, append the given Data to the ShaderKeyGenerator, using operator<<. | |
| void | EmitBoolInt
(
bool Data |
When emitting, call the ShaderKeyGenerator's AppendBoolInt. | |
| void | EmitDebugText
(
FStringView Data |
When emitting, call the ShaderKeyGenerator's AppendDebugText. | |
| void | EmitFunc
(
TFunctionRef< void(FShaderKeyGenerator&)> Callback |
When emitting, call Callback with the ShaderKeyGenerator. | |
| void | When emitting, call the ShaderKeyGenerator's AppendSeparator. | ||
| EMaterialKeyInclude | GetFlags () |
Return the list of include flags. | |
| FShaderKeyGenerator * | When emitting, return pointer to the ShaderKeyGenerator. In all other modes, returns nullptr. | ||
| FShaderKeyGenerator & | Must only be called when emitting; fails assertion if not. | ||
| EMode | GetMode () |
Return the mode the Context is operating in. | |
| FName | The ShaderFormat that corresponds to the ShaderPlatform provided by the caller. | ||
| EShaderPlatform | The ShaderPlatform provided by the caller. | ||
| bool | HasAllFlags
(
EMaterialKeyInclude Flags |
Report whether all requested flags are included. | |
| bool | HasLoadError () |
When loading, report whether any Record function reported an error. | |
| bool | IsEmitting () |
True iff the Context is in emit mode - creating DDC key or hashing material dependencies. | |
| bool | IsLoading () |
True iff the Context is loading from compact binary. | |
| bool | IsRecording () |
True iff the Context is in either IsSaving or IsLoading mode. | |
| bool | IsSaving () |
True iff the Context is saving to compact binary. | |
| void | PostLoad
(
TFunctionRef< void()> Action |
When loading, execute the given function. In all other modes, this function is a noop. | |
| void | Record
(
FUtf8StringView Name, |
When saving or loading, save the given Data with the given name. | |
| void | RecordAndEmit
(
FUtf8StringView Name, |
Output function used by all three modes. | |
| void | When saving or loading, end the object scope started by the last call to RecordObjectStart, and return to the parent object scope. | ||
| void | RecordObjectStart
(
FUtf8StringView Name |
When saving or loading, start a new object scope with the given name. | |
| void | RemoveFlags
(
EMaterialKeyInclude Flags |
Remove include flags. | |
| void | SetFlags
(
EMaterialKeyInclude Flags, |
Add or remove include flags, depending on the value of bIncluded. |
Enums
| Type | Name | Description | |
|---|---|---|---|
| EMode | Which mode the GeneratorContext is operating in; these modes are mutually exclusive, not flags. |