Check if the Device is rendering before waiting on it

Fixes an issue where there were missed references and an ``OperationCancelled`` exception when exiting an application.
This commit is contained in:
Max
2026-05-14 08:49:51 -05:00
committed by KeatonTheBot
parent 23fb4924e3
commit 61e0aba325
2 changed files with 40 additions and 38 deletions
-2
View File
@@ -177,8 +177,6 @@ namespace Ryujinx.Graphics.Vulkan
}
}
// This can somehow become -1.
// Logger.Info?.PrintMsg(LogClass.Gpu, $"_referenceCount: {_referenceCount}");
Debug.Assert(_referenceCount >= 0);
}
+10 -6
View File
@@ -605,15 +605,14 @@ namespace Ryujinx.Ava
// 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);
@@ -1108,6 +1107,8 @@ namespace Ryujinx.Ava
_chrono.Start();
Device.Gpu.Renderer.RunLoop(() =>
{
try
{
Device.Gpu.SetGpuThread();
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
@@ -1136,7 +1137,8 @@ namespace Ryujinx.Ava
InitStatus();
}
Device.PresentFrame(() => (RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.SwapBuffers());
Device.PresentFrame(() =>
(RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.SwapBuffers());
}
if (_ticks >= _ticksPerFrame)
@@ -1144,7 +1146,9 @@ namespace Ryujinx.Ava
UpdateStatus();
}
}
}
finally
{
// Make sure all commands in the run loop are fully executed before leaving the loop.
if (Device.Gpu.Renderer is ThreadedRenderer threaded)
{
@@ -1152,8 +1156,8 @@ namespace Ryujinx.Ava
threaded.FlushThreadedCommands();
Logger.Info?.PrintMsg(LogClass.Gpu, "Flushed!");
}
_gpuDoneEvent.Set();
}
});
(RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL)?.MakeCurrent(true);