SurfaceCommon.cs 892 B

123456789101112131415161718192021222324252627282930313233
  1. using Ryujinx.Common;
  2. using Ryujinx.Graphics.Texture;
  3. namespace Ryujinx.Graphics.Vic.Image
  4. {
  5. static class SurfaceCommon
  6. {
  7. public static int GetPitch(int width, int bytesPerPixel)
  8. {
  9. return BitUtils.AlignUp(width * bytesPerPixel, 256);
  10. }
  11. public static int GetBlockLinearSize(int width, int height, int bytesPerPixel, int gobBlocksInY)
  12. {
  13. return SizeCalculator.GetBlockLinearTextureSize(width, height, 1, 1, 1, 1, 1, bytesPerPixel, gobBlocksInY, 1, 1).TotalSize;
  14. }
  15. public static ulong ExtendOffset(uint offset)
  16. {
  17. return (ulong)offset << 8;
  18. }
  19. public static ushort Upsample(byte value)
  20. {
  21. return (ushort)(value << 2);
  22. }
  23. public static byte Downsample(ushort value)
  24. {
  25. return (byte)(value >> 2);
  26. }
  27. }
  28. }