aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Vulkan/FenceHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/FenceHelper.cs')
-rw-r--r--Ryujinx.Graphics.Vulkan/FenceHelper.cs30
1 files changed, 30 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Vulkan/FenceHelper.cs b/Ryujinx.Graphics.Vulkan/FenceHelper.cs
new file mode 100644
index 00000000..d6731c0e
--- /dev/null
+++ b/Ryujinx.Graphics.Vulkan/FenceHelper.cs
@@ -0,0 +1,30 @@
+using Silk.NET.Vulkan;
+using System;
+
+namespace Ryujinx.Graphics.Vulkan
+{
+ static class FenceHelper
+ {
+ private const ulong DefaultTimeout = 100000000; // 100ms
+
+ public static bool AnySignaled(Vk api, Device device, ReadOnlySpan<Fence> fences, ulong timeout = 0)
+ {
+ return api.WaitForFences(device, (uint)fences.Length, fences, false, timeout) == Result.Success;
+ }
+
+ public static bool AllSignaled(Vk api, Device device, ReadOnlySpan<Fence> fences, ulong timeout = 0)
+ {
+ return api.WaitForFences(device, (uint)fences.Length, fences, true, timeout) == Result.Success;
+ }
+
+ public static void WaitAllIndefinitely(Vk api, Device device, ReadOnlySpan<Fence> fences)
+ {
+ Result result;
+ while ((result = api.WaitForFences(device, (uint)fences.Length, fences, true, DefaultTimeout)) == Result.Timeout)
+ {
+ // Keep waiting while the fence is not signaled.
+ }
+ result.ThrowOnError();
+ }
+ }
+}