From 231fae1a4c97d7588655e9775f37c1dc9bd55fb0 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 8 Jun 2018 21:15:56 -0300 Subject: Texture/Vertex/Index data cache (#132) * Initial implementation of the texture cache * Cache vertex and index data aswell, some cleanup * Improve handling of the cache by storing cached ranges on a list for each page * Delete old data from the caches automatically, ensure that the cache is cleaned when the mapping/size changes, and some general cleanup --- Ryujinx.Core/Gpu/TextureFactory.cs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'Ryujinx.Core/Gpu/TextureFactory.cs') diff --git a/Ryujinx.Core/Gpu/TextureFactory.cs b/Ryujinx.Core/Gpu/TextureFactory.cs index 5206c125..9262b947 100644 --- a/Ryujinx.Core/Gpu/TextureFactory.cs +++ b/Ryujinx.Core/Gpu/TextureFactory.cs @@ -5,7 +5,7 @@ namespace Ryujinx.Core.Gpu { static class TextureFactory { - public static GalTexture MakeTexture(NvGpu Gpu, NvGpuVmm Vmm, long TicPosition) + public static GalTexture MakeTexture(NvGpuVmm Vmm, long TicPosition) { int[] Tic = ReadWords(Vmm, TicPosition, 8); @@ -16,6 +16,25 @@ namespace Ryujinx.Core.Gpu 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 GalTexture( + 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; @@ -40,17 +59,7 @@ namespace Ryujinx.Core.Gpu Swizzle, Format); - byte[] Data = TextureReader.Read(Vmm, Texture); - - return new GalTexture( - Data, - Width, - Height, - Format, - XSource, - YSource, - ZSource, - WSource); + return TextureReader.Read(Vmm, Texture); } public static GalTextureSampler MakeSampler(NvGpu Gpu, NvGpuVmm Vmm, long TscPosition) -- cgit v1.2.3