diff --git a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
index babd1bf32..679def8df 100644
--- a/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
+++ b/src/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs
@@ -422,7 +422,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
_state.State.SetRemapComponentsComponentSize == SetRemapComponentsComponentSize.Four)
{
// Fast path for clears when remap is enabled.
- bufferCache.ClearBuffer(memoryManager, dstGpuVa, size * 4, _state.State.SetRemapConstA);
+ BufferCache.ClearBuffer(_context, memoryManager, dstGpuVa, size * 4, _state.State.SetRemapConstA);
}
else
{
diff --git a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
index 1ac4e2d39..b7948906e 100644
--- a/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
+++ b/src/Ryujinx.Graphics.Gpu/Memory/BufferCache.cs
@@ -358,21 +358,23 @@ namespace Ryujinx.Graphics.Gpu.Memory
///
/// Both the address and size must be aligned to 4 bytes.
///
+ /// GPU context
/// GPU memory manager where the buffer is mapped
/// GPU virtual address of the region to clear
/// Number of bytes to clear
/// Value to be written into the buffer
- public void ClearBuffer(MemoryManager memoryManager, ulong gpuVa, ulong size, uint value)
+ public static void ClearBuffer(GpuContext context, MemoryManager memoryManager, ulong gpuVa, ulong size, uint value)
{
- ulong address = TranslateAndCreateBuffer(memoryManager, gpuVa, size);
+ PhysicalMemory physical = memoryManager.GetBackingMemory(gpuVa);
- Buffer buffer = GetBuffer(address, size);
+ ulong address = physical.BufferCache.TranslateAndCreateBuffer(memoryManager, gpuVa, size);
+ Buffer buffer = physical.BufferCache.GetBuffer(address, size);
int offset = (int)(address - buffer.Address);
- _context.Renderer.Pipeline.ClearBuffer(buffer.Handle, offset, (int)size, value);
+ context.Renderer.Pipeline.ClearBuffer(buffer.Handle, offset, (int)size, value);
- memoryManager.GetBackingMemory(gpuVa).FillTrackedResource(address, size, value, ResourceKind.Buffer);
+ physical.FillTrackedResource(address, size, value, ResourceKind.Buffer);
}
///