diff options
author | riperiperi <rhy3756547@hotmail.com> | 2023-08-14 07:41:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-14 08:41:11 +0200 |
commit | 33f544fd9248361440afd6013e0ef9d69971d6da (patch) | |
tree | 31d7ebbc76182427e0eb9ebb8e7ed0b173a756f7 /src | |
parent | b423197619dd8d9dda1c255a76105bf30e255dae (diff) |
GPU: Track basic buffer copies that modify texture memory (#5554)1.1.986
This branch changes the buffer copy fast path to notify memory tracking for all resources that aren't buffers. This fixes cases where games would copy buffer data directly into texture memory, which before would only work if the texture did not already exist. I imagine this happens when the guest driver is moving data between allocations or uploading it.
Since this only affects the fast path, cases where the source data has been modified from GPU (fast path copy destination doesn't count) will still fail to notify the texture, though I don't imagine games will do this. This should be resolved in future.
This should fix some texture issues with guest OpenGL games on switch, such as Dragon Quest Builders.
This may also be useful in future for games that move shader data around memory, if we end up using memory tracking for those.
Diffstat (limited to 'src')
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs | 2 | ||||
-rw-r--r-- | src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs index 99c571ba..f8f572c6 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs @@ -344,7 +344,7 @@ namespace Ryujinx.Graphics.Gpu.Memory // Optimization: If the data being copied is already in memory, then copy it directly instead of flushing from GPU. dstBuffer.ClearModified(dstAddress, size); - memoryManager.Physical.WriteUntracked(dstAddress, memoryManager.Physical.GetSpan(srcAddress, (int)size)); + memoryManager.Physical.WriteTrackedResource(dstAddress, memoryManager.Physical.GetSpan(srcAddress, (int)size), ResourceKind.Buffer); } } diff --git a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs index d0b4478e..1ca6071b 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs @@ -237,6 +237,18 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> + /// Writes data to the application process, triggering a precise memory tracking event. + /// </summary> + /// <param name="address">Address to write into</param> + /// <param name="data">Data to be written</param> + /// <param name="kind">Kind of the resource being written, which will not be signalled as CPU modified</param> + public void WriteTrackedResource(ulong address, ReadOnlySpan<byte> data, ResourceKind kind) + { + _cpuMemory.SignalMemoryTracking(address, (ulong)data.Length, true, precise: true, exemptId: (int)kind); + _cpuMemory.WriteUntracked(address, data); + } + + /// <summary> /// Writes data to the application process. /// </summary> /// <param name="address">Address to write into</param> |