1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-25 00:36:02 +00:00

Flush buffers on copies

This commit is contained in:
gdk 2019-10-26 23:41:01 -03:00 committed by Thog
parent 8cba252b23
commit f2e84ff566
3 changed files with 28 additions and 21 deletions

View file

@ -69,10 +69,6 @@ namespace Ryujinx.Graphics.Gpu.Engine
{ {
// Buffer to buffer copy. // Buffer to buffer copy.
_bufferManager.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size); _bufferManager.CopyBuffer(cbp.SrcAddress, cbp.DstAddress, (uint)size);
Span<byte> data = _context.MemoryAccessor.Read(cbp.SrcAddress.Pack(), (uint)size);
_context.MemoryAccessor.Write(cbp.DstAddress.Pack(), data);
} }
} }
} }

View file

@ -9,6 +9,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
private IBuffer _buffer; private IBuffer _buffer;
public IBuffer HostBuffer => _buffer;
public ulong Address { get; } public ulong Address { get; }
public ulong Size { get; } public ulong Size { get; }
@ -86,6 +88,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
_buffer.CopyTo(destination._buffer, 0, dstOffset, (int)Size); _buffer.CopyTo(destination._buffer, 0, dstOffset, (int)Size);
} }
public void Flush(ulong address, ulong size)
{
int offset = (int)(address - Address);
byte[] data = _buffer.GetData(offset, (int)size);
_context.PhysicalMemory.Write(address, data);
}
public void Invalidate() public void Invalidate()
{ {
_buffer.SetData(0, _context.PhysicalMemory.Read(Address, Size)); _buffer.SetData(0, _context.PhysicalMemory.Read(Address, Size));

View file

@ -484,17 +484,27 @@ namespace Ryujinx.Graphics.Gpu.Memory
ulong srcAddress = TranslateAndCreateBuffer(srcVa.Pack(), size); ulong srcAddress = TranslateAndCreateBuffer(srcVa.Pack(), size);
ulong dstAddress = TranslateAndCreateBuffer(dstVa.Pack(), size); ulong dstAddress = TranslateAndCreateBuffer(dstVa.Pack(), size);
BufferRange srcBuffer = GetBufferRange(srcAddress, size); Buffer srcBuffer = GetBuffer(srcAddress, size);
BufferRange dstBuffer = GetBufferRange(dstAddress, size); Buffer dstBuffer = GetBuffer(dstAddress, size);
srcBuffer.Buffer.CopyTo( int srcOffset = (int)(srcAddress - srcBuffer.Address);
dstBuffer.Buffer, int dstOffset = (int)(dstAddress - dstBuffer.Address);
srcBuffer.Offset,
dstBuffer.Offset, srcBuffer.HostBuffer.CopyTo(
dstBuffer.HostBuffer,
srcOffset,
dstOffset,
(int)size); (int)size);
dstBuffer.Flush(dstAddress, size);
} }
private BufferRange GetBufferRange(ulong address, ulong size) private BufferRange GetBufferRange(ulong address, ulong size)
{
return GetBuffer(address, size).GetRange(address, size);
}
private Buffer GetBuffer(ulong address, ulong size)
{ {
Buffer buffer; Buffer buffer;
@ -509,7 +519,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
buffer = _buffers.FindFirstOverlap(address, 1); buffer = _buffers.FindFirstOverlap(address, 1);
} }
return buffer.GetRange(address, size); return buffer;
} }
private void SynchronizeBufferRange(ulong address, ulong size) private void SynchronizeBufferRange(ulong address, ulong size)
@ -521,15 +531,5 @@ namespace Ryujinx.Graphics.Gpu.Memory
buffer.SynchronizeMemory(address, size); buffer.SynchronizeMemory(address, size);
} }
} }
public void InvalidateRange(ulong address, ulong size)
{
Buffer[] overlappingBuffers = _buffers.FindOverlaps(address, size);
foreach (Buffer buffer in overlappingBuffers)
{
buffer.Invalidate();
}
}
} }
} }