From 65778a6b78ab8bde4090478482227e40c551db4d Mon Sep 17 00:00:00 2001 From: riperiperi Date: Thu, 24 Nov 2022 14:50:15 +0000 Subject: GPU: Don't trigger uploads for redundant buffer updates (#3828) * Initial implementation * Actually do The Thing * Add remark about performance to IVirtualMemoryManager --- Ryujinx.Memory/AddressSpaceManager.cs | 8 ++++++++ Ryujinx.Memory/IVirtualMemoryManager.cs | 11 +++++++++++ 2 files changed, 19 insertions(+) (limited to 'Ryujinx.Memory') diff --git a/Ryujinx.Memory/AddressSpaceManager.cs b/Ryujinx.Memory/AddressSpaceManager.cs index 45f3225e..ffe880bf 100644 --- a/Ryujinx.Memory/AddressSpaceManager.cs +++ b/Ryujinx.Memory/AddressSpaceManager.cs @@ -136,6 +136,14 @@ namespace Ryujinx.Memory } } + /// + public bool WriteWithRedundancyCheck(ulong va, ReadOnlySpan data) + { + Write(va, data); + + return true; + } + /// public ReadOnlySpan GetSpan(ulong va, int size, bool tracked = false) { diff --git a/Ryujinx.Memory/IVirtualMemoryManager.cs b/Ryujinx.Memory/IVirtualMemoryManager.cs index f97cb0b5..c8a74f66 100644 --- a/Ryujinx.Memory/IVirtualMemoryManager.cs +++ b/Ryujinx.Memory/IVirtualMemoryManager.cs @@ -58,6 +58,17 @@ namespace Ryujinx.Memory /// Throw for unhandled invalid or unmapped memory accesses void Write(ulong va, ReadOnlySpan data); + /// + /// Writes data to the application process, returning false if the data was not changed. + /// This triggers read memory tracking, as a redundancy check would be useless if the data is not up to date. + /// + /// The memory manager can return that memory has changed when it hasn't to avoid expensive data copies. + /// Virtual address to write the data into + /// Data to be written + /// Throw for unhandled invalid or unmapped memory accesses + /// True if the data was changed, false otherwise + bool WriteWithRedundancyCheck(ulong va, ReadOnlySpan data); + void Fill(ulong va, ulong size, byte value) { const int MaxChunkSize = 1 << 24; -- cgit v1.2.3