Handle.cs 571 B

1234567891011121314151617181920212223
  1. using Ryujinx.Graphics.GAL;
  2. using System.Diagnostics;
  3. using System.Runtime.CompilerServices;
  4. namespace Ryujinx.Graphics.OpenGL
  5. {
  6. static class Handle
  7. {
  8. public static T FromInt32<T>(int handle) where T : unmanaged
  9. {
  10. Debug.Assert(Unsafe.SizeOf<T>() == sizeof(ulong));
  11. ulong handle64 = (uint)handle;
  12. return Unsafe.As<ulong, T>(ref handle64);
  13. }
  14. public static int ToInt32(this BufferHandle handle)
  15. {
  16. return (int)Unsafe.As<BufferHandle, ulong>(ref handle);
  17. }
  18. }
  19. }