UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshPassProcessor.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 MeshPassProcessor.h
5=============================================================================*/
6
7#pragma once
8
11#include "MeshMaterialShader.h"
12#include "RendererInterface.h"
13#include "GBufferInfo.h"
14#include "SceneUtils.h"
15#include "MeshBatch.h"
17#include "PSOPrecacheMaterial.h"
18#include "Hash/CityHash.h"
21#include <atomic>
22
23#define MESH_DRAW_COMMAND_DEBUG_DATA ((!UE_BUILD_SHIPPING && !UE_BUILD_TEST) || VALIDATE_MESH_COMMAND_BINDINGS || WANTS_DRAW_MESH_EVENTS || WITH_DEBUG_VIEW_MODES)
24
25class FGPUScene;
27
29
33
90static_assert(EMeshPass::Num <= (1 << EMeshPass::NumBits), "EMeshPass::Num will not fit in EMeshPass::NumBits");
91static_assert(EMeshPass::NumBits <= sizeof(EMeshPass::Type) * 8, "EMeshPass::Type storage is too small");
92
94{
95 switch (MeshPass)
96 {
97 case EMeshPass::DepthPass: return TEXT("DepthPass");
98 case EMeshPass::SecondStageDepthPass: return TEXT("SecondStageDepthPass");
99 case EMeshPass::BasePass: return TEXT("BasePass");
100 case EMeshPass::AnisotropyPass: return TEXT("AnisotropyPass");
101 case EMeshPass::SkyPass: return TEXT("SkyPass");
102 case EMeshPass::SingleLayerWaterPass: return TEXT("SingleLayerWaterPass");
103 case EMeshPass::SingleLayerWaterDepthPrepass: return TEXT("SingleLayerWaterDepthPrepass");
104 case EMeshPass::CSMShadowDepth: return TEXT("CSMShadowDepth");
105 case EMeshPass::VSMShadowDepth: return TEXT("VSMShadowDepth");
106 case EMeshPass::OnePassPointLightShadowDepth: return TEXT("OnePassPointLightShadowDepth");
107 case EMeshPass::Distortion: return TEXT("Distortion");
108 case EMeshPass::Velocity: return TEXT("Velocity");
109 case EMeshPass::TranslucentVelocity: return TEXT("TranslucentVelocity");
110 case EMeshPass::TranslucentVelocityClippedDepth: return TEXT("TranslucentVelocityClippedDepth");
111 case EMeshPass::TranslucencyStandard: return TEXT("TranslucencyStandard");
112 case EMeshPass::TranslucencyStandardModulate: return TEXT("TranslucencyStandardModulate");
113 case EMeshPass::TranslucencyAfterDOF: return TEXT("TranslucencyAfterDOF");
114 case EMeshPass::TranslucencyAfterDOFModulate: return TEXT("TranslucencyAfterDOFModulate");
115 case EMeshPass::TranslucencyAfterMotionBlur: return TEXT("TranslucencyAfterMotionBlur");
116 case EMeshPass::TranslucencyHoldout: return TEXT("TranslucencyHoldout");
117 case EMeshPass::TranslucencyAll: return TEXT("TranslucencyAll");
118 case EMeshPass::LightmapDensity: return TEXT("LightmapDensity");
119 case EMeshPass::DebugViewMode: return TEXT("DebugViewMode");
120 case EMeshPass::CustomDepth: return TEXT("CustomDepth");
121 case EMeshPass::MobileBasePassCSM: return TEXT("MobileBasePassCSM");
122 case EMeshPass::VirtualTexture: return TEXT("VirtualTexture");
123 case EMeshPass::LumenCardCapture: return TEXT("LumenCardCapture");
124 case EMeshPass::LumenCardNanite: return TEXT("LumenCardNanite");
125 case EMeshPass::LumenTranslucencyRadianceCacheMark: return TEXT("LumenTranslucencyRadianceCacheMark");
126 case EMeshPass::LumenFrontLayerTranslucencyGBuffer: return TEXT("LumenFrontLayerTranslucencyGBuffer");
127 case EMeshPass::DitheredLODFadingOutMaskPass: return TEXT("DitheredLODFadingOutMaskPass");
128 case EMeshPass::NaniteMeshPass: return TEXT("NaniteMeshPass");
129 case EMeshPass::MeshDecal_DBuffer: return TEXT("MeshDecal_DBuffer");
130 case EMeshPass::MeshDecal_SceneColorAndGBuffer: return TEXT("MeshDecal_SceneColorAndGBuffer");
131 case EMeshPass::MeshDecal_SceneColorAndGBufferNoNormal: return TEXT("MeshDecal_SceneColorAndGBufferNoNormal");
132 case EMeshPass::MeshDecal_SceneColor: return TEXT("MeshDecal_SceneColor");
133 case EMeshPass::MeshDecal_AmbientOcclusion: return TEXT("MeshDecal_AmbientOcclusion");
134 case EMeshPass::WaterInfoTextureDepthPass: return TEXT("WaterInfoTextureDepthPass");
135 case EMeshPass::WaterInfoTexturePass: return TEXT("WaterInfoTexturePass");
136#if WITH_EDITOR
137 case EMeshPass::HitProxy: return TEXT("HitProxy");
138 case EMeshPass::HitProxyOpaqueOnly: return TEXT("HitProxyOpaqueOnly");
139 case EMeshPass::EditorLevelInstance: return TEXT("EditorLevelInstance");
140 case EMeshPass::EditorSelection: return TEXT("EditorSelection");
141#endif
142 }
143
144#if WITH_EDITOR
145 static_assert(EMeshPass::Num == 39 + 4, "Need to update switch(MeshPass) after changing EMeshPass"); // GUID to prevent incorrect auto-resolves, please change when changing the expression: {674D7D62-CFD8-4971-9A8D-CD91E5612CD8}
146#else
147 static_assert(EMeshPass::Num == 39, "Need to update switch(MeshPass) after changing EMeshPass"); // GUID to prevent incorrect auto-resolves, please change when changing the expression: {674D7D62-CFD8-4971-9A8D-CD91E5612CD8}
148#endif
149
150 checkf(0, TEXT("Missing case for EMeshPass %u"), (uint32)MeshPass);
151 return nullptr;
152}
153
156{
157public:
159 : Data(0)
160 {
161 }
162
164 {
165 Data |= (uint64(1) << Pass);
166 }
167
169 {
170 return !!(Data & (uint64(1) << Pass));
171 }
172
174 {
175 uint64 Mask = 0xFFffFFffFFffFFffULL << Pass;
176 return EMeshPass::Type(FMath::Min<uint64>(EMeshPass::Num, FMath::CountTrailingZeros64(Data & Mask)));
177 }
178
179 int GetNum()
180 {
181 return FMath::CountBits(Data);
182 }
183
185 {
186 Mask.Data |= Data;
187 }
188
189 void Reset()
190 {
191 Data = 0;
192 }
193
194 bool IsEmpty() const
195 {
196 return Data == 0;
197 }
198
200};
201
203{
205
207 {
208 bool bLocalAllShaderAreLoaded = true;
210
211 auto GetShaderResource = [&bLocalAllShaderAreLoaded](FRHIShader* Shader) -> FRHIShader* {
212 if (Shader == nullptr)
213 {
215 }
216 return Shader;
217 };
218
220 {
222#if PLATFORM_SUPPORTS_GEOMETRY_SHADERS
224#endif
225#if PLATFORM_SUPPORTS_MESH_SHADERS
227#endif
229
231 }
232
233#if PLATFORM_SUPPORTS_MESH_SHADERS
235 {
237 }
238 else
239#endif
240 {
246#endif
247 );
248 }
249 }
250
252
253 bool IsShaderAllLoaded() const { return bAllShaderAreLoaded; }
254
255 void ForceShaderReload() const
256 {
258 {
260#if PLATFORM_SUPPORTS_GEOMETRY_SHADERS
262#endif
263#if PLATFORM_SUPPORTS_MESH_SHADERS
265#endif
267
268 bAllShaderAreLoaded = true;
269 }
270 }
271
272 void LazilyInitShaders() const
273 {
274 AsBoundShaderState(); // querying shaders will initialize on demand
275 }
276
278 {
280 {
281 return true;
282 }
284 {
285 return true;
286 }
287#if PLATFORM_SUPPORTS_GEOMETRY_SHADERS
289 {
290 return true;
291 }
292#endif
293#if PLATFORM_SUPPORTS_MESH_SHADERS
295 {
296 return true;
297 }
298#endif
299 return false;
300 }
301
305 mutable bool bAllShaderAreLoaded = true;
306#if PLATFORM_SUPPORTS_GEOMETRY_SHADERS
307 mutable FRHIGeometryShader* CachedGeometryShader = nullptr;
308#endif
309#if PLATFORM_SUPPORTS_MESH_SHADERS
310 mutable FRHIMeshShader* CachedMeshShader = nullptr;
311#endif
314#if PLATFORM_SUPPORTS_GEOMETRY_SHADERS
316#endif
317#if PLATFORM_SUPPORTS_MESH_SHADERS
319#endif
322#if PLATFORM_SUPPORTS_GEOMETRY_SHADERS
324#endif
325#if PLATFORM_SUPPORTS_MESH_SHADERS
327#endif
328};
329
330
337{
338public:
339 // Can't use TEnumByte<EPixelFormat> as it changes the struct to be non trivially constructible, breaking memset
342
349
366
381
382 RENDERER_API void SetupBoundShaderState(FRHIVertexDeclaration* VertexDeclaration, const FMeshProcessorShaders& Shaders);
383
385
425
427 {
428 if (BoundShaderState.VertexDeclarationRHI != rhs.BoundShaderState.VertexDeclarationRHI ||
429 BoundShaderState.VertexShaderResource != rhs.BoundShaderState.VertexShaderResource ||
430 BoundShaderState.PixelShaderResource != rhs.BoundShaderState.PixelShaderResource ||
431 BoundShaderState.VertexShaderIndex != rhs.BoundShaderState.VertexShaderIndex ||
432 BoundShaderState.PixelShaderIndex != rhs.BoundShaderState.PixelShaderIndex ||
434 BoundShaderState.GeometryShaderResource != rhs.BoundShaderState.GeometryShaderResource ||
435 BoundShaderState.GeometryShaderIndex != rhs.BoundShaderState.GeometryShaderIndex ||
436#endif
437 BlendState != rhs.BlendState ||
438 RasterizerState != rhs.RasterizerState ||
439 DepthStencilState != rhs.DepthStencilState ||
440 ImmutableSamplerState != rhs.ImmutableSamplerState ||
441 bDepthBounds != rhs.bDepthBounds ||
442 bAllowVariableRateShading != rhs.bAllowVariableRateShading ||
443 DrawShadingRate != rhs.DrawShadingRate ||
444 PrimitiveType != rhs.PrimitiveType)
445 {
446 return false;
447 }
448
449 return true;
450 }
451
453 {
454 return !(*this == rhs);
455 }
456
458 {
459 //add and initialize any leftover padding within the struct to avoid unstable key
460 struct FHashKey
461 {
462 uint32 VertexDeclaration;
465 uint32 RasterizerState;
466 } HashKey;
467 HashKey.VertexDeclaration = PointerHash(Initializer.BoundShaderState.VertexDeclarationRHI);
468 HashKey.VertexShader = GetTypeHash(Initializer.BoundShaderState.VertexShaderIndex);
469 HashKey.PixelShader = GetTypeHash(Initializer.BoundShaderState.PixelShaderIndex);
470 HashKey.RasterizerState = PointerHash(Initializer.RasterizerState);
471
472 return uint32(CityHash64((const char*)&HashKey, sizeof(FHashKey)));
473 }
474
475#define COMPARE_FIELD_BEGIN(Field) \
476 if (Field != rhs.Field) \
477 { return Field COMPARE_OP rhs.Field; }
478
479#define COMPARE_FIELD(Field) \
480 else if (Field != rhs.Field) \
481 { return Field COMPARE_OP rhs.Field; }
482
483#define COMPARE_FIELD_END \
484 else { return false; }
485
510
535
536#undef COMPARE_FIELD_BEGIN
537#undef COMPARE_FIELD
538#undef COMPARE_FIELD_END
539
540 // TODO: [PSO API] - As we migrate reuse existing API objects, but eventually we can move to the direct initializers.
541 // When we do that work, move this to RHI.h as its more appropriate there, but here for now since dependent typdefs are here.
547
548 // Note: FGraphicsMinimalPipelineStateInitializer is 8-byte aligned and can't have any implicit padding,
549 // as it is sometimes hashed and compared as raw bytes. Explicit padding is therefore required between
550 // all data members and at the end of the structure.
551 bool bDepthBounds = false;
554
556
557 // Data hash of the minimal PSO which is used to optimize the computation of the full PSO
559 // The PSO precache state - updated at draw time and can be used to skip draw when still precaching
561};
562
563static_assert(sizeof(FMeshPassMask::Data) * 8 >= EMeshPass::Num, "FMeshPassMask::Data is too small to fit all mesh passes.");
564
567
570{
571public:
573 {
575 return PackedId;
576 }
577
578 inline bool IsValid() const
579 {
580 return bValid != 0;
581 }
582
583
585 {
586 return PackedId == rhs.PackedId;
587 }
588
590 {
591 return !(*this == rhs);
592 }
593
595 {
597 {
598 return InPipelineSet.GetByElementId(SetElementIndex);
599 }
600
601 {
602 FRWScopeLock ReadLock(PersistentIdTableLock, SLT_ReadOnly);
603 const auto& Result = PersistentIdTable.GetByElementId(SetElementIndex);
604#if MESH_DRAW_COMMAND_DEBUG_DATA
605 checkf(Result.Value.RefNum && Result.Value.DebugSalt == DebugSalt, TEXT("Pipeline state ID used after release. Call 'AddRefPersistentId' to ensure pipeline state doesn't get released while in use."));
606#endif
607 return Result.Key;
608 }
609 }
610
611 static void InitializePersistentIds();
616
621
626
628 {
629#if MESH_DRAW_COMMAND_DEBUG_DATA
630 return LocalPipelineIdTableSize;
631#else
632 return 0;
633#endif //MESH_DRAW_COMMAND_DEBUG_DATA
634 }
635 static void ResetLocalPipelineIdTableSize();
637
639 {
640 FRWScopeLock ReadLock(PersistentIdTableLock, SLT_ReadOnly);
641 return PersistentIdTable.GetAllocatedSize();
642 }
644 {
645 FRWScopeLock ReadLock(PersistentIdTableLock, SLT_ReadOnly);
646 return PersistentIdTable.Num();
647 }
648
655 static void FreezeIdTable(bool bEnable);
656
657private:
658 union
659 {
661
662 struct
663 {
667 };
668 };
669
670 struct FRefCountedGraphicsMinimalPipelineState
671 {
672 FRefCountedGraphicsMinimalPipelineState() : RefNum(0)
673 {
674#if MESH_DRAW_COMMAND_DEBUG_DATA
675 DebugSalt = DebugSaltAllocationIndex++;
676#endif
677 }
678
679 FRefCountedGraphicsMinimalPipelineState(const FRefCountedGraphicsMinimalPipelineState&& Other) :
680 RefNum(Other.RefNum.load())
681 {
682#if MESH_DRAW_COMMAND_DEBUG_DATA
683 DebugSalt = Other.DebugSalt;
684#endif
685 }
686
687 std::atomic<uint32> RefNum;
688#if MESH_DRAW_COMMAND_DEBUG_DATA
689 int32 DebugSalt;
690#endif
691 };
692
693 static FRWLock PersistentIdTableLock;
695 static PersistentTableType PersistentIdTable;
696 static bool NeedsShaderInitialisation;
697
698 static bool bIsIdTableFrozen;
699 static std::atomic<int32> ReffedItemCount; // Number of items with a non-zero reference count
700
701#if MESH_DRAW_COMMAND_DEBUG_DATA
702 int32 DebugSalt;
703 static std::atomic<int32> DebugSaltAllocationIndex;
704 static std::atomic<int32> LocalPipelineIdTableSize;
705 static std::atomic<int32> CurrentLocalPipelineIdTableSize;
706#endif //MESH_DRAW_COMMAND_DEBUG_DATA
707};
708
717
719{
725#if RHI_RAYTRACING
727#endif
728
730 {
731 if (Frequency == SF_Vertex)
732 {
733 return VertexShader;
734 }
735 if (Frequency == SF_Pixel)
736 {
737 return PixelShader;
738 }
739 if (Frequency == SF_Geometry)
740 {
741 return GeometryShader;
742 }
743 if (Frequency == SF_Compute)
744 {
745 return ComputeShader;
746 }
748 {
749 return WorkGraphShader;
750 }
751#if RHI_RAYTRACING
753 {
754 if (RayTracingShader.IsValid() && Frequency != RayTracingShader->GetFrequency())
755 {
756 checkf(0, TEXT("Requested raytracing shader frequency (%d) doesn't match assigned shader frequency (%d)."), Frequency, RayTracingShader->GetFrequency());
757 return TShaderRef<FShader>();
758 }
759 return RayTracingShader;
760 }
761#endif // RHI_RAYTRACING
762
763 checkf(0, TEXT("Unhandled shader frequency"));
764 return TShaderRef<FShader>();
765 }
766
768 {
770 if (VertexShader.IsValid())
771 {
772 Shaders.Add(VertexShader);
773 }
774 if (PixelShader.IsValid())
775 {
776 Shaders.Add(PixelShader);
777 }
778 if (GeometryShader.IsValid())
779 {
780 Shaders.Add(GeometryShader);
781 }
782 if (ComputeShader.IsValid())
783 {
784 Shaders.Add(ComputeShader);
785 }
786#if RHI_RAYTRACING
787 if (RayTracingShader.IsValid())
788 {
789 Shaders.Add(RayTracingShader);
790 }
791#endif
792 return Shaders;
793 }
794};
795
802
807{
808#if MESH_DRAW_COMMAND_DEBUG_DATA
809 // sorted from larger to smaller to minimize padding
812 // Warning: the following members may not be valid if state buckets are being used (ie if GPUScene is enabled); they can point to invalid or even deleted resources
813 // This is because multiple proxies can share the same MDC. In the case of MaterialRenderProxies, it's rare for them to differ, but it can happen
816
817 // This could in theory be inaccurate when bucketing is active, but it should be correct the vast majority of the time (even if the Proxy ptr changes), so it's good enough for draw events
819
821#if PSO_PRECACHING_VALIDATE
822 // so far these are only used for PSO precaching validation
823 const FVertexFactory* VertexFactory;
824 const FVertexFactoryType* VertexFactoryType;
825#endif
827#if PSO_PRECACHING_VALIDATE
828 uint32 PSOCollectorIndex;
829#endif
832#endif
833};
834
837{
838#if MESH_DRAW_COMMAND_STATS
840 FName CategoryName;
842 uint32 NumVertices;
843#endif
844};
845
847{
848public:
849
854
856 {
857 // Must init to impossible values to avoid filtering the first draw's state
858 PipelineId = -1;
859 StencilRef = -1;
860 }
861
863 {
865 StencilRef = -1;
866
867 // Vertex streams must be reset if PSO changes.
869 {
871 }
872
873 // Shader bindings must be reset if PSO changes
875 {
877
878 for (int32 SlotIndex = 0; SlotIndex <= ShaderBinding.MaxUniformBufferUsed; SlotIndex++)
879 {
880 ShaderBinding.UniformBuffers[SlotIndex] = nullptr;
881 }
882
883 ShaderBinding.MaxUniformBufferUsed = -1;
884 }
885 }
886
888 {
890 {
892 for (int32 SlotIndex = 0; SlotIndex <= ShaderBinding.MaxUniformBufferUsed; SlotIndex++)
893 {
894 if (ShaderBinding.UniformBuffers[SlotIndex] == UniformBuffer)
895 {
896 ShaderBinding.UniformBuffers[SlotIndex] = nullptr;
897 }
898 }
899 }
900 }
901};
902
903
908{
909public:
911 {
912 static_assert(sizeof(ShaderFrequencyBits) * 8 > SF_NumFrequencies, "Please increase ShaderFrequencyBits size");
913 }
914
916 {
917 if (!UsesInlineStorage())
918 {
919 delete[] Data.GetHeapData();
920 }
921 Size = Other.Size;
922 ShaderFrequencyBits = Other.ShaderFrequencyBits;
923 ShaderLayouts = MoveTemp(Other.ShaderLayouts);
924 if (Other.UsesInlineStorage())
925 {
926 Data = MoveTemp(Other.Data);
927 }
928 else
929 {
930 Data.SetHeapData(Other.Data.GetHeapData());
931 Other.Data.SetHeapData(nullptr);
932 }
933 Other.Size = 0;
934 }
935
937 {
938 CopyFrom(Other);
939 }
940
942
944 {
945 CopyFrom(Other);
946 return *this;
947 }
948
950 {
951 if (!UsesInlineStorage())
952 {
953 delete[] Data.GetHeapData();
954 }
955 Size = Other.Size;
956 ShaderFrequencyBits = Other.ShaderFrequencyBits;
957 ShaderLayouts = MoveTemp(Other.ShaderLayouts);
958 if (Other.UsesInlineStorage())
959 {
960 Data = MoveTemp(Other.Data);
961 }
962 else
963 {
964 Data.SetHeapData(Other.Data.GetHeapData());
965 Other.Data.SetHeapData(nullptr);
966 }
967 Other.Size = 0;
968 return *this;
969 }
970
972 RENDERER_API void Initialize(const FMeshProcessorShaders& Shaders);
974
977
979 {
980 int FrequencyIndex = FPlatformMath::CountBits(ShaderFrequencyBits & ((1 << (Frequency + 1)) - 1)) - 1;
981
982#if DO_CHECK && !(UE_BUILD_TEST || UE_BUILD_SHIPPING)
984 for (int32 BindingIndex = 0; BindingIndex < FrequencyIndex; BindingIndex++)
985 {
986 CheckedDataOffset += ShaderLayouts[BindingIndex].GetDataSizeBytes();
987 }
988 checkf(CheckedDataOffset == DataOffset, TEXT("GetSingleShaderBindings was not called in the order of ShaderFrequencies"));
989#endif
990 if (FrequencyIndex >= 0)
991 {
992 int32 StartDataOffset = DataOffset;
993 DataOffset += ShaderLayouts[FrequencyIndex].GetDataSizeBytes();
994 return FMeshDrawSingleShaderBindings(ShaderLayouts[FrequencyIndex], GetData() + StartDataOffset);
995 }
996
997 checkf(0, TEXT("Invalid shader binding frequency requested"));
999 }
1000
1006
1009
1012
1013#if RHI_RAYTRACING
1014 RENDERER_API FRayTracingLocalShaderBindings* SetRayTracingShaderBindings(FRayTracingLocalShaderBindingWriter* BindingWriter, uint32 ShaderIndexInPipeline, uint32 RecordIndex, uint32 UserData, ERayTracingLocalShaderBindingType BindingType) const;
1016
1017 // TODO: should these move to a binding writer too? should we introduce a different class to do these bindings since they aren't mesh related? rename this class entirely?
1019#endif // RHI_RAYTRACING
1020
1023
1025
1027 {
1028 SIZE_T Bytes = ShaderLayouts.GetAllocatedSize();
1029 if (!UsesInlineStorage())
1030 {
1031 Bytes += Size;
1032 }
1033
1034 return Bytes;
1035 }
1036
1038 {
1039 OutShaderFrequencies.Empty(ShaderLayouts.Num());
1040
1041 for (int32 BindingIndex = 0; BindingIndex < SF_NumFrequencies; BindingIndex++)
1042 {
1043 if ((ShaderFrequencyBits & (1 << BindingIndex)) != 0)
1044 {
1045 OutShaderFrequencies.Add(EShaderFrequency(BindingIndex));
1046 }
1047 }
1048 }
1049
1050 inline int32 GetDataSize() const { return Size; }
1051
1052private:
1054 struct FData
1055 {
1056 uint8* InlineStorage[NumInlineShaderBindings] = {};
1057 uint8* GetHeapData()
1058 {
1059 return InlineStorage[0];
1060 }
1061 const uint8* GetHeapData() const
1062 {
1063 return InlineStorage[0];
1064 }
1065 void SetHeapData(uint8* HeapData)
1066 {
1067 InlineStorage[0] = HeapData;
1068 }
1069 } Data = {};
1070 uint16 ShaderFrequencyBits = 0;
1071 uint16 Size = 0;
1072
1073 void Allocate(uint16 InSize)
1074 {
1075 check(Size == 0 && Data.GetHeapData() == nullptr);
1076
1077 Size = InSize;
1078
1079 if (InSize > sizeof(FData))
1080 {
1081 Data.SetHeapData(new uint8[InSize]);
1082 }
1083 }
1084
1085 void AllocateZeroed(uint16 InSize)
1086 {
1087 Allocate(InSize);
1088
1089 // Verify no type overflow
1090 check(Size == InSize);
1091
1092 if (!UsesInlineStorage())
1093 {
1094 FPlatformMemory::Memzero(GetData(), InSize);
1095 }
1096 }
1097
1098 inline bool UsesInlineStorage() const
1099 {
1100 return Size <= sizeof(FData);
1101 }
1102
1103 uint8* GetData()
1104 {
1105 return UsesInlineStorage() ? reinterpret_cast<uint8*>(&Data.InlineStorage[0]) : Data.GetHeapData();
1106 }
1107
1108 const uint8* GetData() const
1109 {
1110 return UsesInlineStorage() ? reinterpret_cast<const uint8*>(&Data.InlineStorage[0]) : Data.GetHeapData();
1111 }
1112
1113 RENDERER_API void CopyFrom(const FMeshDrawShaderBindings& Other);
1114
1115 RENDERER_API void Release();
1116};
1117
1119{
1120public:
1125
1129
1132 {
1133 Data = Bindings.Data;
1134 }
1135
1141
1143 {
1144 return (FRHIUniformBuffer**)(Data + GetUniformBufferOffset());
1145 }
1146
1148 {
1149 const uint8* SamplerDataStart = Data + GetSamplerOffset();
1151 }
1152
1153 inline FRHIResource** GetSRVStart() const
1154 {
1155 const uint8* SRVDataStart = Data + GetSRVOffset();
1156 return (FRHIResource**)SRVDataStart;
1157 }
1158
1159 inline const uint8* GetSRVTypeStart() const
1160 {
1161 const uint8* SRVTypeDataStart = Data + GetSRVTypeOffset();
1162 return SRVTypeDataStart;
1163 }
1164
1165 inline const uint8* GetLooseDataStart() const
1166 {
1167 const uint8* LooseDataStart = Data + GetLooseDataOffset();
1168 return LooseDataStart;
1169 }
1170
1171private:
1172 const uint8* Data;
1173};
1174
1193
1212
1223{
1224public:
1225
1232
1237
1244
1245 union
1246 {
1247 struct
1248 {
1252
1253 struct
1254 {
1258 };
1259
1261
1264
1267
1273
1275 {
1276 return CachedPipelineId == Rhs.CachedPipelineId
1277 && StencilRef == Rhs.StencilRef
1278 && ShaderBindings.MatchesForDynamicInstancing(Rhs.ShaderBindings)
1279 && VertexStreams == Rhs.VertexStreams
1280 && PrimitiveIdStreamIndex == Rhs.PrimitiveIdStreamIndex
1281 && IndexBuffer == Rhs.IndexBuffer
1282 && FirstIndex == Rhs.FirstIndex
1283 && NumPrimitives == Rhs.NumPrimitives
1284 && NumInstances == Rhs.NumInstances
1285 && ((NumPrimitives > 0 && VertexParams.BaseVertexIndex == Rhs.VertexParams.BaseVertexIndex && VertexParams.NumVertices == Rhs.VertexParams.NumVertices)
1286 || (NumPrimitives == 0 && IndirectArgs.Buffer == Rhs.IndirectArgs.Buffer && IndirectArgs.Offset == Rhs.IndirectArgs.Offset));
1287 }
1288
1290 {
1291 //add and initialize any leftover padding within the struct to avoid unstable keys
1292 struct FHashKey
1293 {
1295 uint32 VertexBuffers = 0;
1296 uint32 VertexStreams = 0;
1297 uint32 PipelineId;
1299 uint32 FirstIndex;
1300 uint32 NumPrimitives;
1301 uint32 NumInstances;
1303 uint32 NumVertices;
1305
1306 static inline uint32 PointerHash(const void* Key)
1307 {
1308#if PLATFORM_64BITS
1309 // Ignoring the lower 4 bits since they are likely zero anyway.
1310 // Higher bits are more significant in 64 bit builds.
1311 return static_cast<uint32>(reinterpret_cast<UPTRINT>(Key) >> 4);
1312#else
1313 return reinterpret_cast<UPTRINT>(Key);
1314#endif
1315 };
1316
1317 static inline uint32 HashCombine(uint32 A, uint32 B)
1318 {
1319 return A ^ (B + 0x9e3779b9 + (A << 6) + (A >> 2));
1320 }
1321 } HashKey;
1322
1323 HashKey.PipelineId = CachedPipelineId.GetId();
1324 HashKey.StencilRefAndPrimitiveIdStreamIndex = StencilRef | (PrimitiveIdStreamIndex << 8);
1325 HashKey.DynamicInstancingHash = ShaderBindings.GetDynamicInstancingHash();
1326
1327 for (int index = 0; index < VertexStreams.Num(); index++)
1328 {
1330 const uint32 StreamIndex = VertexInputStream.StreamIndex;
1331 const uint32 Offset = VertexInputStream.Offset;
1332
1333 uint32 Packed = (StreamIndex << 28) | Offset;
1334 HashKey.VertexStreams = FHashKey::HashCombine(HashKey.VertexStreams, Packed);
1335 HashKey.VertexBuffers = FHashKey::HashCombine(HashKey.VertexBuffers, FHashKey::PointerHash(VertexInputStream.Pointer));
1336 }
1337
1338 HashKey.IndexBuffer = FHashKey::PointerHash(IndexBuffer);
1339 HashKey.FirstIndex = FirstIndex;
1340 HashKey.NumPrimitives = NumPrimitives;
1341 HashKey.NumInstances = NumInstances;
1342
1343 if (NumPrimitives > 0)
1344 {
1345 HashKey.IndirectArgsBufferOrBaseVertexIndex = VertexParams.BaseVertexIndex;
1346 HashKey.NumVertices = VertexParams.NumVertices;
1347 }
1348 else
1349 {
1350 HashKey.IndirectArgsBufferOrBaseVertexIndex = FHashKey::PointerHash(IndirectArgs.Buffer);
1351 HashKey.NumVertices = IndirectArgs.Offset;
1352 }
1353
1354 return uint32(CityHash64((char*)&HashKey, sizeof(FHashKey)));
1355 }
1356
1359 {
1360 ShaderBindings.Initialize(Shaders);
1361 }
1362
1364 {
1365 StencilRef = static_cast<uint8>(InStencilRef);
1366 // Verify no overflow
1368 }
1369
1372 const FMeshBatch& MeshBatch,
1376
1382
1387 static bool SubmitDrawBegin(
1388 const FMeshDrawCommand& RESTRICT MeshDrawCommand,
1389 const FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
1391 uint32 InstanceFactor,
1392 FRHICommandList& RHICmdList,
1395
1397 static void SubmitDrawEnd(const FMeshDrawCommand& MeshDrawCommand, const FMeshDrawCommandSceneArgs& SceneArgs, uint32 InstanceFactor, FRHICommandList& RHICmdList);
1398
1403 static bool SubmitDrawIndirectBegin(
1404 const FMeshDrawCommand& RESTRICT MeshDrawCommand,
1405 const FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
1407 uint32 InstanceFactor,
1408 FRHICommandList& RHICmdList,
1411
1413 static void SubmitDrawIndirectEnd(const FMeshDrawCommand& MeshDrawCommand, const FMeshDrawCommandSceneArgs& SceneArgs, uint32 InstanceFactor, FRHICommandList& RHICmdList);
1414
1416 static bool SubmitDraw(
1417 const FMeshDrawCommand& RESTRICT MeshDrawCommand,
1418 const FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
1420 uint32 InstanceFactor,
1421 FRHICommandList& CommandList,
1422 class FMeshDrawCommandStateCache& RESTRICT StateCache);
1423
1426
1429
1431 {
1432 return Other.CachedPipelineId.GetId();
1433 }
1434#if MESH_DRAW_COMMAND_DEBUG_DATA
1435 RENDERER_API void SetDebugData(const FPrimitiveSceneProxy* PrimitiveSceneProxy, const FMaterial* Material, const FMaterialRenderProxy* MaterialRenderProxy, const FMeshProcessorShaders& UntypedShaders, const FVertexFactory* VertexFactory, const FMeshBatch& MeshBatch, int32 PSOCollectorIndex);
1436#else
1437 void SetDebugData(const FPrimitiveSceneProxy* PrimitiveSceneProxy, const FMaterial* Material, const FMaterialRenderProxy* MaterialRenderProxy, const FMeshProcessorShaders& UntypedShaders, const FVertexFactory* VertexFactory, const FMeshBatch& MeshBatch, int32 PSOCollectorIndex) {}
1438#endif
1439
1444
1446 {
1447#if MESH_DRAW_COMMAND_DEBUG_DATA
1448 return sizeof(DebugData);
1449#else
1450 return 0;
1451#endif
1452 }
1453
1454#if MESH_DRAW_COMMAND_DEBUG_DATA
1456 {
1458 }
1459
1461 {
1462 return DebugData;
1463 }
1464private:
1465 mutable FMeshDrawCommandDebugData DebugData;
1466#endif
1467
1468#if MESH_DRAW_COMMAND_STATS
1469private:
1471public:
1472 RENDERER_API void SetStatsData(const FPrimitiveSceneProxy* PrimitiveSceneProxy);
1474#else
1475public:
1476 void SetStatsData(const FPrimitiveSceneProxy* PrimitiveSceneProxy) {}
1477#endif
1478};
1479
1482{
1483public:
1484 union
1485 {
1487
1488 struct
1489 {
1490 uint64 VertexShaderHash : 16; // Order by vertex shader's hash.
1491 uint64 PixelShaderHash : 32; // Order by pixel shader's hash.
1493 uint64 Masked : 15; // First order by masked.
1495
1496 struct
1497 {
1498 uint64 MeshIdInPrimitive : 16; // Order meshes belonging to the same primitive by a stable id.
1499 uint64 Distance : 32; // Order by distance.
1500 uint64 Priority : 16; // First order by priority.
1502
1503 struct
1504 {
1505 uint64 VertexShaderHash : 32; // Order by vertex shader's hash.
1506 uint64 PixelShaderHash : 32; // First order by pixel shader's hash.
1508 };
1509
1511 {
1512 return PackedData != B.PackedData;
1513 }
1514
1516 {
1517 return PackedData < B.PackedData;
1518 }
1519
1521};
1522
1523
1553static_assert(uint32(EFVisibleMeshDrawCommandFlags::All) < (1U << uint32(EFVisibleMeshDrawCommandFlags::NumBits)), "EFVisibleMeshDrawCommandFlags::NumBits too small to represent all flags in EFVisibleMeshDrawCommandFlags.");
1554
1559{
1560 bool IsValid() const { return Index != INDEX_NONE; }
1562
1564 {
1565 return Index == B.Index;
1566 }
1567};
1568
1573{
1575
1576 // Use this ctor for scene primitves
1584
1585 UE_DEPRECATED(5.4, "Use the above Ctor instead.")
1586 // Use this ctor when for dynamic primitives like editor widgets
1594
1595 // Draw PrimitiveId this draw command is associated with - used by the shader to fetch primitive data from the PrimitiveSceneData SRV.
1596 // If it's < Scene->Primitives.Num() then it's a valid Scene PrimitiveIndex and can be used to backtrack to the FPrimitiveSceneInfo.
1598
1599 // Scene PrimitiveId that generated this draw command, or -1 if no FPrimitiveSceneInfo. Can be used to backtrack to the FPrimitiveSceneInfo.
1601
1602 // Offset to the first instance belonging to the primitive in GPU scene
1604
1605 // Set to true if the primitive ID and instance data offset is a dynamic ID, which means it needs to be translated before use.
1607};
1608
1613{
1614 union
1615 {
1617 struct
1618 {
1622 };
1623 };
1624
1626
1627 // Pack screen sizes into fixed point 3.10
1628 static uint32 PackScreenSize(float ScreenSize)
1629 {
1630 constexpr float MaxExpressibleValue = (float)(0x1FFFU) / (float)(1 << 10);
1631 ScreenSize = FMath::Clamp(ScreenSize, 0.f, MaxExpressibleValue);
1632 return (uint32)(ScreenSize * (1 << 10)) & 0x1FFF;
1633 }
1634
1636 {
1637 return (float)(PackedScreenSize & 0x1FFFU) / (float)(1 << 10);
1638 }
1639};
1640
1642{
1643 FMeshDrawCommandCullingPayload CullingPayload;
1644 CullingPayload.LodIndex = MeshBatch.LODIndex;
1647 CullingPayload.DynamicMeshBoundsIndex = MeshBatch.DynamicMeshBoundsIndex;
1648 return CullingPayload;
1649}
1650
1655{
1656 Default = 0U,
1657 MinScreenSizeCull = 1U, // Cull when below a minimum screen space size.
1658 MaxScreenSizeCull = 2U, // Cull when above a maximum screen space size.
1659
1662 NumBits = 2U
1663};
1665static_assert(uint32(EMeshDrawCommandCullingPayloadFlags::All) < (1U << uint32(EMeshDrawCommandCullingPayloadFlags::NumBits)), "EMeshDrawCommandCullingPayloadFlags::NumBits too small to represent all flags in EMeshDrawCommandCullingPayloadFlags.");
1666
1667
1670{
1671public:
1672
1674
1676
1677 virtual void FinalizeCommand(
1678 const FMeshBatch& MeshBatch,
1681 ERasterizerFillMode MeshFillMode,
1682 ERasterizerCullMode MeshCullMode,
1685 const FGraphicsMinimalPipelineStateInitializer& PipelineState,
1687 FMeshDrawCommand& MeshDrawCommand) = 0;
1688};
1689
1692{
1693public:
1694 // Using TChunkedArray to support growing without moving FMeshDrawCommand, since FVisibleMeshDrawCommand stores a pointer to these
1696};
1697
1703{
1704public:
1705
1706 // Note: no ctor as TChunkedArray::CopyToLinearArray requires POD types
1707
1734
1735 // Mesh Draw Command stored separately to avoid fetching its data during sorting
1737
1738 // Sort key for non state based sorting (e.g. sort translucent draws by depth).
1740
1742
1743 // Offset into the buffer of PrimitiveIds built for this pass, in int32's.
1745
1746 // Dynamic instancing state bucket ID.
1747 // Any commands with the same StateBucketId can be merged into one draw call with instancing.
1748 // A value of -1 means the draw is not in any state bucket and should be sorted by other factors instead.
1750
1751 // Used for passing sub-selection of instances through to the culling
1754
1755 // Used for passing LOD info to the culling
1758
1759 // Needed for view overrides
1762
1764};
1765
1767{
1769 {
1770 // First order by a sort key.
1771 if (A.SortKey != B.SortKey)
1772 {
1773 return A.SortKey < B.SortKey;
1774 }
1775
1776 // Next order by instancing bucket.
1777 if (A.StateBucketId != B.StateBucketId)
1778 {
1779 return A.StateBucketId < B.StateBucketId;
1780 }
1781
1782 return false;
1783 }
1784};
1785
1786template <>
1788{
1789 // Prevent Memcpy call overhead during FVisibleMeshDrawCommand sorting
1790 enum { Value = false };
1791};
1792
1795
1798{
1799public:
1801 (
1806 ) :
1807 DrawListStorage(InDrawListStorage),
1808 DrawList(InDrawList),
1809 GraphicsMinimalPipelineStateSet(InPipelineStateSet),
1810 NeedsShaderInitialisation(InNeedsShaderInitialisation)
1811 {}
1812
1813 virtual FMeshDrawCommand& AddCommand(FMeshDrawCommand& Initializer, uint32 NumElements) override final
1814 {
1815 const int32 Index = DrawListStorage.MeshDrawCommands.AddElement(Initializer);
1816 FMeshDrawCommand& NewCommand = DrawListStorage.MeshDrawCommands[Index];
1817 return NewCommand;
1818 }
1819
1820 virtual void FinalizeCommand(
1821 const FMeshBatch& MeshBatch,
1824 ERasterizerFillMode MeshFillMode,
1825 ERasterizerCullMode MeshCullMode,
1828 const FGraphicsMinimalPipelineStateInitializer& PipelineState,
1830 FMeshDrawCommand& MeshDrawCommand) override final
1831 {
1832 FGraphicsMinimalPipelineStateId PipelineId = FGraphicsMinimalPipelineStateId::GetPipelineStateId(PipelineState, GraphicsMinimalPipelineStateSet, NeedsShaderInitialisation);
1833
1834 MeshDrawCommand.SetDrawParametersAndFinalize(MeshBatch, BatchElementIndex, PipelineId, ShadersForDebugging);
1835
1837 //@todo MeshCommandPipeline - assign usable state ID for dynamic path draws
1838 // Currently dynamic path draws will not get dynamic instancing, but they will be roughly sorted by state
1840 NewVisibleMeshDrawCommand.Setup(&MeshDrawCommand, IdInfo, -1, MeshFillMode, MeshCullMode, Flags, SortKey,
1841 CreateCullingPayload(MeshBatch, MeshBatchElement),
1843 MeshBatchElement.bIsInstanceRuns ? MeshBatchElement.InstanceRuns : nullptr,
1844 MeshBatchElement.bIsInstanceRuns ? MeshBatchElement.NumInstances : 0
1845 );
1847 }
1848
1856
1857private:
1858 FDynamicMeshDrawCommandStorage& DrawListStorage;
1859 FMeshCommandOneFrameArray& DrawList;
1860 FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet;
1861 bool& NeedsShaderInitialisation;
1862};
1863
1864#if PLATFORM_SUPPORTS_PRAGMA_PACK
1865 #pragma pack (push,4)
1866#endif
1867
1873{
1874public:
1877
1887
1889
1890 // Stores the index into FScene::CachedDrawLists of the corresponding FMeshDrawCommand, or -1 if not stored there
1892
1893 // Stores the index into FScene::CachedMeshDrawCommandStateBuckets of the corresponding FMeshDrawCommand, or -1 if not stored there
1895
1896 // Used for passing LOD info to the culling
1898
1899 // Needed for easier debugging and faster removal of cached mesh draw commands.
1901
1902 // Needed for view overrides
1905
1907};
1908
1909#if PLATFORM_SUPPORTS_PRAGMA_PACK
1910 #pragma pack (pop)
1911#endif
1912
1925
1927{
1929 Num(0)
1930 {
1931
1932 }
1933
1935 Num(Other.Num.load())
1936 {
1937
1938 }
1939
1940 std::atomic<uint32> Num;
1941};
1942
1943struct MeshDrawCommandKeyFuncs : TDefaultMapHashableKeyFuncs<FMeshDrawCommand, FMeshDrawCommandCount, false>
1944{
1948 static inline bool Matches(KeyInitType A, KeyInitType B)
1949 {
1950 return A.MatchesForDynamicInstancing(B);
1951 }
1952
1954 static inline uint32 GetKeyHash(KeyInitType Key)
1955 {
1956 return Key.GetDynamicInstancingHash();
1957 }
1958};
1959
1962
1964{
1965public:
1967 {
1970
1976
1978 {
1979 Context.EndMeshPass();
1980 }
1981
1982 private:
1984 };
1985
1987
1989 virtual FMeshDrawCommand& AddCommand(FMeshDrawCommand& Initializer, uint32 NumElements) override final;
1990
1992 void EndMeshPass();
1993
1995 void EndMesh();
1996
1999
2000protected:
2002 const FMeshBatch& MeshBatch,
2004 ERasterizerFillMode MeshFillMode,
2005 ERasterizerCullMode MeshCullMode,
2008 const FGraphicsMinimalPipelineStateInitializer& PipelineState,
2010 FMeshDrawCommand& MeshDrawCommand);
2011
2016 bool bUseGPUScene = false;
2018};
2019
2037
2039{
2040public:
2042
2044 {
2046 {
2047 DeferredCommands.Reserve(MaxCommandsExpected);
2048 if (LIKELY(bUseGPUScene))
2049 {
2050 DeferredCommandHashes.Reserve(DeferredCommands.Max());
2051 }
2052 }
2053 }
2054
2055 virtual void FinalizeCommand(
2056 const FMeshBatch& MeshBatch,
2059 ERasterizerFillMode MeshFillMode,
2060 ERasterizerCullMode MeshCullMode,
2063 const FGraphicsMinimalPipelineStateInitializer& PipelineState,
2065 FMeshDrawCommand& MeshDrawCommand) override final;
2066
2068
2069private:
2070 TArray<FMeshDrawCommand> DeferredCommands;
2071 TArray<Experimental::FHashType> DeferredCommandHashes;
2072};
2073
2074template<typename VertexType, typename PixelType, typename GeometryType = FMeshMaterialShader, typename RayTracingType = FMeshMaterialShader, typename ComputeType = FMeshMaterialShader>
2076{
2080
2081 UE_DEPRECATED(5.4, "Compute shader mesh passes should use FMeshProcessorShaders directly instead of using TMeshProcessorShaders")
2083#if RHI_RAYTRACING
2084 UE_DEPRECATED(5.4, "RayTracing shader mesh passes should use FMeshProcessorShaders directly instead of using TMeshProcessorShaders")
2086#endif
2087
2089
2091 {
2092 FMeshProcessorShaders Shaders;
2093 Shaders.VertexShader = VertexShader;
2094 Shaders.PixelShader = PixelShader;
2097 Shaders.ComputeShader = ComputeShader;
2098#if RHI_RAYTRACING
2099 Shaders.RayTracingShader = RayTracingShader;
2100#endif
2102 return Shaders;
2103 }
2104};
2105
2107{
2108 Default = 0,
2109 PositionOnly = 1 << 0,
2110 PositionAndNormalOnly = 1 << 1,
2111};
2113
2118{
2122
2123public:
2128
2130 {
2131 return BlendState;
2132 }
2133
2135 {
2136 DepthStencilState = InDepthStencilState;
2137 StencilRef = 0;
2138 }
2139
2144
2146 {
2147 return DepthStencilState;
2148 }
2149
2154
2156 {
2157 return DepthStencilAccess;
2158 }
2159
2161 {
2162 return StencilRef;
2163 }
2164
2166 {
2167 GraphicsPSOInit.BlendState = BlendState;
2168 GraphicsPSOInit.DepthStencilState = DepthStencilState;
2169 }
2170
2171private:
2172 FRHIBlendState* BlendState = nullptr;
2173 FRHIDepthStencilState* DepthStencilState = nullptr;
2175
2176 FRHIUniformBuffer* ViewUniformBuffer = nullptr;
2177 FRHIUniformBuffer* InstancedViewUniformBuffer = nullptr;
2178
2179 FRHIUniformBuffer* PassUniformBuffer = nullptr;
2180 FRHIUniformBuffer* NaniteUniformBuffer = nullptr;
2181
2182 uint32 StencilRef = 0;
2183};
2184
2186{
2187 None = 0,
2188 TwoSided = 1 << 0,
2189 DitheredLODTransition = 1 << 1,
2190 Wireframe = 1 << 2,
2191 ReverseCullMode = 1 << 3,
2192};
2194
2199{
2200public:
2201
2207
2208 UE_DEPRECATED(5.4, "Use the below Ctor instead which provides either EMeshPass::Type or the name of the mesh pass directly.")
2211
2214
2216
2221
2222 // FMeshPassProcessor interface
2223 // Add a FMeshBatch to the pass
2225
2226 // By default no PSOs collected
2228
2230 {
2231 return CullMode == CM_None ? CM_None : (CullMode == CM_CCW ? CM_CW : CM_CCW);
2232 }
2233
2239
2242
2245
2246 template<typename PassShadersType, typename ShaderElementDataType>
2250 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy,
2251 const FMaterialRenderProxy& RESTRICT MaterialRenderProxy,
2252 const FMaterial& RESTRICT MaterialResource,
2253 const FMeshPassProcessorRenderState& RESTRICT DrawRenderState,
2255 ERasterizerFillMode MeshFillMode,
2256 ERasterizerCullMode MeshCullMode,
2260
2261 template<typename PassShadersType>
2263 const FPSOPrecacheVertexFactoryData& VertexFactoryData,
2264 const FMaterial& RESTRICT MaterialResource,
2265 const FMeshPassProcessorRenderState& RESTRICT DrawRenderState,
2268 ERasterizerFillMode MeshFillMode,
2269 ERasterizerCullMode MeshCullMode,
2270 EPrimitiveType PrimitiveType,
2272 bool bRequired,
2274
2275 template<typename PassShadersType>
2277 const FPSOPrecacheVertexFactoryData& VertexFactoryData,
2278 const FMaterial& RESTRICT MaterialResource,
2279 const FMeshPassProcessorRenderState& RESTRICT DrawRenderState,
2282 ERasterizerFillMode MeshFillMode,
2283 ERasterizerCullMode MeshCullMode,
2284 EPrimitiveType PrimitiveType,
2286 ESubpassHint SubpassHint,
2287 uint8 SubpassIndex,
2288 bool bRequired,
2291
2292protected:
2294 const FPrimitiveSceneInfo* RESTRICT PrimitiveSceneInfo,
2295 const FMeshBatchElement& BatchElement) const;
2296
2299 const FPrimitiveSceneProxy* RESTRICT PrimitiveSceneProxy
2300 ) const;
2301
2304};
2305
2306#if PSO_PRECACHING_VALIDATE
2307
2308namespace PSOCollectorStats
2309{
2314
2319
2324
2328 RENDERER_API extern void CheckShaderOnlyStateInCache(const FGraphicsMinimalPipelineStateInitializer& Initializer, const FMaterial& Material, const FVertexFactoryType* VFType, const FPrimitiveSceneProxy* PrimitiveSceneProxy, int32 PSOCollectorIndex);
2329
2333 RENDERER_API extern void CheckMinimalPipelineStateInCache(const FGraphicsMinimalPipelineStateInitializer& Initializer, const FMaterial& Material, const FVertexFactoryType* VFType, const FPrimitiveSceneProxy* PrimitiveSceneProxy, int32 PSOCollectorIndex);
2334}
2335
2336#endif // PSO_PRECACHING_VALIDATE
2337
2338typedef FMeshPassProcessor* (*DeprecatedPassProcessorCreateFunction)(const FScene* Scene, const FSceneView* InViewIfDynamicMeshCommand, FMeshPassDrawListContext* InDrawListContext);
2340
2342{
2343 None = 0,
2344 CachedMeshCommands = 1 << 0,
2345 MainView = 1 << 1
2346};
2348
2350{
2351public:
2352
2354 {
2355 check(ShadingPath < EShadingPath::Num&& PassType < EMeshPass::Num);
2356 uint32 ShadingPathIdx = (uint32)ShadingPath;
2357 checkf(JumpTable[ShadingPathIdx][PassType] || DeprecatedJumpTable[ShadingPathIdx][PassType], TEXT("Pass type %u create function was never registered for shading path %u. Use a FRegisterPassProcessorCreateFunction to register a create function for this enum value."), (uint32)PassType, ShadingPathIdx);
2358 if (JumpTable[ShadingPathIdx][PassType])
2359 {
2360 return JumpTable[ShadingPathIdx][PassType](FeatureLevel, Scene, InViewIfDynamicMeshCommand, InDrawListContext);
2361 }
2362 else
2363 {
2364 return DeprecatedJumpTable[ShadingPathIdx][PassType](Scene, InViewIfDynamicMeshCommand, InDrawListContext);
2365 }
2366 }
2367
2369 {
2370 check(ShadingPath < EShadingPath::Num && PassType < EMeshPass::Num);
2371 uint32 ShadingPathIdx = (uint32)ShadingPath;
2372 return Flags[ShadingPathIdx][PassType];
2373 }
2374
2376 {
2377 if (PassType == EMeshPass::Num)
2378 {
2379 return INDEX_NONE;
2380 }
2381
2382 check(ShadingPath < EShadingPath::Num);
2383 uint32 ShadingPathIdx = (uint32)ShadingPath;
2384 return PSOCollectorIndex[ShadingPathIdx][PassType];
2385 }
2386
2388 static void SetPassFlags(EShadingPath ShadingPath, EMeshPass::Type PassType, EMeshPassFlags NewFlags);
2389
2390private:
2394 RENDERER_API static int32 PSOCollectorIndex[(uint32)EShadingPath::Num][EMeshPass::Num];
2396};
2397
2399{
2400public:
2402 : ShadingPath(InShadingPath)
2403 , PassType(InPassType)
2404 {
2405 uint32 ShadingPathIdx = (uint32)ShadingPath;
2406 FPassProcessorManager::JumpTable[ShadingPathIdx][PassType] = CreateFunction;
2407 FPassProcessorManager::Flags[ShadingPathIdx][PassType] = PassFlags;
2408 FPassProcessorManager::PSOCollectorIndex[ShadingPathIdx][PassType] = PSOCollectorIndex;
2409 }
2410
2412 {
2413 uint32 ShadingPathIdx = (uint32)ShadingPath;
2414 FPassProcessorManager::JumpTable[ShadingPathIdx][PassType] = nullptr;
2415 FPassProcessorManager::Flags[ShadingPathIdx][PassType] = EMeshPassFlags::None;
2416 FPassProcessorManager::PSOCollectorIndex[ShadingPathIdx][PassType] = INDEX_NONE;
2417 }
2418
2419private:
2420 EShadingPath ShadingPath;
2421 EMeshPass::Type PassType;
2422};
2423
2424// Helper marco to register the mesh pass processor to both the FPassProcessorManager & the FPSOCollectorCreateManager
2425#define REGISTER_MESHPASSPROCESSOR_AND_PSOCOLLECTOR(Name, MeshPassProcessorCreateFunction, ShadingPath, MeshPass, MeshPassFlags) \
2426 IPSOCollector* CreatePSOCollector##Name(ERHIFeatureLevel::Type FeatureLevel) \
2427 { \
2428 return MeshPassProcessorCreateFunction(FeatureLevel, nullptr, nullptr, nullptr); \
2429 } \
2430 FRegisterPSOCollectorCreateFunction RegisterPSOCollector##Name(&CreatePSOCollector##Name, ShadingPath, GetMeshPassName(MeshPass)); \
2431 FRegisterPassProcessorCreateFunction RegisterMeshPassProcesser##Name(&MeshPassProcessorCreateFunction, ShadingPath, MeshPass, MeshPassFlags, RegisterPSOCollector##Name.GetIndex());
2432
2433
2435 const FMeshCommandOneFrameArray& VisibleMeshDrawCommands,
2436 const FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
2439 bool bDynamicInstancing,
2440 uint32 InstanceFactor,
2441 FRHICommandList& RHICmdList);
2442
2443extern void SubmitMeshDrawCommandsRange(
2444 const FMeshCommandOneFrameArray& VisibleMeshDrawCommands,
2445 const FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
2448 bool bDynamicInstancing,
2449 int32 StartIndex,
2450 int32 NumMeshDrawCommands,
2451 uint32 InstanceFactor,
2452 FRHICommandList& RHICmdList);
2453
2455 const FSceneView& View,
2456 FMeshCommandOneFrameArray& VisibleMeshDrawCommands,
2457 FDynamicMeshDrawCommandStorage& DynamicMeshDrawCommandStorage,
2458 FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
2459 bool& NeedsShaderInitialisation);
2460
2462 const FSceneView& View,
2463 FRHICommandList& RHICmdList,
2464 FMeshCommandOneFrameArray& VisibleMeshDrawCommands,
2465 FDynamicMeshDrawCommandStorage& DynamicMeshDrawCommandStorage,
2466 FGraphicsMinimalPipelineStateSet& GraphicsMinimalPipelineStateSet,
2468 uint32 InstanceFactor);
2469
2471
2476RENDERER_API extern ESubpassHint GetSubpassHint(const FStaticShaderPlatform Platform, bool bIsUsingGBuffers, bool bMultiViewRendering, uint32 NumSamples);
2477
#define PLATFORM_SUPPORTS_GEOMETRY_SHADERS
Definition AndroidPlatform.h:62
#define FORCENOINLINE
Definition AndroidPlatform.h:142
#define FORCEINLINE
Definition AndroidPlatform.h:140
#define checkSlow(expr)
Definition AssertionMacros.h:332
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
uint64 CityHash64(const char *s, uint32 len)
Definition CityHash.cpp:388
#define LIKELY(x)
Definition CityHash.cpp:107
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define FORCEINLINE_DEBUGGABLE
Definition CoreMiscDefines.h:74
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
@ InPlace
Definition CoreMiscDefines.h:162
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
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
FPlatformTypes::UPTRINT UPTRINT
An unsigned integer the same size as a pointer.
Definition Platform.h:1146
#define RESTRICT
Definition Platform.h:706
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint64 RHIComputeStatePrecachePSOHash(const FGraphicsPipelineStateInitializer &Initializer)
Definition DynamicRHI.h:1386
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EGBufferLayout
Definition GBufferInfo.h:107
@ GBL_Default
Definition GBufferInfo.h:108
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
RENDERER_API void SubmitMeshDrawCommands(const FMeshCommandOneFrameArray &VisibleMeshDrawCommands, const FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 PrimitiveIdBufferStride, bool bDynamicInstancing, uint32 InstanceFactor, FRHICommandList &RHICmdList)
Definition MeshPassProcessor.cpp:1604
const TCHAR * GetMeshPassName(EMeshPass::Type MeshPass)
Definition MeshPassProcessor.h:93
EFVisibleMeshDrawCommandFlags
Definition MeshPassProcessor.h:1526
EDrawingPolicyOverrideFlags
Definition MeshPassProcessor.h:2186
TMap< int32, FUniformBufferRHIRef, SceneRenderingSetAllocator > FTranslucentSelfShadowUniformBufferMap
Definition MeshPassProcessor.h:1794
#define COMPARE_FIELD_BEGIN(Field)
Definition MeshPassProcessor.h:475
EMeshPassFlags
Definition MeshPassProcessor.h:2342
EMeshPassFeatures
Definition MeshPassProcessor.h:2107
RENDERER_API void AddRenderTargetInfo(EPixelFormat PixelFormat, ETextureCreateFlags CreateFlags, FGraphicsPipelineRenderTargetsInfo &RenderTargetsInfo)
Definition MeshPassProcessor.cpp:2189
RENDERER_API void SetupDepthStencilInfo(EPixelFormat DepthStencilFormat, ETextureCreateFlags DepthStencilCreateFlags, ERenderTargetLoadAction DepthTargetLoadAction, ERenderTargetLoadAction StencilTargetLoadAction, FExclusiveDepthStencil DepthStencilAccess, FGraphicsPipelineRenderTargetsInfo &RenderTargetsInfo)
Definition MeshPassProcessor.cpp:2199
FMeshPassProcessor *(* PassProcessorCreateFunction)(ERHIFeatureLevel::Type FeatureLevel, const FScene *Scene, const FSceneView *InViewIfDynamicMeshCommand, FMeshPassDrawListContext *InDrawListContext)
Definition MeshPassProcessor.h:2339
RENDERER_API void ApplyTargetsInfo(FGraphicsPipelineStateInitializer &GraphicsPSOInit, const FGraphicsPipelineRenderTargetsInfo &RenderTargetsInfo)
Definition MeshPassProcessor.cpp:1473
#define COMPARE_FIELD(Field)
Definition MeshPassProcessor.h:479
RENDERER_API FMeshDrawCommandSortKey CalculateMeshStaticSortKey(const FMeshMaterialShader *VertexShader, const FMeshMaterialShader *PixelShader)
Definition MeshPassProcessor.cpp:1772
TArray< FVisibleMeshDrawCommand, SceneRenderingAllocator > FMeshCommandOneFrameArray
Definition MeshPassProcessor.h:1793
const int32 NumInlineShaderBindings
Definition MeshPassProcessor.h:801
Experimental::TRobinHoodHashSet< FGraphicsMinimalPipelineStateInitializer > FGraphicsMinimalPipelineStateSet
Definition MeshPassProcessor.h:566
RENDERER_API ESubpassHint GetSubpassHint(const FStaticShaderPlatform Platform, bool bIsUsingGBuffers, bool bMultiViewRendering, uint32 NumSamples)
Definition MeshPassProcessor.cpp:1493
void ApplyViewOverridesToMeshDrawCommands(const FSceneView &View, FMeshCommandOneFrameArray &VisibleMeshDrawCommands, FDynamicMeshDrawCommandStorage &DynamicMeshDrawCommandStorage, FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, bool &NeedsShaderInitialisation)
Definition MeshPassProcessor.cpp:1649
EMeshDrawCommandCullingPayloadFlags
Definition MeshPassProcessor.h:1655
#define COMPARE_FIELD_END
Definition MeshPassProcessor.h:483
FMeshPassProcessor *(* DeprecatedPassProcessorCreateFunction)(const FScene *Scene, const FSceneView *InViewIfDynamicMeshCommand, FMeshPassDrawListContext *InDrawListContext)
Definition MeshPassProcessor.h:2338
RENDERER_API void SetupGBufferRenderTargetInfo(const FSceneTexturesConfig &SceneTexturesConfig, FGraphicsPipelineRenderTargetsInfo &RenderTargetsInfo, bool bSetupDepthStencil, EGBufferLayout Layout=GBL_Default)
Definition MeshPassProcessor.cpp:2220
void SubmitMeshDrawCommandsRange(const FMeshCommandOneFrameArray &VisibleMeshDrawCommands, const FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 PrimitiveIdBufferStride, bool bDynamicInstancing, int32 StartIndex, int32 NumMeshDrawCommands, uint32 InstanceFactor, FRHICommandList &RHICmdList)
Definition MeshPassProcessor.cpp:1616
RENDERER_API void DrawDynamicMeshPassPrivate(const FSceneView &View, FRHICommandList &RHICmdList, FMeshCommandOneFrameArray &VisibleMeshDrawCommands, FDynamicMeshDrawCommandStorage &DynamicMeshDrawCommandStorage, FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, bool &InNeedsShaderInitialisation, uint32 InstanceFactor)
Definition MeshPassProcessor.cpp:1729
@ Num
Definition MetalRHIPrivate.h:234
EPSOPrecacheResult
Definition PipelineStateCache.h:55
EPixelFormat
Definition PixelFormat.h:16
@ PF_Unknown
Definition PixelFormat.h:17
ERayTracingLocalShaderBindingType
Definition RHICommandList.h:259
EShaderFrequency
Definition RHIDefinitions.h:202
@ SF_Compute
Definition RHIDefinitions.h:208
@ SF_NumFrequencies
Definition RHIDefinitions.h:216
@ SF_Vertex
Definition RHIDefinitions.h:203
@ SF_Geometry
Definition RHIDefinitions.h:207
@ SF_RayCallable
Definition RHIDefinitions.h:212
@ SF_RayMiss
Definition RHIDefinitions.h:210
@ SF_RayHitGroup
Definition RHIDefinitions.h:211
@ SF_WorkGraphComputeNode
Definition RHIDefinitions.h:214
@ SF_Pixel
Definition RHIDefinitions.h:206
@ SF_NumStandardFrequencies
Definition RHIDefinitions.h:222
@ MAX_UNIFORM_BUFFER_STATIC_SLOTS
Definition RHIDefinitions.h:727
@ MaxSimultaneousRenderTargets
Definition RHIDefinitions.h:287
@ MaxVertexElementCount
Definition RHIDefinitions.h:276
ERasterizerCullMode
Definition RHIDefinitions.h:369
@ ERasterizerCullMode_Num
Definition RHIDefinitions.h:374
@ ERasterizerCullMode_NumBits
Definition RHIDefinitions.h:375
@ CM_CCW
Definition RHIDefinitions.h:372
@ CM_CW
Definition RHIDefinitions.h:371
@ CM_None
Definition RHIDefinitions.h:370
#define TexCreate_None
Definition RHIDefinitions.h:1191
uint8 FUniformBufferStaticSlot
Definition RHIDefinitions.h:722
ETextureCreateFlags
Definition RHIDefinitions.h:1091
ERenderTargetLoadAction
Definition RHIDefinitions.h:1253
ERasterizerFillMode
Definition RHIDefinitions.h:358
@ ERasterizerFillMode_Num
Definition RHIDefinitions.h:363
@ ERasterizerFillMode_NumBits
Definition RHIDefinitions.h:364
EPrimitiveType
Definition RHIDefinitions.h:822
@ PT_NumBits
Definition RHIDefinitions.h:847
@ PT_TriangleList
Definition RHIDefinitions.h:824
@ PT_Num
Definition RHIDefinitions.h:846
EVRSShadingRate
Definition RHIDefinitions.h:860
@ VRSSR_1x1
Definition RHIDefinitions.h:861
ESubpassHint
Definition RHIResources.h:4526
EShadingPath
Definition SceneUtils.h:24
@ SLT_ReadOnly
Definition ScopeRWLock.h:138
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
uint32 PointerHash(const void *Key)
Definition TypeHash.h:91
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Size
Definition VulkanMemory.cpp:4034
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
int32 Num() const
Definition RobinHoodHashTable.h:847
SizeType GetAllocatedSize() const
Definition RobinHoodHashTable.h:842
ElementType & GetByElementId(FHashElementId Id)
Definition RobinHoodHashTable.h:857
Definition RobinHoodHashTable.h:1135
Definition MeshPassProcessor.h:1873
int32 StateBucketId
Definition MeshPassProcessor.h:1894
ERasterizerCullMode MeshCullMode
Definition MeshPassProcessor.h:1904
EFVisibleMeshDrawCommandFlags Flags
Definition MeshPassProcessor.h:1906
FMeshDrawCommandCullingPayload CullingPayload
Definition MeshPassProcessor.h:1897
int32 CommandIndex
Definition MeshPassProcessor.h:1891
FMeshDrawCommandSortKey SortKey
Definition MeshPassProcessor.h:1888
FCachedMeshDrawCommandInfo(EMeshPass::Type InMeshPass)
Definition MeshPassProcessor.h:1878
ERasterizerFillMode MeshFillMode
Definition MeshPassProcessor.h:1903
FCachedMeshDrawCommandInfo()
Definition MeshPassProcessor.h:1875
EMeshPass::Type MeshPass
Definition MeshPassProcessor.h:1900
Definition MeshPassProcessor.h:2039
FCachedPassMeshDrawListContextDeferred(FScene &InScene)
Definition MeshPassProcessor.h:2041
virtual void ReserveMemoryForCommands(int32 MaxCommandsExpected) override final
Definition MeshPassProcessor.h:2043
virtual void FinalizeCommand(const FMeshBatch &MeshBatch, int32 BatchElementIndex, const FMeshDrawCommandPrimitiveIdInfo &IdInfo, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, FMeshDrawCommandSortKey SortKey, EFVisibleMeshDrawCommandFlags Flags, const FGraphicsMinimalPipelineStateInitializer &PipelineState, const FMeshProcessorShaders *ShadersForDebugging, FMeshDrawCommand &MeshDrawCommand) override final
Definition MeshPassProcessor.cpp:2081
void DeferredFinalizeMeshDrawCommands(const TArrayView< FPrimitiveSceneInfo * > &SceneInfos, int32 Start, int32 End)
Definition MeshPassProcessor.cpp:2123
Definition MeshPassProcessor.h:2021
virtual void FinalizeCommand(const FMeshBatch &MeshBatch, int32 BatchElementIndex, const FMeshDrawCommandPrimitiveIdInfo &IdInfo, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, FMeshDrawCommandSortKey SortKey, EFVisibleMeshDrawCommandFlags Flags, const FGraphicsMinimalPipelineStateInitializer &PipelineState, const FMeshProcessorShaders *ShadersForDebugging, FMeshDrawCommand &MeshDrawCommand) override final
Definition MeshPassProcessor.cpp:2032
FCachedPassMeshDrawListContextImmediate(FScene &InScene)
Definition MeshPassProcessor.h:2023
Definition MeshPassProcessor.h:1964
FCachedMeshDrawCommandInfo CommandInfo
Definition MeshPassProcessor.h:2014
bool HasAnyLooseParameterBuffers() const
Definition MeshPassProcessor.h:1998
virtual void ReserveMemoryForCommands(int32 MaxCommandsExpected)
Definition MeshPassProcessor.h:1988
EMeshPass::Type CurrMeshPass
Definition MeshPassProcessor.h:2015
FScene & Scene
Definition MeshPassProcessor.h:2012
bool bAnyLooseParameterBuffers
Definition MeshPassProcessor.h:2017
FCachedMeshDrawCommandInfo GetCommandInfoAndReset()
Definition MeshPassProcessor.cpp:1958
void BeginMeshPass(EMeshPass::Type MeshPass)
Definition MeshPassProcessor.cpp:1945
FMeshDrawCommand MeshDrawCommandForStateBucketing
Definition MeshPassProcessor.h:2013
void FinalizeCommandCommon(const FMeshBatch &MeshBatch, int32 BatchElementIndex, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, FMeshDrawCommandSortKey SortKey, EFVisibleMeshDrawCommandFlags Flags, const FGraphicsMinimalPipelineStateInitializer &PipelineState, const FMeshProcessorShaders *ShadersForDebugging, FMeshDrawCommand &MeshDrawCommand)
Definition MeshPassProcessor.cpp:1966
bool bUseGPUScene
Definition MeshPassProcessor.h:2016
void BeginMesh(int32 SceneInfoIndex, int32 MeshIndex)
void EndMeshPass()
Definition MeshPassProcessor.cpp:1952
virtual FMeshDrawCommand & AddCommand(FMeshDrawCommand &Initializer, uint32 NumElements) override final
Definition MeshPassProcessor.cpp:1929
Definition MeshPassProcessor.h:1914
TSparseArray< FMeshDrawCommand > MeshDrawCommands
Definition MeshPassProcessor.h:1922
FCachedPassMeshDrawList()
Definition MeshPassProcessor.h:1917
int32 LowestFreeIndexSearchStart
Definition MeshPassProcessor.h:1923
Definition MeshPassProcessor.h:1692
TChunkedArray< FMeshDrawCommand > MeshDrawCommands
Definition MeshPassProcessor.h:1695
Definition MeshPassProcessor.h:1798
virtual void FinalizeCommand(const FMeshBatch &MeshBatch, int32 BatchElementIndex, const FMeshDrawCommandPrimitiveIdInfo &IdInfo, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, FMeshDrawCommandSortKey SortKey, EFVisibleMeshDrawCommandFlags Flags, const FGraphicsMinimalPipelineStateInitializer &PipelineState, const FMeshProcessorShaders *ShadersForDebugging, FMeshDrawCommand &MeshDrawCommand) override final
Definition MeshPassProcessor.h:1820
FDynamicPassMeshDrawListContext(FDynamicMeshDrawCommandStorage &InDrawListStorage, FMeshCommandOneFrameArray &InDrawList, FGraphicsMinimalPipelineStateSet &InPipelineStateSet, bool &InNeedsShaderInitialisation)
Definition MeshPassProcessor.h:1801
FORCEINLINE void AddVisibleMeshDrawCommand(const FVisibleMeshDrawCommand &VisibleMeshDrawCommand)
Definition MeshPassProcessor.h:1852
virtual FMeshDrawCommand & AddCommand(FMeshDrawCommand &Initializer, uint32 NumElements) override final
Definition MeshPassProcessor.h:1813
Definition RHIResources.h:409
Type
Definition RHIResources.h:412
@ DepthRead_StencilRead
Definition RHIResources.h:429
@ DepthNop
Definition RHIResources.h:415
Definition GPUScene.h:217
Definition MeshPassProcessor.h:570
static int32 GetLocalPipelineIdTableSize()
Definition MeshPassProcessor.h:627
uint32 bValid
Definition MeshPassProcessor.h:666
uint32 PackedId
Definition MeshPassProcessor.h:660
bool operator==(const FGraphicsMinimalPipelineStateId &rhs) const
Definition MeshPassProcessor.h:584
const FGraphicsMinimalPipelineStateInitializer & GetPipelineState(const FGraphicsMinimalPipelineStateSet &InPipelineSet) const
Definition MeshPassProcessor.h:594
static void InitializePersistentIds()
Definition MeshPassProcessor.cpp:489
static void AddSizeToLocalPipelineIdTableSize(SIZE_T Size)
Definition MeshPassProcessor.cpp:598
static void ResetLocalPipelineIdTableSize()
Definition MeshPassProcessor.cpp:585
static void FreezeIdTable(bool bEnable)
Definition MeshPassProcessor.cpp:525
static SIZE_T GetPersistentIdTableSize()
Definition MeshPassProcessor.h:638
static void RemovePersistentId(FGraphicsMinimalPipelineStateId Id)
Definition MeshPassProcessor.cpp:504
uint32 SetElementIndex
Definition MeshPassProcessor.h:664
static FGraphicsMinimalPipelineStateId GetPersistentId(const FGraphicsMinimalPipelineStateInitializer &InPipelineState)
Definition MeshPassProcessor.cpp:433
bool operator!=(const FGraphicsMinimalPipelineStateId &rhs) const
Definition MeshPassProcessor.h:589
static int32 GetPersistentIdNum()
Definition MeshPassProcessor.h:643
static RENDERER_API FGraphicsMinimalPipelineStateId GetPipelineStateId(const FGraphicsMinimalPipelineStateInitializer &InPipelineState, FGraphicsMinimalPipelineStateSet &InOutPassSet, bool &NeedsShaderInitialisation)
Definition MeshPassProcessor.cpp:560
uint32 bComesFromLocalPipelineStateSet
Definition MeshPassProcessor.h:665
FORCEINLINE_DEBUGGABLE uint32 GetId() const
Definition MeshPassProcessor.h:572
bool IsValid() const
Definition MeshPassProcessor.h:578
Definition MeshPassProcessor.h:337
FGraphicsPipelineStateInitializer AsGraphicsPipelineStateInitializer() const
Definition MeshPassProcessor.h:386
uint64 StatePrecachePSOHash
Definition MeshPassProcessor.h:558
FGraphicsMinimalPipelineStateInitializer(FMinimalBoundShaderStateInput InBoundShaderState, FRHIBlendState *InBlendState, FRHIRasterizerState *InRasterizerState, FRHIDepthStencilState *InDepthStencilState, FImmutableSamplerState InImmutableSamplerState, EPrimitiveType InPrimitiveType)
Definition MeshPassProcessor.h:350
friend uint32 GetTypeHash(const FGraphicsMinimalPipelineStateInitializer &Initializer)
Definition MeshPassProcessor.h:457
bool operator!=(const FGraphicsMinimalPipelineStateInitializer &rhs) const
Definition MeshPassProcessor.h:452
bool operator<(const FGraphicsMinimalPipelineStateInitializer &rhs) const
Definition MeshPassProcessor.h:486
RENDERER_API void SetupBoundShaderState(FRHIVertexDeclaration *VertexDeclaration, const FMeshProcessorShaders &Shaders)
Definition MeshPassProcessor.cpp:858
FImmutableSamplerState ImmutableSamplerState
Definition MeshPassProcessor.h:546
EPSOPrecacheResult PSOPrecacheState
Definition MeshPassProcessor.h:560
bool operator==(const FGraphicsMinimalPipelineStateInitializer &rhs) const
Definition MeshPassProcessor.h:426
bool operator>(const FGraphicsMinimalPipelineStateInitializer &rhs) const
Definition MeshPassProcessor.h:511
FGraphicsMinimalPipelineStateInitializer()
Definition MeshPassProcessor.h:343
bool bDepthBounds
Definition MeshPassProcessor.h:551
RENDERER_API void ComputeStatePrecachePSOHash()
Definition MeshPassProcessor.cpp:890
EVRSShadingRate DrawShadingRate
Definition MeshPassProcessor.h:553
FRHIBlendState * BlendState
Definition MeshPassProcessor.h:543
EPrimitiveType PrimitiveType
Definition MeshPassProcessor.h:555
FRHIRasterizerState * RasterizerState
Definition MeshPassProcessor.h:544
FRHIDepthStencilState * DepthStencilState
Definition MeshPassProcessor.h:545
bool bAllowVariableRateShading
Definition MeshPassProcessor.h:552
FMinimalBoundShaderStateInput BoundShaderState
Definition MeshPassProcessor.h:542
FGraphicsMinimalPipelineStateInitializer(const FGraphicsMinimalPipelineStateInitializer &InMinimalState)
Definition MeshPassProcessor.h:367
Definition RHIResources.h:4572
FRHIBlendState * BlendState
Definition RHIResources.h:4755
uint64 StatePrecachePSOHash
Definition RHIResources.h:4816
FRHIDepthStencilState * DepthStencilState
Definition RHIResources.h:4757
Definition MaterialRenderProxy.h:102
Definition MaterialShared.h:2058
Definition MeshPassProcessor.h:1482
FORCEINLINE bool operator<(FMeshDrawCommandSortKey B) const
Definition MeshPassProcessor.h:1515
uint64 PackedData
Definition MeshPassProcessor.h:1486
struct FMeshDrawCommandSortKey::@1867::@1869 BasePass
struct FMeshDrawCommandSortKey::@1867::@1871 Generic
uint64 Priority
Definition MeshPassProcessor.h:1500
uint64 VertexShaderHash
Definition MeshPassProcessor.h:1490
uint64 Masked
Definition MeshPassProcessor.h:1493
struct FMeshDrawCommandSortKey::@1867::@1870 Translucent
FORCEINLINE bool operator!=(FMeshDrawCommandSortKey B) const
Definition MeshPassProcessor.h:1510
uint64 Background
Definition MeshPassProcessor.h:1492
uint64 Distance
Definition MeshPassProcessor.h:1499
uint64 PixelShaderHash
Definition MeshPassProcessor.h:1491
uint64 MeshIdInPrimitive
Definition MeshPassProcessor.h:1498
static RENDERER_API const FMeshDrawCommandSortKey Default
Definition MeshPassProcessor.h:39
Definition MeshPassProcessor.h:847
uint32 StencilRef
Definition MeshPassProcessor.h:851
FShaderBindingState ShaderBindings[SF_NumStandardFrequencies]
Definition MeshPassProcessor.h:852
FVertexInputStream VertexStreams[MaxVertexElementCount]
Definition MeshPassProcessor.h:853
void InvalidateUniformBuffer(const FRHIUniformBuffer *UniformBuffer)
Definition MeshPassProcessor.h:887
void SetPipelineState(int32 NewPipelineId)
Definition MeshPassProcessor.h:862
FMeshDrawCommandStateCache()
Definition MeshPassProcessor.h:855
uint32 PipelineId
Definition MeshPassProcessor.h:850
Definition MeshPassProcessor.h:1223
FMeshDrawCommand & operator=(const FMeshDrawCommand &Other)=default
uint32 Offset
Definition MeshPassProcessor.h:1256
uint32 NumVertices
Definition MeshPassProcessor.h:1250
void SetStencilRef(uint32 InStencilRef)
Definition MeshPassProcessor.h:1363
uint32 NumInstances
Definition MeshPassProcessor.h:1243
static void SubmitDrawIndirectEnd(const FMeshDrawCommand &MeshDrawCommand, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 InstanceFactor, FRHICommandList &RHICmdList)
Definition MeshPassProcessor.cpp:1378
uint8 StencilRef
Definition MeshPassProcessor.h:1263
uint32 FirstIndex
Definition MeshPassProcessor.h:1241
void ClearDebugPrimitiveSceneProxy() const
Definition MeshPassProcessor.h:1455
int8 PrimitiveIdStreamIndex
Definition MeshPassProcessor.h:1260
void SetStatsData(const FPrimitiveSceneProxy *PrimitiveSceneProxy)
Definition MeshPassProcessor.h:1476
void InitializeShaderBindings(const FMeshProcessorShaders &Shaders)
Definition MeshPassProcessor.h:1358
FMeshDrawCommand(FMeshDrawCommand &&Other)=default
void Finalize(FGraphicsMinimalPipelineStateId PipelineId, const FMeshProcessorShaders *ShadersForDebugging)
Definition MeshPassProcessor.h:1377
FMeshDrawShaderBindings ShaderBindings
Definition MeshPassProcessor.h:1229
FVertexInputStreamArray VertexStreams
Definition MeshPassProcessor.h:1230
FRHIBuffer * Buffer
Definition MeshPassProcessor.h:1255
struct FMeshDrawCommand::@1863::@1865 VertexParams
RENDERER_API void SetDrawParametersAndFinalize(const FMeshBatch &MeshBatch, int32 BatchElementIndex, FGraphicsMinimalPipelineStateId PipelineId, const FMeshProcessorShaders *ShadersForDebugging)
Definition MeshPassProcessor.cpp:903
FRHIBuffer * IndexBuffer
Definition MeshPassProcessor.h:1231
EPrimitiveType PrimitiveType
Definition MeshPassProcessor.h:1266
FMeshDrawCommand & operator=(FMeshDrawCommand &&Other)=default
uint32 GetDynamicInstancingHash() const
Definition MeshPassProcessor.h:1289
uint32 BaseVertexIndex
Definition MeshPassProcessor.h:1249
const FMeshDrawCommandDebugData & GetDebugData() const
Definition MeshPassProcessor.h:1460
struct FMeshDrawCommand::@1863::@1866 IndirectArgs
FORCENOINLINE friend uint32 GetTypeHash(const FMeshDrawCommand &Other)
Definition MeshPassProcessor.h:1430
RENDERER_API void SetDebugData(const FPrimitiveSceneProxy *PrimitiveSceneProxy, const FMaterial *Material, const FMaterialRenderProxy *MaterialRenderProxy, const FMeshProcessorShaders &UntypedShaders, const FVertexFactory *VertexFactory, const FMeshBatch &MeshBatch, int32 PSOCollectorIndex)
bool MatchesForDynamicInstancing(const FMeshDrawCommand &Rhs) const
Definition MeshPassProcessor.h:1274
SIZE_T GetDebugDataSize() const
Definition MeshPassProcessor.h:1445
SIZE_T GetAllocatedSize() const
Definition MeshPassProcessor.h:1440
FMeshDrawCommand(const FMeshDrawCommand &Other)=default
uint32 NumPrimitives
Definition MeshPassProcessor.h:1242
static bool SubmitDrawIndirectBegin(const FMeshDrawCommand &RESTRICT MeshDrawCommand, const FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 InstanceFactor, FRHICommandList &RHICmdList, FMeshDrawCommandStateCache &RESTRICT StateCache, bool bAllowSkipDrawCommand)
Definition MeshPassProcessor.cpp:1358
static bool SubmitDraw(const FMeshDrawCommand &RESTRICT MeshDrawCommand, const FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 InstanceFactor, FRHICommandList &CommandList, class FMeshDrawCommandStateCache &RESTRICT StateCache)
Definition MeshPassProcessor.cpp:1447
uint64 GetPipelineStateSortingKey(FRHICommandList &RHICmdList, const FGraphicsPipelineRenderTargetsInfo &RenderTargetsInfo) const
Definition MeshPassProcessor.cpp:1512
FGraphicsMinimalPipelineStateId CachedPipelineId
Definition MeshPassProcessor.h:1236
static bool SubmitDrawBegin(const FMeshDrawCommand &RESTRICT MeshDrawCommand, const FGraphicsMinimalPipelineStateSet &GraphicsMinimalPipelineStateSet, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 InstanceFactor, FRHICommandList &RHICmdList, FMeshDrawCommandStateCache &RESTRICT StateCache, bool bAllowSkipDrawCommand)
Definition MeshPassProcessor.cpp:1218
static void SubmitDrawEnd(const FMeshDrawCommand &MeshDrawCommand, const FMeshDrawCommandSceneArgs &SceneArgs, uint32 InstanceFactor, FRHICommandList &RHICmdList)
Definition MeshPassProcessor.cpp:1302
FMeshDrawCommand()
Definition MeshPassProcessor.h:1268
Definition MeshDrawShaderBindings.h:17
uint32 GetSRVOffset() const
Definition MeshDrawShaderBindings.h:82
uint32 GetLooseDataOffset() const
Definition MeshDrawShaderBindings.h:94
uint32 GetSRVTypeOffset() const
Definition MeshDrawShaderBindings.h:88
uint32 GetUniformBufferOffset() const
Definition MeshDrawShaderBindings.h:72
uint32 GetSamplerOffset() const
Definition MeshDrawShaderBindings.h:77
Definition MeshPassProcessor.h:908
void GetShaderFrequencies(TArray< EShaderFrequency, TInlineAllocator< SF_NumFrequencies > > &OutShaderFrequencies) const
Definition MeshPassProcessor.h:1037
RENDERER_API void SetParameters(FRHIBatchedShaderParameters &BatchedParameters, class FShaderBindingState *StateCacheShaderBindings=nullptr) const
Definition MeshPassProcessor.cpp:996
FORCEINLINE FMeshDrawSingleShaderBindings GetSingleShaderBindings(EShaderFrequency Frequency, int32 &DataOffset)
Definition MeshPassProcessor.h:978
RENDERER_API void SetOnCommandList(FRHICommandList &RHICmdList, const FBoundShaderStateInput &Shaders, class FShaderBindingState *StateCacheShaderBindings) const
Definition MeshPassProcessor.cpp:948
FMeshDrawShaderBindings & operator=(FMeshDrawShaderBindings &&Other)
Definition MeshPassProcessor.h:949
FORCEINLINE FMeshDrawSingleShaderBindings GetSingleShaderBindings(EShaderFrequency Frequency)
Definition MeshPassProcessor.h:1001
int32 GetDataSize() const
Definition MeshPassProcessor.h:1050
FMeshDrawShaderBindings(FMeshDrawShaderBindings &&Other)
Definition MeshPassProcessor.h:915
FMeshDrawShaderBindings(const FMeshDrawShaderBindings &Other)
Definition MeshPassProcessor.h:936
bool RENDERER_API MatchesForDynamicInstancing(const FMeshDrawShaderBindings &Rhs) const
Definition MeshPassProcessor.cpp:1018
FMeshDrawShaderBindings & operator=(const FMeshDrawShaderBindings &Other)
Definition MeshPassProcessor.h:943
RENDERER_API void Finalize(const FMeshProcessorShaders *ShadersForDebugging)
Definition MeshPassProcessor.cpp:711
uint32 RENDERER_API GetDynamicInstancingHash() const
Definition MeshPassProcessor.cpp:1108
RENDERER_API void Initialize(const FMeshProcessorShaders &Shaders)
Definition MeshPassProcessor.cpp:610
RENDERER_API ~FMeshDrawShaderBindings()
Definition MeshPassProcessor.cpp:605
FMeshDrawShaderBindings()
Definition MeshPassProcessor.h:910
SIZE_T GetAllocatedSize() const
Definition MeshPassProcessor.h:1026
Definition MeshDrawShaderBindings.h:104
Definition MeshMaterialShader.h:68
Definition MeshPassProcessor.h:1670
virtual void FinalizeCommand(const FMeshBatch &MeshBatch, int32 BatchElementIndex, const FMeshDrawCommandPrimitiveIdInfo &IdInfo, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, FMeshDrawCommandSortKey SortKey, EFVisibleMeshDrawCommandFlags Flags, const FGraphicsMinimalPipelineStateInitializer &PipelineState, const FMeshProcessorShaders *ShadersForDebugging, FMeshDrawCommand &MeshDrawCommand)=0
virtual FMeshDrawCommand & AddCommand(FMeshDrawCommand &Initializer, uint32 NumElements)=0
virtual ~FMeshPassDrawListContext()
Definition MeshPassProcessor.h:1673
Definition MeshPassProcessor.h:156
uint64 Data
Definition MeshPassProcessor.h:199
void Set(EMeshPass::Type Pass)
Definition MeshPassProcessor.h:163
bool Get(EMeshPass::Type Pass) const
Definition MeshPassProcessor.h:168
void AppendTo(FMeshPassMask &Mask) const
Definition MeshPassProcessor.h:184
FMeshPassMask()
Definition MeshPassProcessor.h:158
void Reset()
Definition MeshPassProcessor.h:189
bool IsEmpty() const
Definition MeshPassProcessor.h:194
EMeshPass::Type SkipEmpty(EMeshPass::Type Pass) const
Definition MeshPassProcessor.h:173
int GetNum()
Definition MeshPassProcessor.h:179
Definition MeshPassProcessor.h:2199
static RENDERER_API ERasterizerFillMode ComputeMeshFillMode(const FMaterial &InMaterialResource, const FMeshDrawingPolicyOverrideSettings &InOverrideSettings)
Definition MeshPassProcessor.cpp:1823
RENDERER_API bool HardwareVariableRateShadingSupportedByScene() const
Definition MeshPassProcessor.cpp:1906
const FScene *RESTRICT Scene
Definition MeshPassProcessor.h:2203
const FSceneView * ViewIfDynamicMeshCommand
Definition MeshPassProcessor.h:2205
EMeshPass::Type MeshPassType
Definition MeshPassProcessor.h:2202
RENDERER_API bool PipelineVariableRateShadingEnabled() const
Definition MeshPassProcessor.cpp:1901
static FORCEINLINE_DEBUGGABLE ERasterizerCullMode InverseCullMode(ERasterizerCullMode CullMode)
Definition MeshPassProcessor.h:2229
virtual void CollectPSOInitializers(const FSceneTexturesConfig &SceneTexturesConfig, const FMaterial &Material, const FPSOPrecacheVertexFactoryData &VertexFactoryData, const FPSOPrecacheParams &PreCacheParams, TArray< FPSOPrecacheData > &PSOInitializers) override
Definition MeshPassProcessor.h:2227
void BuildMeshDrawCommands(const FMeshBatch &RESTRICT MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy *RESTRICT PrimitiveSceneProxy, const FMaterialRenderProxy &RESTRICT MaterialRenderProxy, const FMaterial &RESTRICT MaterialResource, const FMeshPassProcessorRenderState &RESTRICT DrawRenderState, const PassShadersType &PassShaders, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, FMeshDrawCommandSortKey SortKey, EMeshPassFeatures MeshPassFeatures, const ShaderElementDataType &ShaderElementData)
Definition MeshPassProcessor.inl:50
static RENDERER_API FMeshDrawingPolicyOverrideSettings ComputeMeshOverrideSettings(const FPSOPrecacheParams &PrecachePSOParams)
Definition MeshPassProcessor.cpp:1801
virtual ~FMeshPassProcessor()
Definition MeshPassProcessor.h:2215
void AddGraphicsPipelineStateInitializer(const FPSOPrecacheVertexFactoryData &VertexFactoryData, const FMaterial &RESTRICT MaterialResource, const FMeshPassProcessorRenderState &RESTRICT DrawRenderState, const FGraphicsPipelineRenderTargetsInfo &RESTRICT RenderTargetsInfo, const PassShadersType &PassShaders, ERasterizerFillMode MeshFillMode, ERasterizerCullMode MeshCullMode, EPrimitiveType PrimitiveType, EMeshPassFeatures MeshPassFeatures, bool bRequired, TArray< FPSOPrecacheData > &PSOInitializers)
Definition MeshPassProcessor.inl:211
ERHIFeatureLevel::Type FeatureLevel
Definition MeshPassProcessor.h:2204
void SetDrawListContext(FMeshPassDrawListContext *InDrawListContext)
Definition MeshPassProcessor.h:2217
static RENDERER_API ERasterizerCullMode ComputeMeshCullMode(const FMaterial &InMaterialResource, const FMeshDrawingPolicyOverrideSettings &InOverrideSettings)
Definition MeshPassProcessor.cpp:1830
FMeshPassDrawListContext * DrawListContext
Definition MeshPassProcessor.h:2206
virtual void AddMeshBatch(const FMeshBatch &RESTRICT MeshBatch, uint64 BatchElementMask, const FPrimitiveSceneProxy *RESTRICT PrimitiveSceneProxy, int32 StaticMeshId=-1)=0
RENDERER_API FMeshDrawCommandPrimitiveIdInfo GetDrawCommandPrimitiveId(const FPrimitiveSceneInfo *RESTRICT PrimitiveSceneInfo, const FMeshBatchElement &BatchElement) const
Definition MeshPassProcessor.cpp:1840
RENDERER_API bool ShouldSkipMeshDrawCommand(const FMeshBatch &RESTRICT MeshBatch, const FPrimitiveSceneProxy *RESTRICT PrimitiveSceneProxy) const
Definition MeshPassProcessor.cpp:1874
Definition NameTypes.h:617
Definition MeshPassProcessor.h:2350
static EMeshPassFlags GetPassFlags(EShadingPath ShadingPath, EMeshPass::Type PassType)
Definition MeshPassProcessor.h:2368
static void SetPassFlags(EShadingPath ShadingPath, EMeshPass::Type PassType, EMeshPassFlags NewFlags)
Definition MeshPassProcessor.cpp:2179
static int32 GetPSOCollectorIndex(EShadingPath ShadingPath, EMeshPass::Type PassType)
Definition MeshPassProcessor.h:2375
static FMeshPassProcessor * CreateMeshPassProcessor(EShadingPath ShadingPath, EMeshPass::Type PassType, ERHIFeatureLevel::Type FeatureLevel, const FScene *Scene, const FSceneView *InViewIfDynamicMeshCommand, FMeshPassDrawListContext *InDrawListContext)
Definition MeshPassProcessor.h:2353
Definition PrimitiveSceneInfo.h:266
Definition PrimitiveSceneProxy.h:296
Definition RHIResources.h:696
Definition RHIResources.h:1581
Definition RHICommandList.h:3819
Definition RHICommandList.h:2735
Definition RHIResources.h:1018
Definition RHIResources.h:686
Definition RHIResources.h:978
Definition RHIResources.h:960
Definition RHIResources.h:972
Definition RHIResources.h:679
Definition RHIResources.h:3729
Definition RHIResources.h:54
Definition RHIResources.h:671
Definition RHIResources.h:3863
Definition RHIResources.h:854
Definition RHIResources.h:1232
Definition RHIResources.h:725
Definition RHIResources.h:954
Definition ScopeRWLock.h:199
Definition PipelineStateCache.cpp:1285
Definition MeshPassProcessor.h:1119
FReadOnlyMeshDrawSingleShaderBindings(const FMeshDrawSingleShaderBindings &Bindings)
Definition MeshPassProcessor.h:1130
FReadOnlyMeshDrawSingleShaderBindings(const FMeshDrawShaderBindingsLayout &InLayout, const uint8 *InData)
Definition MeshPassProcessor.h:1136
FRHIUniformBuffer *const * GetUniformBufferStart() const
Definition MeshPassProcessor.h:1142
const uint8 * GetSRVTypeStart() const
Definition MeshPassProcessor.h:1159
static RENDERER_API void SetShaderBindings(FRHIBatchedShaderParameters &BatchedParameters, const class FReadOnlyMeshDrawSingleShaderBindings &RESTRICT SingleShaderBindings, FShaderBindingState &RESTRICT ShaderBindingState)
const uint8 * GetLooseDataStart() const
Definition MeshPassProcessor.h:1165
static RENDERER_API void SetShaderBindings(FRHIBatchedShaderParameters &BatchedParameters, const class FReadOnlyMeshDrawSingleShaderBindings &RESTRICT SingleShaderBindings)
FRHIResource ** GetSRVStart() const
Definition MeshPassProcessor.h:1153
FRHISamplerState ** GetSamplerStart() const
Definition MeshPassProcessor.h:1147
Definition MeshPassProcessor.h:2399
~FRegisterPassProcessorCreateFunction()
Definition MeshPassProcessor.h:2411
FRegisterPassProcessorCreateFunction(PassProcessorCreateFunction CreateFunction, EShadingPath InShadingPath, EMeshPass::Type InPassType, EMeshPassFlags PassFlags, int32 PSOCollectorIndex=INDEX_NONE)
Definition MeshPassProcessor.h:2401
Definition SceneView.h:1425
Definition ScenePrivate.h:2875
Definition MeshPassProcessor.h:710
@ MAX_UNIFORM_BUFFERS_PER_STAGE
Definition MeshPassProcessor.h:712
FRHIUniformBuffer * UniformBuffers[MAX_UNIFORM_BUFFERS_PER_STAGE]
Definition MeshPassProcessor.h:715
int32 MaxUniformBufferUsed
Definition MeshPassProcessor.h:714
bool HasShader(int32 ShaderIndex) const
Definition Shader.h:359
FRHIShader * GetShader(int32 ShaderIndex, bool bRequired=true)
Definition Shader.h:399
Definition VertexFactory.h:314
Definition VertexFactory.h:661
Definition MeshPassProcessor.h:1703
const FMeshDrawCommand * MeshDrawCommand
Definition MeshPassProcessor.h:1736
ERasterizerFillMode MeshFillMode
Definition MeshPassProcessor.h:1760
FMeshDrawCommandPrimitiveIdInfo PrimitiveIdInfo
Definition MeshPassProcessor.h:1741
int32 StateBucketId
Definition MeshPassProcessor.h:1749
FMeshDrawCommandCullingPayload CullingPayload
Definition MeshPassProcessor.h:1756
int32 NumRuns
Definition MeshPassProcessor.h:1753
EFVisibleMeshDrawCommandFlags Flags
Definition MeshPassProcessor.h:1763
FORCEINLINE_DEBUGGABLE void Setup(const FMeshDrawCommand *InMeshDrawCommand, const FMeshDrawCommandPrimitiveIdInfo &InPrimitiveIdInfo, int32 InStateBucketId, ERasterizerFillMode InMeshFillMode, ERasterizerCullMode InMeshCullMode, EFVisibleMeshDrawCommandFlags InFlags, FMeshDrawCommandSortKey InSortKey, FMeshDrawCommandCullingPayload InCullingPayload, EMeshDrawCommandCullingPayloadFlags InCullingPayloadFlags, const uint32 *InRunArray=nullptr, int32 InNumRuns=0)
Definition MeshPassProcessor.h:1708
const uint32 * RunArray
Definition MeshPassProcessor.h:1752
ERasterizerCullMode MeshCullMode
Definition MeshPassProcessor.h:1761
EMeshDrawCommandCullingPayloadFlags CullingPayloadFlags
Definition MeshPassProcessor.h:1757
FMeshDrawCommandSortKey SortKey
Definition MeshPassProcessor.h:1739
int32 PrimitiveIdBufferOffset
Definition MeshPassProcessor.h:1744
Definition PSOPrecacheMaterial.h:24
int32 PSOCollectorIndex
Definition PSOPrecacheMaterial.h:42
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
UE_REWRITE SizeType Max() const
Definition Array.h:1161
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize(void) const
Definition Array.h:1059
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
Definition ChunkedArray.h:56
int32 AddElement(const ElementType &Item)
Definition ChunkedArray.h:193
Definition UnrealString.h.inl:34
Definition RefCounting.h:454
Definition Shader.h:1021
Definition ContainerAllocationPolicies.h:894
Definition SparseArray.h:524
Definition StaticArray.h:26
Definition CriticalSection.h:14
Definition MeshPassProcessor.h:36
Type
Definition MeshPassProcessor.h:38
@ AnisotropyPass
Definition MeshPassProcessor.h:42
@ MeshDecal_SceneColor
Definition MeshPassProcessor.h:74
@ LumenFrontLayerTranslucencyGBuffer
Definition MeshPassProcessor.h:68
@ SingleLayerWaterPass
Definition MeshPassProcessor.h:44
@ LumenCardCapture
Definition MeshPassProcessor.h:65
@ SecondStageDepthPass
Definition MeshPassProcessor.h:40
@ NaniteMeshPass
Definition MeshPassProcessor.h:70
@ CSMShadowDepth
Definition MeshPassProcessor.h:46
@ SkyPass
Definition MeshPassProcessor.h:43
@ WaterInfoTexturePass
Definition MeshPassProcessor.h:77
@ TranslucentVelocity
Definition MeshPassProcessor.h:51
@ VirtualTexture
Definition MeshPassProcessor.h:64
@ DebugViewMode
Definition MeshPassProcessor.h:61
@ MeshDecal_DBuffer
Definition MeshPassProcessor.h:71
@ SingleLayerWaterDepthPrepass
Definition MeshPassProcessor.h:45
@ OnePassPointLightShadowDepth
Definition MeshPassProcessor.h:48
@ LumenTranslucencyRadianceCacheMark
Definition MeshPassProcessor.h:67
@ VSMShadowDepth
Definition MeshPassProcessor.h:47
@ TranslucentVelocityClippedDepth
Definition MeshPassProcessor.h:52
@ NumBits
Definition MeshPassProcessor.h:87
@ BasePass
Definition MeshPassProcessor.h:41
@ MeshDecal_SceneColorAndGBufferNoNormal
Definition MeshPassProcessor.h:73
@ TranslucencyAfterMotionBlur
Definition MeshPassProcessor.h:57
@ LumenCardNanite
Definition MeshPassProcessor.h:66
@ Distortion
Definition MeshPassProcessor.h:49
@ TranslucencyHoldout
Definition MeshPassProcessor.h:58
@ Num
Definition MeshPassProcessor.h:86
@ MeshDecal_SceneColorAndGBuffer
Definition MeshPassProcessor.h:72
@ Velocity
Definition MeshPassProcessor.h:50
@ WaterInfoTextureDepthPass
Definition MeshPassProcessor.h:76
@ TranslucencyAfterDOFModulate
Definition MeshPassProcessor.h:56
@ TranslucencyStandard
Definition MeshPassProcessor.h:53
@ TranslucencyAfterDOF
Definition MeshPassProcessor.h:55
@ TranslucencyStandardModulate
Definition MeshPassProcessor.h:54
@ DepthPass
Definition MeshPassProcessor.h:39
@ MobileBasePassCSM
Definition MeshPassProcessor.h:63
@ LightmapDensity
Definition MeshPassProcessor.h:60
@ MeshDecal_AmbientOcclusion
Definition MeshPassProcessor.h:75
@ CustomDepth
Definition MeshPassProcessor.h:62
@ DitheredLODFadingOutMaskPass
Definition MeshPassProcessor.h:69
@ TranslucencyAll
Definition MeshPassProcessor.h:59
Definition SceneComponent.h:24
Type
Definition RHIFeatureLevel.h:20
RHI_API bool IsPSOPrecachingEnabled()
Definition PipelineStateCache.cpp:4406
U16 Index
Definition radfft.cpp:71
Definition RHIResources.h:4362
Definition MeshPassProcessor.h:1967
FMeshPassScope & operator=(const FMeshPassScope &)=delete
FMeshPassScope(FCachedPassMeshDrawListContext &InContext, EMeshPass::Type MeshPass)
Definition MeshPassProcessor.h:1971
FMeshPassScope(const FMeshPassScope &)=delete
~FMeshPassScope()
Definition MeshPassProcessor.h:1977
Definition MeshPassProcessor.h:1767
FORCEINLINE bool operator()(const FVisibleMeshDrawCommand &A, const FVisibleMeshDrawCommand &B) const
Definition MeshPassProcessor.h:1768
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition GenericPlatformMemory.h:586
Definition RHIResources.h:4547
Definition RHIImmutableSamplerState.h:17
static constexpr UE_FORCEINLINE_HINT T Clamp(const T X, const T MinValue, const T MaxValue)
Definition UnrealMathUtility.h:592
Definition MeshBatch.h:232
Definition MeshBatch.h:371
Definition MeshPassProcessor.h:1927
std::atomic< uint32 > Num
Definition MeshPassProcessor.h:1940
FMeshDrawCommandCount(FMeshDrawCommandCount &&Other)
Definition MeshPassProcessor.h:1934
FMeshDrawCommandCount()
Definition MeshPassProcessor.h:1928
Definition MeshPassProcessor.h:1613
static float UnpackScreenSize(uint32 PackedScreenSize)
Definition MeshPassProcessor.h:1635
uint32 MaxScreenSize
Definition MeshPassProcessor.h:1621
uint32 MinScreenSize
Definition MeshPassProcessor.h:1620
uint32 PackedData
Definition MeshPassProcessor.h:1616
static uint32 PackScreenSize(float ScreenSize)
Definition MeshPassProcessor.h:1628
int32 DynamicMeshBoundsIndex
Definition MeshPassProcessor.h:1625
uint32 LodIndex
Definition MeshPassProcessor.h:1619
Definition MeshPassProcessor.h:807
FName ResourceName
Definition MeshPassProcessor.h:826
TShaderRef< FShader > PixelShader
Definition MeshPassProcessor.h:811
FString MaterialRenderProxyName
Definition MeshPassProcessor.h:818
int32 SegmentIndex
Definition MeshPassProcessor.h:831
const FPrimitiveSceneProxy * PrimitiveSceneProxyIfNotUsingStateBuckets
Definition MeshPassProcessor.h:814
TShaderRef< FShader > VertexShader
Definition MeshPassProcessor.h:810
int8 LODIndex
Definition MeshPassProcessor.h:830
const FMaterialRenderProxy * MaterialRenderProxyIfNotUsingStateBuckets
Definition MeshPassProcessor.h:815
const FMaterial * Material
Definition MeshPassProcessor.h:820
Definition MeshPassProcessor.h:1176
FRHIBuffer * InstanceBuffer
Definition MeshPassProcessor.h:1177
FRHIUniformBuffer * InstanceCullingStaticUB
Definition MeshPassProcessor.h:1179
FMeshDrawCommandOverrideArgs()
Definition MeshPassProcessor.h:1184
TOptional< FUintVector4 > RootConstants
Definition MeshPassProcessor.h:1182
FRHIBuffer * IndirectArgsBuffer
Definition MeshPassProcessor.h:1178
uint32 IndirectArgsByteOffset
Definition MeshPassProcessor.h:1181
uint32 InstanceDataByteOffset
Definition MeshPassProcessor.h:1180
Definition MeshPassProcessor.h:1573
int32 DrawPrimitiveId
Definition MeshPassProcessor.h:1597
FORCEINLINE FMeshDrawCommandPrimitiveIdInfo(int32 InScenePrimitiveId, FPersistentPrimitiveIndex InDrawPrimitiveId, int32 InInstanceSceneDataOffset)
Definition MeshPassProcessor.h:1577
int32 ScenePrimitiveId
Definition MeshPassProcessor.h:1600
int32 InstanceSceneDataOffset
Definition MeshPassProcessor.h:1603
uint32 bIsDynamicPrimitive
Definition MeshPassProcessor.h:1606
FORCEINLINE FMeshDrawCommandPrimitiveIdInfo()
Definition MeshPassProcessor.h:1574
Definition MeshPassProcessor.h:1195
FRHIBuffer * PrimitiveIdsBuffer
Definition MeshPassProcessor.h:1196
FMeshDrawCommandSceneArgs()
Definition MeshPassProcessor.h:1203
FUniformBufferStaticSlot BatchedPrimitiveSlot
Definition MeshPassProcessor.h:1200
uint32 PrimitiveIdOffset
Definition MeshPassProcessor.h:1198
FRHIBuffer * IndirectArgsBuffer
Definition MeshPassProcessor.h:1197
TOptional< FUintVector4 > RootConstants
Definition MeshPassProcessor.h:1201
uint32 IndirectArgsByteOffset
Definition MeshPassProcessor.h:1199
Definition MeshPassProcessor.h:837
Definition MeshPassProcessor.h:2118
FORCEINLINE_DEBUGGABLE void SetStencilRef(uint32 InStencilRef)
Definition MeshPassProcessor.h:2140
FORCEINLINE_DEBUGGABLE void SetDepthStencilState(FRHIDepthStencilState *InDepthStencilState)
Definition MeshPassProcessor.h:2134
FORCEINLINE_DEBUGGABLE void SetDepthStencilAccess(FExclusiveDepthStencil::Type InDepthStencilAccess)
Definition MeshPassProcessor.h:2150
FORCEINLINE_DEBUGGABLE uint32 GetStencilRef() const
Definition MeshPassProcessor.h:2160
FMeshPassProcessorRenderState(const FMeshPassProcessorRenderState &DrawRenderState)=default
FORCEINLINE_DEBUGGABLE FRHIDepthStencilState * GetDepthStencilState() const
Definition MeshPassProcessor.h:2145
FORCEINLINE_DEBUGGABLE FExclusiveDepthStencil::Type GetDepthStencilAccess() const
Definition MeshPassProcessor.h:2155
FORCEINLINE_DEBUGGABLE void ApplyToPSO(FGraphicsPipelineStateInitializer &GraphicsPSOInit) const
Definition MeshPassProcessor.h:2165
FORCEINLINE_DEBUGGABLE void SetBlendState(FRHIBlendState *InBlendState)
Definition MeshPassProcessor.h:2124
FORCEINLINE_DEBUGGABLE FRHIBlendState * GetBlendState() const
Definition MeshPassProcessor.h:2129
EDrawingPolicyOverrideFlags MeshOverrideFlags
Definition MeshPassProcessor.h:2236
EPrimitiveType MeshPrimitiveType
Definition MeshPassProcessor.h:2237
Definition MeshPassProcessor.h:719
TShaderRef< FShader > PixelShader
Definition MeshPassProcessor.h:721
TShaderRef< FShader > VertexShader
Definition MeshPassProcessor.h:720
TShaderRef< FShader > GeometryShader
Definition MeshPassProcessor.h:722
TArray< TShaderRef< FShader >, TInlineAllocator< 3 > > GetValidShaders() const
Definition MeshPassProcessor.h:767
TShaderRef< FShader > GetShader(EShaderFrequency Frequency) const
Definition MeshPassProcessor.h:729
TShaderRef< FShader > ComputeShader
Definition MeshPassProcessor.h:723
TShaderRef< FShader > WorkGraphShader
Definition MeshPassProcessor.h:724
Definition MeshPassProcessor.h:203
bool NeedsShaderInitialisation() const
Definition MeshPassProcessor.h:277
int32 VertexShaderIndex
Definition MeshPassProcessor.h:320
FMinimalBoundShaderStateInput()
Definition MeshPassProcessor.h:204
FBoundShaderStateInput AsBoundShaderState() const
Definition MeshPassProcessor.h:206
FRHIVertexShader * CachedVertexShader
Definition MeshPassProcessor.h:303
RENDERER_API bool AllowSkipUnloadedShaders() const
Definition MeshPassProcessor.cpp:853
FRHIPixelShader * CachedPixelShader
Definition MeshPassProcessor.h:304
bool IsShaderAllLoaded() const
Definition MeshPassProcessor.h:253
TRefCountPtr< FShaderMapResource > VertexShaderResource
Definition MeshPassProcessor.h:312
void ForceShaderReload() const
Definition MeshPassProcessor.h:255
int32 PixelShaderIndex
Definition MeshPassProcessor.h:321
bool bAllShaderAreLoaded
Definition MeshPassProcessor.h:305
FRHIVertexDeclaration * VertexDeclarationRHI
Definition MeshPassProcessor.h:302
TRefCountPtr< FShaderMapResource > PixelShaderResource
Definition MeshPassProcessor.h:313
void LazilyInitShaders() const
Definition MeshPassProcessor.h:272
Definition PSOPrecache.h:30
Definition PSOPrecache.h:150
Definition MeshPassProcessor.h:1559
FORCEINLINE bool operator==(FPersistentPrimitiveIndex B) const
Definition MeshPassProcessor.h:1563
bool IsValid() const
Definition MeshPassProcessor.h:1560
Definition RHIShaderParameters.h:241
Definition RHICommandList.h:267
Definition SceneTexturesConfig.h:114
Definition AndroidStaticShaderPlatform.inl:18
Definition VertexFactory.h:49
FRHIBuffer * VertexBuffer
Definition VertexFactory.h:57
Definition MeshPassProcessor.h:1944
static bool Matches(KeyInitType A, KeyInitType B)
Definition MeshPassProcessor.h:1948
static uint32 GetKeyHash(KeyInitType Key)
Definition MeshPassProcessor.h:1954
Definition Map.h:111
TTypeTraits< KeyType >::ConstPointerType KeyInitType
Definition Map.h:78
Definition MeshPassProcessor.h:2076
TShaderRef< ComputeType > ComputeShader
Definition MeshPassProcessor.h:2082
TShaderRef< VertexType > VertexShader
Definition MeshPassProcessor.h:2077
TShaderRef< GeometryType > GeometryShader
Definition MeshPassProcessor.h:2079
TShaderRef< PixelType > PixelShader
Definition MeshPassProcessor.h:2078
FMeshProcessorShaders GetUntypedShaders() const
Definition MeshPassProcessor.h:2090
TMeshProcessorShaders()=default
Definition Optional.h:131
Definition UseBitwiseSwap.h:13
@ Value
Definition UseBitwiseSwap.h:15