mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
SDL2Driver: Invoke dispatcher on main thread (#3818)
This commit is contained in:
parent
d9053bbe37
commit
204c031fef
5 changed files with 31 additions and 21 deletions
|
@ -8,6 +8,7 @@ using Ryujinx.Common.Logging;
|
|||
using Ryujinx.Common.System;
|
||||
using Ryujinx.Common.SystemInfo;
|
||||
using Ryujinx.Modules;
|
||||
using Ryujinx.SDL2.Common;
|
||||
using Ryujinx.Ui.Common;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using Ryujinx.Ui.Common.Helper;
|
||||
|
@ -94,6 +95,9 @@ namespace Ryujinx.Ava
|
|||
// Initialize Discord integration.
|
||||
DiscordIntegrationModule.Initialize();
|
||||
|
||||
// Initialize SDL2 driver
|
||||
SDL2Driver.MainThreadDispatcher = action => Dispatcher.UIThread.InvokeAsync(action, DispatcherPriority.Input);
|
||||
|
||||
ReloadConfig();
|
||||
|
||||
ForceDpiAware.Windows();
|
||||
|
|
|
@ -638,16 +638,7 @@ namespace Ryujinx.Headless.SDL2
|
|||
|
||||
Translator.IsReadyForTranslation.Reset();
|
||||
|
||||
Thread windowThread = new Thread(() =>
|
||||
{
|
||||
ExecutionEntrypoint();
|
||||
})
|
||||
{
|
||||
Name = "GUI.WindowThread"
|
||||
};
|
||||
|
||||
windowThread.Start();
|
||||
windowThread.Join();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -168,14 +168,6 @@ namespace Ryujinx.Headless.SDL2
|
|||
|
||||
public void Render()
|
||||
{
|
||||
InitializeWindowRenderer();
|
||||
|
||||
Device.Gpu.Renderer.Initialize(_glLogLevel);
|
||||
|
||||
InitializeRenderer();
|
||||
|
||||
_gpuVendorName = GetGpuVendorName();
|
||||
|
||||
Device.Gpu.Renderer.RunLoop(() =>
|
||||
{
|
||||
Device.Gpu.SetGpuThread();
|
||||
|
@ -323,6 +315,14 @@ namespace Ryujinx.Headless.SDL2
|
|||
|
||||
InitializeWindow();
|
||||
|
||||
InitializeWindowRenderer();
|
||||
|
||||
Device.Gpu.Renderer.Initialize(_glLogLevel);
|
||||
|
||||
InitializeRenderer();
|
||||
|
||||
_gpuVendorName = GetGpuVendorName();
|
||||
|
||||
Thread renderLoopThread = new Thread(Render)
|
||||
{
|
||||
Name = "GUI.RenderLoop"
|
||||
|
|
|
@ -28,6 +28,8 @@ namespace Ryujinx.SDL2.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static Action<Action> MainThreadDispatcher { get; set; }
|
||||
|
||||
private const uint SdlInitFlags = SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_VIDEO;
|
||||
|
||||
private bool _isRunning;
|
||||
|
@ -153,11 +155,14 @@ namespace Ryujinx.SDL2.Common
|
|||
using ManualResetEventSlim waitHandle = new ManualResetEventSlim(false);
|
||||
|
||||
while (_isRunning)
|
||||
{
|
||||
MainThreadDispatcher?.Invoke(() =>
|
||||
{
|
||||
while (SDL_PollEvent(out SDL_Event evnt) != 0)
|
||||
{
|
||||
HandleSDLEvent(ref evnt);
|
||||
}
|
||||
});
|
||||
|
||||
waitHandle.Wait(WaitTimeMs);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ using Ryujinx.Common.Logging;
|
|||
using Ryujinx.Common.System;
|
||||
using Ryujinx.Common.SystemInfo;
|
||||
using Ryujinx.Modules;
|
||||
using Ryujinx.SDL2.Common;
|
||||
using Ryujinx.Ui;
|
||||
using Ryujinx.Ui.Common;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
|
@ -111,6 +112,15 @@ namespace Ryujinx
|
|||
// Initialize Discord integration.
|
||||
DiscordIntegrationModule.Initialize();
|
||||
|
||||
// Initialize SDL2 driver
|
||||
SDL2Driver.MainThreadDispatcher = action =>
|
||||
{
|
||||
Gtk.Application.Invoke(delegate
|
||||
{
|
||||
action();
|
||||
});
|
||||
};
|
||||
|
||||
// Sets ImageSharp Jpeg Encoder Quality.
|
||||
SixLabors.ImageSharp.Configuration.Default.ImageFormatsManager.SetEncoder(JpegFormat.Instance, new JpegEncoder()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue