From 111d14f74aca5e6467473ec73ab0825b9c0b4db1 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 27 Oct 2018 15:46:17 -0300 Subject: [PATCH] Crop instead of resizing on 2d engine texture copies (#482) * Crop instead of resizing on 2d engine texture copies * Remove unused local --- Ryujinx.Graphics/NvGpuEngine2d.cs | 48 ++++++++-------------------- Ryujinx.Graphics/NvGpuEngine2dReg.cs | 16 +++++++++- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Ryujinx.Graphics/NvGpuEngine2d.cs b/Ryujinx.Graphics/NvGpuEngine2d.cs index 4bf7c1e8..711df122 100644 --- a/Ryujinx.Graphics/NvGpuEngine2d.cs +++ b/Ryujinx.Graphics/NvGpuEngine2d.cs @@ -1,7 +1,7 @@ using Ryujinx.Graphics.Gal; using Ryujinx.Graphics.Memory; using Ryujinx.Graphics.Texture; -using System.Collections.Generic; +using System; namespace Ryujinx.Graphics { @@ -22,42 +22,24 @@ namespace Ryujinx.Graphics private NvGpu Gpu; - private Dictionary Methods; - public NvGpuEngine2d(NvGpu Gpu) { this.Gpu = Gpu; - Registers = new int[0xe00]; - - Methods = new Dictionary(); - - void AddMethod(int Meth, int Count, int Stride, NvGpuMethod Method) - { - while (Count-- > 0) - { - Methods.Add(Meth, Method); - - Meth += Stride; - } - } - - AddMethod(0xb5, 1, 1, TextureCopy); + Registers = new int[0x238]; } public void CallMethod(NvGpuVmm Vmm, NvGpuPBEntry PBEntry) { - if (Methods.TryGetValue(PBEntry.Method, out NvGpuMethod Method)) + WriteRegister(PBEntry); + + if ((NvGpuEngine2dReg)PBEntry.Method == NvGpuEngine2dReg.BlitSrcYInt) { - Method(Vmm, PBEntry); - } - else - { - WriteRegister(PBEntry); + TextureCopy(Vmm); } } - private void TextureCopy(NvGpuVmm Vmm, NvGpuPBEntry PBEntry) + private void TextureCopy(NvGpuVmm Vmm) { CopyOperation Operation = (CopyOperation)ReadRegister(NvGpuEngine2dReg.CopyOperation); @@ -107,17 +89,20 @@ namespace Ryujinx.Graphics Gpu.ResourceManager.SendTexture(Vmm, SrcKey, SrcTexture); Gpu.ResourceManager.SendTexture(Vmm, DstKey, DstTexture); + int Width = Math.Min(SrcWidth, DstWidth); + int Height = Math.Min(SrcHeight, DstHeight); + Gpu.Renderer.RenderTarget.Copy( SrcKey, DstKey, 0, 0, - SrcWidth, - SrcHeight, + Width, + Height, 0, 0, - DstWidth, - DstHeight); + Width, + Height); } private static GalMemoryLayout GetLayout(bool Linear) @@ -148,10 +133,5 @@ namespace Ryujinx.Graphics { return Registers[(int)Reg]; } - - private void WriteRegister(NvGpuEngine2dReg Reg, int Value) - { - Registers[(int)Reg] = Value; - } } } \ No newline at end of file diff --git a/Ryujinx.Graphics/NvGpuEngine2dReg.cs b/Ryujinx.Graphics/NvGpuEngine2dReg.cs index 00f6f578..fe003745 100644 --- a/Ryujinx.Graphics/NvGpuEngine2dReg.cs +++ b/Ryujinx.Graphics/NvGpuEngine2dReg.cs @@ -20,6 +20,20 @@ namespace Ryujinx.Graphics SrcWidth = 0x92, SrcHeight = 0x93, SrcAddress = 0x94, - CopyOperation = 0xab + ClipEnable = 0xa4, + CopyOperation = 0xab, + BlitControl = 0x223, + BlitDstX = 0x22c, + BlitDstY = 0x22d, + BlitDstW = 0x22e, + BlitDstH = 0x22f, + BlitDuDxFract = 0x230, + BlitDuDxInt = 0x231, + BlitDvDyFract = 0x232, + BlitDvDyInt = 0x233, + BlitSrcXFract = 0x234, + BlitSrcXInt = 0x235, + BlitSrcYFract = 0x236, + BlitSrcYInt = 0x237 } } \ No newline at end of file