aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2021-09-29 01:27:03 +0100
committerGitHub <noreply@github.com>2021-09-29 02:27:03 +0200
commitd92fff541bf6fddadabf6ab628ddf8fec41cd52e (patch)
treeda60acfa16612bb2a33de2bd5b0a0534dd84aa09 /Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
parentb6e093b0fce3dc4fe607a84f57e6406b5ab8e387 (diff)
Replace CacheResourceWrite with more general "precise" write (#2684)
* Replace CacheResourceWrite with more general "precise" write The goal of CacheResourceWrite was to notify GPU resources when they were modified directly, by looking up the modified address/size in a structure and calling a method on each resource. The downside of this is that each resource cache has to be queried individually, they all have to implement their own way to do this, and it can only signal to resources using the same PhysicalMemory instance. This PR adds the ability to signal a write as "precise" on the tracking, which signals a special handler (if present) which can be used to avoid unnecessary flush actions, or maybe even more. For buffers, precise writes specifically do not flush, and instead punch a hole in the modified range list to indicate that the data on GPU has been replaced. The downside is that precise actions must ignore the page protection bits and always signal - as they need to notify the target resource to ignore the sequence number optimization. I had to reintroduce the sequence number increment after I2M, as removing it was causing issues in rabbids kingdom battle. However - all resources modified by I2M are notified directly to lower their sequence number, so the problem is likely that another unrelated resource is not being properly updated. Thankfully, doing this does not affect performance in the games I tested. This should fix regressions from #2624. Test any games that were broken by that. (RF4, rabbids kingdom battle) I've also added a sequence number increment to ThreedClass.IncrementSyncpoint, as it seems to fix buffer corruption in OpenGL homebrew. (this was a regression from removing sequence number increment from constant buffer update - another unrelated resource thing) * Add tests. * Add XML docs for GpuRegionHandle * Skip UpdateProtection if only precise actions were called This allows precise actions to skip reprotection costs.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs33
1 files changed, 11 insertions, 22 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
index 0ec41a8f..d292fab0 100644
--- a/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
+++ b/Ryujinx.Graphics.Gpu/Memory/PhysicalMemory.cs
@@ -81,28 +81,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
- /// Write data to memory that is destined for a resource in a cache.
- /// This avoids triggering write tracking when possible, which can avoid flushes and incrementing sequence number.
- /// </summary>
- /// <param name="memoryManager">The GPU memory manager</param>
- /// <param name="gpuVa">GPU virtual address to write the data into</param>
- /// <param name="data">The data to be written</param>
- public void CacheResourceWrite(MemoryManager memoryManager, ulong gpuVa, ReadOnlySpan<byte> data)
- {
- if (TextureCache.IsTextureInRange(memoryManager, gpuVa, (ulong)data.Length))
- {
- // No fast path yet - copy the data back and trigger write tracking.
- memoryManager.Write(gpuVa, data);
- _context.AdvanceSequence();
- }
- else
- {
- BufferCache.ForceDirty(memoryManager, gpuVa, (ulong)data.Length);
- memoryManager.WriteUntracked(gpuVa, data);
- }
- }
-
- /// <summary>
/// Gets a span of data from the application process.
/// </summary>
/// <param name="address">Start address of the range</param>
@@ -180,6 +158,17 @@ 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>
+ public void WriteTrackedResource(ulong address, ReadOnlySpan<byte> data)
+ {
+ _cpuMemory.SignalMemoryTracking(address, (ulong)data.Length, true, precise: true);
+ _cpuMemory.WriteUntracked(address, data);
+ }
+
+ /// <summary>
/// Writes data to the application process.
/// </summary>
/// <param name="address">Address to write into</param>