UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshDrawCommands.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4MeshDrawCommands.h: Mesh draw commands.
5=============================================================================*/
6
7#pragma once
8
9#include "MeshPassProcessor.h"
13#include "ScenePrivateBase.h"
14
19
30
32{
33public:
36
40
41 virtual void ReleaseRHI() override;
42
43private:
44 uint32 DiscardId;
46 FCriticalSection AllocationCS;
47};
48
50
55{
56public:
58
60 const FScene* Scene;
70
71 // Mesh pass processor.
76
77 // Commands.
89
90 // Resources preallocated on rendering thread.
92
93 // For UpdateTranslucentMeshSortKeys.
100
101 // For logging instancing stats.
105
107};
108
114{
115public:
117 : bHasInstanceCullingDrawParameters(false)
118 , MaxNumDraws(0)
119 {
120 }
121
123
129 FScene* Scene,
130 const FViewInfo& View,
131 FInstanceCullingContext &&InstanceCullingContext,
132 EMeshPass::Type PassType,
133 FExclusiveDepthStencil::Type BasePassDepthStencilAccess,
134 FMeshPassProcessor* MeshPassProcessor,
136 const TArray<FMeshPassMask, SceneRenderingAllocator>* DynamicMeshElementsPassRelevance,
137 int32 NumDynamicMeshElements,
140 int32 NumDynamicMeshCommandBuildRequestElements,
142 FMeshPassProcessor* MobileBasePassCSMMeshPassProcessor = nullptr, // Required only for the mobile base pass.
143 FMeshCommandOneFrameArray* InOutMobileBasePassCSMMeshDrawCommands = nullptr // Required only for the mobile base pass.
144 );
145
151 FRDGBuilder& GraphBuilder,
152 const FGPUScene& GPUScene,
154
158 void WaitForSetupTask();
159
163 void Draw(FRHICommandList& RHICmdList, const FInstanceCullingDrawParams* InstanceCullingDrawParams = nullptr) const;
166
168 UE_DEPRECATED(5.5, "Use Draw / Dispatch instead.")
171
172 void Cleanup();
173 void SetDumpInstancingStats(const FString& InPassName);
174 bool HasAnyDraw() const { return MaxNumDraws > 0; }
175
177
179 const FGraphEventRef& GetTaskEvent() const { return TaskEventRef; }
180
181 FGraphEventRef&& AcquireTaskEvent() { return MoveTemp(TaskEventRef); }
182
183 // NOTE: It is only safe to access mesh draw commands after the setup task is complete (use WaitForSetupTask).
184 // Only access the data late in the frame to allow as much time as possible for async tasks to complete.
186 {
187 return TaskContext.MeshDrawCommands;
188 }
189
190private:
192 FGraphEventRef TaskEventRef;
193 FString PassNameForStats;
194
195 bool bHasInstanceCullingDrawParameters;
196
197 // Maximum number of draws for this pass. Used to prealocate resources on rendering thread.
198 // Has a guarantee that if there won't be any draws, then MaxNumDraws = 0;
199 int32 MaxNumDraws;
200
201 void DumpInstancingStats() const;
202};
203
205{
206 return Pass && Pass->HasAnyDraw();
207}
208
210 const FSceneView& SceneView,
211 FRHICommandList& RHICmdList,
212 FMeshCommandOneFrameArray& VisibleMeshDrawCommands,
213 FDynamicMeshDrawCommandStorage& MeshDrawCommandStorage,
215 uint32 InstanceFactor,
216 const FGPUScenePrimitiveCollector* DynamicPrimitiveCollector);
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
bool HasAnyDraw(const FParallelMeshDrawCommandPass *Pass)
Definition MeshDrawCommands.h:204
RENDERER_API TGlobalResource< FPrimitiveIdVertexBufferPool > GPrimitiveIdVertexBufferPool
Definition MeshDrawCommands.cpp:20
RENDERER_API void SortAndMergeDynamicPassMeshDrawCommands(const FSceneView &SceneView, FRHICommandList &RHICmdList, FMeshCommandOneFrameArray &VisibleMeshDrawCommands, FDynamicMeshDrawCommandStorage &MeshDrawCommandStorage, FRHIBuffer *&OutPrimitiveIdVertexBuffer, uint32 InstanceFactor, const FGPUScenePrimitiveCollector *DynamicPrimitiveCollector)
Definition MeshDrawCommands.cpp:1228
EShaderPlatform
Definition RHIShaderPlatform.h:11
EShadingPath
Definition SceneUtils.h:24
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MeshPassProcessor.h:1692
Type
Definition RHIResources.h:412
Definition GPUScene.h:80
Definition GPUScene.h:217
Definition InstanceCullingContext.h:74
Definition InstanceCullingManager.h:45
Definition MeshDrawCommands.h:55
FDynamicMeshDrawCommandStorage MeshDrawCommandStorage
Definition MeshDrawCommands.h:86
FMeshPassProcessor * MeshPassProcessor
Definition MeshDrawCommands.h:72
FExclusiveDepthStencil::Type BasePassDepthStencilAccess
Definition MeshDrawCommands.h:68
FMeshCommandOneFrameArray TempVisibleMeshDrawCommands
Definition MeshDrawCommands.h:91
EShadingPath ShadingPath
Definition MeshDrawCommands.h:61
FMeshCommandOneFrameArray MeshDrawCommands
Definition MeshDrawCommands.h:81
EMeshPass::Type PassType
Definition MeshDrawCommands.h:63
int32 MaxInstances
Definition MeshDrawCommands.h:104
FMatrix ViewMatrix
Definition MeshDrawCommands.h:98
int32 NumDynamicMeshElements
Definition MeshDrawCommands.h:79
ETranslucencyPass::Type TranslucencyPass
Definition MeshDrawCommands.h:94
int32 NumDynamicMeshCommandBuildRequestElements
Definition MeshDrawCommands.h:80
FMeshDrawCommandPassSetupTaskContext()
Definition MeshDrawCommands.cpp:981
TArray< EMeshDrawCommandCullingPayloadFlags, SceneRenderingAllocator > DynamicMeshCommandBuildFlags
Definition MeshDrawCommands.h:84
FGraphicsMinimalPipelineStateSet MinimalPipelineStatePassSet
Definition MeshDrawCommands.h:87
EShaderPlatform ShaderPlatform
Definition MeshDrawCommands.h:62
FVector ViewOrigin
Definition MeshDrawCommands.h:97
FExclusiveDepthStencil::Type DefaultBasePassDepthStencilAccess
Definition MeshDrawCommands.h:69
FVector TranslucentSortAxis
Definition MeshDrawCommands.h:96
bool bReverseCulling
Definition MeshDrawCommands.h:66
ETranslucentSortPolicy::Type TranslucentSortPolicy
Definition MeshDrawCommands.h:95
TArray< const FStaticMeshBatch *, SceneRenderingAllocator > DynamicMeshCommandBuildRequests
Definition MeshDrawCommands.h:83
const FScene * Scene
Definition MeshDrawCommands.h:60
FMeshPassProcessor * MobileBasePassCSMMeshPassProcessor
Definition MeshDrawCommands.h:73
int32 InstanceFactor
Definition MeshDrawCommands.h:78
bool bDynamicInstancing
Definition MeshDrawCommands.h:65
const TScenePrimitiveArray< struct FPrimitiveBounds > * PrimitiveBounds
Definition MeshDrawCommands.h:99
FInstanceCullingContext InstanceCullingContext
Definition MeshDrawCommands.h:106
int32 VisibleMeshDrawCommandsNum
Definition MeshDrawCommands.h:102
const FViewInfo * View
Definition MeshDrawCommands.h:59
bool NeedsShaderInitialisation
Definition MeshDrawCommands.h:88
const TArray< FMeshPassMask, SceneRenderingAllocator > * DynamicMeshElementsPassRelevance
Definition MeshDrawCommands.h:75
bool bRenderSceneTwoSided
Definition MeshDrawCommands.h:67
const TArray< FMeshBatchAndRelevance, SceneRenderingAllocator > * DynamicMeshElements
Definition MeshDrawCommands.h:74
FMeshCommandOneFrameArray MobileBasePassCSMMeshDrawCommands
Definition MeshDrawCommands.h:82
bool bUseGPUScene
Definition MeshDrawCommands.h:64
TArray< const FStaticMeshBatch *, SceneRenderingAllocator > MobileBasePassCSMDynamicMeshCommandBuildRequests
Definition MeshDrawCommands.h:85
int32 NewPassVisibleMeshDrawCommandsNum
Definition MeshDrawCommands.h:103
Definition MeshPassProcessor.h:2199
Definition MeshDrawCommands.h:114
void SetDumpInstancingStats(const FString &InPassName)
Definition MeshDrawCommands.cpp:1823
const FMeshCommandOneFrameArray & GetMeshDrawCommands() const
Definition MeshDrawCommands.h:185
static bool IsOnDemandShaderCreationEnabled()
Definition MeshDrawCommands.cpp:1498
void Dispatch(FRDGDispatchPassBuilder &DispatchPassBuilder, const FInstanceCullingDrawParams *InstanceCullingDrawParams=nullptr, float ViewportScale=1.0f) const
Definition MeshDrawCommands.cpp:1757
void Draw(FRHICommandList &RHICmdList, const FInstanceCullingDrawParams *InstanceCullingDrawParams=nullptr) const
Definition MeshDrawCommands.cpp:1718
void WaitForSetupTask()
Definition MeshDrawCommands.cpp:1507
FInstanceCullingContext * GetInstanceCullingContext()
Definition MeshDrawCommands.h:178
~FParallelMeshDrawCommandPass()
Definition MeshDrawCommands.cpp:1548
PRAGMA_ENABLE_DEPRECATION_WARNINGS void Cleanup()
Definition MeshDrawCommands.cpp:1518
void DispatchPassSetup(FScene *Scene, const FViewInfo &View, FInstanceCullingContext &&InstanceCullingContext, EMeshPass::Type PassType, FExclusiveDepthStencil::Type BasePassDepthStencilAccess, FMeshPassProcessor *MeshPassProcessor, const TArray< FMeshBatchAndRelevance, SceneRenderingAllocator > &DynamicMeshElements, const TArray< FMeshPassMask, SceneRenderingAllocator > *DynamicMeshElementsPassRelevance, int32 NumDynamicMeshElements, TArray< const FStaticMeshBatch *, SceneRenderingAllocator > &InOutDynamicMeshCommandBuildRequests, TArray< EMeshDrawCommandCullingPayloadFlags, SceneRenderingAllocator > InOutDynamicMeshCommandBuildFlags, int32 NumDynamicMeshCommandBuildRequestElements, FMeshCommandOneFrameArray &InOutMeshDrawCommands, FMeshPassProcessor *MobileBasePassCSMMeshPassProcessor=nullptr, FMeshCommandOneFrameArray *InOutMobileBasePassCSMMeshDrawCommands=nullptr)
Definition MeshDrawCommands.cpp:1359
bool HasAnyDraw() const
Definition MeshDrawCommands.h:174
void BuildRenderingCommands(FRDGBuilder &GraphBuilder, const FGPUScene &GPUScene, FInstanceCullingDrawParams &OutInstanceCullingDrawParams)
Definition MeshDrawCommands.cpp:1629
FParallelMeshDrawCommandPass()
Definition MeshDrawCommands.h:116
FGraphEventRef && AcquireTaskEvent()
Definition MeshDrawCommands.h:181
PRAGMA_DISABLE_DEPRECATION_WARNINGS void DispatchDraw(FParallelCommandListSet *ParallelCommandListSet, FRHICommandList &RHICmdList, const FInstanceCullingDrawParams *InstanceCullingDrawParams=nullptr) const
Definition MeshDrawCommands.cpp:1659
const FGraphEventRef & GetTaskEvent() const
Definition MeshDrawCommands.h:179
Definition MeshDrawCommands.h:32
virtual void ReleaseRHI() override
Definition MeshDrawCommands.cpp:141
~FPrimitiveIdVertexBufferPool()
Definition MeshDrawCommands.cpp:56
RENDERER_API void DiscardAll()
Definition MeshDrawCommands.cpp:121
FPrimitiveIdVertexBufferPool()
Definition MeshDrawCommands.cpp:51
void ReturnToFreeList(FPrimitiveIdVertexBufferPoolEntry Entry)
Definition MeshDrawCommands.cpp:113
FPrimitiveIdVertexBufferPoolEntry Allocate(FRHICommandList &RHICmdList, int32 BufferSize)
Definition MeshDrawCommands.cpp:61
Definition RenderGraphBuilder.h:49
Definition RenderGraphPass.h:736
Definition RHIResources.h:1581
Definition RHICommandList.h:3819
Definition RenderResource.h:37
Definition SceneView.h:1425
Definition ScenePrivate.h:2875
Definition StaticMeshBatch.h:16
Definition SceneRendering.h:1132
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition RenderResource.h:543
Definition ScenePrivateBase.h:55
Type
Definition MeshPassProcessor.h:38
Type
Definition TranslucentPassResource.h:13
Type
Definition EngineTypes.h:435
@ false
Definition radaudio_common.h:23
Definition SceneManagement.h:1462
Definition MeshDrawCommands.h:25
uint32 LastDiscardId
Definition MeshDrawCommands.h:27
FBufferRHIRef BufferRHI
Definition MeshDrawCommands.h:28
int32 BufferSize
Definition MeshDrawCommands.h:26