aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Vic/Image/SurfaceCommon.cs
blob: 635f083bd4fb142626bac4ae35b5369161357ba9 (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
using Ryujinx.Common;
using Ryujinx.Graphics.Texture;

namespace Ryujinx.Graphics.Vic.Image
{
    static class SurfaceCommon
    {
        public static int GetPitch(int width, int bytesPerPixel)
        {
            return BitUtils.AlignUp(width * bytesPerPixel, 256);
        }

        public static int GetBlockLinearSize(int width, int height, int bytesPerPixel, int gobBlocksInY)
        {
            return SizeCalculator.GetBlockLinearTextureSize(width, height, 1, 1, 1, 1, 1, bytesPerPixel, gobBlocksInY, 1, 1).TotalSize;
        }

        public static ulong ExtendOffset(uint offset)
        {
            return (ulong)offset << 8;
        }

        public static ushort Upsample(byte value)
        {
            return (ushort)(value << 2);
        }

        public static byte Downsample(ushort value)
        {
            return (byte)(value >> 2);
        }
    }
}