From 89ea41ef84aa9d88261274b453c6ddbe9aa019cc Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 12 May 2026 02:38:09 +0000 Subject: [PATCH 1/2] Check if the Device is rendering before waiting on it (#86) Fixes an issue where there were missed references and an ``OperationCancelled`` exception when exiting an application. Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/86 --- src/Ryujinx.Graphics.Vulkan/Auto.cs | 4 +- src/Ryujinx/Systems/AppHost.cs | 75 +++++++++++++++-------------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/Ryujinx.Graphics.Vulkan/Auto.cs b/src/Ryujinx.Graphics.Vulkan/Auto.cs index 9c8c7ff4b..d97d69ad3 100644 --- a/src/Ryujinx.Graphics.Vulkan/Auto.cs +++ b/src/Ryujinx.Graphics.Vulkan/Auto.cs @@ -176,9 +176,7 @@ namespace Ryujinx.Graphics.Vulkan } } } - - // This can somehow become -1. - // Logger.Info?.PrintMsg(LogClass.Gpu, $"_referenceCount: {_referenceCount}"); + Debug.Assert(_referenceCount >= 0); } diff --git a/src/Ryujinx/Systems/AppHost.cs b/src/Ryujinx/Systems/AppHost.cs index 6675972be..358b585f4 100644 --- a/src/Ryujinx/Systems/AppHost.cs +++ b/src/Ryujinx/Systems/AppHost.cs @@ -622,15 +622,15 @@ namespace Ryujinx.Ava.Systems // If the GPU has no work and is cancelled, we need to handle that as well. WaitHandle.WaitAny(new[] { _gpuDoneEvent, _gpuCancellationTokenSource.Token.WaitHandle }); - _gpuCancellationTokenSource.Dispose(); - - // Waiting for work to be finished before we dispose. + if (_renderingStarted) { + // Waiting for work to be finished before we dispose. Device.Gpu.WaitUntilGpuReady(); } _gpuDoneEvent.Dispose(); + _gpuCancellationTokenSource.Dispose(); DisposeGpu(); AppExit?.Invoke(this, EventArgs.Empty); @@ -1095,51 +1095,56 @@ namespace Ryujinx.Ava.Systems Device.Gpu.Renderer.RunLoop(() => { - Device.Gpu.SetGpuThread(); - Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token); - - _renderer.Window.ChangeVSyncMode(Device.VSyncMode); - - while (_isActive) + try { - _ticks += _chrono.ElapsedTicks; + Device.Gpu.SetGpuThread(); + Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token); - _chrono.Restart(); + _renderer.Window.ChangeVSyncMode(Device.VSyncMode); - if (Device.WaitFifo()) + while (_isActive) { - Device.Statistics.RecordFifoStart(); - Device.ProcessFrame(); - Device.Statistics.RecordFifoEnd(); - } + _ticks += _chrono.ElapsedTicks; - while (Device.ConsumeFrameAvailable()) - { - if (!_renderingStarted) + _chrono.Restart(); + + if (Device.WaitFifo()) { - _renderingStarted = true; - _viewModel.SwitchToRenderer(false); - InitStatus(); + Device.Statistics.RecordFifoStart(); + Device.ProcessFrame(); + Device.Statistics.RecordFifoEnd(); } - Device.PresentFrame(() => (RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.SwapBuffers()); - } + while (Device.ConsumeFrameAvailable()) + { + if (!_renderingStarted) + { + _renderingStarted = true; + _viewModel.SwitchToRenderer(false); + InitStatus(); + } - if (_ticks >= _ticksPerFrame) - { - UpdateStatus(); + Device.PresentFrame(() => + (RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.SwapBuffers()); + } + + if (_ticks >= _ticksPerFrame) + { + UpdateStatus(); + } } } - - // Make sure all commands in the run loop are fully executed before leaving the loop. - if (Device.Gpu.Renderer is ThreadedRenderer threaded) + finally { - Logger.Info?.PrintMsg(LogClass.Gpu, "Flushing threaded commands..."); - threaded.FlushThreadedCommands(); - Logger.Info?.PrintMsg(LogClass.Gpu, "Flushed!"); + // Make sure all commands in the run loop are fully executed before leaving the loop. + if (Device.Gpu.Renderer is ThreadedRenderer threaded) + { + Logger.Info?.PrintMsg(LogClass.Gpu, "Flushing threaded commands..."); + threaded.FlushThreadedCommands(); + Logger.Info?.PrintMsg(LogClass.Gpu, "Flushed!"); + } + _gpuDoneEvent.Set(); } - - _gpuDoneEvent.Set(); }); (RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.MakeCurrent(true); From 49891ba7af2f1c9469347ae7156def073e5fea6b Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 12 May 2026 02:41:10 +0000 Subject: [PATCH 2/2] Update avalonia monorepo to 11.3.15 (#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [Avalonia](https://avaloniaui.net/?utm_source=nuget&utm_medium=referral&utm_content=project_homepage_link) ([source](https://github.com/AvaloniaUI/Avalonia)) | `11.3.14` → `11.3.15` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Avalonia/11.3.15?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Avalonia/11.3.14/11.3.15?slim=true) | | [Avalonia.Desktop](https://avaloniaui.net/?utm_source=nuget&utm_medium=referral&utm_content=project_homepage_link) ([source](https://github.com/AvaloniaUI/Avalonia)) | `11.3.14` → `11.3.15` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Avalonia.Desktop/11.3.15?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Avalonia.Desktop/11.3.14/11.3.15?slim=true) | | [Avalonia.Diagnostics](https://avaloniaui.net/?utm_source=nuget&utm_medium=referral&utm_content=project_homepage_link) ([source](https://github.com/AvaloniaUI/Avalonia)) | `11.3.14` → `11.3.15` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Avalonia.Diagnostics/11.3.15?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Avalonia.Diagnostics/11.3.14/11.3.15?slim=true) | | [Avalonia.Markup.Xaml.Loader](https://avaloniaui.net/?utm_source=nuget&utm_medium=referral&utm_content=project_homepage_link) ([source](https://github.com/AvaloniaUI/Avalonia)) | `11.3.14` → `11.3.15` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Avalonia.Markup.Xaml.Loader/11.3.15?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Avalonia.Markup.Xaml.Loader/11.3.14/11.3.15?slim=true) | --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/85 --- Directory.Packages.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4466f2777..3d39156b5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,11 +3,11 @@ true - + - - - + + +