aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/Gpu/Texture
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/Gpu/Texture')
-rw-r--r--Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs59
-rw-r--r--Ryujinx.HLE/Gpu/Texture/ISwizzle.cs7
-rw-r--r--Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs19
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureFactory.cs125
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureHelper.cs204
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureInfo.cs60
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureReader.cs366
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs11
-rw-r--r--Ryujinx.HLE/Gpu/Texture/TextureWriter.cs33
9 files changed, 0 insertions, 884 deletions
diff --git a/Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs b/Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs
deleted file mode 100644
index e66d7613..00000000
--- a/Ryujinx.HLE/Gpu/Texture/BlockLinearSwizzle.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-
-namespace Ryujinx.HLE.Gpu.Texture
-{
- class BlockLinearSwizzle : ISwizzle
- {
- private int BhShift;
- private int BppShift;
- private int BhMask;
-
- private int XShift;
- private int GobStride;
-
- public BlockLinearSwizzle(int Width, int Bpp, int BlockHeight = 16)
- {
- BhMask = (BlockHeight * 8) - 1;
-
- BhShift = CountLsbZeros(BlockHeight * 8);
- BppShift = CountLsbZeros(Bpp);
-
- int WidthInGobs = (int)MathF.Ceiling(Width * Bpp / 64f);
-
- GobStride = 512 * BlockHeight * WidthInGobs;
-
- XShift = CountLsbZeros(512 * BlockHeight);
- }
-
- private int CountLsbZeros(int Value)
- {
- int Count = 0;
-
- while (((Value >> Count) & 1) == 0)
- {
- Count++;
- }
-
- return Count;
- }
-
- public int GetSwizzleOffset(int X, int Y)
- {
- X <<= BppShift;
-
- int Position = (Y >> BhShift) * GobStride;
-
- Position += (X >> 6) << XShift;
-
- Position += ((Y & BhMask) >> 3) << 9;
-
- Position += ((X & 0x3f) >> 5) << 8;
- Position += ((Y & 0x07) >> 1) << 6;
- Position += ((X & 0x1f) >> 4) << 5;
- Position += ((Y & 0x01) >> 0) << 4;
- Position += ((X & 0x0f) >> 0) << 0;
-
- return Position;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Texture/ISwizzle.cs b/Ryujinx.HLE/Gpu/Texture/ISwizzle.cs
deleted file mode 100644
index 222aab16..00000000
--- a/Ryujinx.HLE/Gpu/Texture/ISwizzle.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Ryujinx.HLE.Gpu.Texture
-{
- interface ISwizzle
- {
- int GetSwizzleOffset(int X, int Y);
- }
-} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs b/Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs
deleted file mode 100644
index 720f7832..00000000
--- a/Ryujinx.HLE/Gpu/Texture/LinearSwizzle.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace Ryujinx.HLE.Gpu.Texture
-{
- class LinearSwizzle : ISwizzle
- {
- private int Pitch;
- private int Bpp;
-
- public LinearSwizzle(int Pitch, int Bpp)
- {
- this.Pitch = Pitch;
- this.Bpp = Bpp;
- }
-
- public int GetSwizzleOffset(int X, int Y)
- {
- return X * Bpp + Y * Pitch;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureFactory.cs b/Ryujinx.HLE/Gpu/Texture/TextureFactory.cs
deleted file mode 100644
index 0ef33d3b..00000000
--- a/Ryujinx.HLE/Gpu/Texture/TextureFactory.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using Ryujinx.Graphics.Gal;
-using Ryujinx.HLE.Gpu.Memory;
-using System;
-
-namespace Ryujinx.HLE.Gpu.Texture
-{
- static class TextureFactory
- {
- public static GalImage MakeTexture(NvGpuVmm Vmm, long TicPosition)
- {
- int[] Tic = ReadWords(Vmm, TicPosition, 8);
-
- GalTextureType RType = (GalTextureType)((Tic[0] >> 7) & 7);
- GalTextureType GType = (GalTextureType)((Tic[0] >> 10) & 7);
- GalTextureType BType = (GalTextureType)((Tic[0] >> 13) & 7);
- GalTextureType AType = (GalTextureType)((Tic[0] >> 16) & 7);
-
- GalImageFormat Format = ImageFormatConverter.ConvertTexture((GalTextureFormat)(Tic[0] & 0x7f), RType, GType, BType, AType);
-
- GalTextureSource XSource = (GalTextureSource)((Tic[0] >> 19) & 7);
- GalTextureSource YSource = (GalTextureSource)((Tic[0] >> 22) & 7);
- GalTextureSource ZSource = (GalTextureSource)((Tic[0] >> 25) & 7);
- GalTextureSource WSource = (GalTextureSource)((Tic[0] >> 28) & 7);
-
- int Width = (Tic[4] & 0xffff) + 1;
- int Height = (Tic[5] & 0xffff) + 1;
-
- return new GalImage(
- Width,
- Height,
- Format,
- XSource,
- YSource,
- ZSource,
- WSource);
- }
-
- public static byte[] GetTextureData(NvGpuVmm Vmm, long TicPosition)
- {
- int[] Tic = ReadWords(Vmm, TicPosition, 8);
-
- GalTextureFormat Format = (GalTextureFormat)(Tic[0] & 0x7f);
-
- long TextureAddress = (uint)Tic[1];
-
- TextureAddress |= (long)((ushort)Tic[2]) << 32;
-
- TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7);
-
- if (Swizzle == TextureSwizzle.BlockLinear ||
- Swizzle == TextureSwizzle.BlockLinearColorKey)
- {
- TextureAddress &= ~0x1ffL;
- }
- else if (Swizzle == TextureSwizzle.Pitch ||
- Swizzle == TextureSwizzle.PitchColorKey)
- {
- TextureAddress &= ~0x1fL;
- }
-
- int Pitch = (Tic[3] & 0xffff) << 5;
-
- int BlockHeightLog2 = (Tic[3] >> 3) & 7;
- int TileWidthLog2 = (Tic[3] >> 10) & 7;
-
- int BlockHeight = 1 << BlockHeightLog2;
- int TileWidth = 1 << TileWidthLog2;
-
- int Width = (Tic[4] & 0xffff) + 1;
- int Height = (Tic[5] & 0xffff) + 1;
-
- TextureInfo Texture = new TextureInfo(
- TextureAddress,
- Width,
- Height,
- Pitch,
- BlockHeight,
- TileWidth,
- Swizzle,
- Format);
-
- return TextureReader.Read(Vmm, Texture);
- }
-
- public static GalTextureSampler MakeSampler(NvGpu Gpu, NvGpuVmm Vmm, long TscPosition)
- {
- int[] Tsc = ReadWords(Vmm, TscPosition, 8);
-
- GalTextureWrap AddressU = (GalTextureWrap)((Tsc[0] >> 0) & 7);
- GalTextureWrap AddressV = (GalTextureWrap)((Tsc[0] >> 3) & 7);
- GalTextureWrap AddressP = (GalTextureWrap)((Tsc[0] >> 6) & 7);
-
- GalTextureFilter MagFilter = (GalTextureFilter) ((Tsc[1] >> 0) & 3);
- GalTextureFilter MinFilter = (GalTextureFilter) ((Tsc[1] >> 4) & 3);
- GalTextureMipFilter MipFilter = (GalTextureMipFilter)((Tsc[1] >> 6) & 3);
-
- GalColorF BorderColor = new GalColorF(
- BitConverter.Int32BitsToSingle(Tsc[4]),
- BitConverter.Int32BitsToSingle(Tsc[5]),
- BitConverter.Int32BitsToSingle(Tsc[6]),
- BitConverter.Int32BitsToSingle(Tsc[7]));
-
- return new GalTextureSampler(
- AddressU,
- AddressV,
- AddressP,
- MinFilter,
- MagFilter,
- MipFilter,
- BorderColor);
- }
-
- private static int[] ReadWords(NvGpuVmm Vmm, long Position, int Count)
- {
- int[] Words = new int[Count];
-
- for (int Index = 0; Index < Count; Index++, Position += 4)
- {
- Words[Index] = Vmm.ReadInt32(Position);
- }
-
- return Words;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs b/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
deleted file mode 100644
index 2683174d..00000000
--- a/Ryujinx.HLE/Gpu/Texture/TextureHelper.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-using ChocolArm64.Memory;
-using Ryujinx.Graphics.Gal;
-using Ryujinx.HLE.Gpu.Memory;
-using System;
-
-namespace Ryujinx.HLE.Gpu.Texture
-{
- static class TextureHelper
- {
- public static ISwizzle GetSwizzle(TextureInfo Texture, int BlockWidth, int Bpp)
- {
- int Width = (Texture.Width + (BlockWidth - 1)) / BlockWidth;
-
- int AlignMask = Texture.TileWidth * (64 / Bpp) - 1;
-
- Width = (Width + AlignMask) & ~AlignMask;
-
- switch (Texture.Swizzle)
- {
- case TextureSwizzle._1dBuffer:
- case TextureSwizzle.Pitch:
- case TextureSwizzle.PitchColorKey:
- return new LinearSwizzle(Texture.Pitch, Bpp);
-
- case TextureSwizzle.BlockLinear:
- case TextureSwizzle.BlockLinearColorKey:
- return new BlockLinearSwizzle(Width, Bpp, Texture.BlockHeight);
- }
-
- throw new NotImplementedException(Texture.Swizzle.ToString());
- }
-
- public static int GetTextureSize(GalImage Image)
- {
- switch (Image.Format)
- {
- case GalImageFormat.R32G32B32A32_SFLOAT:
- case GalImageFormat.R32G32B32A32_SINT:
- case GalImageFormat.R32G32B32A32_UINT:
- return Image.Width * Image.Height * 16;
-
- case GalImageFormat.R16G16B16A16_SFLOAT:
- case GalImageFormat.R16G16B16A16_SINT:
- case GalImageFormat.R16G16B16A16_SNORM:
- case GalImageFormat.R16G16B16A16_UINT:
- case GalImageFormat.R16G16B16A16_UNORM:
- case GalImageFormat.D32_SFLOAT_S8_UINT:
- case GalImageFormat.R32G32_SFLOAT:
- case GalImageFormat.R32G32_SINT:
- case GalImageFormat.R32G32_UINT:
- return Image.Width * Image.Height * 8;
-
- case GalImageFormat.A8B8G8R8_SINT_PACK32:
- case GalImageFormat.A8B8G8R8_SNORM_PACK32:
- case GalImageFormat.A8B8G8R8_UINT_PACK32:
- case GalImageFormat.A8B8G8R8_UNORM_PACK32:
- case GalImageFormat.A8B8G8R8_SRGB_PACK32:
- case GalImageFormat.A2B10G10R10_SINT_PACK32:
- case GalImageFormat.A2B10G10R10_SNORM_PACK32:
- case GalImageFormat.A2B10G10R10_UINT_PACK32:
- case GalImageFormat.A2B10G10R10_UNORM_PACK32:
- case GalImageFormat.R16G16_SFLOAT:
- case GalImageFormat.R16G16_SINT:
- case GalImageFormat.R16G16_SNORM:
- case GalImageFormat.R16G16_UINT:
- case GalImageFormat.R16G16_UNORM:
- case GalImageFormat.R32_SFLOAT:
- case GalImageFormat.R32_SINT:
- case GalImageFormat.R32_UINT:
- case GalImageFormat.D32_SFLOAT:
- case GalImageFormat.B10G11R11_UFLOAT_PACK32:
- case GalImageFormat.D24_UNORM_S8_UINT:
- return Image.Width * Image.Height * 4;
-
- case GalImageFormat.B4G4R4A4_UNORM_PACK16:
- case GalImageFormat.A1R5G5B5_UNORM_PACK16:
- case GalImageFormat.B5G6R5_UNORM_PACK16:
- case GalImageFormat.R8G8_SINT:
- case GalImageFormat.R8G8_SNORM:
- case GalImageFormat.R8G8_UINT:
- case GalImageFormat.R8G8_UNORM:
- case GalImageFormat.R16_SFLOAT:
- case GalImageFormat.R16_SINT:
- case GalImageFormat.R16_SNORM:
- case GalImageFormat.R16_UINT:
- case GalImageFormat.R16_UNORM:
- case GalImageFormat.D16_UNORM:
- return Image.Width * Image.Height * 2;
-
- case GalImageFormat.R8_SINT:
- case GalImageFormat.R8_SNORM:
- case GalImageFormat.R8_UINT:
- case GalImageFormat.R8_UNORM:
- return Image.Width * Image.Height;
-
- case GalImageFormat.BC1_RGBA_UNORM_BLOCK:
- case GalImageFormat.BC4_SNORM_BLOCK:
- case GalImageFormat.BC4_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 4, 4, 8);
- }
-
- case GalImageFormat.BC6H_SFLOAT_BLOCK:
- case GalImageFormat.BC6H_UFLOAT_BLOCK:
- case GalImageFormat.BC7_UNORM_BLOCK:
- case GalImageFormat.BC2_UNORM_BLOCK:
- case GalImageFormat.BC3_UNORM_BLOCK:
- case GalImageFormat.BC5_SNORM_BLOCK:
- case GalImageFormat.BC5_UNORM_BLOCK:
- case GalImageFormat.ASTC_4x4_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 4, 4, 16);
- }
-
- case GalImageFormat.ASTC_5x5_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 5, 5, 16);
- }
-
- case GalImageFormat.ASTC_6x6_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 6, 6, 16);
- }
-
- case GalImageFormat.ASTC_8x8_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 8, 8, 16);
- }
-
- case GalImageFormat.ASTC_10x10_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 10, 10, 16);
- }
-
- case GalImageFormat.ASTC_12x12_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 12, 12, 16);
- }
-
- case GalImageFormat.ASTC_5x4_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 5, 4, 16);
- }
-
- case GalImageFormat.ASTC_6x5_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 6, 5, 16);
- }
-
- case GalImageFormat.ASTC_8x6_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 8, 6, 16);
- }
-
- case GalImageFormat.ASTC_10x8_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 10, 8, 16);
- }
-
- case GalImageFormat.ASTC_12x10_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 12, 10, 16);
- }
-
- case GalImageFormat.ASTC_8x5_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 8, 5, 16);
- }
-
- case GalImageFormat.ASTC_10x5_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 10, 5, 16);
- }
-
- case GalImageFormat.ASTC_10x6_UNORM_BLOCK:
- {
- return CompressedTextureSize(Image.Width, Image.Height, 10, 6, 16);
- }
- }
-
- throw new NotImplementedException(Image.Format.ToString());
- }
-
- public static int CompressedTextureSize(int TextureWidth, int TextureHeight, int BlockWidth, int BlockHeight, int Bpb)
- {
- int W = (TextureWidth + (BlockWidth - 1)) / BlockWidth;
- int H = (TextureHeight + (BlockHeight - 1)) / BlockHeight;
-
- return W * H * Bpb;
- }
-
- public static (AMemory Memory, long Position) GetMemoryAndPosition(
- IAMemory Memory,
- long Position)
- {
- if (Memory is NvGpuVmm Vmm)
- {
- return (Vmm.Memory, Vmm.GetPhysicalAddress(Position));
- }
-
- return ((AMemory)Memory, Position);
- }
- }
-}
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureInfo.cs b/Ryujinx.HLE/Gpu/Texture/TextureInfo.cs
deleted file mode 100644
index 2a98ce00..00000000
--- a/Ryujinx.HLE/Gpu/Texture/TextureInfo.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using Ryujinx.Graphics.Gal;
-
-namespace Ryujinx.HLE.Gpu.Texture
-{
- struct TextureInfo
- {
- public long Position { get; private set; }
-
- public int Width { get; private set; }
- public int Height { get; private set; }
- public int Pitch { get; private set; }
-
- public int BlockHeight { get; private set; }
- public int TileWidth { get; private set; }
-
- public TextureSwizzle Swizzle { get; private set; }
-
- public GalTextureFormat Format { get; private set; }
-
- public TextureInfo(
- long Position,
- int Width,
- int Height)
- {
- this.Position = Position;
- this.Width = Width;
- this.Height = Height;
-
- Pitch = 0;
-
- BlockHeight = 16;
-
- TileWidth = 1;
-
- Swizzle = TextureSwizzle.BlockLinear;
-
- Format = GalTextureFormat.A8B8G8R8;
- }
-
- public TextureInfo(
- long Position,
- int Width,
- int Height,
- int Pitch,
- int BlockHeight,
- int TileWidth,
- TextureSwizzle Swizzle,
- GalTextureFormat Format)
- {
- this.Position = Position;
- this.Width = Width;
- this.Height = Height;
- this.Pitch = Pitch;
- this.BlockHeight = BlockHeight;
- this.TileWidth = TileWidth;
- this.Swizzle = Swizzle;
- this.Format = Format;
- }
- }
-} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs b/Ryujinx.HLE/Gpu/Texture/TextureReader.cs
deleted file mode 100644
index d293bf9f..00000000
--- a/Ryujinx.HLE/Gpu/Texture/TextureReader.cs
+++ /dev/null
@@ -1,366 +0,0 @@
-using ChocolArm64.Memory;
-using Ryujinx.Graphics.Gal;
-using System;
-
-namespace Ryujinx.HLE.Gpu.Texture
-{
- static class TextureReader
- {
- public static byte[] Read(IAMemory Memory, TextureInfo Texture)
- {
- switch (Texture.Format)
- {
- case GalTextureFormat.R32G32B32A32: return Read16Bpp (Memory, Texture);
- case GalTextureFormat.R16G16B16A16: return Read8Bpp (Memory, Texture);
- case GalTextureFormat.R32G32: return Read8Bpp (Memory, Texture);
- case GalTextureFormat.A8B8G8R8: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.A2B10G10R10: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.R32: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.BF10GF11RF11: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.Z24S8: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.A1B5G5R5: return Read5551 (Memory, Texture);
- case GalTextureFormat.B5G6R5: return Read565 (Memory, Texture);
- case GalTextureFormat.A4B4G4R4: return Read2Bpp (Memory, Texture);
- case GalTextureFormat.G8R8: return Read2Bpp (Memory, Texture);
- case GalTextureFormat.R16: return Read2Bpp (Memory, Texture);
- case GalTextureFormat.R8: return Read1Bpp (Memory, Texture);
- case GalTextureFormat.BC6H_SF16: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.BC6H_UF16: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.BC7U: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.BC1: return Read8Bpt4x4 (Memory, Texture);
- case GalTextureFormat.BC2: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.BC3: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.BC4: return Read8Bpt4x4 (Memory, Texture);
- case GalTextureFormat.BC5: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.ZF32: return Read4Bpp (Memory, Texture);
- case GalTextureFormat.ZF32_X24S8: return Read8Bpp (Memory, Texture);
- case GalTextureFormat.Astc2D4x4: return Read16BptCompressedTexture(Memory, Texture, 4, 4);
- case GalTextureFormat.Astc2D5x5: return Read16BptCompressedTexture(Memory, Texture, 5, 5);
- case GalTextureFormat.Astc2D6x6: return Read16BptCompressedTexture(Memory, Texture, 6, 6);
- case GalTextureFormat.Astc2D8x8: return Read16BptCompressedTexture(Memory, Texture, 8, 8);
- case GalTextureFormat.Astc2D10x10: return Read16BptCompressedTexture(Memory, Texture, 10, 10);
- case GalTextureFormat.Astc2D12x12: return Read16BptCompressedTexture(Memory, Texture, 12, 12);
- case GalTextureFormat.Astc2D5x4: return Read16BptCompressedTexture(Memory, Texture, 5, 4);
- case GalTextureFormat.Astc2D6x5: return Read16BptCompressedTexture(Memory, Texture, 6, 5);
- case GalTextureFormat.Astc2D8x6: return Read16BptCompressedTexture(Memory, Texture, 8, 6);
- case GalTextureFormat.Astc2D10x8: return Read16BptCompressedTexture(Memory, Texture, 10, 8);
- case GalTextureFormat.Astc2D12x10: return Read16BptCompressedTexture(Memory, Texture, 12, 10);
- case GalTextureFormat.Astc2D8x5: return Read16BptCompressedTexture(Memory, Texture, 8, 5);
- case GalTextureFormat.Astc2D10x5: return Read16BptCompressedTexture(Memory, Texture, 10, 5);
- case GalTextureFormat.Astc2D10x6: return Read16BptCompressedTexture(Memory, Texture, 10, 6);
- }
-
- throw new NotImplementedException("0x" + ((int)Texture.Format).ToString("x2"));
- }
-
- private unsafe static byte[] Read1Bpp(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 1);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- byte Pixel = CpuMem.ReadByte(Position + Offset);
-
- *(BuffPtr + OutOffs) = Pixel;
-
- OutOffs++;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read5551(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 2];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- uint Pixel = (uint)CpuMem.ReadInt16(Position + Offset);
-
- Pixel = (Pixel & 0x001f) << 11 |
- (Pixel & 0x03e0) << 1 |
- (Pixel & 0x7c00) >> 9 |
- (Pixel & 0x8000) >> 15;
-
- *(short*)(BuffPtr + OutOffs) = (short)Pixel;
-
- OutOffs += 2;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read565(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 2];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- uint Pixel = (uint)CpuMem.ReadInt16(Position + Offset);
-
- Pixel = (Pixel & 0x001f) << 11 |
- (Pixel & 0x07e0) |
- (Pixel & 0xf800) >> 11;
-
- *(short*)(BuffPtr + OutOffs) = (short)Pixel;
-
- OutOffs += 2;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read2Bpp(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 2];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 2);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- short Pixel = CpuMem.ReadInt16(Position + Offset);
-
- *(short*)(BuffPtr + OutOffs) = Pixel;
-
- OutOffs += 2;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read4Bpp(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 4];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 4);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- int Pixel = CpuMem.ReadInt32(Position + Offset);
-
- *(int*)(BuffPtr + OutOffs) = Pixel;
-
- OutOffs += 4;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read8Bpp(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 8];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 8);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- long Pixel = CpuMem.ReadInt64(Position + Offset);
-
- *(long*)(BuffPtr + OutOffs) = Pixel;
-
- OutOffs += 8;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read16Bpp(IAMemory Memory, TextureInfo Texture)
- {
- int Width = Texture.Width;
- int Height = Texture.Height;
-
- byte[] Output = new byte[Width * Height * 16];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 16);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- long PxLow = CpuMem.ReadInt64(Position + Offset + 0);
- long PxHigh = CpuMem.ReadInt64(Position + Offset + 8);
-
- *(long*)(BuffPtr + OutOffs + 0) = PxLow;
- *(long*)(BuffPtr + OutOffs + 8) = PxHigh;
-
- OutOffs += 16;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read8Bpt4x4(IAMemory Memory, TextureInfo Texture)
- {
- int Width = (Texture.Width + 3) / 4;
- int Height = (Texture.Height + 3) / 4;
-
- byte[] Output = new byte[Width * Height * 8];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 4, 8);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- long Tile = CpuMem.ReadInt64(Position + Offset);
-
- *(long*)(BuffPtr + OutOffs) = Tile;
-
- OutOffs += 8;
- }
- }
-
- return Output;
- }
-
- private unsafe static byte[] Read16BptCompressedTexture(IAMemory Memory, TextureInfo Texture, int BlockWidth, int BlockHeight)
- {
- int Width = (Texture.Width + (BlockWidth - 1)) / BlockWidth;
- int Height = (Texture.Height + (BlockHeight - 1)) / BlockHeight;
-
- byte[] Output = new byte[Width * Height * 16];
-
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, BlockWidth, 16);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Output)
- {
- long OutOffs = 0;
-
- for (int Y = 0; Y < Height; Y++)
- for (int X = 0; X < Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- long Tile0 = CpuMem.ReadInt64(Position + Offset + 0);
- long Tile1 = CpuMem.ReadInt64(Position + Offset + 8);
-
- *(long*)(BuffPtr + OutOffs + 0) = Tile0;
- *(long*)(BuffPtr + OutOffs + 8) = Tile1;
-
- OutOffs += 16;
- }
- }
-
- return Output;
- }
- }
-}
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs b/Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs
deleted file mode 100644
index 076df97a..00000000
--- a/Ryujinx.HLE/Gpu/Texture/TextureSwizzle.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Ryujinx.HLE.Gpu.Texture
-{
- enum TextureSwizzle
- {
- _1dBuffer = 0,
- PitchColorKey = 1,
- Pitch = 2,
- BlockLinear = 3,
- BlockLinearColorKey = 4
- }
-} \ No newline at end of file
diff --git a/Ryujinx.HLE/Gpu/Texture/TextureWriter.cs b/Ryujinx.HLE/Gpu/Texture/TextureWriter.cs
deleted file mode 100644
index 6c3dda6b..00000000
--- a/Ryujinx.HLE/Gpu/Texture/TextureWriter.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using ChocolArm64.Memory;
-
-namespace Ryujinx.HLE.Gpu.Texture
-{
- static class TextureWriter
- {
- public unsafe static void Write(IAMemory Memory, TextureInfo Texture, byte[] Data)
- {
- ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, 1, 4);
-
- (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(
- Memory,
- Texture.Position);
-
- fixed (byte* BuffPtr = Data)
- {
- long InOffs = 0;
-
- for (int Y = 0; Y < Texture.Height; Y++)
- for (int X = 0; X < Texture.Width; X++)
- {
- long Offset = (uint)Swizzle.GetSwizzleOffset(X, Y);
-
- int Pixel = *(int*)(BuffPtr + InOffs);
-
- CpuMem.WriteInt32(Position + Offset, Pixel);
-
- InOffs += 4;
- }
- }
- }
- }
-}