aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.OpenGL/Handle.cs
blob: 4b2f05e672b44c9d91ea96ecec04e236430912f3 (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);
        }
    }
}