diff --git a/ARMeilleure/Memory/MemoryManager.cs b/ARMeilleure/Memory/MemoryManager.cs index f813bd7e73..874dbdf8d1 100644 --- a/ARMeilleure/Memory/MemoryManager.cs +++ b/ARMeilleure/Memory/MemoryManager.cs @@ -552,6 +552,39 @@ namespace ARMeilleure.Memory return data; } + public Span GetSpan(ulong address, ulong size) + { + if (IsContiguous(address, size)) + { + return new Span((void*)Translate((long)address), (int)size); + } + else + { + return ReadBytes((long)address, (long)size); + } + } + + private bool IsContiguous(ulong address, ulong size) + { + ulong endVa = (address + size + PageMask) & ~(ulong)PageMask; + + address &= ~(ulong)PageMask; + + int pages = (int)((endVa - address) / PageSize); + + for (int page = 0; page < pages - 1; page++) + { + if (GetPtEntry((long)address) + PageSize != GetPtEntry((long)address + PageSize)) + { + return false; + } + + address += PageSize; + } + + return true; + } + public void WriteSByte(long position, sbyte value) { WriteByte(position, (byte)value); diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index 0acbd94ad0..5f448fc172 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -632,7 +632,7 @@ namespace Ryujinx.Graphics.Gpu.Memory dstOffset, (int)size); - dstBuffer.Flush(dstAddress, size); + // dstBuffer.Flush(dstAddress, size); } /// diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs index 71384df237..510f50a1ed 100644 --- a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs +++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs @@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Memory /// The data at the specified memory location public Span Read(ulong address, ulong size) { - return _cpuMemory.ReadBytes((long)address, (long)size); + return _cpuMemory.GetSpan(address, size); } /// diff --git a/Ryujinx.Graphics.Gpu/NvGpuFifo.cs b/Ryujinx.Graphics.Gpu/NvGpuFifo.cs index 853e5dfdd3..1e8a8767bc 100644 --- a/Ryujinx.Graphics.Gpu/NvGpuFifo.cs +++ b/Ryujinx.Graphics.Gpu/NvGpuFifo.cs @@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Gpu { _context.Methods.PerformDeferredDraws(); - _context.Renderer.FlushPipelines(); + // _context.Renderer.FlushPipelines(); break; }