2018-09-08 19:51:50 +02:00
|
|
|
using ChocolArm64.Memory;
|
|
|
|
using Ryujinx.Graphics.Gal;
|
|
|
|
using Ryujinx.Graphics.Memory;
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Texture
|
|
|
|
{
|
|
|
|
static class TextureHelper
|
|
|
|
{
|
2018-09-18 06:30:35 +02:00
|
|
|
public static ISwizzle GetSwizzle(GalImage Image)
|
2018-09-08 19:51:50 +02:00
|
|
|
{
|
2018-09-18 06:30:35 +02:00
|
|
|
int BlockWidth = ImageUtils.GetBlockWidth (Image.Format);
|
|
|
|
int BytesPerPixel = ImageUtils.GetBytesPerPixel(Image.Format);
|
2018-09-08 19:51:50 +02:00
|
|
|
|
2018-09-18 06:30:35 +02:00
|
|
|
int Width = (Image.Width + (BlockWidth - 1)) / BlockWidth;
|
2018-09-08 19:51:50 +02:00
|
|
|
|
2018-09-18 06:30:35 +02:00
|
|
|
if (Image.Layout == GalMemoryLayout.BlockLinear)
|
2018-09-08 19:51:50 +02:00
|
|
|
{
|
2018-09-18 06:30:35 +02:00
|
|
|
int AlignMask = Image.TileWidth * (64 / BytesPerPixel) - 1;
|
2018-09-08 19:51:50 +02:00
|
|
|
|
2018-09-18 06:30:35 +02:00
|
|
|
Width = (Width + AlignMask) & ~AlignMask;
|
2018-09-08 19:51:50 +02:00
|
|
|
|
2018-09-18 06:30:35 +02:00
|
|
|
return new BlockLinearSwizzle(Width, BytesPerPixel, Image.GobBlockHeight);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return new LinearSwizzle(Image.Pitch, BytesPerPixel);
|
|
|
|
}
|
2018-09-08 19:51:50 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
public static (MemoryManager Memory, long Position) GetMemoryAndPosition(
|
|
|
|
IMemory Memory,
|
|
|
|
long Position)
|
2018-09-08 19:51:50 +02:00
|
|
|
{
|
|
|
|
if (Memory is NvGpuVmm Vmm)
|
|
|
|
{
|
|
|
|
return (Vmm.Memory, Vmm.GetPhysicalAddress(Position));
|
|
|
|
}
|
|
|
|
|
2018-10-31 02:43:02 +01:00
|
|
|
return ((MemoryManager)Memory, Position);
|
2018-09-08 19:51:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|