aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.OpenGL/Handle.cs
blob: b63e8f946f8356033da19685be768171905922e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using Ryujinx.Graphics.GAL;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Ryujinx.Graphics.OpenGL
{
    static class Handle
    {
        public static T FromInt32<T>(int handle) where T : unmanaged
        {
            Debug.Assert(Unsafe.SizeOf<T>() == sizeof(ulong));

            ulong handle64 = (uint)handle;

            return Unsafe.As<ulong, T>(ref handle64);
        }

        public static int ToInt32(this BufferHandle handle)
        {
            return (int)Unsafe.As<BufferHandle, ulong>(ref handle);
        }
    }
}