Fix dependent virtual buffers

This commit is contained in:
riperiperi 2024-05-10 23:13:31 +01:00
parent 5c98f51482
commit e8882d5189
2 changed files with 5 additions and 18 deletions

View file

@ -391,7 +391,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (BackingState.IsDeviceLocal)
{
_preFlush ??= new BufferPreFlush(_context, _physicalMemory, this, FlushImpl);
_preFlush ??= new BufferPreFlush(_context, this, FlushImpl);
if (_preFlush.ShouldCopy)
{

View file

@ -38,20 +38,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
public bool ShouldCopy { get; private set; }
private readonly GpuContext _context;
private readonly PhysicalMemory _physicalMemory;
private readonly Buffer _buffer;
private readonly PreFlushPage[] _pages;
private readonly ulong _address;
private readonly ulong _size;
private readonly ulong _misalignment;
private readonly Action<ulong, ulong> _flushAction;
private readonly Action<BufferHandle, ulong, ulong> _flushAction;
private BufferHandle _flushBuffer;
public BufferPreFlush(GpuContext context, PhysicalMemory physicalMemory, Buffer parent, Action<ulong, ulong> flushAction)
public BufferPreFlush(GpuContext context, Buffer parent, Action<BufferHandle, ulong, ulong> flushAction)
{
_context = context;
_physicalMemory = physicalMemory;
_buffer = parent;
_address = parent.Address;
_size = parent.Size;
@ -162,19 +160,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (end >= offset)
{
if (preFlush)
{
// Flush from the host mapped buffer
using PinnedSpan<byte> data = _context.Renderer.GetBufferData(_flushBuffer, offset, end - offset);
// TODO: dependant virtual buffers thing? maybe just disable pre-flush when that is active
_physicalMemory.WriteUntracked(_address + (ulong)offset, data.Get());
}
else
{
// Flush from the real buffer
_flushAction(_address + (ulong)offset, (ulong)(end - offset));
}
BufferHandle handle = preFlush ? _flushBuffer : _buffer.Handle;
_flushAction(handle, _address + (ulong)offset, (ulong)(end - offset));
}
}