diff --git a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs index bd946b52dc..8604f8e11f 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/Buffer.cs @@ -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) { diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferPreFlush.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferPreFlush.cs index 53b7a623c8..eefc03903f 100644 --- a/src/Ryujinx.Graphics.Gpu/Memory/BufferPreFlush.cs +++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferPreFlush.cs @@ -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 _flushAction; + private readonly Action _flushAction; private BufferHandle _flushBuffer; - public BufferPreFlush(GpuContext context, PhysicalMemory physicalMemory, Buffer parent, Action flushAction) + public BufferPreFlush(GpuContext context, Buffer parent, Action 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 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)); } }