Experimental performance improvements

This commit is contained in:
gdkchan 2020-01-11 19:40:40 -03:00
commit 8a3eee19be
4 changed files with 36 additions and 3 deletions

View file

@ -552,6 +552,39 @@ namespace ARMeilleure.Memory
return data; return data;
} }
public Span<byte> GetSpan(ulong address, ulong size)
{
if (IsContiguous(address, size))
{
return new Span<byte>((void*)Translate((long)address), (int)size);
}
else
{
return ReadBytes((long)address, (long)size);
}
}
private bool IsContiguous(ulong address, ulong size)
{
ulong endVa = (address + size + PageMask) & ~(ulong)PageMask;
address &= ~(ulong)PageMask;
int pages = (int)((endVa - address) / PageSize);
for (int page = 0; page < pages - 1; page++)
{
if (GetPtEntry((long)address) + PageSize != GetPtEntry((long)address + PageSize))
{
return false;
}
address += PageSize;
}
return true;
}
public void WriteSByte(long position, sbyte value) public void WriteSByte(long position, sbyte value)
{ {
WriteByte(position, (byte)value); WriteByte(position, (byte)value);

View file

@ -632,7 +632,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
dstOffset, dstOffset,
(int)size); (int)size);
dstBuffer.Flush(dstAddress, size); // dstBuffer.Flush(dstAddress, size);
} }
/// <summary> /// <summary>

View file

@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <returns>The data at the specified memory location</returns> /// <returns>The data at the specified memory location</returns>
public Span<byte> Read(ulong address, ulong size) public Span<byte> Read(ulong address, ulong size)
{ {
return _cpuMemory.ReadBytes((long)address, (long)size); return _cpuMemory.GetSpan(address, size);
} }
/// <summary> /// <summary>

View file

@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Gpu
{ {
_context.Methods.PerformDeferredDraws(); _context.Methods.PerformDeferredDraws();
_context.Renderer.FlushPipelines(); // _context.Renderer.FlushPipelines();
break; break;
} }