mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-11-30 05:53:01 +00: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.
|
// 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue