aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-05-29 05:51:10 -0300
committerGitHub <noreply@github.com>2020-05-29 10:51:10 +0200
commit44d7fcff399888d311f61772a53146d924ee5b62 (patch)
treeb79faa532e47b3a4e688939691e5cbf4b6efd21f /Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs
parent12cfaf56f083cdf250381c3525eaf4ecf5ee9257 (diff)
Implement FIFO semaphore (#1286)
* Implement FIFO semaphore * New enum for FIFO semaphore operation
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Engine/MethodFifo.cs28
1 files changed, 27 insertions, 1 deletions
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,5 +1,4 @@
using Ryujinx.Graphics.Gpu.State;
-using System;
using System.Threading;
namespace Ryujinx.Graphics.Gpu.Engine
@@ -7,6 +6,33 @@ namespace Ryujinx.Graphics.Gpu.Engine
partial class Methods
{
/// <summary>
+ /// Writes a GPU counter to guest memory.
+ /// </summary>
+ /// <param name="state">Current GPU state</param>
+ /// <param name="argument">Method call argument</param>
+ public void Semaphore(GpuState state, int argument)
+ {
+ FifoSemaphoreOperation op = (FifoSemaphoreOperation)(argument & 3);
+
+ var semaphore = state.Get<SemaphoreState>(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<int>(semaphore.Address.Pack());
+ }
+
+ _context.MemoryAccessor.Write(semaphore.Address.Pack(), value);
+
+ _context.AdvanceSequence();
+ }
+
+ /// <summary>
/// Waits for the GPU to be idle.
/// </summary>
/// <param name="state">Current GPU state</param>