UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VulkanSynchronization.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
9#include "VulkanThirdParty.h"
10
11class FVulkanDevice;
13
14// Internal Vulkan Fence class that wrap VkFence management
15// (not to be confused with FVulkanGPUFence class that maps to RHI's FRHIFence)
17{
18public:
20
21 inline VkFence GetHandle() const
22 {
23 return Handle;
24 }
25
26 inline bool IsSignaled() const
27 {
28 return State == EState::Signaled;
29 }
30
32 {
33 return Owner;
34 }
35
36protected:
38
39 enum class EState
40 {
41 // Initial state
43
44 // After GPU processed it
46 };
47
49
51
52 // Only owner can delete!
55};
56
58{
59public:
65
66 void Deinit();
67
69
70 inline bool IsFenceSignaled(FVulkanFence* Fence)
71 {
72 if (Fence->IsSignaled())
73 {
74 return true;
75 }
76
77 return CheckFenceState(Fence);
78 }
79
80 // Returns false if it timed out
83
84 void ResetFence(FVulkanFence* Fence);
85
86 // Sets it to nullptr
87 void ReleaseFence(FVulkanFence*& Fence);
88
89 // Sets it to nullptr
91
92protected:
97
98 // Returns true if signaled
99 bool CheckFenceState(FVulkanFence* Fence);
100
101 void DestroyFence(FVulkanFence* Fence);
102};
103
104
105
107{
108 None = 0,
109
110 // Will not delete handle on destruction
111 ExternallyOwned = 1 << 1,
112
113 // Inform submission pipeline that the signal will not come from a payload (acquired image semaphore for example)
114 ExternallySignaled = 1 << 2,
115
116 // Create a timeline semaphore (must be supported)
117 Timeline = 1 << 3,
118
119 // Will not be queued for deferred deletion
120 ImmediateDeletion = 1 << 4
121};
123
124
125// Internal Vulkan Semaphore class that wrap VkSemaphore management (binary or timeline)
161
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
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EVulkanSemaphoreFlags
Definition VulkanSynchronization.h:107
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition RefCounting.h:283
Definition VulkanDevice.h:279
Definition VulkanSynchronization.h:58
void ReleaseFence(FVulkanFence *&Fence)
Definition VulkanSynchronization.cpp:70
void Deinit()
Definition VulkanSynchronization.cpp:38
FVulkanDevice & Device
Definition VulkanSynchronization.h:93
bool IsFenceSignaled(FVulkanFence *Fence)
Definition VulkanSynchronization.h:70
FVulkanFenceManager(FVulkanDevice &InDevice)
Definition VulkanSynchronization.h:60
TArray< FVulkanFence * > UsedFences
Definition VulkanSynchronization.h:96
void DestroyFence(FVulkanFence *Fence)
Definition VulkanSynchronization.cpp:30
FVulkanFence * AllocateFence(bool bCreateSignaled=false)
Definition VulkanSynchronization.cpp:48
void WaitAndReleaseFence(FVulkanFence *&Fence, uint64 TimeInNanoseconds)
Definition VulkanSynchronization.cpp:83
bool CheckFenceState(FVulkanFence *Fence)
Definition VulkanSynchronization.cpp:97
bool WaitForFence(FVulkanFence *Fence, uint64 TimeInNanoseconds)
Definition VulkanSynchronization.cpp:119
~FVulkanFenceManager()
Definition VulkanSynchronization.cpp:25
void ResetFence(FVulkanFence *Fence)
Definition VulkanSynchronization.cpp:175
bool WaitForAnyFence(TArrayView< FVulkanFence * > Fences, uint64 TimeInNanoseconds)
Definition VulkanSynchronization.cpp:143
FCriticalSection FenceLock
Definition VulkanSynchronization.h:94
TArray< FVulkanFence * > FreeFences
Definition VulkanSynchronization.h:95
Definition VulkanSynchronization.h:17
FVulkanFenceManager & GetOwner()
Definition VulkanSynchronization.h:31
EState
Definition VulkanSynchronization.h:40
VkFence Handle
Definition VulkanSynchronization.h:37
friend FVulkanFenceManager
Definition VulkanSynchronization.h:54
VkFence GetHandle() const
Definition VulkanSynchronization.h:21
EState State
Definition VulkanSynchronization.h:48
~FVulkanFence()
Definition VulkanSynchronization.cpp:18
FVulkanFenceManager & Owner
Definition VulkanSynchronization.h:50
bool IsSignaled() const
Definition VulkanSynchronization.h:26
Definition VulkanSynchronization.h:127
bool IsExternallySignaled() const
Definition VulkanSynchronization.h:143
bool IsTimeline() const
Definition VulkanSynchronization.h:148
bool IsExternallyOwned() const
Definition VulkanSynchronization.h:138
bool WaitForTimelineSemaphoreValue(uint64 Value, uint64 Timeout)
Definition VulkanSynchronization.cpp:229
VkSemaphore GetHandle() const
Definition VulkanSynchronization.h:133
uint64 GetTimelineSemaphoreValue()
Definition VulkanSynchronization.cpp:252
virtual ~FVulkanSemaphore()
Definition VulkanSynchronization.cpp:215
Definition ArrayView.h:139
Definition Array.h:670