diff options
author | comex <comexk@gmail.com> | 2020-11-22 16:05:18 -0500 |
---|---|---|
committer | comex <comexk@gmail.com> | 2020-11-23 17:58:49 -0500 |
commit | 994f4977810749c0b597e7a7531a02d907967a68 (patch) | |
tree | 82eaf8b6dea5baf60e17601771dc8191b8e69a8f /src/core/frontend | |
parent | 5d1447897aebc371439507f42507bd98f1cfc223 (diff) |
Overhaul EmuWindow::PollEvents to fix yuzu-cmd calling SDL_PollEvents off main thread
EmuWindow::PollEvents was called from the GPU thread (or the CPU thread
in sync-GPU mode) when swapping buffers. It had three implementations:
- In GRenderWindow, it didn't actually poll events, just set a flag and
emit a signal to indicate that a frame was displayed.
- In EmuWindow_SDL2_Hide, it did nothing.
- In EmuWindow_SDL2, it did call SDL_PollEvents, but this is wrong
because SDL_PollEvents is supposed to be called on the thread that set
up video - in this case, the main thread, which was sleeping in a
busyloop (regardless of whether sync-GPU was enabled). On macOS this
causes a crash.
To fix this:
- Rename EmuWindow::PollEvents to OnFrameDisplayed, and give it a
default implementation that does nothing.
- In EmuWindow_SDL2, do not override OnFrameDisplayed, but instead have
the main thread call SDL_WaitEvent in a loop.
Diffstat (limited to 'src/core/frontend')
-rw-r--r-- | src/core/frontend/emu_window.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 3e8780243..276d2b906 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h @@ -102,8 +102,8 @@ public: float render_surface_scale = 1.0f; }; - /// Polls window events - virtual void PollEvents() = 0; + /// Called from GPU thread when a frame is displayed. + virtual void OnFrameDisplayed() {} /** * Returns a GraphicsContext that the frontend provides to be used for rendering. |