From 9aa6d1c735fd48d686ba9f24d0af8899f75505cf Mon Sep 17 00:00:00 2001 From: Logan Stromberg Date: Thu, 23 Dec 2021 21:09:27 -0800 Subject: [PATCH] Revert "Revert "Add support for releasing a semaphore to DmaClass (#2926)"" This reverts commit ec8a5fd05362f04cc77436ee3e45a9188777f75e. --- Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs | 36 +++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs b/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs index 8e4ac5e22..856d52a9a 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Dma/DmaClass.cs @@ -1,4 +1,5 @@ using Ryujinx.Common; +using Ryujinx.Common.Logging; using Ryujinx.Graphics.Device; using Ryujinx.Graphics.Gpu.Engine.Threed; using Ryujinx.Graphics.Texture; @@ -98,11 +99,32 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma } } + /// + /// Releases a semaphore for a given LaunchDma method call. + /// + /// The LaunchDma call argument + private void ReleaseSemaphore(int argument) + { + LaunchDmaSemaphoreType type = (LaunchDmaSemaphoreType)((argument >> 3) & 0x3); + if (type != LaunchDmaSemaphoreType.None) + { + ulong address = ((ulong)_state.State.SetSemaphoreA << 32) | _state.State.SetSemaphoreB; + if (type == LaunchDmaSemaphoreType.ReleaseOneWordSemaphore) + { + _channel.MemoryManager.Write(address, _state.State.SetSemaphorePayload); + } + else /* if (type == LaunchDmaSemaphoreType.ReleaseFourWordSemaphore) */ + { + Logger.Warning?.Print(LogClass.Gpu, "DMA semaphore type ReleaseFourWordSemaphore was used, but is not currently implemented."); + } + } + } + /// /// Performs a buffer to buffer, or buffer to texture copy. /// - /// Method call argument - private void LaunchDma(int argument) + /// The LaunchDma call argument + private void DmaCopy(int argument) { var memoryManager = _channel.MemoryManager; @@ -296,5 +318,15 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma } } } + + /// + /// Performs a buffer to buffer, or buffer to texture copy, then optionally releases a semaphore. + /// + /// Method call argument + private void LaunchDma(int argument) + { + DmaCopy(argument); + ReleaseSemaphore(argument); + } } }