/ src / Ryujinx.Graphics.Vulkan / FenceHelper.cs
FenceHelper.cs
 1  using Silk.NET.Vulkan;
 2  using System;
 3  
 4  namespace Ryujinx.Graphics.Vulkan
 5  {
 6      static class FenceHelper
 7      {
 8          private const ulong DefaultTimeout = 100000000; // 100ms
 9  
10          public static bool AnySignaled(Vk api, Device device, ReadOnlySpan<Fence> fences, ulong timeout = 0)
11          {
12              return api.WaitForFences(device, (uint)fences.Length, fences, false, timeout) == Result.Success;
13          }
14  
15          public static bool AllSignaled(Vk api, Device device, ReadOnlySpan<Fence> fences, ulong timeout = 0)
16          {
17              return api.WaitForFences(device, (uint)fences.Length, fences, true, timeout) == Result.Success;
18          }
19  
20          public static void WaitAllIndefinitely(Vk api, Device device, ReadOnlySpan<Fence> fences)
21          {
22              Result result;
23              while ((result = api.WaitForFences(device, (uint)fences.Length, fences, true, DefaultTimeout)) == Result.Timeout)
24              {
25                  // Keep waiting while the fence is not signaled.
26              }
27              result.ThrowOnError();
28          }
29      }
30  }