aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Nvdec.Vp9/Common/MemoryUtil.cs
blob: 909a948329b427678efee23551d9c5997ec8d9dd (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 System;
using System.Runtime.InteropServices;

namespace Ryujinx.Graphics.Nvdec.Vp9.Common
{
    internal static class MemoryUtil
    {
        public static unsafe void Copy<T>(T* dest, T* source, int length) where T : unmanaged
        {
            new Span<T>(source, length).CopyTo(new Span<T>(dest, length));
        }

        public static void Copy<T>(ref T dest, ref T source) where T : unmanaged
        {
            MemoryMarshal.CreateSpan(ref source, 1).CopyTo(MemoryMarshal.CreateSpan(ref dest, 1));
        }

        public static unsafe void Fill<T>(T* ptr, T value, int length) where T : unmanaged
        {
            new Span<T>(ptr, length).Fill(value);
        }
    }
}