From df820a72def62319fe97236a2006c64bfb7c065a Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 12 Jan 2021 18:50:54 -0300 Subject: Implement clear buffer (fast path) (#1902) * Implement clear buffer (fast path) * Remove blank line --- Ryujinx.Graphics.Gpu/Memory/BufferManager.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Ryujinx.Graphics.Gpu/Memory') diff --git a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs index 1d48b38c..0c643191 100644 --- a/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs +++ b/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs @@ -821,6 +821,28 @@ namespace Ryujinx.Graphics.Gpu.Memory dstBuffer.Flush(dstAddress, size); } + /// + /// Clears a buffer at a given address with the specified value. + /// + /// + /// Both the address and size must be aligned to 4 bytes. + /// + /// GPU virtual address of the region to clear + /// Number of bytes to clear + /// Value to be written into the buffer + public void ClearBuffer(GpuVa gpuVa, ulong size, uint value) + { + ulong address = TranslateAndCreateBuffer(gpuVa.Pack(), size); + + Buffer buffer = GetBuffer(address, size); + + int offset = (int)(address - buffer.Address); + + _context.Renderer.Pipeline.ClearBuffer(buffer.Handle, offset, (int)size, value); + + buffer.Flush(address, size); + } + /// /// Gets a buffer sub-range for a given memory range. /// -- cgit v1.2.3