Implement clear buffer (fast path) (#1902)

* Implement clear buffer (fast path)

* Remove blank line
This commit is contained in:
gdkchan 2021-01-12 18:50:54 -03:00 committed by GitHub
parent 68f6b79fd3
commit df820a72de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 125 additions and 5 deletions

View file

@ -821,6 +821,28 @@ namespace Ryujinx.Graphics.Gpu.Memory
dstBuffer.Flush(dstAddress, size);
}
/// <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>