mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-30 05:53: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.
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using ARMeilleure.Signal;
|
|
using Ryujinx.Memory;
|
|
using Ryujinx.Memory.Tracking;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.Cpu
|
|
{
|
|
class MemoryEhMeilleure : IDisposable
|
|
{
|
|
private delegate bool TrackingEventDelegate(ulong address, ulong size, bool write, bool precise = false);
|
|
|
|
private readonly MemoryBlock _addressSpace;
|
|
private readonly MemoryTracking _tracking;
|
|
private readonly TrackingEventDelegate _trackingEvent;
|
|
|
|
private readonly ulong _baseAddress;
|
|
|
|
public MemoryEhMeilleure(MemoryBlock addressSpace, MemoryTracking tracking)
|
|
{
|
|
_addressSpace = addressSpace;
|
|
_tracking = tracking;
|
|
|
|
_baseAddress = (ulong)_addressSpace.Pointer;
|
|
ulong endAddress = _baseAddress + addressSpace.Size;
|
|
|
|
_trackingEvent = new TrackingEventDelegate(tracking.VirtualMemoryEvent);
|
|
bool added = NativeSignalHandler.AddTrackedRegion((nuint)_baseAddress, (nuint)endAddress, Marshal.GetFunctionPointerForDelegate(_trackingEvent));
|
|
|
|
if (!added)
|
|
{
|
|
throw new InvalidOperationException("Number of allowed tracked regions exceeded.");
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
NativeSignalHandler.RemoveTrackedRegion((nuint)_baseAddress);
|
|
}
|
|
}
|
|
}
|