aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/GalImage.cs
blob: 92f43cc9d4ceeb076c30c324d5122bff4c4bb581 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using Ryujinx.Graphics.Texture;

namespace Ryujinx.Graphics.Gal
{
    public struct GalImage
    {
        public int Width;
        public int Height;
        public int TileWidth;
        public int GobBlockHeight;
        public int Pitch;

        public GalImageFormat   Format;
        public GalMemoryLayout  Layout;
        public GalTextureSource XSource;
        public GalTextureSource YSource;
        public GalTextureSource ZSource;
        public GalTextureSource WSource;

        public GalImage(
            int              Width,
            int              Height,
            int              TileWidth,
            int              GobBlockHeight,
            GalMemoryLayout  Layout,
            GalImageFormat   Format,
            GalTextureSource XSource = GalTextureSource.Red,
            GalTextureSource YSource = GalTextureSource.Green,
            GalTextureSource ZSource = GalTextureSource.Blue,
            GalTextureSource WSource = GalTextureSource.Alpha)
        {
            this.Width          = Width;
            this.Height         = Height;
            this.TileWidth      = TileWidth;
            this.GobBlockHeight = GobBlockHeight;
            this.Layout         = Layout;
            this.Format         = Format;
            this.XSource        = XSource;
            this.YSource        = YSource;
            this.ZSource        = ZSource;
            this.WSource        = WSource;

            Pitch = ImageUtils.GetPitch(Format, Width);
        }

        public bool SizeMatches(GalImage Image)
        {
            if (ImageUtils.GetBytesPerPixel(Format) !=
                ImageUtils.GetBytesPerPixel(Image.Format))
            {
                return false;
            }

            if (ImageUtils.GetAlignedWidth(this) !=
                ImageUtils.GetAlignedWidth(Image))
            {
                return false;
            }

            return Height == Image.Height;
        }
    }
}