VulkanException.cs 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Silk.NET.Vulkan;
  2. using System;
  3. using System.Runtime.Serialization;
  4. namespace Ryujinx.Graphics.Vulkan
  5. {
  6. static class ResultExtensions
  7. {
  8. public static void ThrowOnError(this Result result)
  9. {
  10. // Only negative result codes are errors.
  11. if ((int)result < (int)Result.Success)
  12. {
  13. throw new VulkanException(result);
  14. }
  15. }
  16. }
  17. class VulkanException : Exception
  18. {
  19. public VulkanException()
  20. {
  21. }
  22. public VulkanException(Result result) : base($"Unexpected API error \"{result}\".")
  23. {
  24. }
  25. public VulkanException(string message) : base(message)
  26. {
  27. }
  28. public VulkanException(string message, Exception innerException) : base(message, innerException)
  29. {
  30. }
  31. protected VulkanException(SerializationInfo info, StreamingContext context) : base(info, context)
  32. {
  33. }
  34. }
  35. }