aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-01-12 18:50:54 -0300
committerGitHub <noreply@github.com>2021-01-13 08:50:54 +1100
commitdf820a72def62319fe97236a2006c64bfb7c065a (patch)
tree0e5d2c4f278548245e828e67194ff03d04532ce3 /Ryujinx.Graphics.Gpu/Memory/BufferManager.cs
parent68f6b79fd3f06ea572d5f0edd5fc8cbaee1ae449 (diff)
Implement clear buffer (fast path) (#1902)
* Implement clear buffer (fast path) * Remove blank line
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/BufferManager.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Memory/BufferManager.cs22
1 files changed, 22 insertions, 0 deletions
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
@@ -822,6 +822,28 @@ namespace Ryujinx.Graphics.Gpu.Memory
}
/// <summary>
+ /// Clears a buffer at a given address with the specified value.
+ /// </summary>
+ /// <remarks>
+ /// Both the address and size must be aligned to 4 bytes.
+ /// </remarks>
+ /// <param name="gpuVa">GPU virtual address of the region to clear</param>
+ /// <param name="size">Number of bytes to clear</param>
+ /// <param name="value">Value to be written into the buffer</param>
+ 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);
+ }
+
+ /// <summary>
/// Gets a buffer sub-range for a given memory range.
/// </summary>
/// <param name="address">Start address of the memory range</param>