UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VertexFactory.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 VertexFactory.h: Vertex factory definitions.
5=============================================================================*/
6
7#pragma once
8
9#include "Containers/Array.h"
12#include "Containers/List.h"
13#include "Containers/Map.h"
15#include "CoreMinimal.h"
16#include "CoreTypes.h"
17#include "HAL/PlatformCrt.h"
18#include "Math/NumericLimits.h"
20#include "Misc/CString.h"
21#include "Misc/EnumClassFlags.h"
22#include "Misc/SecureHash.h"
23#include "RHI.h"
24#include "RHIDefinitions.h"
25#include "RenderResource.h"
29#include "Shader.h"
30#include "ShaderCore.h"
32#include "UObject/NameTypes.h"
34
35#include <atomic>
36
37class FCbFieldView;
38class FCbWriter;
39class FMaterial;
43
44#if PLATFORM_SUPPORTS_PRAGMA_PACK
45 #pragma pack (push,4)
46#endif
47
49{
53
54 union
55 {
56 // Contains the direct vertex buffer pointer
58
59 // Contains the stream source slot
61
62 // Represents either ptr type as an opaque int for comparisons.
63 void* Pointer;
64 };
65
67
69 StreamIndex(0),
70 Offset(0),
72 VertexBuffer(nullptr)
73 {}
74
77 {
78 // Verify no overflow
79 checkSlow(InStreamIndex == StreamIndex && InOffset == Offset);
80 }
81
88
95
96 inline bool operator==(const FVertexInputStream& rhs) const
97 {
98 if (StreamIndex != rhs.StreamIndex ||
99 Offset != rhs.Offset ||
100 Pointer != rhs.Pointer)
101 {
102 return false;
103 }
104
105 return true;
106 }
107
108 inline bool operator!=(const FVertexInputStream& rhs) const
109 {
110 return !(*this == rhs);
111 }
112};
113
114#if PLATFORM_SUPPORTS_PRAGMA_PACK
115 #pragma pack (pop)
116#endif
117
124
126
128{
129 Default = 0,
132 Count
133};
134
136{
137 None = 0u,
138 UsedWithMaterials = 1u << 1,
139 SupportsStaticLighting = 1u << 2,
140 SupportsDynamicLighting = 1u << 3,
142 SupportsPositionOnly = 1u << 5,
145 SupportsNaniteRendering = 1u << 8,
146 SupportsRayTracing = 1u << 9,
149 SupportsLightmapBaking = 1u << 12,
150 SupportsPSOPrecaching = 1u << 13,
151 SupportsManualVertexFetch = 1u << 14,
154 SupportsComputeShading = 1u << 17,
155 SupportsLumenMeshCards = 1u << 18,
156 SupportsLandscape = 1u << 19,
157 IncludesFwdShader = 1u << 20,
158 SupportsTriangleSorting = 1u << 21,
159};
161
165#define STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer,VertexType,Member,MemberType) \
166 FVertexStreamComponent(VertexBuffer,STRUCT_OFFSET(VertexType,Member),sizeof(VertexType),MemberType)
167
172{
174public:
175 void Bind(const class FShaderParameterMap& ParameterMap) {}
176
182 const class FSceneInterface* Scene,
183 const class FSceneView* View,
184 const class FMeshMaterialShader* Shader,
186 ERHIFeatureLevel::Type FeatureLevel,
187 const class FVertexFactory* VertexFactory,
188 const struct FMeshBatchElement& BatchElement,
189 class FMeshDrawSingleShaderBindings& ShaderBindings,
190 FVertexInputStreamArray& VertexStreams) const {}
191
192private:
193 // Should remove, but first need to fix some logic surrounding empty base classes
194 LAYOUT_FIELD_INITIALIZED(uint32, Size_DEPRECATED, 0u);
195};
196
197template<EShaderFrequency ShaderFrequency, typename VertexFactoryType>
199{
200 static const FTypeLayoutDesc* GetLayout() { return nullptr; }
201 static FVertexFactoryShaderParameters* Create(const class FShaderParameterMap& ParameterMap) { return nullptr; }
202
204 const FVertexFactoryShaderParameters* Parameters,
205 const class FSceneInterface* Scene,
206 const class FSceneView* View,
207 const class FMeshMaterialShader* Shader,
209 ERHIFeatureLevel::Type FeatureLevel,
210 const class FVertexFactory* VertexFactory,
211 const struct FMeshBatchElement& BatchElement,
212 class FMeshDrawSingleShaderBindings& ShaderBindings,
213 FVertexInputStreamArray& VertexStreams) {}
214};
215
216#define IMPLEMENT_VERTEX_FACTORY_PARAMETER_TYPE(FactoryClass, ShaderFrequency, ParameterClass) \
217 template<> struct TVertexFactoryParameterTraits<ShaderFrequency, FactoryClass> \
218 { \
219 static const FTypeLayoutDesc* GetLayout() { return &StaticGetTypeLayoutDesc<ParameterClass>(); } \
220 static FVertexFactoryShaderParameters* Create(const class FShaderParameterMap& ParameterMap) { ParameterClass* Result = new ParameterClass(); Result->Bind(ParameterMap); return Result; } \
221 static void GetElementShaderBindings( \
222 const FVertexFactoryShaderParameters* Parameters, \
223 const class FSceneInterface* Scene, \
224 const class FSceneView* View, \
225 const class FMeshMaterialShader* Shader, \
226 const EVertexInputStreamType InputStreamType, \
227 ERHIFeatureLevel::Type FeatureLevel, \
228 const class FVertexFactory* VertexFactory, \
229 const struct FMeshBatchElement& BatchElement, \
230 class FMeshDrawSingleShaderBindings& ShaderBindings, \
231 FVertexInputStreamArray& VertexStreams) \
232 { \
233 static_cast<const ParameterClass*>(Parameters)->GetElementShaderBindings(Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); \
234 } \
235 }
236
237template<typename VertexFactoryType>
238static const FTypeLayoutDesc* GetVertexFactoryParametersLayout(EShaderFrequency ShaderFrequency)
239{
240 switch (ShaderFrequency)
241 {
254 default: checkNoEntry(); return nullptr;
255 }
256}
257
258template<typename VertexFactoryType>
259static FVertexFactoryShaderParameters* ConstructVertexFactoryParameters(EShaderFrequency ShaderFrequency, const class FShaderParameterMap& ParameterMap)
260{
261 switch (ShaderFrequency)
262 {
275 default: checkNoEntry(); return nullptr;
276 }
277}
278
279
280template<typename VertexFactoryType>
281static void GetVertexFactoryParametersElementShaderBindings(EShaderFrequency ShaderFrequency, const FVertexFactoryShaderParameters* Parameters,
282 const class FSceneInterface* Scene,
283 const class FSceneView* View,
284 const class FMeshMaterialShader* Shader,
286 ERHIFeatureLevel::Type FeatureLevel,
287 const class FVertexFactory* VertexFactory,
288 const struct FMeshBatchElement& BatchElement,
289 class FMeshDrawSingleShaderBindings& ShaderBindings,
290 FVertexInputStreamArray& VertexStreams)
291{
292 switch (ShaderFrequency)
293 {
294 case SF_Vertex: TVertexFactoryParameterTraits<SF_Vertex, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
295 case SF_Mesh: TVertexFactoryParameterTraits<SF_Mesh, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
296 case SF_Amplification: TVertexFactoryParameterTraits<SF_Amplification, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
297 case SF_Pixel: TVertexFactoryParameterTraits<SF_Pixel, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
298 case SF_Geometry: TVertexFactoryParameterTraits<SF_Geometry, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
299 case SF_Compute: TVertexFactoryParameterTraits<SF_Compute, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
300 case SF_RayGen: TVertexFactoryParameterTraits<SF_RayGen, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
301 case SF_RayMiss: TVertexFactoryParameterTraits<SF_RayMiss, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
302 case SF_RayHitGroup: TVertexFactoryParameterTraits<SF_RayHitGroup, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
303 case SF_RayCallable: TVertexFactoryParameterTraits<SF_RayCallable, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
304 case SF_WorkGraphRoot: TVertexFactoryParameterTraits<SF_WorkGraphRoot, VertexFactoryType>::GetElementShaderBindings(Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); break;
306 default: checkNoEntry(); break;
307 }
308}
309
314{
315public:
316
317 typedef FVertexFactoryShaderParameters* (*ConstructParametersType)(EShaderFrequency ShaderFrequency, const class FShaderParameterMap& ParameterMap);
318 typedef const FTypeLayoutDesc* (*GetParameterTypeLayoutType)(EShaderFrequency ShaderFrequency);
320 const FVertexFactoryShaderParameters* Parameters,
321 const class FSceneInterface* Scene,
322 const class FSceneView* View,
323 const class FMeshMaterialShader* Shader,
325 ERHIFeatureLevel::Type FeatureLevel,
326 const class FVertexFactory* VertexFactory,
327 const struct FMeshBatchElement& BatchElement,
328 class FMeshDrawSingleShaderBindings& ShaderBindings,
329 FVertexInputStreamArray& VertexStreams);
332
333#if WITH_EDITOR
336#endif // WITH_EDITOR
337
338 static int32 GetNumVertexFactoryTypes() { return NumVertexFactories; }
339
344
346
351
354
356 const TCHAR* InName,
357 const TCHAR* InShaderFilename,
364#if WITH_EDITOR
367#endif // WITH_EDITOR
368 );
369
371
372 // Accessors.
373 const TCHAR* GetName() const { return Name; }
374 FName GetFName() const { return TypeName; }
375 const FHashedName& GetHashedName() const { return HashedName; }
376 const TCHAR* GetShaderFilename() const { return ShaderFilename; }
377 const TCHAR* GetShaderFwdFilename() const { return *ShaderFwdFilename; }
378
379 FVertexFactoryShaderParameters* CreateShaderParameters(EShaderFrequency ShaderFrequency, const class FShaderParameterMap& ParameterMap) const { return (*ConstructParameters)(ShaderFrequency, ParameterMap); }
380 const FTypeLayoutDesc* GetShaderParameterLayout(EShaderFrequency ShaderFrequency) const { return (*GetParameterTypeLayout)(ShaderFrequency); }
382 const FVertexFactoryShaderParameters* Parameters,
383 const class FSceneInterface* Scene,
384 const class FSceneView* View,
385 const class FMeshMaterialShader* Shader,
387 ERHIFeatureLevel::Type FeatureLevel,
388 const class FVertexFactory* VertexFactory,
389 const struct FMeshBatchElement& BatchElement,
390 class FMeshDrawSingleShaderBindings& ShaderBindings,
391 FVertexInputStreamArray& VertexStreams) const { (*GetParameterTypeElementShaderBindings)(ShaderFrequency, Parameters, Scene, View, Shader, InputStreamType, FeatureLevel, VertexFactory, BatchElement, ShaderBindings, VertexStreams); }
393
395 {
396 return Flags;
397 }
398
404
425
430
432
433 // Hash function.
435 {
436 return Type ? GetTypeHash(Type->HashedName) : 0u;
437 }
438
440 RENDERCORE_API const FSHAHash& GetSourceHash(EShaderPlatform ShaderPlatform) const;
441
446 {
447 return (*ShouldCacheRef)(Parameters);
448 }
449
450#if WITH_EDITOR
455 void ModifyCompilationEnvironment(const FVertexFactoryShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment) const
456 {
457 // Set up the mapping from VertexFactory.usf to the vertex factory type's source code.
458 FString VertexFactoryIncludeString = FString::Printf( TEXT("#include \"%s\""), GetShaderFilename() );
459 OutEnvironment.IncludeVirtualPathToContentsMap.Add(TEXT("/Engine/Generated/VertexFactory.ush"), VertexFactoryIncludeString);
460
462 {
463 FString VertexFactoryFwdIncludeString = FString::Printf(TEXT("#include \"%s\""), GetShaderFwdFilename());
464 OutEnvironment.IncludeVirtualPathToContentsMap.Add(TEXT("/Engine/Generated/VertexFactoryFwd.ush"), VertexFactoryFwdIncludeString);
465 OutEnvironment.SetDefine(TEXT("USE_VERTEX_FACTORY_FWD"), 1);
466 }
467 else
468 {
469 OutEnvironment.IncludeVirtualPathToContentsMap.Add(TEXT("/Engine/Generated/VertexFactoryFwd.ush"), TEXT("#include \"/Engine/Private/VertexFactoryDefaultFwd.ush\""));
470 }
471
472 OutEnvironment.SetDefine(TEXT("HAS_PRIMITIVE_UNIFORM_BUFFER"), 1);
473
474 (*ModifyCompilationEnvironmentRef)(Parameters, OutEnvironment);
475 }
476
477 void ValidateCompiledResult(EShaderPlatform Platform, const FShaderParameterMap& ParameterMap, TArray<FString>& OutErrors) const
478 {
479 (*ValidateCompiledResultRef)(this, Platform, ParameterMap, OutErrors);
480 }
481
484
485 UE_DEPRECATED(5.5, "GetReferencedUniformBufferNames is deprecated; call GetReferencedUniformBuffers instead.")
487 {
489 return EmptySet;
490 };
491
493 {
494 return ReferencedUniformBuffers;
495 }
496
498#endif // WITH_EDITOR
499
500private:
501 static RENDERCORE_API uint32 NumVertexFactories;
502
504 static bool bVertexFactoriesInitialized;
505
506 const TCHAR* Name;
507 const TCHAR* ShaderFilename;
508 FString ShaderFwdFilename;
509 FName TypeName;
510 FHashedName HashedName;
512 ConstructParametersType ConstructParameters;
513 GetParameterTypeLayoutType GetParameterTypeLayout;
514 GetParameterTypeElementShaderBindingsType GetParameterTypeElementShaderBindings;
515 GetPSOPrecacheVertexFetchElementsType GetPSOPrecacheVertexFetchElements;
516 ShouldCacheType ShouldCacheRef;
517#if WITH_EDITOR
520#endif // WITH_EDITOR
521
523
524#if WITH_EDITOR
530 TSet<const FShaderParametersMetadata*> ReferencedUniformBuffers;
531#endif // WITH_EDITOR
532};
533
538
544
548#define DECLARE_VERTEX_FACTORY_TYPE(FactoryClass) \
549 public: \
550 static FVertexFactoryType StaticType; \
551 virtual FVertexFactoryType* GetType() const override;
552
553#define DECLARE_VERTEX_FACTORY_TYPE_API(FactoryClass, ModuleApi) \
554 public: \
555 ModuleApi static FVertexFactoryType StaticType; \
556 ModuleApi virtual FVertexFactoryType* GetType() const override;
557
558#if WITH_EDITOR
559 #define IMPLEMENT_VERTEX_FACTORY_EDITOR_VTABLE(FactoryClass) \
560 , FactoryClass::ModifyCompilationEnvironment \
561 , FactoryClass::ValidateCompiledResult
562#else
563 #define IMPLEMENT_VERTEX_FACTORY_EDITOR_VTABLE(FactoryClass)
564#endif // WITH_EDITOR
565
566#define IMPLEMENT_VERTEX_FACTORY_VTABLE(FactoryClass) \
567 &ConstructVertexFactoryParameters<FactoryClass>, \
568 &GetVertexFactoryParametersLayout<FactoryClass>, \
569 &GetVertexFactoryParametersElementShaderBindings<FactoryClass>, \
570 FactoryClass::GetPSOPrecacheVertexFetchElements, \
571 FactoryClass::ShouldCompilePermutation \
572 IMPLEMENT_VERTEX_FACTORY_EDITOR_VTABLE(FactoryClass)
573
577#define IMPLEMENT_VERTEX_FACTORY_TYPE(FactoryClass, ShaderFilename, Flags) \
578 FVertexFactoryType FactoryClass::StaticType( \
579 TEXT(#FactoryClass), \
580 TEXT(ShaderFilename), \
581 Flags, \
582 IMPLEMENT_VERTEX_FACTORY_VTABLE(FactoryClass) \
583 ); \
584 FVertexFactoryType* FactoryClass::GetType() const { return &StaticType; }
588#define IMPLEMENT_TEMPLATE_VERTEX_FACTORY_TYPE(TemplatePrefix, FactoryClass, ShaderFilename, Flags) \
589 PREPROCESSOR_REMOVE_OPTIONAL_PARENS(TemplatePrefix) FVertexFactoryType FactoryClass::StaticType( \
590 TEXT(#FactoryClass), \
591 TEXT(ShaderFilename), \
592 Flags, \
593 IMPLEMENT_VERTEX_FACTORY_VTABLE(FactoryClass) \
594 ); \
595 PREPROCESSOR_REMOVE_OPTIONAL_PARENS(TemplatePrefix) FVertexFactoryType* FactoryClass::GetType() const { return &StaticType; }
596
599{
600public:
602
604
607
609 {
610 Ar << Ref.VertexFactoryTypeName << Ref.VFSourceHash;
611 return Ar;
612 }
613
614 bool operator==(const FVertexFactoryTypeDependency& Reference) const
615 {
616 return VertexFactoryTypeName == Reference.VertexFactoryTypeName && VFSourceHash == Reference.VFSourceHash;
617 }
618
619 bool operator!=(const FVertexFactoryTypeDependency& Reference) const
620 {
621 return !(*this == Reference);
622 }
623
626
627private:
628#if WITH_EDITOR
629 // Compact binary API with hidden friend operator<<
630 RENDERCORE_API void Save(FCbWriter& Writer) const;
631 bool TryLoad(FCbFieldView Field);
632 friend inline FCbWriter& operator<<(FCbWriter& Writer, const FVertexFactoryTypeDependency& Value)
633 {
634 Value.Save(Writer);
635 return Writer;
636 }
638#endif
639};
640
643{
644public:
645 inline bool operator()(const FVertexFactoryType& A, const FVertexFactoryType& B ) const
646 {
647 int32 AL = FCString::Strlen(A.GetName());
648 int32 BL = FCString::Strlen(B.GetName());
649 if ( AL == BL )
650 {
651 return FCString::Strncmp(A.GetName(), B.GetName(), AL) > 0;
652 }
653 return AL > BL;
654 }
655};
656
661{
662public:
665 {
666 for (int32 i = 0; i < UE_ARRAY_COUNT(PrimitiveIdStreamIndex); ++i)
667 {
668 PrimitiveIdStreamIndex[i] = INDEX_NONE;
669 }
670 }
671
673
674 virtual FVertexFactoryType* GetType() const { return nullptr; }
675
677
679
684
688 static void ValidateCompiledResult(const FVertexFactoryType* Type, EShaderPlatform Platform, const FShaderParameterMap& ParameterMap, TArray<FString>& OutErrors) {}
689
694
695 // FRenderResource interface.
696 RENDERCORE_API virtual void ReleaseRHI();
697
698 // Accessors.
699 FVertexDeclarationRHIRef& GetDeclaration() { return Declaration; }
701
702 const FVertexDeclarationRHIRef& GetDeclaration(EVertexInputStreamType InputStreamType/* = FVertexInputStreamType::Default*/) const
703 {
704 switch (InputStreamType)
705 {
706 case EVertexInputStreamType::Default: return Declaration;
707 case EVertexInputStreamType::PositionOnly: return PositionDeclaration;
708 case EVertexInputStreamType::PositionAndNormalOnly: return PositionAndNormalDeclaration;
709 }
710
711 return Declaration;
712 }
713
715 virtual bool SupportsPositionOnlyStream() const { return !!PositionStream.Num(); }
716
718 virtual bool SupportsPositionAndNormalOnlyStream() const { return !!PositionAndNormalStream.Num(); }
719
722 {
724 }
725
727 {
729 }
730
732 {
733 return nullptr;
734 }
735
736#if WITH_EDITORONLY_DATA
737 virtual bool IsCoarseProxyMesh() const { return false; }
738#endif
739
740 virtual bool RendersPrimitivesAsCameraFacingSprites() const { return false; }
741
742 bool NeedsDeclaration() const { return bNeedsDeclaration; }
743
748
750 {
751 return PrimitiveIdStreamIndex[TranslatePrimitiveIdStreamIndex(InFeatureLevel, InputStreamType)];
752 }
753
758
759protected:
761 {
762 check(StreamIndex >= TNumericLimits<int8>::Min() && StreamIndex <= TNumericLimits<int8>::Max());
763 PrimitiveIdStreamIndex[TranslatePrimitiveIdStreamIndex(InFeatureLevel, InputStreamType)] = static_cast<int8>(StreamIndex);
764 }
765
767
775 {
776 return AccessStreamComponent(Component, AttributeIndex, Streams);
777 }
778
787
795 template<typename VertexStreamListType>
797 {
799 VertexStream.VertexBuffer = Component.VertexBuffer;
800 VertexStream.Stride = Component.Stride;
801 VertexStream.Offset = Component.StreamOffset;
802 VertexStream.VertexStreamUsage = Component.VertexStreamUsage;
803 return FVertexElement((uint8)InOutStreams.AddUnique(VertexStream), Component.Offset, Component.Type, AttributeIndex, VertexStream.Stride, EnumHasAnyFlags(EVertexStreamUsage::Instancing, VertexStream.VertexStreamUsage));
804 }
805
806
812
817 {
818 const FVertexBuffer* VertexBuffer = nullptr;
823
824 friend bool operator==(const FVertexStream& A,const FVertexStream& B)
825 {
826 return A.VertexBuffer == B.VertexBuffer && A.Stride == B.Stride && A.Offset == B.Offset && A.VertexStreamUsage == B.VertexStreamUsage;
827 }
828
830 {
831 }
832 };
833
835
838
839private:
840
843 TArray<FVertexStream, TInlineAllocator<3> > PositionAndNormalStream;
844
846 FVertexDeclarationRHIRef Declaration;
847
849 FVertexDeclarationRHIRef PositionDeclaration;
850 FVertexDeclarationRHIRef PositionAndNormalDeclaration;
851
852#if WITH_EDITOR
853 // In the editor PrimtiveId streams may differ between mobile and desktop feature levels, so we store them separately
854 int8 PrimitiveIdStreamIndex[(int32)EVertexInputStreamType::Count * 2];
855#else
856 int8 PrimitiveIdStreamIndex[(int32)EVertexInputStreamType::Count];
857#endif
858
859protected:
860 /* VF can explicitly set this to false to avoid errors without decls; this is for VFs that fetch from buffers directly (e.g. Niagara) */
861 bool bNeedsDeclaration = true;
862
863private:
864 static int32 TranslatePrimitiveIdStreamIndex(const FStaticFeatureLevel InFeatureLevel, EVertexInputStreamType InputStreamType)
865 {
866 #if WITH_EDITOR
868 #else
869 return static_cast<int32>(InputStreamType);
870 #endif
871 }
872};
873
879{
880public:
881
882 virtual void InitRHI(FRHICommandListBase& RHICmdList) override;
883
884 virtual void ReleaseRHI() override
885 {
888 }
889
891};
892
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkNoEntry()
Definition AssertionMacros.h:316
bool LoadFromCompactBinary(FCbFieldView Field, FAssetDependency &Dependency)
Definition AssetRegistry.cpp:10420
#define WITH_EDITOR
Definition Build.h:67
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TYPE_OF_NULLPTR TYPE_OF_NULLPTR
The type of the C++ nullptr keyword.
Definition Platform.h:1157
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
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
constexpr bool EnumHasAllFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:28
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define DECLARE_EXPORTED_TYPE_LAYOUT(T, RequiredAPI, Interface)
Definition MemoryLayout.h:559
#define LAYOUT_FIELD_INITIALIZED(T, Name, Value,...)
Definition MemoryLayout.h:473
const bool
Definition NetworkReplayStreaming.h:178
EShaderFrequency
Definition RHIDefinitions.h:202
@ SF_Compute
Definition RHIDefinitions.h:208
@ SF_Amplification
Definition RHIDefinitions.h:205
@ SF_Vertex
Definition RHIDefinitions.h:203
@ SF_Mesh
Definition RHIDefinitions.h:204
@ SF_Geometry
Definition RHIDefinitions.h:207
@ SF_RayGen
Definition RHIDefinitions.h:209
@ SF_RayCallable
Definition RHIDefinitions.h:212
@ SF_RayMiss
Definition RHIDefinitions.h:210
@ SF_RayHitGroup
Definition RHIDefinitions.h:211
@ SF_WorkGraphRoot
Definition RHIDefinitions.h:213
@ SF_WorkGraphComputeNode
Definition RHIDefinitions.h:214
@ SF_Pixel
Definition RHIDefinitions.h:206
EShaderPlatform
Definition RHIShaderPlatform.h:11
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
TArray< FVertexInputStream, TInlineAllocator< 7 > > FVertexInputStreamArray
Definition VertexFactory.h:123
EVertexInputStreamType
Definition VertexFactory.h:128
RENDERCORE_API FVertexFactoryType * FindVertexFactoryType(const FHashedName &TypeName)
Definition VertexFactory.cpp:208
EVertexFactoryFlags
Definition VertexFactory.h:136
@ SupportsRayTracingProceduralPrimitive
RENDERCORE_API FArchive & operator<<(FArchive &Ar, FVertexFactoryType *&TypeRef)
Definition VertexFactory.cpp:192
RENDERCORE_API TGlobalResource< FPrimitiveIdDummyBuffer > GPrimitiveIdDummy
Definition VertexFactory.cpp:432
EVertexStreamUsage
Definition VertexStreamComponent.h:11
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition CompactBinary.h:610
Definition CompactBinaryWriter.h:68
Definition VertexFactory.h:643
bool operator()(const FVertexFactoryType &A, const FVertexFactoryType &B) const
Definition VertexFactory.h:645
Definition MemoryImage.h:858
Definition MaterialShared.h:2058
Definition MeshDrawShaderBindings.h:104
Definition MeshMaterialShader.h:68
Definition NameTypes.h:617
Definition VertexFactory.h:879
virtual void ReleaseRHI() override
Definition VertexFactory.h:884
FShaderResourceViewRHIRef VertexBufferSRV
Definition VertexFactory.h:890
virtual void InitRHI(FRHICommandListBase &RHICmdList) override
Definition VertexFactory.cpp:416
Definition PrimitiveSceneProxy.h:296
Definition RHIResources.h:1581
Definition RHICommandList.h:455
Definition RHICommandList.h:3819
Definition RHIResources.h:1643
Definition RenderResource.h:37
Definition SecureHash.h:226
Definition SceneInterface.h:106
Definition SceneView.h:1425
Definition ShaderCore.h:323
Definition RenderResource.h:474
virtual RENDERCORE_API void ReleaseRHI() override
Definition RenderResource.cpp:556
Definition VertexFactory.h:172
void GetElementShaderBindings(const class FSceneInterface *Scene, const class FSceneView *View, const class FMeshMaterialShader *Shader, const EVertexInputStreamType InputStreamType, ERHIFeatureLevel::Type FeatureLevel, const class FVertexFactory *VertexFactory, const struct FMeshBatchElement &BatchElement, class FMeshDrawSingleShaderBindings &ShaderBindings, FVertexInputStreamArray &VertexStreams) const
Definition VertexFactory.h:181
void Bind(const class FShaderParameterMap &ParameterMap)
Definition VertexFactory.h:175
Definition VertexFactory.h:599
bool operator!=(const FVertexFactoryTypeDependency &Reference) const
Definition VertexFactory.h:619
FVertexFactoryTypeDependency()
Definition VertexFactory.h:601
bool operator==(const FVertexFactoryTypeDependency &Reference) const
Definition VertexFactory.h:614
FHashedName VertexFactoryTypeName
Definition VertexFactory.h:603
RENDERCORE_API void RefreshCachedSourceHash(EShaderPlatform ShaderPlatform)
Definition VertexFactory.cpp:213
friend FArchive & operator<<(FArchive &Ar, class FVertexFactoryTypeDependency &Ref)
Definition VertexFactory.h:608
FSHAHash VFSourceHash
Definition VertexFactory.h:606
Definition VertexFactory.h:314
bool SupportsRayTracingProceduralPrimitive() const
Definition VertexFactory.h:415
const TCHAR * GetShaderFwdFilename() const
Definition VertexFactory.h:377
virtual RENDERCORE_API ~FVertexFactoryType()
Definition VertexFactory.cpp:163
bool SupportsLumenMeshCards() const
Definition VertexFactory.h:421
static RENDERCORE_API FVertexFactoryType * GetVFByName(const FHashedName &VFName)
Definition VertexFactory.cpp:66
FName GetFName() const
Definition VertexFactory.h:374
bool SupportsPositionOnly() const
Definition VertexFactory.h:409
bool SupportsLightmapBaking() const
Definition VertexFactory.h:416
bool SupportsPrimitiveIdStream() const
Definition VertexFactory.h:411
friend uint32 GetTypeHash(const FVertexFactoryType *Type)
Definition VertexFactory.h:434
bool IsUsedWithMaterials() const
Definition VertexFactory.h:405
static RENDERCORE_API TLinkedList< FVertexFactoryType * > *& GetTypeList()
Definition VertexFactory.cpp:53
const TCHAR * GetName() const
Definition VertexFactory.h:373
bool SupportsManualVertexFetch(ERHIFeatureLevel::Type InFeatureLevel) const
Definition VertexFactory.h:426
bool SupportsRayTracing() const
Definition VertexFactory.h:413
void(* GetPSOPrecacheVertexFetchElementsType)(EVertexInputStreamType VertexInputStreamType, FVertexDeclarationElementList &Elements)
Definition VertexFactory.h:330
bool(* ShouldCacheType)(const FVertexFactoryShaderPermutationParameters &)
Definition VertexFactory.h:331
bool SupportsGPUSkinPassThrough() const
Definition VertexFactory.h:419
bool SupportsRayTracingDynamicGeometry() const
Definition VertexFactory.h:414
const TCHAR * GetShaderFilename() const
Definition VertexFactory.h:376
bool SupportsNaniteRendering() const
Definition VertexFactory.h:412
const FHashedName & GetHashedName() const
Definition VertexFactory.h:375
bool SupportsLandscape() const
Definition VertexFactory.h:422
RENDERCORE_API const FSHAHash & GetSourceHash(EShaderPlatform ShaderPlatform) const
Definition VertexFactory.cpp:187
FVertexFactoryShaderParameters *(* ConstructParametersType)(EShaderFrequency ShaderFrequency, const class FShaderParameterMap &ParameterMap)
Definition VertexFactory.h:317
bool SupportsPSOPrecaching() const
Definition VertexFactory.h:417
bool SupportsCachingMeshDrawCommands() const
Definition VertexFactory.h:410
bool HasFlags(EVertexFactoryFlags FlagsToCheck) const
Definition VertexFactory.h:400
FVertexFactoryShaderParameters * CreateShaderParameters(EShaderFrequency ShaderFrequency, const class FShaderParameterMap &ParameterMap) const
Definition VertexFactory.h:379
bool IncludesFwdShaderFile() const
Definition VertexFactory.h:423
void GetShaderPSOPrecacheVertexFetchElements(EVertexInputStreamType VertexInputStreamType, FVertexDeclarationElementList &Elements) const
Definition VertexFactory.h:392
const FTypeLayoutDesc * GetShaderParameterLayout(EShaderFrequency ShaderFrequency) const
Definition VertexFactory.h:380
static RENDERCORE_API bool CheckManualVertexFetchSupport(ERHIFeatureLevel::Type InFeatureLevel)
Definition VertexFactory.cpp:180
static int32 GetNumVertexFactoryTypes()
Definition VertexFactory.h:338
static RENDERCORE_API const TArray< FVertexFactoryType * > & GetSortedMaterialTypes()
Definition VertexFactory.cpp:58
bool SupportsDynamicLighting() const
Definition VertexFactory.h:407
bool ShouldCache(const FVertexFactoryShaderPermutationParameters &Parameters) const
Definition VertexFactory.h:445
const FTypeLayoutDesc *(* GetParameterTypeLayoutType)(EShaderFrequency ShaderFrequency)
Definition VertexFactory.h:318
bool SupportsPrecisePrevWorldPos() const
Definition VertexFactory.h:408
bool SupportsStaticLighting() const
Definition VertexFactory.h:406
void(* GetParameterTypeElementShaderBindingsType)(EShaderFrequency ShaderFrequency, const FVertexFactoryShaderParameters *Parameters, const class FSceneInterface *Scene, const class FSceneView *View, const class FMeshMaterialShader *Shader, const EVertexInputStreamType InputStreamType, ERHIFeatureLevel::Type FeatureLevel, const class FVertexFactory *VertexFactory, const struct FMeshBatchElement &BatchElement, class FMeshDrawSingleShaderBindings &ShaderBindings, FVertexInputStreamArray &VertexStreams)
Definition VertexFactory.h:319
bool SupportsTriangleSorting() const
Definition VertexFactory.h:424
void GetShaderParameterElementShaderBindings(EShaderFrequency ShaderFrequency, const FVertexFactoryShaderParameters *Parameters, const class FSceneInterface *Scene, const class FSceneView *View, const class FMeshMaterialShader *Shader, const EVertexInputStreamType InputStreamType, ERHIFeatureLevel::Type FeatureLevel, const class FVertexFactory *VertexFactory, const struct FMeshBatchElement &BatchElement, class FMeshDrawSingleShaderBindings &ShaderBindings, FVertexInputStreamArray &VertexStreams) const
Definition VertexFactory.h:381
EVertexFactoryFlags GetFlags() const
Definition VertexFactory.h:394
bool SupportsNullPixelShader() const
Definition VertexFactory.h:418
bool SupportsComputeShading() const
Definition VertexFactory.h:420
Definition VertexFactory.h:661
static void ModifyCompilationEnvironment(const FVertexFactoryShaderPermutationParameters &Parameters, FShaderCompilerEnvironment &OutEnvironment)
Definition VertexFactory.h:683
TArray< FVertexStream, TInlineAllocator< 8 > > FVertexStreamList
Definition VertexFactory.h:834
virtual bool RendersPrimitivesAsCameraFacingSprites() const
Definition VertexFactory.h:740
bool SupportsManualVertexFetch(const FStaticFeatureLevel InFeatureLevel) const
Definition VertexFactory.h:744
static void GetPSOPrecacheVertexFetchElements(EVertexInputStreamType VertexInputStreamType, FVertexDeclarationElementList &Elements)
Definition VertexFactory.h:693
bool NeedsDeclaration() const
Definition VertexFactory.h:742
static FVertexElement AccessStreamComponent(const FVertexStreamComponent &Component, uint8 AttributeIndex, VertexStreamListType &InOutStreams)
Definition VertexFactory.h:796
bool bNeedsDeclaration
Definition VertexFactory.h:861
FVertexFactory(ERHIFeatureLevel::Type InFeatureLevel)
Definition VertexFactory.h:663
virtual bool SupportsPositionAndNormalOnlyStream() const
Definition VertexFactory.h:718
virtual FVertexFactoryType * GetType() const
Definition VertexFactory.h:674
virtual RENDERCORE_API ~FVertexFactory()
void SetDeclaration(FVertexDeclarationRHIRef &NewDeclaration)
Definition VertexFactory.h:700
static void ValidateCompiledResult(const FVertexFactoryType *Type, EShaderPlatform Platform, const FShaderParameterMap &ParameterMap, TArray< FString > &OutErrors)
Definition VertexFactory.h:688
FVertexElement AccessStreamComponent(const FVertexStreamComponent &Component, uint8 AttributeIndex)
Definition VertexFactory.h:774
virtual RENDERCORE_API void ReleaseRHI()
Definition VertexFactory.cpp:340
RENDERCORE_API void InitDeclaration(const FVertexDeclarationElementList &Elements, EVertexInputStreamType StreamType=EVertexInputStreamType::Default)
Definition VertexFactory.cpp:398
const FVertexDeclarationRHIRef & GetDeclaration(EVertexInputStreamType InputStreamType) const
Definition VertexFactory.h:702
bool SupportsGPUScene(const FStaticFeatureLevel InFeatureLevel) const
Definition VertexFactory.h:754
virtual FShaderResourceViewRHIRef GetTriangleSortingPositionSRV() const
Definition VertexFactory.h:731
RENDERCORE_API bool AddPrimitiveIdStreamElement(EVertexInputStreamType InputStreamType, FVertexDeclarationElementList &Elements, uint8 AttributeIndex, uint8 AttributeIndex_Mobile)
Definition VertexFactory.cpp:350
FVertexDeclarationRHIRef & GetDeclaration()
Definition VertexFactory.h:699
RENDERCORE_API void GetStreams(ERHIFeatureLevel::Type InFeatureLevel, EVertexInputStreamType VertexStreamType, FVertexInputStreamArray &OutVertexStreams) const
Definition VertexFactory.cpp:256
bool SupportsTriangleSorting() const
Definition VertexFactory.h:726
virtual bool SupportsPositionOnlyStream() const
Definition VertexFactory.h:715
bool SupportsNullPixelShader() const
Definition VertexFactory.h:721
FVertexStreamList Streams
Definition VertexFactory.h:837
int32 GetPrimitiveIdStreamIndex(const FStaticFeatureLevel InFeatureLevel, EVertexInputStreamType InputStreamType) const
Definition VertexFactory.h:749
void SetPrimitiveIdStreamIndex(const FStaticFeatureLevel InFeatureLevel, EVertexInputStreamType InputStreamType, int32 StreamIndex)
Definition VertexFactory.h:760
RENDERCORE_API void OffsetInstanceStreams(uint32 InstanceOffset, EVertexInputStreamType VertexStreamType, FVertexInputStreamArray &VertexStreams) const
Definition VertexFactory.cpp:316
Definition Array.h:670
Definition RenderResource.h:543
Definition List.h:285
Definition UnrealString.h.inl:34
UE_FORCEINLINE_HINT void SafeRelease()
Definition RefCounting.h:599
Type
Definition RHIFeatureLevel.h:20
@ ES3_1
Definition RHIFeatureLevel.h:25
Definition FieldSystemNoiseAlgo.cpp:6
Definition MeshBatch.h:232
Definition ShaderCore.h:544
Definition AndroidStaticFeatureLevel.inl:12
Definition MemoryLayout.h:108
Definition RHI.h:182
Definition MeshMaterialShader.h:44
Definition VertexFactory.h:817
friend bool operator==(const FVertexStream &A, const FVertexStream &B)
Definition VertexFactory.h:824
EVertexStreamUsage VertexStreamUsage
Definition VertexFactory.h:821
uint8 Padding
Definition VertexFactory.h:822
FVertexStream()
Definition VertexFactory.h:829
uint16 Stride
Definition VertexFactory.h:820
uint32 Offset
Definition VertexFactory.h:819
const FVertexBuffer * VertexBuffer
Definition VertexFactory.h:818
Definition VertexFactory.h:49
RENDERCORE_API void SetOnRHICommandList(FRHICommandList &RHICmdList) const
Definition VertexFactory.cpp:38
uint32 Offset
Definition VertexFactory.h:51
FVertexInputStream(uint32 InStreamIndex, uint32 InOffset, FRHIStreamSourceSlot *InStreamSourceSlot)
Definition VertexFactory.h:82
FVertexInputStream(uint32 InStreamIndex, uint32 InOffset, FRHIBuffer *InVertexBuffer)
Definition VertexFactory.h:89
uint32 StreamIndex
Definition VertexFactory.h:50
FVertexInputStream()
Definition VertexFactory.h:68
bool operator==(const FVertexInputStream &rhs) const
Definition VertexFactory.h:96
uint32 bStreamSourceSlot
Definition VertexFactory.h:52
FVertexInputStream(uint32 InStreamIndex, uint32 InOffset, TYPE_OF_NULLPTR)
Definition VertexFactory.h:75
FRHIStreamSourceSlot * StreamSourceSlot
Definition VertexFactory.h:60
FRHIBuffer * VertexBuffer
Definition VertexFactory.h:57
bool operator!=(const FVertexInputStream &rhs) const
Definition VertexFactory.h:108
void * Pointer
Definition VertexFactory.h:63
Definition VertexStreamComponent.h:22
static int32 Strlen(const CharType *String)
Definition CString.h:1047
static UE_FORCEINLINE_HINT int32 Strncmp(const CharType *String1, const CharType *String2, SIZE_T Count)
Definition CString.h:1024
Definition NumericLimits.h:41
Definition VertexFactory.h:199
static const FTypeLayoutDesc * GetLayout()
Definition VertexFactory.h:200
static void GetElementShaderBindings(const FVertexFactoryShaderParameters *Parameters, const class FSceneInterface *Scene, const class FSceneView *View, const class FMeshMaterialShader *Shader, const EVertexInputStreamType InputStreamType, ERHIFeatureLevel::Type FeatureLevel, const class FVertexFactory *VertexFactory, const struct FMeshBatchElement &BatchElement, class FMeshDrawSingleShaderBindings &ShaderBindings, FVertexInputStreamArray &VertexStreams)
Definition VertexFactory.h:203
static FVertexFactoryShaderParameters * Create(const class FShaderParameterMap &ParameterMap)
Definition VertexFactory.h:201