SurfaceCommon.cs 819 B

1234567891011121314151617181920212223242526
  1. using Ryujinx.Graphics.Texture;
  2. using Ryujinx.Graphics.Video;
  3. using System;
  4. namespace Ryujinx.Graphics.Nvdec.Image
  5. {
  6. static class SurfaceCommon
  7. {
  8. public static int GetBlockLinearSize(int width, int height, int bytesPerPixel)
  9. {
  10. return SizeCalculator.GetBlockLinearTextureSize(width, height, 1, 1, 1, 1, 1, bytesPerPixel, 2, 1, 1).TotalSize;
  11. }
  12. public static void Copy(ISurface src, ISurface dst)
  13. {
  14. src.YPlane.AsSpan().CopyTo(dst.YPlane.AsSpan());
  15. src.UPlane.AsSpan().CopyTo(dst.UPlane.AsSpan());
  16. src.VPlane.AsSpan().CopyTo(dst.VPlane.AsSpan());
  17. }
  18. public unsafe static Span<byte> AsSpan(this Plane plane)
  19. {
  20. return new Span<byte>((void*)plane.Pointer, plane.Length);
  21. }
  22. }
  23. }