UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MaterialIREmitter.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
7
8#if WITH_EDITOR
9
10#define UE_MIR_CHECKPOINT(Emitter) if (Emitter.CurrentExpressionHasErrors()) return
11
12namespace MIR {
13
14enum class EVectorComponent : uint8_t
15{
16 X, Y, Z, W,
17};
18
19// Return the lower case string representation of given component (e.g. "x")
21
22// This utility data structure is used to define how a swizzle operation should be performed.
23struct FSwizzleMask
24{
25 // Which component should be extracted from the argument, in order. E.g. [Z, Z, X] to model "MyVec.zzx".
26 EVectorComponent Components[4];
27
28 // How many components have been defined for swizzle should be made of (maximum four).
29 int NumComponents{};
30
31 // Convenience ".xyz" swizzle mask.
32 static FSwizzleMask XYZ();
33
34 FSwizzleMask() {}
39 FSwizzleMask(bool bMaskX, bool bMaskY, bool bMaskZ, bool bMaskW);
40
41 // Pushes a component to this swizzle mask.
43
44 // Returns true if this is an identity swizzle mask XYZW, which implies i.e. it's a redundant swizzle mask.
45 bool IsXYZW() const;
46
47 const EVectorComponent* begin() const { return Components; }
48 const EVectorComponent* end() const { return Components + NumComponents; }
49};
50
51// A lightweight wrapper around FValue* that also optionally tracks the source expression input.
52// Used to carry both value and its origin in the expression graph.
53// A null reference evaluates has the FValue* set to nullptr and evaluates false. It is
54// returned by the FEmitter::TryInput() value to indicate a missing value. An invalid reference
55// is either null or has a poison value. It is usually generated as the result of an invalid
56// operation.
57// Important: The Emitter APIs can safely take both null and poison values. Operations that
58// take a single argument simply return the argument if it is invalid (null or poison),
59// whereas operations that take multiple arguments return poison if any is invalid.
60//
61// When your intention is to test for whether a value is not-null (available), leverage the
62// operator bool()
63//
64// if (Value) { /* handle case when value is available */ }
65//
66// Otherwise, if you would like the value to be available AND valid (not-poison) you should
67// test for IsValid()
68//
69// if (Value.IsValid()) {
70// /* handle case when the operations that produced the value were all succesful */
71// }
72//
73// Note: In user Expression::Build() implementations, you should avoid testing values validity
74// directly and instead leverage the UE_MIR_CHECKPOINT() macro to verify that all emitter
75// performed so far were all valid, and thus the values you have computed so far are what
76// you expect.
77struct FValueRef
78{
79 // Default constructor. Creates an invalid reference.
80 FValueRef() {}
81
82 // Constructs from a value pointer.
83 FValueRef(FValue* Value) : Value{ Value } {}
84
85 // Constructs from a value pointer and its corresponding input source.
86 FValueRef(FValue* Value, const FExpressionInput* Input) : Value{ Value }, Input{ Input } {}
87
88 // Returns whether this references a non-null value.
89 operator bool() const { return Value != nullptr; }
90
91 // Returns the referenced value, which must be non-null.
92 operator FValue*() const { return Value; }
93
94 // Returns the referenced value, which must be non-null.
95 FValue* operator->() const { return Value; }
96
97 // Checks if the reference holds a valid non-null value.
98 bool IsValid() const;
99
100 // Checks if the reference holds a poison value.
101 bool IsPoison() const;
102
103 // Creates a new reference with the same input but a different value.
104 FValueRef To(FValue* Value) const;
105
106 // Creates a poison version of the current reference (same input, but poison value).
107 FValueRef ToPoison() const;
108
109 // The referenced value.
110 FValue* Value{};
111
112 // The expression input being read.
113 const FExpressionInput* Input{};
114};
115
116// An assignment to a material aggregate attribute, used when constructing an aggregate instance.
118{
119 // Then name of the assigned aggregate attribute.
120 FName Name;
121
122 // The value it is assigned to.
124};
125
126// Describes a user-specified HLSL function.
128{
129 // The function name, used for debugging purposes and referenced in the generated HLSL.
131
132 // The function return type.
133 FType ReturnType{};
134
135 // The number of parameters that are input-only.
137
138 // The number of input-output parameters after the input-only parameters.
140
141 // The number of output-only parameters after the input-output parameters.
143
144 // Array of descriptions of the function parameters.
145 FFunctionParameter Parameters[MIR::MaxNumFunctionParameters];
146
147 // The user-specified HLSL code inside the function body.
148 FStringView Code{};
149
150 // Array of user-specified defines to declare before this function.
152
153 // Array of user-specified #include directives to declare before this function.
155
156 // Pushes an input-only parameter and returns whether there was an available free parameter to push this one into.
157 bool PushInputOnlyParameter(FName Name, FType Type);
158
159 // Pushes an input-output parameter and returns whether there was an available free parameter to push this one into.
160 bool PushInputOutputParameter(FName Name, FType Type);
161
162 // Pushes an output-only parameter and returns whether there was an available free parameter to push this one into.
163 bool PushOutputOnlyParameter(FName Name, FType Type);
164
165 // Returns the total number of parameters.
166 uint32 GetNumParameters() const { return NumInputOnlyParams + NumInputOutputParams + NumOutputOnlyParams; }
167};
168
169// Helper structure to simplify passing attributes to texture sampling emitter functions that share the same attributes.
171{
172 // Specifies which sampler source mode to use. By default SSM_FromTextureAsset.
174
175 // Specifies Which sampler type to use. By default SAMPLERTYPE_MAX which implies the sampler type is fetched from the texture object.
176 // See SamplerType field in FTextureObject, FRuntimeVirtualTextureObject, and FUniformParameter.
178
179 // Specifies whether to enable virtual texture sampling feedback. This is only used for pixel shaders. Enabled by default.
180 bool bEnableFeedback : 1 { true };
181
182 // True if adaptive VT sampling is used. Only used for virtual textures.
183 bool bIsAdaptive : 1 { false };
184};
185
186// The FEmitter is a helper object responsible for emitting MIR values and instructions.
187// It is primarily used within UMaterialExpression::Build() implementations to lower the
188// high-level semantics of a material expression into corresponding lower-level MIR nodes.
189//
190// During the emission process, the emitter automatically performs various
191// simplifications and constant folding optimizations where possible.
192//
193// An instance of the emitter is created and managed by the FMaterialIRModuleBuilder.
194// This instance is then passed to the UMaterialExpression::Build() functions
195// so that they can emit their corresponding IR values.
196//
197// IMPORTANT: Users should *not* assume the exact MIR::FType of the FValue* returned
198// by EmitXXX() functions. The emitter is free to optimize operations, which may
199// result in a returned value having a different type than naively expected (e.g.,
200// folding an operation into a constant).
201//
202// The emitter handles invalid inputs gracefully. If an operation is attempted
203// with invalid arguments (e.g., acting on arguments of unexpected types), the emitter
204// automatically reports an error and returns the MIR::FPoison value. Furthermore, all
205// EmitXXX() functions are robust to receiving MIR::FPoison as input; they will simply
206// propagate the poison value without attempting the operation.
207class FEmitter
208{
209public:
210 /*--------------------------------- Error handling ---------------------------------*/
211
212 // Returns whether the current expression generated an error.
213 // You can also use UE_MIR_CHECKPOINT() in your code to check this and automatically return if an error occurred.
215
216 // Reports an error using printf-like format and arguments to format the error message.
217 template <typename... TArgs>
219 {
220 Error(Source, FString::Printf(Format, Args...));
221 }
222
223 // Reports an error using printf-like format and arguments to format the error message.
224 template <typename... TArgs>
226 {
227 Error(FString::Printf(Format, Args...));
228 }
229
230 // Reports an error with given error message.
231 void Error(FValueRef Source, FStringView Message);
232
233 // Reports an error with given error message.
234 void Error(FStringView Message);
235
236 /*--------------------------------- Type handling ----------------------------------*/
237
238 // Tries to find a common type between A and B.
239 // The trivial case is when A and B are the same type, in which case that type is
240 // the common type. When A and B are primitive, the common type is defined as the type
241 // with the highest dimensions between the two and with a scalar kind that follows the
242 // progression: bool -> int -> float
243 // As an example, the common type between a float3 and a bool4 will be a float4.
244 // Note; that this may cause a loss of data when casting from int to float.
245 // It returns the common type if it exists, nullptr otherwise.
246 FType TryGetCommonType(FType A, FType B);
247
248 // Gets the common type between A and B and reports an error if no such type exists.
249 // See TryGetCommonType()
250 FType GetCommonType(FType A, FType B);
251
252 // Gets the common type between the specified values types. Note that values in this array
253 // are allowed to be null/poison.
254 // See GetCommonType(FType A, FType B)
256
257 // Returns the type of the i-th attribute in the given material aggregate.
259
260 // Returns the UTexture or URuntimeVirtualTexture of the specified texture object or uniform parameter.
261 UObject* GetTextureFromValue(MIR::FValueRef Texture);
262
263 /*-------------------------------- Input management --------------------------------*/
264
265 // Retrieves the value from the given input, if present. A null reference otherwise.
266 // Note: it does not report an error if the value is missing.
267 // It is safe to pass returned value to other Emitter functions as argument even if null.
268 // For instance, the following is safe and idiomatic
269 //
270 // FValueRef Value = Emitter.CheckIsArithmetic(Emitter.TryInput(&A));
271 // UE_MIR_CHECKPOINT(Emitter);
272 // if (Value) { /* handle case when value is provided */ }
273 //
274 // Keep in mind that a reference can be null (its Value is null) or invalid (which means
275 // that it's null OR poison).
277
278 // Retrieves the value flowing into given input.
279 // If the value is missing, it reports an error and returns poison.
281
282 // If the input has no value flowing in (e.g., because the input is disconnected),
283 // these DefaultXXX() functions will emit a constant value, bind it to the input, and
284 // return it.
294
295 // Retrieves the value from the given input of given type kind.
296 // If the value is missing or its type does not have the given kind, it reports an error and returns poison.
297 FValueRef CheckTypeIsKind(FValueRef Value, ETypeKind Kind);
298
299 // Validates that the value is of a primitive type. If not, reports an error and returns poison.
301
302 // Validates that the value is of an arithmetic type (int or float). Reports error and returns poison otherwise.
304
305 // Validates that the value is of a boolean type. If not, reports an error and returns poison.
307
308 // Validates that the value is of a integral type. If not, reports an error and returns poison.
310
311 // Validates that the value is a scalar. If not, reports error and returns poison.
313
314 // Validates that the value is a vector. If not, reports error and returns poison.
316
317 // Validates that the value is either a scalar or a vector. Reports error and returns poison otherwise.
319
320 // Validates that the value is a matrix. If not, reports error and returns poison.
322
323 // Retrieves the texture value flowing into given input.
324 // If the value is missing or cannot be cast to a texture, it reports an error and returns poison.
326
327 // Validates that the value is of an aggregate type. If not, reports error and returns poison.
329
330 // Casts the value flowing into this input to a constant boolean and returns it.
331 // If the value is missing, or is not a constant boolean it reports an error and returns false.
333
334 /*-------------------------------- Output management -------------------------------*/
335
336 // Flows given `Value` out of the expression output with given `OutputIndex`.
337 FEmitter& Output(int32 OutputIndex, FValueRef Value);
338
339 // Flows given `Value` out of given expression `ExpressionOutput`.
340 FEmitter& Output(const FExpressionOutput* ExpressionOutput, FValueRef Value);
341
342 // Flows given `Value` out of given expression output list. Each output applies its respective mask.
344
345 /*------------------------------- Constants emission -------------------------------*/
346
347 // Converts the given UE::Shader::FValue to a MIR constant value and returns it.
349
350 // Emits a default value of given type (zero initialized).
351 FValueRef ConstantDefault(FType Type);
352
353 // Emits a scalar constant value of given kind with value 0 and returns it.
355
356 // Emits a scalar constant value of given kind with value 1 and returns it.
358
359 // Casts the given float value to the given scalar kind and returns its value.
361
362 // Returns the constant boolean scalar `true`.
364
365 // Returns the constant boolean scalar `false`.
367
368 // Returns the given constant boolean scalar.
370
371 // Emits a constant bool 2D column vector and returns it.
372 FValueRef ConstantBool2(bool InX, bool InY);
373
374 // Emits a constant bool 3D column vector and returns it.
375 FValueRef ConstantBool3(bool InX, bool InY, bool InZ);
376
377 // Emits a constant bool 4D column vector and returns it.
378 FValueRef ConstantBool4(bool InX, bool InY, bool InZ, bool InW);
379
380 // Returns the given constant integer scalar.
382
383 // Emits a constant integer 2D column vector and returns it.
385
386 // Emits a constant integer 3D column vector and returns it.
388
389 // Emits a constant integer 4D column vector and returns it.
391
392 // Returns the given constant float scalar.
394
395 // Emits a constant float 2D column vector and returns it.
397
398 // Emits a constant float 3D column vector and returns it.
400
401 // Emits a constant float 4D column vector and returns it.
403
404 // Returns the given constant LWC scalar.
406
407 /*--------------------- Other non-instruction values emission ---------------------*/
408
409 // Emits the poison value.
411
412 // Emits an external input value of given input Id and returns it.
414
415 // Emits a material parameter collection.
417
418 // Emits a shading model.
420
421 // Emits a texture object value of fiven sampler type and returns it.
423
424 // Emits a runtime virtual texture object value.
426
427 // Emits a material parameter value with given name, metadata, sampler type (if it's a texture) and optional parameters for RVT layer index and page table index.
429
430 // Emits a preshader parameter value with given opcode.
432
433 // Emits a custom primitive data value with given index.
434 FValueRef CustomPrimitiveData(uint32 PrimitiveDataIndex);
435
436 // Emit a screen texture with the given Scene Texture id.
437 FValueRef SceneTexture(ESceneTextureId SceneTextureId);
438
439 // Emit a screen texture with the given User Scene Texture name.
440 FValueRef UserSceneTexture(FName UserSceneTexture);
441
442 // Emit a screen texture with the given DBuffer Texture id.
444
445 // Emit another type of screen texture (not one of the three types above).
447
448 /*----------------------------- Instructions emission -----------------------------*/
449
450 // Emits an instruction that sets the material attribute with given property to given argument.
451 // Note: this API is used by the builder and you should not use it manually.
453
454 // Emits a 2D column vector from X and Y values.
456
457 // Emits a 3D vector from a 2D vector (XY) and a Z value.
459
460 // Emits a 3D vector from separate X, Y, and Z values.
462
463 // Emits a 4D vector from a 3D vector (XYZ) and a W value.
465
466 // Emits a 4D vector from a 2D vector (XY), a Z value, and a W value.
468
469 // Emits a 4D vector from separate X, Y, Z, and W values.
471
472 // Constructs an aggregate value using the provided aggregate definition.
473 // The resulting value has default-initialized attributes.
475
476 // Constructs an aggregate value using the given type and prototype, and initializes it with
477 // the provided list of attribute values. Each value corresponds to an attribute in declaration order.
478 // AttributeValues can be smaller than the number attributes in the aggregate. For excess attributes,
479 // the value in the prototype (if provided) or default initialized otherwise.
481
482 // Constructs an aggregate value using the given type and prototype, initializing its attributes using the provided assignments.
483 // Each assignment specifies the target attribute and its initial value.
484 // Unassigned attributes use the value in the prototype (if provided) or default initialized otherwise.
486
487 // Emits a mathematical operation instruction with given operator and arguments.
488 // Note: This function will try to simplify the operation at translation time if possible.
489 // The returned value is therefore not guaranteed to be an FOperator instruction instance.
490 FValueRef Operator(EOperator Operator, FValueRef A, FValueRef B = {}, FValueRef C = {});
491
492 // Emits a branch instruction.
493 // When the result of the Condition argument is true, the instruction will evaluate
494 // the True argument, otherwise the False argument.
495 // This instruction will place the as much of the other instructions whose results
496 // serve the computation of True or False within separate inner scopes, in order to
497 // avoid unnecessarily computing the inactive argument.
499
500 // Casts the given value to the specified target type. Returns poison if the cast is invalid.
501 FValueRef Cast(FValueRef Value, FType TargetType);
502
503 // Casts the given primitive value to a scalar. If this is a vector, it will convert to its first component.
505
506 // Casts the given primitive value to a row vector of specified columns.
508
509 // Casts the given primitive value to a given scalar kind, maintaining the same
510 // number of rows and columns.
515
516 // These functions cast the given value to the a primitive scalar or column vector type of given rows.
517 // If the value is missing ore could not be cast to the relative primitive type, they repors an error and return poison.
518 FValueRef CastToBool(FValueRef Value, int NumColumns);
519 FValueRef CastToInt(FValueRef Value, int NumColumns);
520 FValueRef CastToFloat(FValueRef Value, int NumColumns);
521
522 // Extracts the component with given index from the given argument value.
523 // The argument value must be a scalar or a vector primitive type, otherwise it reports an error and returns poison.
524 // Note that if no error occurred, the returned value is guaranteed to be a primitive scalar.
526
527 // Swizzles the given argument by given mask.
528 // The argument value must be a scalar or vector type. If the operation is invalid on
529 // given argument and mask it reports an error and returns poison.
531
532 // Transposes the given MxN primitive value into the NxM result.
533 // Note if Value is a row-vector, returns a column-vector and viceversa.
534 // If Value is not a primitive type, reports an error and returns poison.
536
537 // Emits a stage switch instruction. Use this instruction to select a different value
538 // in each execution stage.
539 // Note: ValuePerStage must have no more than MIR::NumStages elements.
541
542 // Emits a NOP instruction that behaves as a default value of Arg type, but will still
543 // cause Arg to be analyzed. Use it when you want Arg to be analyzed (to record side effects
544 // on the module), but not evaluated.
546
547 // Emits a texture gather instruction.
548 //
549 // @param Texture The texture to sample. Must be of type MIR::FTextureObject, MIR::FRuntimeVirtualTextureObject, or MIR::FUniformParameter.
550 // @param TexCoord The UV coordinates at which to sample the texture.
551 // @param GatherMode What channel to gather (any ::GatherXXX value).
552 // @param BaseAttributes Base sampling attributes for sampler source and type as well as VT attributes.
554
555 // Emits a texture sample instruction.
556 //
557 // @param Texture The texture to sample. Must be of type MIR::FTextureObject, MIR::FRuntimeVirtualTextureObject, or MIR::FUniformParameter.
558 // @param TexCoord The UV coordinates at which to sample the texture.
559 // @param bAddViewMaterialMipBias Whether to add the view material texture mip bias to the mip level.
560 // @param BaseAttributes Base sampling attributes for sampler source and type as well as VT attributes.
562
563 // Emits a texture sample instruction with a manually given mip level.
564 //
565 // @param Texture The texture to sample. Must be of type MIR::FTextureObject, MIR::FRuntimeVirtualTextureObject, or MIR::FUniformParameter.
566 // @param TexCoord The UV coordinates at which to sample the texture.
567 // @param MipLevel Which mip level to use for this sample.
568 // @param bAddViewMaterialMipBias Whether to add the view material texture mip bias to the mip level.
569 // @param BaseAttributes Base sampling attributes for sampler source and type as well as VT attributes.
571
572 // Emits a texture sample instruction with bias added to the automatically selected mip level.
573 //
574 // @param Texture The texture to sample. Must be of type MIR::FTextureObject, MIR::FRuntimeVirtualTextureObject, or MIR::FUniformParameter.
575 // @param TexCoord The UV coordinates at which to sample the texture.
576 // @param MipBias The bias to add to the automatically selected mip level.
577 // @param bAddViewMaterialMipBias Whether to add the view material texture mip bias to the mip level.
578 // @param BaseAttributes Base sampling attributes for sampler source and type as well as VT attributes.
580
581 // Emits a texture sample instruction using user provided partial derivatives.
582 //
583 // @param Texture The texture to sample. Must be of type MIR::FTextureObject, MIR::FRuntimeVirtualTextureObject, or MIR::FUniformParameter.
584 // @param TexCoord The UV coordinates at which to sample the texture.
585 // @param TexCoordDdx The partial derivative of the texture coordinates along the screen space x axis.
586 // @param TexCoordDdy The partial derivative of the texture coordinates along the screen space y axis.
587 // @param bAddViewMaterialMipBias Whether to add the view material texture mip bias to the mip level.
588 // @param BaseAttributes Base sampling attributes for sampler source and type as well as VT attributes.
590
591 // Emits the virtual texture page load instruction.
592 //
593 // @param Texture The texture to sample. Must be of type MIR::FTextureObject, MIR::FRuntimeVirtualTextureObject, or MIR::FUniformParameter.
594 // @param AddressU Texture address mode for the U-coordinate.
595 // @param AddressV Texture address mode for the V-coordinate.
596 // @param TexCoord The UV coordinates at which to sample the virtual texture.
597 // @param TexCoordDdx The partial derivative of the texture coordinates along the screen space x axis.
598 // @param TexCoordDdy The partial derivative of the texture coordinates along the screen space y axis.
599 // @param bEnableFeedback Specifies whether to enable virtual texture sampling feedback. This is only used for pixel shaders. Enabled by default.
600 // @param bIsAdaptive Specifies whether the page table instruction corresponds to an adaptive RVT.
601 // @param MipValueMode Specifies the MIP value mode. This determines what page table load function in the shader will be emitted, i.e. TextureLoadVirtualPageTable(), TextureLoadVirtualPageTableLevel(), etc..
602 // @param MipValue Optional value for an explicit MIP level or bias.
604 FValueRef Texture, TextureAddress AddressU, TextureAddress AddressV, FValueRef TexCoord,
605 FValueRef TexCoordDdx = {}, FValueRef TexCoordDdy = {}, bool bEnableFeedback = true, bool bIsAdaptive = false, ETextureMipValueMode MipValueMode = TMVM_None, FValueRef MipValue = {});
606
607 // Emits the partial derivative of given value.
608 // This function differentiates the given value with respect to the given axis.
609 // If differentiation is not possible, it returns a poison value to indicate an error.
610 // This API can be used regardless of the stages value will execute in. Hardware partial
611 // derivatives will be used by default where available. If not available, the analytical
612 // derivative will be computed instead.
613 // @param Value The value to differentiate.
614 // @param Axis The axis along which to compute the partial derivative (X for ddx, Y for ddy).
615 // @return A new FValueRef representing the partial derivative, or a poison value if invalid.
617
618 // Computes and emits the analytical partial derivative of a give value.
619 // @param Value The value to differentiate.
620 // @param Axis The axis along which to compute the partial derivative (X for ddx, Y for ddy).
621 // @return A new FValueRef representing the analytical derivative, or a poison value if invalid.
623
624 // Emit a new HLSL function inline within the material shader.
625 // @param Type The expected output type of the HLSL code.
626 // @param Code The HLSL code to be emitted.
627 // @param InputValues An array of input values required by the HLSL code.
628 // @param ValueFlags Flags that specify additional properties for this value (default is None).
629 // @param UsedGraphProperties Properties used during graph processing (default is None).
630 FValueRef InlineHLSL(FType Type, FStringView Code, TConstArrayView<FValueRef> InputValues = {}, EValueFlags ValueFlags = EValueFlags::None, EGraphProperties UsedGraphProperties = EGraphProperties::None);
631
632 // Emit a new HLSL function inline within the material shader based on an external code declaration.
633 // @param InExternalCodeDeclaration The external HLSL code declaration to use for emission.
634 // @param InputValues An array of input values required by the HLSL code.
635 // @param UsedGraphProperties Properties used during graph processing (default is None).
637
638 // Emits an instruction that promotes a Substrate parameter, encoded as MCT_Substrate.
640
641 // Defines a user-specified HLSL function to embed in the generated HLSL when generated IR Module is translated to HLSL.
642 // This will create a local function with the specified description. You can issue calls to the returned functions using the Call() API.
643 const FFunction* FunctionHLSL(const FFunctionHLSLDesc& Desc);
644
645 // Emits a call to a specified user function using specified input arguments.
646 // Note that the InputArguments must provide an argument for *all* function input parameters (that is including the input-output ones).
648
649 // Emits an instruction that retrieves the output parameter value from a function call.
650 FValueRef CallParameterOutput(FValueRef Call, uint32 ParameterIndex);
651
652 /*--------------------------- Unary operators shortcuts ----------------------------*/
653
654 FValueRef BitwiseNot(FValueRef A) { return Operator(UO_BitwiseNot, A); }
655 FValueRef Negate(FValueRef A) { return Operator(UO_Negate, A); }
656 FValueRef Not(FValueRef A) { return Operator(UO_Not, A); }
657 FValueRef Abs(FValueRef A) { return Operator(UO_Abs, A); }
658 FValueRef ACos(FValueRef A) { return Operator(UO_ACos, A); }
659 FValueRef ACosh(FValueRef A) { return Operator(UO_ACosh, A); }
660 FValueRef ASin(FValueRef A) { return Operator(UO_ASin, A); }
661 FValueRef ASinh(FValueRef A) { return Operator(UO_ASinh, A); }
662 FValueRef ATan(FValueRef A) { return Operator(UO_ATan, A); }
663 FValueRef ATanh(FValueRef A) { return Operator(UO_ATan, A); }
664 FValueRef Ceil(FValueRef A) { return Operator(UO_Ceil, A); }
665 FValueRef Cos(FValueRef A) { return Operator(UO_Cos, A); }
666 FValueRef Cosh(FValueRef A) { return Operator(UO_Cosh, A); }
667 FValueRef Exponential(FValueRef A) { return Operator(UO_Exponential, A); }
668 FValueRef Exponential2(FValueRef A) { return Operator(UO_Exponential2, A); }
669 FValueRef Floor(FValueRef A) { return Operator(UO_Floor, A); }
670 FValueRef Frac(FValueRef A) { return Operator(UO_Frac, A); }
671 FValueRef Length(FValueRef A) { return Operator(UO_Length, A); }
672 FValueRef Logarithm(FValueRef A) { return Operator(UO_Logarithm, A); }
673 FValueRef Logarithm2(FValueRef A) { return Operator(UO_Logarithm2, A); }
674 FValueRef Logarithm10(FValueRef A) { return Operator(UO_Logarithm10, A); }
675 FValueRef LWCTile(FValueRef A) { return Operator(UO_LWCTile, A); }
676 FValueRef Reciprocal(FValueRef A) { return Operator(UO_Reciprocal, A); }
677 FValueRef Round(FValueRef A) { return Operator(UO_Round, A); }
678 FValueRef Rsqrt(FValueRef A) { return Operator(UO_Rsqrt, A); }
679 FValueRef Saturate(FValueRef A) { return Operator(UO_Saturate, A); }
680 FValueRef Sign(FValueRef A) { return Operator(UO_Sign, A); }
681 FValueRef Sin(FValueRef A) { return Operator(UO_Sin, A); }
682 FValueRef Sinh(FValueRef A) { return Operator(UO_Sinh, A); }
683 FValueRef Sqrt(FValueRef A) { return Operator(UO_Sqrt, A); }
684 FValueRef Tan(FValueRef A) { return Operator(UO_Tan, A); }
685 FValueRef Truncate(FValueRef A) { return Operator(UO_Truncate, A); }
686
687 /*-------------------------- Binary operators shortcuts ----------------------------*/
688
689 FValueRef GreaterThan(FValueRef A, FValueRef B) { return Operator(BO_GreaterThan, A, B); }
691 FValueRef LessThan(FValueRef A, FValueRef B) { return Operator(BO_LessThan, A, B); }
693 FValueRef Equals(FValueRef A, FValueRef B) { return Operator(BO_Equals, A, B); }
694 FValueRef NotEquals(FValueRef A, FValueRef B) { return Operator(BO_NotEquals, A, B); }
695 FValueRef And(FValueRef A, FValueRef B) { return Operator(BO_And, A, B); }
696 FValueRef Or(FValueRef A, FValueRef B) { return Operator(BO_Or, A, B); }
697 FValueRef Add(FValueRef A, FValueRef B) { return Operator(BO_Add, A, B); }
698 FValueRef Subtract(FValueRef A, FValueRef B) { return Operator(BO_Subtract, A, B); }
699 FValueRef Multiply(FValueRef A, FValueRef B) { return Operator(BO_Multiply, A, B); }
701 FValueRef Divide(FValueRef A, FValueRef B) { return Operator(BO_Divide, A, B); }
702 FValueRef BitwiseAnd(FValueRef A, FValueRef B) { return Operator(BO_BitwiseAnd, A, B); }
703 FValueRef BitwiseOr(FValueRef A, FValueRef B) { return Operator(BO_BitwiseOr, A, B); }
704 FValueRef BitShiftLeft(FValueRef A, FValueRef B) { return Operator(BO_BitShiftLeft, A, B); }
706 FValueRef Fmod(FValueRef A, FValueRef B) { return Operator(BO_Fmod, A, B); }
707 FValueRef Max(FValueRef A, FValueRef B) { return Operator(BO_Max, A, B); }
708 FValueRef Modulo(FValueRef A, FValueRef B) { return Operator(BO_Modulo, A, B); }
709 FValueRef Min(FValueRef A, FValueRef B) { return Operator(BO_Min, A, B); }
710 FValueRef Step(FValueRef A, FValueRef B) { return Operator(BO_Step, A, B); }
711 FValueRef Dot(FValueRef A, FValueRef B) { return Operator(BO_Dot, A, B); }
712 FValueRef Cross(FValueRef A, FValueRef B) { return Operator(BO_Cross, A, B); }
713 FValueRef Atan2(FValueRef A, FValueRef B) { return Operator(BO_ATan2, A, B); }
714 FValueRef Pow(FValueRef A, FValueRef B) { return Operator(BO_Pow, A, B); }
715
716 /*-------------------------- Ternary operators shortcuts ---------------------------*/
717
718 FValueRef Clamp(FValueRef A, FValueRef B, FValueRef C) { return Operator(TO_Clamp, A, B, C); }
719 FValueRef Lerp(FValueRef A, FValueRef B, FValueRef C) { return Operator(TO_Lerp, A, B, C); }
720 FValueRef Select(FValueRef A, FValueRef B, FValueRef C) { return Operator(TO_Select, A, B, C); }
721 FValueRef Smoothstep(FValueRef A, FValueRef B, FValueRef C) { return Operator(TO_Smoothstep, A, B, C); }
722
723 /*-------------------------- Pass through accessors ---------------------------*/
724 EShaderPlatform GetShaderPlatform() const;
725 const ITargetPlatform* GetTargetPlatform() const;
726 ERHIFeatureLevel::Type GetFeatureLevel() const;
727 EMaterialQualityLevel::Type GetQualityLevel() const;
728
729 // Internal
730 struct FPrivate;
731
732private:
733 struct FValueKeyFuncs : DefaultKeyFuncs<FValue*>
734 {
735 static bool Matches(KeyInitType A, KeyInitType B);
736 static uint32 GetKeyHash(KeyInitType Key);
737 };
738
739private:
740 FEmitter() {}
741
742 // Initializes the emitter, called by the friend builder.
743 void Initialize();
744
745private:
746 // Pointer to the builder internal implementation.
748
749 // The material being translated.
751
752 // The IR module being built.
753 FMaterialIRModule* Module{};
754
755 // The set of static parameter assignments to use during this translation.
757
758 // The current expression being built (set by the builder).
760
761 // Whether the current expression has reported any error.
762 bool bCurrentExpressionHasErrors = false;
763
764 // Global "true" constant.
766
767 // Global "false" constant.
769
770 // The set of all values previously emitted. It is used to avoid duplicating identical
771 // values, explointing the strict SSA data-flow paradigm of MIR to efficiently reuse
772 // calculations.
774
777};
778
779} // namespace MIR
780
781#endif // #if WITH_EDITOR
@ INDEX_NONE
Definition CoreMiscDefines.h:150
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
TCopyQualifiersFromTo_T< From, To > * Cast(From *Src)
Definition Casts.h:95
ESamplerSourceMode
Definition EngineTypes.h:281
ETextureMipValueMode
Definition EngineTypes.h:295
EMaterialSamplerType
Definition EngineTypes.h:936
@ SAMPLERTYPE_MAX
Definition EngineTypes.h:958
EMaterialShadingModel
Definition EngineTypes.h:705
#define X(Name, Desc)
Definition FormatStringSan.h:47
EDBufferTextureId
Definition MaterialExpressionDBufferTexture.h:12
ESceneTextureId
Definition MaterialSceneTextureId.h:13
const bool
Definition NetworkReplayStreaming.h:178
@ BO_Min
Definition RHIDefinitions.h:462
@ BO_Add
Definition RHIDefinitions.h:460
@ BO_Subtract
Definition RHIDefinitions.h:461
@ BO_Max
Definition RHIDefinitions.h:463
EShaderPlatform
Definition RHIShaderPlatform.h:11
EMaterialProperty
Definition SceneTypes.h:148
TextureAddress
Definition TextureDefines.h:496
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition MaterialAggregate.h:82
Definition MaterialExpression.h:150
Definition MaterialParameterCollection.h:79
Definition Material.h:432
Definition Object.h:95
Definition RuntimeVirtualTexture.h:18
Definition Texture.h:1219
constexpr bool Includes(const DataTypeA *DataA, SizeTypeA NumA, const DataTypeB *DataB, SizeTypeB NumB, ProjectionType Projection, SortPredicateType SortPredicate)
Definition Includes.h:14
@ Not
Definition BTCompositeNode.h:46
Type
Definition SceneTypes.h:132
const Type ValueSet
Definition UnrealType.h:6846
Type
Definition RHIFeatureLevel.h:20
@ TextureObject
Definition SlateShaderResource.h:26
Definition MaterialExpression.h:36
FORCEINLINE FStridedReferenceIterator begin(FStridedReferenceView View)
Definition FastReferenceCollector.h:490
FORCEINLINE FStridedReferenceIterator end(FStridedReferenceView View)
Definition FastReferenceCollector.h:491
FDocument::ValueType FValue
Definition RapidJsonUtils.h:61
FValue Atan2(const FValue &Lhs, const FValue &Rhs)
Definition ShaderValue.cpp:1564
EPreshaderOpcode
Definition Preshader.h:20
VERSECOMPILER_API bool Matches(const CTypeBase *PositiveType1, const CTypeBase *NegativeType2, const uint32_t UploadedAtFnVersion)
Determine if argument PositiveType1 is a match for parameter NegativeType2
Definition SemanticTypes.cpp:2971
U16 Index
Definition radfft.cpp:71
Definition SetUtilities.h:36
Definition MaterialExpressionIO.h:23
Definition MaterialExpressionIO.h:115
Definition MaterialExternalCodeRegistry.h:113
Definition MaterialParameters.h:446
Definition StaticParameterSet.h:462
Definition IntVector.h:670
Definition IntVector.h:22
Definition IntVector.h:1216
Definition Vector2D.h:38
Definition Vector4.h:30
Definition Vector.h:51
Definition ShaderTypes.h:368