UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VulkanSubmission.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 VulkanContext.h: Class to generate Vulkan command buffers from RHI CommandLists
5=============================================================================*/
6
7#pragma once
8
9#include "VulkanRHIPrivate.h"
10#include "VulkanQuery.h"
11
12class FVulkanDevice;
14class FVulkanFence;
17class FVulkanQueue;
20class FVulkanTiming;
22
23
25{
26 // Sync points of this type do not include an FGraphEvent, so cannot
27 // report completion to the CPU (via either IsComplete() or Wait())
28 // The will resolve into binary or timeline semaphores at submit time.
29 //GPUOnly, :todo-jn: Move GPU syncs to new FVulkanSyncPoint class
30
31 // Sync points of this type include an FGraphEvent. The IsComplete() and Wait() functions
32 // can be used to poll for completion from the CPU, or block the CPU, respectively.
34
35 // Same as GPUAndCPU but not time critical and can be pushed back up until the end of the frame.
36 // Generally meant to be used for work that can happen at any point after the command buffers
37 // are done executing on the GPU.
38 Context,
39};
40
43
44//
45// A sync point is a logical point on a GPU queue's timeline that can be awaited by other queues, or the CPU.
46// These are used throughout the RHI as a way to abstract the underlying Vulkan semaphores and fences.
47// The submission thread manages the underlying semaphores, fences and signaled values, and reports completion
48// to the relevant sync points via an FGraphEvent.
49//
50// Sync points are one-shot, meaning they represent a single timeline point, and are released after use, via ref-counting.
51// Use FVulkanSyncPoint::Create() to make a new sync point and hold a reference to it via a FVulkanSyncPointRef object.
52//
54{
55 friend FVulkanDynamicRHI;
56 friend FVulkanQueue;
57
59
60 // No copying or moving
61 FVulkanSyncPoint(FVulkanSyncPoint const&) = delete;
63
65 : Type(InType)
66#if RHI_USE_SYNC_POINT_DEBUG_NAME
67 , DebugName(InDebugName)
68#endif
69 {
71 {
72 GraphEvent = FGraphEvent::CreateGraphEvent();
73 }
74 }
75
76public:
78 {
79 LLM_SCOPE_BYNAME(TEXT("RHIMisc/CreateSyncPoint"));
80 return new FVulkanSyncPoint(Type, InDebugName);
81 }
82
83 bool IsComplete() const
84 {
85 checkf(GraphEvent, TEXT("This sync point was not created with a CPU event. Cannot check completion on the CPU."));
86 return GraphEvent->IsComplete();
87 }
88
89 void Wait() const;
90
92 {
93 checkf(GraphEvent, TEXT("This sync point was not created with a CPU event."));
94 return GraphEvent;
95 }
96
98 {
99 return Type;
100 }
101
102 void* operator new(size_t Size)
103 {
104 check(Size == sizeof(FVulkanSyncPoint));
105
106 void* Memory = MemoryPool.Pop();
107 if (!Memory)
108 {
109 Memory = FMemory::Malloc(sizeof(FVulkanSyncPoint), alignof(FVulkanSyncPoint));
110 }
111 return Memory;
112 }
113
114 void operator delete(void* Pointer)
115 {
116 MemoryPool.Push(Pointer);
117 }
118
119 inline const TCHAR* GetDebugName() const
120 {
121#if RHI_USE_SYNC_POINT_DEBUG_NAME
122 return DebugName;
123#else
124 return TEXT("SyncPointBusyWait");
125#endif
126 }
127
128private:
129 FGraphEventRef GraphEvent;
131
132#if RHI_USE_SYNC_POINT_DEBUG_NAME
133 const TCHAR* DebugName = nullptr;
134#endif
135};
136
137
138
144
145
146
148{
151 friend class FVulkanDynamicRHI;
152 friend class FVulkanQueue;
153
154public:
156 : Queue(InQueue)
158 , EventStream(InQueue.GetProfilerQueue())
159#endif
160 {}
161
163
164protected:
165
166 // Must only be used to merge Secondary or Parallel command buffers
168
169 void PreExecute();
170
172 TArray<VkPipelineStageFlags> WaitFlags; // flags that match 1:1 with WaitSemaphores
173 TArray<FVulkanSemaphore*> WaitSemaphores; // wait before command buffers
175 TArray<FVulkanSemaphore*> SignalSemaphores; // signaled after command buffers
176
177 // Signaled when the payload has been submitted to the GPU queue
179
180 // For internal completion tracking of the payload
182 FVulkanFence* Fence = nullptr;
183
184 // Used to sync other CPU work to payload completion
186
187 // Queries used in the command lists of this payload
189
190 // Used DescriptorPoolSetContainers that can be cleaned up on completion
192
193 // Used by RHIRunOnQueue
195
196#if WITH_RHI_BREADCRUMBS
199#endif
200
201#if RHI_NEW_GPU_PROFILER
203 TOptional<uint64> ExternalGPUTime;
206#else
207 bool bEndFrame = false;
208#endif
209
210 // UpdateReservedResources
212};
213
214struct FVulkanPlatformCommandList : public IRHIPlatformCommandList, public TArray<FVulkanPayload*>
215{
216};
217
218template<>
223
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
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::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
#define LLM_SCOPE_BYNAME(...)
Definition LowLevelMemTracker.h:1098
#define RHI_NEW_GPU_PROFILER
Definition RHIDefinitions.h:69
uint32 Size
Definition VulkanMemory.cpp:4034
EVulkanSyncPointType
Definition VulkanSubmission.h:25
if(Failed) console_printf("Failed.\n")
Definition TaskGraphInterfaces.h:471
static FGraphEventRef CreateGraphEvent()
Definition TaskGraphInterfaces.h:743
bool IsComplete() const
Definition TaskGraphInterfaces.h:529
Definition RefCounting.h:283
Definition VulkanContext.h:241
Definition VulkanContext.h:55
Definition VulkanDescriptorSets.h:363
Definition VulkanDevice.h:279
Definition VulkanDynamicRHI.h:69
Definition VulkanSynchronization.h:17
Definition VulkanSubmission.h:148
bool bEndFrame
Definition VulkanSubmission.h:207
FVulkanQueue & Queue
Definition VulkanSubmission.h:171
TArray< FVulkanCommandBuffer * > CommandBuffers
Definition VulkanSubmission.h:174
~FVulkanPayload()
Definition VulkanSubmission.cpp:39
TArray< FVulkanDescriptorPoolSetContainer * > DescriptorPoolSetContainers
Definition VulkanSubmission.h:191
TFunction< void(VkQueue)> PreExecuteCallback
Definition VulkanSubmission.h:194
TArray< FVulkanCommitReservedResourceDesc > ReservedResourcesToCommit
Definition VulkanSubmission.h:211
uint64 TimelineSemaphoreValue
Definition VulkanSubmission.h:181
FVulkanPayload(FVulkanQueue &InQueue)
Definition VulkanSubmission.h:155
TStaticArray< TArray< FVulkanQueryPool * >,(int32) EVulkanQueryPoolType::Count > QueryPools
Definition VulkanSubmission.h:188
TArray< FGraphEventRef > SubmissionEvents
Definition VulkanSubmission.h:178
TArray< FVulkanSemaphore * > WaitSemaphores
Definition VulkanSubmission.h:173
void PreExecute()
Definition VulkanSubmission.cpp:889
TArray< FVulkanSemaphore * > SignalSemaphores
Definition VulkanSubmission.h:175
FVulkanFence * Fence
Definition VulkanSubmission.h:182
TArray< FVulkanSyncPointRef > SyncPoints
Definition VulkanSubmission.h:185
TArray< VkPipelineStageFlags > WaitFlags
Definition VulkanSubmission.h:172
Definition VulkanPendingState.h:21
Definition VulkanPendingState.h:121
Definition VulkanQueue.h:53
Definition VulkanSynchronization.h:127
Definition VulkanSwapChain.h:30
Definition VulkanSubmission.h:54
EVulkanSyncPointType GetType() const
Definition VulkanSubmission.h:97
void Wait() const
Definition VulkanSubmission.cpp:23
FGraphEvent * GetGraphEvent() const
Definition VulkanSubmission.h:91
const TCHAR * GetDebugName() const
Definition VulkanSubmission.h:119
bool IsComplete() const
Definition VulkanSubmission.h:83
static FVulkanSyncPointRef Create(EVulkanSyncPointType Type, const TCHAR *InDebugName)
Definition VulkanSubmission.h:77
Definition RHIContext.h:234
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
void Push(T *NewItem)
Definition LockFreeList.h:849
T * Pop()
Definition LockFreeList.h:858
Definition LockFreeList.h:904
Definition SharedPointer.h:692
Definition StaticArray.h:26
Definition GPUProfiler.h:310
Definition VulkanSubmission.h:140
TRefCountPtr< FRHIResource > Resource
Definition VulkanSubmission.h:141
uint64 CommitSizeInBytes
Definition VulkanSubmission.h:142
Definition VulkanSubmission.h:215
Definition Optional.h:131
FVulkanPlatformCommandList TConcreteType
Definition VulkanSubmission.h:221
Definition VulkanResources.h:1168