mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-22 15:52:01 +00:00
d92fff541b
* 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.
71 lines
2.7 KiB
C#
71 lines
2.7 KiB
C#
using Ryujinx.Memory.Range;
|
|
|
|
namespace Ryujinx.Memory.Tracking
|
|
{
|
|
/// <summary>
|
|
/// A region of memory.
|
|
/// </summary>
|
|
abstract class AbstractRegion : INonOverlappingRange
|
|
{
|
|
/// <summary>
|
|
/// Base address.
|
|
/// </summary>
|
|
public ulong Address { get; }
|
|
|
|
/// <summary>
|
|
/// Size of the range in bytes.
|
|
/// </summary>
|
|
public ulong Size { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// End address.
|
|
/// </summary>
|
|
public ulong EndAddress => Address + Size;
|
|
|
|
/// <summary>
|
|
/// Create a new region.
|
|
/// </summary>
|
|
/// <param name="address">Base address</param>
|
|
/// <param name="size">Size of the range</param>
|
|
protected AbstractRegion(ulong address, ulong size)
|
|
{
|
|
Address = address;
|
|
Size = size;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Check if this range overlaps with another.
|
|
/// </summary>
|
|
/// <param name="address">Base address</param>
|
|
/// <param name="size">Size of the range</param>
|
|
/// <returns>True if overlapping, false otherwise</returns>
|
|
public bool OverlapsWith(ulong address, ulong size)
|
|
{
|
|
return Address < address + size && address < EndAddress;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Signals to the handles that a memory event has occurred, and unprotects the region. Assumes that the tracking lock has been obtained.
|
|
/// </summary>
|
|
/// <param name="address">Address accessed</param>
|
|
/// <param name="size">Size of the region affected in bytes</param>
|
|
/// <param name="write">Whether the region was written to or read</param>
|
|
public abstract void Signal(ulong address, ulong size, bool write);
|
|
|
|
/// <summary>
|
|
/// Signals to the handles that a precise memory event has occurred. Assumes that the tracking lock has been obtained.
|
|
/// </summary>
|
|
/// <param name="address">Address accessed</param>
|
|
/// <param name="size">Size of the region affected in bytes</param>
|
|
/// <param name="write">Whether the region was written to or read</param>
|
|
public abstract void SignalPrecise(ulong address, ulong size, bool write);
|
|
|
|
/// <summary>
|
|
/// Split this region into two, around the specified address.
|
|
/// This region is updated to end at the split address, and a new region is created to represent past that point.
|
|
/// </summary>
|
|
/// <param name="splitAddress">Address to split the region around</param>
|
|
/// <returns>The second part of the split region, with start address at the given split.</returns>
|
|
public abstract INonOverlappingRange Split(ulong splitAddress);
|
|
}
|
|
}
|