FenceHelper.cs 1.0 KB

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