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.
This commit is contained in:
parent
5d1447897a
commit
994f497781
10 changed files with 68 additions and 73 deletions
|
@ -23,38 +23,38 @@ public:
|
|||
explicit EmuWindow_SDL2(InputCommon::InputSubsystem* input_subsystem);
|
||||
~EmuWindow_SDL2();
|
||||
|
||||
/// Polls window events
|
||||
void PollEvents() override;
|
||||
|
||||
/// Whether the window is still open, and a close request hasn't yet been sent
|
||||
bool IsOpen() const;
|
||||
|
||||
/// Returns if window is shown (not minimized)
|
||||
bool IsShown() const override;
|
||||
|
||||
/// Wait for the next event on the main thread.
|
||||
void WaitEvent();
|
||||
|
||||
protected:
|
||||
/// Called by PollEvents when a key is pressed or released.
|
||||
/// Called by WaitEvent when a key is pressed or released.
|
||||
void OnKeyEvent(int key, u8 state);
|
||||
|
||||
/// Called by PollEvents when the mouse moves.
|
||||
/// Called by WaitEvent when the mouse moves.
|
||||
void OnMouseMotion(s32 x, s32 y);
|
||||
|
||||
/// Called by PollEvents when a mouse button is pressed or released
|
||||
/// Called by WaitEvent when a mouse button is pressed or released
|
||||
void OnMouseButton(u32 button, u8 state, s32 x, s32 y);
|
||||
|
||||
/// Translates pixel position (0..1) to pixel positions
|
||||
std::pair<unsigned, unsigned> TouchToPixelPos(float touch_x, float touch_y) const;
|
||||
|
||||
/// Called by PollEvents when a finger starts touching the touchscreen
|
||||
/// Called by WaitEvent when a finger starts touching the touchscreen
|
||||
void OnFingerDown(float x, float y);
|
||||
|
||||
/// Called by PollEvents when a finger moves while touching the touchscreen
|
||||
/// Called by WaitEvent when a finger moves while touching the touchscreen
|
||||
void OnFingerMotion(float x, float y);
|
||||
|
||||
/// Called by PollEvents when a finger stops touching the touchscreen
|
||||
/// Called by WaitEvent when a finger stops touching the touchscreen
|
||||
void OnFingerUp();
|
||||
|
||||
/// Called by PollEvents when any event that may cause the window to be resized occurs
|
||||
/// Called by WaitEvent when any event that may cause the window to be resized occurs
|
||||
void OnResize();
|
||||
|
||||
/// Called when user passes the fullscreen parameter flag
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue