From 91420a402c9e786ddef2811bb671003dd0a40565 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 9 Jun 2018 00:46:06 -0300 Subject: [PATCH] Use source texture size when doing reads for texure copy --- Ryujinx.Core/Gpu/NvGpuEngine2d.cs | 28 ++++++++++++++++++++++++---- Ryujinx.Core/Gpu/TextureWriter.cs | 19 +++++++++++++------ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Ryujinx.Core/Gpu/NvGpuEngine2d.cs b/Ryujinx.Core/Gpu/NvGpuEngine2d.cs index c419355e8..fd19bc54f 100644 --- a/Ryujinx.Core/Gpu/NvGpuEngine2d.cs +++ b/Ryujinx.Core/Gpu/NvGpuEngine2d.cs @@ -98,9 +98,19 @@ namespace Ryujinx.Core.Gpu if (IsFbTexture) { + //TODO: Change this when the correct frame buffer resolution is used. + //Currently, the frame buffer size is hardcoded to 1280x720. + SrcWidth = 1280; + SrcHeight = 720; + Gpu.Renderer.GetFrameBufferData(Tag, (byte[] Buffer) => { - CopyTexture(Vmm, DstTexture, Buffer); + CopyTexture( + Vmm, + DstTexture, + Buffer, + SrcWidth, + SrcHeight); }); } else @@ -109,13 +119,23 @@ namespace Ryujinx.Core.Gpu byte[] Buffer = Vmm.ReadBytes(SrcAddress, Size); - CopyTexture(Vmm, DstTexture, Buffer); + CopyTexture( + Vmm, + DstTexture, + Buffer, + SrcWidth, + SrcHeight); } } - private void CopyTexture(NvGpuVmm Vmm, Texture Texture, byte[] Buffer) + private void CopyTexture( + NvGpuVmm Vmm, + Texture Texture, + byte[] Buffer, + int Width, + int Height) { - TextureWriter.Write(Vmm, Texture, Buffer); + TextureWriter.Write(Vmm, Texture, Buffer, Width, Height); } private long MakeInt64From2xInt32(NvGpuEngine2dReg Reg) diff --git a/Ryujinx.Core/Gpu/TextureWriter.cs b/Ryujinx.Core/Gpu/TextureWriter.cs index 686d0dce6..5633614fb 100644 --- a/Ryujinx.Core/Gpu/TextureWriter.cs +++ b/Ryujinx.Core/Gpu/TextureWriter.cs @@ -6,21 +6,28 @@ namespace Ryujinx.Core.Gpu { static class TextureWriter { - public static void Write(IAMemory Memory, Texture Texture, byte[] Data) + public static void Write( + IAMemory Memory, + Texture Texture, + byte[] Data, + int Width, + int Height) { switch (Texture.Format) { - case GalTextureFormat.A8B8G8R8: Write4Bpp(Memory, Texture, Data); break; + case GalTextureFormat.A8B8G8R8: Write4Bpp(Memory, Texture, Data, Width, Height); break; default: throw new NotImplementedException(Texture.Format.ToString()); } } - private unsafe static void Write4Bpp(IAMemory Memory, Texture Texture, byte[] Data) + private unsafe static void Write4Bpp( + IAMemory Memory, + Texture Texture, + byte[] Data, + int Width, + int Height) { - int Width = Texture.Width; - int Height = Texture.Height; - ISwizzle Swizzle = TextureHelper.GetSwizzle(Texture, Width, 4); (AMemory CpuMem, long Position) = TextureHelper.GetMemoryAndPosition(