diff options
Diffstat (limited to 'Ryujinx/Ui/RendererWidgetBase.cs')
-rw-r--r-- | Ryujinx/Ui/RendererWidgetBase.cs | 98 |
1 files changed, 57 insertions, 41 deletions
diff --git a/Ryujinx/Ui/RendererWidgetBase.cs b/Ryujinx/Ui/RendererWidgetBase.cs index d099d509..da10ba47 100644 --- a/Ryujinx/Ui/RendererWidgetBase.cs +++ b/Ryujinx/Ui/RendererWidgetBase.cs @@ -7,6 +7,7 @@ using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; using Ryujinx.Configuration; using Ryujinx.Graphics.GAL; +using Ryujinx.Graphics.GAL.Multithreading; using Ryujinx.Input; using Ryujinx.Input.GTK3; using Ryujinx.Input.HLE; @@ -293,7 +294,15 @@ namespace Ryujinx.Ui public void Initialize(Switch device) { Device = device; - Renderer = Device.Gpu.Renderer; + + IRenderer renderer = Device.Gpu.Renderer; + + if (renderer is ThreadedRenderer tr) + { + renderer = tr.BaseRenderer; + } + + Renderer = renderer; Renderer?.Window.SetSize(_windowWidth, _windowHeight); if (Renderer != null) @@ -375,52 +384,55 @@ namespace Ryujinx.Ui _gpuVendorName = GetGpuVendorName(); - Device.Gpu.InitializeShaderCache(); - Translator.IsReadyForTranslation.Set(); - - while (_isActive) + Device.Gpu.Renderer.RunLoop(() => { - if (_isStopped) - { - return; - } + Device.Gpu.InitializeShaderCache(); + Translator.IsReadyForTranslation.Set(); - _ticks += _chrono.ElapsedTicks; + while (_isActive) + { + if (_isStopped) + { + return; + } - _chrono.Restart(); + _ticks += _chrono.ElapsedTicks; - if (Device.WaitFifo()) - { - Device.Statistics.RecordFifoStart(); - Device.ProcessFrame(); - Device.Statistics.RecordFifoEnd(); - } + _chrono.Restart(); - while (Device.ConsumeFrameAvailable()) - { - Device.PresentFrame(SwapBuffers); - } + if (Device.WaitFifo()) + { + Device.Statistics.RecordFifoStart(); + Device.ProcessFrame(); + Device.Statistics.RecordFifoEnd(); + } - if (_ticks >= _ticksPerFrame) - { - string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld"; - float scale = Graphics.Gpu.GraphicsConfig.ResScale; - if (scale != 1) + while (Device.ConsumeFrameAvailable()) { - dockedMode += $" ({scale}x)"; + Device.PresentFrame(SwapBuffers); } - StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( - Device.EnableDeviceVsync, - dockedMode, - ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(), - $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS", - $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %", - $"GPU: {_gpuVendorName}")); + if (_ticks >= _ticksPerFrame) + { + string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? "Docked" : "Handheld"; + float scale = Graphics.Gpu.GraphicsConfig.ResScale; + if (scale != 1) + { + dockedMode += $" ({scale}x)"; + } + + StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( + Device.EnableDeviceVsync, + dockedMode, + ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(), + $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS", + $"FIFO: {Device.Statistics.GetFifoPercent():0.00} %", + $"GPU: {_gpuVendorName}")); - _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame); + _ticks = Math.Min(_ticks - _ticksPerFrame, _ticksPerFrame); + } } - } + }); } public void Start() @@ -455,16 +467,20 @@ namespace Ryujinx.Ui }; renderLoopThread.Start(); - Thread nvStutterWorkaround = new Thread(NVStutterWorkaround) + Thread nvStutterWorkaround = null; + if (Renderer is Graphics.OpenGL.Renderer) { - Name = "GUI.NVStutterWorkaround" - }; - nvStutterWorkaround.Start(); + nvStutterWorkaround = new Thread(NVStutterWorkaround) + { + Name = "GUI.NVStutterWorkaround" + }; + nvStutterWorkaround.Start(); + } MainLoop(); renderLoopThread.Join(); - nvStutterWorkaround.Join(); + nvStutterWorkaround?.Join(); Exit(); } |