diff options
author | Patric Stout <truebrain@openttd.org> | 2021-02-06 14:09:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-06 14:09:45 +0100 |
commit | 2c9084d48cf1a3ad3c5f8d3bcad83c396e8d29fd (patch) | |
tree | 9d2a1ba6521d4763e27c63b381ee68232b5c92ed | |
parent | 4f0692c437c7c89b38134255a5b7aea9f0378c19 (diff) | |
download | openttd-2c9084d48cf1a3ad3c5f8d3bcad83c396e8d29fd.tar.xz |
Fix #8029: [SDL2] disable draw-thread on wayland SDL video driver (#8648)
When the wayland SDL video driver is used, an EGL context is
created in the main thread. It is not allowed to update this
context from another thread, which is exactly what our draw-thread
is trying.
The other solution would be to move all of SDL into the
draw-thread, but that would introduce a whole scala of different
problems.
The wayland SDL backend is significantly faster than the
X11 SDL backend, but there is a performance hit nevertheless.
-rw-r--r-- | src/video/sdl2_v.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 66e6586fd..fd6cf6c11 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -715,6 +715,17 @@ const char *VideoDriver_SDL::Start(const StringList &parm) MarkWholeScreenDirty(); _draw_threaded = !GetDriverParamBool(parm, "no_threads") && !GetDriverParamBool(parm, "no_thread"); + /* Wayland SDL video driver uses EGL to render the game. SDL created the + * EGL context from the main-thread, and with EGL you are not allowed to + * draw in another thread than the context was created. The function of + * _draw_threaded is to do exactly this: draw in another thread than the + * window was created, and as such, this fails on Wayland SDL video + * driver. So, we disable threading by default if Wayland SDL video + * driver is detected. + */ + if (strcmp(dname, "wayland") == 0) { + _draw_threaded = false; + } SDL_StopTextInput(); this->edit_box_focused = false; |