MemoryUtil.cs 773 B

12345678910111213141516171819202122232425
  1. using Ryujinx.Common.Memory;
  2. using System;
  3. using System.Runtime.CompilerServices;
  4. using System.Runtime.InteropServices;
  5. namespace Ryujinx.Graphics.Nvdec.Vp9.Common
  6. {
  7. internal static class MemoryUtil
  8. {
  9. public static unsafe void Copy<T>(T* dest, T* source, int length) where T : unmanaged
  10. {
  11. new Span<T>(source, length).CopyTo(new Span<T>(dest, length));
  12. }
  13. public static void Copy<T>(ref T dest, ref T source) where T : unmanaged
  14. {
  15. MemoryMarshal.CreateSpan(ref source, 1).CopyTo(MemoryMarshal.CreateSpan(ref dest, 1));
  16. }
  17. public static unsafe void Fill<T>(T* ptr, T value, int length) where T : unmanaged
  18. {
  19. new Span<T>(ptr, length).Fill(value);
  20. }
  21. }
  22. }