MemoryUtil.cs 705 B

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