Ryujinx/Ryujinx.Memory.Tests/MockVirtualMemoryManager.cs
riperiperi a1f77a5b6a
Implement lazy flush-on-read for Buffers (SSBO/Copy) (#1790)
* Initial implementation of buffer flush (VERY WIP)

* Host shaders need to be rebuilt for the SSBO write flag.

* New approach with reserved regions and gl sync

* Fix a ton of buffer issues.

* Remove unused buffer unmapped behaviour

* Revert "Remove unused buffer unmapped behaviour"

This reverts commit f1700e52fb8760180ac5e0987a07d409d1e70ece.

* Delete modified ranges on unmap

Fixes potential crashes in Super Smash Bros, where a previously modified range could lie on either side of an unmap.

* Cache some more delegates.

* Dispose Sync on Close

* Also create host sync for GPFifo syncpoint increment.

* Copy buffer optimization, add docs

* Fix race condition with OpenGL Sync

* Enable read tracking on CommandBuffer, insert syncpoint on WaitForIdle

* Performance: Only flush individual pages of SSBO at a time

This avoids flushing large amounts of data when only a small amount is actually used.

* Signal Modified rather than flushing after clear

* Fix some docs and code style.

* Introduce a new test for tracking memory protection.

Sucessfully demonstrates that the bug causing write protection to be cleared by a read action has been fixed. (these tests fail on master)

* Address Comments

* Add host sync for SetReference

This ensures that any indirect draws will correctly flush any related buffer data written before them. Fixes some flashing and misplaced world geometry in MH rise.

* Make PageAlign static

* Re-enable read tracking, for reads.
2021-01-17 17:08:06 -03:00

91 lines
2.3 KiB
C#

using System;
namespace Ryujinx.Memory.Tests
{
class MockVirtualMemoryManager : IVirtualMemoryManager
{
public bool NoMappings;
public event Action<ulong, ulong, MemoryPermission> OnProtect;
public MockVirtualMemoryManager(ulong size, int pageSize)
{
}
public void Map(ulong va, ulong pa, ulong size)
{
throw new NotImplementedException();
}
public void Unmap(ulong va, ulong size)
{
throw new NotImplementedException();
}
public T Read<T>(ulong va) where T : unmanaged
{
throw new NotImplementedException();
}
public void Read(ulong va, Span<byte> data)
{
throw new NotImplementedException();
}
public void Write<T>(ulong va, T value) where T : unmanaged
{
throw new NotImplementedException();
}
public void Write(ulong va, ReadOnlySpan<byte> data)
{
throw new NotImplementedException();
}
public ReadOnlySpan<byte> GetSpan(ulong va, int size, bool tracked = false)
{
throw new NotImplementedException();
}
public WritableRegion GetWritableRegion(ulong va, int size)
{
throw new NotImplementedException();
}
public ref T GetRef<T>(ulong va) where T : unmanaged
{
throw new NotImplementedException();
}
public (ulong address, ulong size)[] GetPhysicalRegions(ulong va, ulong size)
{
return NoMappings ? new (ulong address, ulong size)[0] : new (ulong address, ulong size)[] { (va, size) };
}
public bool IsMapped(ulong va)
{
return true;
}
public bool IsRangeMapped(ulong va, ulong size)
{
return true;
}
public ulong GetPhysicalAddress(ulong va)
{
throw new NotImplementedException();
}
public void SignalMemoryTracking(ulong va, ulong size, bool write)
{
throw new NotImplementedException();
}
public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection)
{
OnProtect?.Invoke(va, size, protection);
}
}
}