aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Texture/TextureFactory.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-09-18 01:30:35 -0300
committerGitHub <noreply@github.com>2018-09-18 01:30:35 -0300
commitd4187aaa9d7194aa26d04aee838edbc3a38f1862 (patch)
tree06fe725c1067b4aeca21749799b835d85e7d2787 /Ryujinx.Graphics/Texture/TextureFactory.cs
parentbec95cacc1061f91373a1e3a1411981af7fe2e4e (diff)
Allow "reinterpretation" of framebuffer/zeta formats (#418)
* (Re)Implement format reinterpretation, other changes * Implement writeback to guest memory, some refactoring * More refactoring, implement reinterpretation the old way again * Clean up * Some fixes on M2MF (old Dma engine), added partial support for P2MF, fix conditional ssy, add Z24S8 zeta format, other fixes * nit: Formatting * Address PR feedback
Diffstat (limited to 'Ryujinx.Graphics/Texture/TextureFactory.cs')
-rw-r--r--Ryujinx.Graphics/Texture/TextureFactory.cs52
1 files changed, 14 insertions, 38 deletions
diff --git a/Ryujinx.Graphics/Texture/TextureFactory.cs b/Ryujinx.Graphics/Texture/TextureFactory.cs
index fa7a0f80..766c53da 100644
--- a/Ryujinx.Graphics/Texture/TextureFactory.cs
+++ b/Ryujinx.Graphics/Texture/TextureFactory.cs
@@ -17,44 +17,20 @@ namespace Ryujinx.Graphics.Texture
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);
-
- GalImageFormat Format = GetImageFormat(Tic);
-
- long TextureAddress = (uint)Tic[1];
-
- TextureAddress |= (long)((ushort)Tic[2]) << 32;
-
TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7);
+ GalMemoryLayout Layout;
+
if (Swizzle == TextureSwizzle.BlockLinear ||
Swizzle == TextureSwizzle.BlockLinearColorKey)
{
- TextureAddress &= ~0x1ffL;
+ Layout = GalMemoryLayout.BlockLinear;
}
- else if (Swizzle == TextureSwizzle.Pitch ||
- Swizzle == TextureSwizzle.PitchColorKey)
+ else
{
- TextureAddress &= ~0x1fL;
+ Layout = GalMemoryLayout.Pitch;
}
- int Pitch = (Tic[3] & 0xffff) << 5;
-
int BlockHeightLog2 = (Tic[3] >> 3) & 7;
int TileWidthLog2 = (Tic[3] >> 10) & 7;
@@ -64,17 +40,17 @@ namespace Ryujinx.Graphics.Texture
int Width = (Tic[4] & 0xffff) + 1;
int Height = (Tic[5] & 0xffff) + 1;
- TextureInfo Texture = new TextureInfo(
- TextureAddress,
+ return new GalImage(
Width,
Height,
- Pitch,
- BlockHeight,
TileWidth,
- Swizzle,
- Format);
-
- return TextureReader.Read(Vmm, Texture);
+ BlockHeight,
+ Layout,
+ Format,
+ XSource,
+ YSource,
+ ZSource,
+ WSource);
}
public static GalTextureSampler MakeSampler(NvGpu Gpu, NvGpuVmm Vmm, long TscPosition)
@@ -107,7 +83,7 @@ namespace Ryujinx.Graphics.Texture
private static GalImageFormat GetImageFormat(int[] Tic)
{
- GalTextureType RType = (GalTextureType)((Tic[0] >> 7) & 7);
+ 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);