From 44d7fcff399888d311f61772a53146d924ee5b62 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 29 May 2020 05:51:10 -0300 Subject: Implement FIFO semaphore (#1286) * Implement FIFO semaphore * New enum for FIFO semaphore operation --- Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs') diff --git a/Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs b/Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs index 1c0e72e5..c1f45941 100644 --- a/Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs +++ b/Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs @@ -1,11 +1,37 @@ using Ryujinx.Graphics.Gpu.State; -using System; using System.Threading; namespace Ryujinx.Graphics.Gpu.Engine { partial class Methods { + /// + /// Writes a GPU counter to guest memory. + /// + /// Current GPU state + /// Method call argument + public void Semaphore(GpuState state, int argument) + { + FifoSemaphoreOperation op = (FifoSemaphoreOperation)(argument & 3); + + var semaphore = state.Get(MethodOffset.Semaphore); + + int value = semaphore.Payload; + + if (op == FifoSemaphoreOperation.Counter) + { + // TODO: There's much more that should be done here. + // NVN only supports the "Accumulate" mode, so we + // can't currently guess which bits specify the + // reduction operation. + value += _context.MemoryAccessor.Read(semaphore.Address.Pack()); + } + + _context.MemoryAccessor.Write(semaphore.Address.Pack(), value); + + _context.AdvanceSequence(); + } + /// /// Waits for the GPU to be idle. /// -- cgit v1.2.3