GalImage.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Ryujinx.Graphics.Texture;
  2. namespace Ryujinx.Graphics.Gal
  3. {
  4. public struct GalImage
  5. {
  6. public int Width;
  7. public int Height;
  8. // FIXME: separate layer and depth
  9. public int Depth;
  10. public int LayerCount;
  11. public int TileWidth;
  12. public int GobBlockHeight;
  13. public int GobBlockDepth;
  14. public int Pitch;
  15. public int MaxMipmapLevel;
  16. public GalImageFormat Format;
  17. public GalMemoryLayout Layout;
  18. public GalTextureSource XSource;
  19. public GalTextureSource YSource;
  20. public GalTextureSource ZSource;
  21. public GalTextureSource WSource;
  22. public GalTextureTarget TextureTarget;
  23. public GalImage(
  24. int width,
  25. int height,
  26. int depth,
  27. int layerCount,
  28. int tileWidth,
  29. int gobBlockHeight,
  30. int gobBlockDepth,
  31. GalMemoryLayout layout,
  32. GalImageFormat format,
  33. GalTextureTarget textureTarget,
  34. int maxMipmapLevel = 1,
  35. GalTextureSource xSource = GalTextureSource.Red,
  36. GalTextureSource ySource = GalTextureSource.Green,
  37. GalTextureSource zSource = GalTextureSource.Blue,
  38. GalTextureSource wSource = GalTextureSource.Alpha)
  39. {
  40. Width = width;
  41. Height = height;
  42. LayerCount = layerCount;
  43. Depth = depth;
  44. TileWidth = tileWidth;
  45. GobBlockHeight = gobBlockHeight;
  46. GobBlockDepth = gobBlockDepth;
  47. Layout = layout;
  48. Format = format;
  49. MaxMipmapLevel = maxMipmapLevel;
  50. XSource = xSource;
  51. YSource = ySource;
  52. ZSource = zSource;
  53. WSource = wSource;
  54. TextureTarget = textureTarget;
  55. Pitch = ImageUtils.GetPitch(format, width);
  56. }
  57. public bool SizeMatches(GalImage image, bool ignoreLayer = false)
  58. {
  59. if (ImageUtils.GetBytesPerPixel(Format) !=
  60. ImageUtils.GetBytesPerPixel(image.Format))
  61. {
  62. return false;
  63. }
  64. if (ImageUtils.GetAlignedWidth(this) !=
  65. ImageUtils.GetAlignedWidth(image))
  66. {
  67. return false;
  68. }
  69. bool result = Height == image.Height && Depth == image.Depth;
  70. if (!ignoreLayer)
  71. {
  72. result = result && LayerCount == image.LayerCount;
  73. }
  74. return result;
  75. }
  76. }
  77. }