mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-18 06:38:42 +02:00
Flush buffers on copies
This commit is contained in:
parent
8cba252b23
commit
f2e84ff566
3 changed files with 28 additions and 21 deletions
|
@ -69,10 +69,6 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
|||
{
|
||||
// Buffer to buffer copy.
|
||||
_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
|
||||
private IBuffer _buffer;
|
||||
|
||||
public IBuffer HostBuffer => _buffer;
|
||||
|
||||
public ulong Address { get; }
|
||||
public ulong Size { get; }
|
||||
|
||||
|
@ -86,6 +88,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
_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()
|
||||
{
|
||||
_buffer.SetData(0, _context.PhysicalMemory.Read(Address, Size));
|
||||
|
|
|
@ -484,17 +484,27 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
ulong srcAddress = TranslateAndCreateBuffer(srcVa.Pack(), size);
|
||||
ulong dstAddress = TranslateAndCreateBuffer(dstVa.Pack(), size);
|
||||
|
||||
BufferRange srcBuffer = GetBufferRange(srcAddress, size);
|
||||
BufferRange dstBuffer = GetBufferRange(dstAddress, size);
|
||||
Buffer srcBuffer = GetBuffer(srcAddress, size);
|
||||
Buffer dstBuffer = GetBuffer(dstAddress, size);
|
||||
|
||||
srcBuffer.Buffer.CopyTo(
|
||||
dstBuffer.Buffer,
|
||||
srcBuffer.Offset,
|
||||
dstBuffer.Offset,
|
||||
int srcOffset = (int)(srcAddress - srcBuffer.Address);
|
||||
int dstOffset = (int)(dstAddress - dstBuffer.Address);
|
||||
|
||||
srcBuffer.HostBuffer.CopyTo(
|
||||
dstBuffer.HostBuffer,
|
||||
srcOffset,
|
||||
dstOffset,
|
||||
(int)size);
|
||||
|
||||
dstBuffer.Flush(dstAddress, size);
|
||||
}
|
||||
|
||||
private BufferRange GetBufferRange(ulong address, ulong size)
|
||||
{
|
||||
return GetBuffer(address, size).GetRange(address, size);
|
||||
}
|
||||
|
||||
private Buffer GetBuffer(ulong address, ulong size)
|
||||
{
|
||||
Buffer buffer;
|
||||
|
||||
|
@ -509,7 +519,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
buffer = _buffers.FindFirstOverlap(address, 1);
|
||||
}
|
||||
|
||||
return buffer.GetRange(address, size);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private void SynchronizeBufferRange(ulong address, ulong size)
|
||||
|
@ -521,15 +531,5 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||
buffer.SynchronizeMemory(address, size);
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateRange(ulong address, ulong size)
|
||||
{
|
||||
Buffer[] overlappingBuffers = _buffers.FindOverlaps(address, size);
|
||||
|
||||
foreach (Buffer buffer in overlappingBuffers)
|
||||
{
|
||||
buffer.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue