TextureHelper.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using ChocolArm64.Memory;
  2. using System;
  3. namespace Ryujinx.Core.Gpu
  4. {
  5. static class TextureHelper
  6. {
  7. public static ISwizzle GetSwizzle(Texture Texture, int Width, int Bpp)
  8. {
  9. switch (Texture.Swizzle)
  10. {
  11. case TextureSwizzle.Pitch:
  12. case TextureSwizzle.PitchColorKey:
  13. return new LinearSwizzle(Texture.Pitch, Bpp);
  14. case TextureSwizzle.BlockLinear:
  15. case TextureSwizzle.BlockLinearColorKey:
  16. return new BlockLinearSwizzle(Width, Bpp, Texture.BlockHeight);
  17. }
  18. throw new NotImplementedException(Texture.Swizzle.ToString());
  19. }
  20. public static (AMemory Memory, long Position) GetMemoryAndPosition(
  21. IAMemory Memory,
  22. long Position)
  23. {
  24. if (Memory is NvGpuVmm Vmm)
  25. {
  26. return (Vmm.Memory, Vmm.GetPhysicalAddress(Position));
  27. }
  28. return ((AMemory)Memory, Position);
  29. }
  30. }
  31. }