From f27471fbd806c9e2ee48f0e49f9d4f8f4e6af0a8 Mon Sep 17 00:00:00 2001 From: Riteo Date: Thu, 27 Jun 2024 23:28:29 +0200 Subject: Wayland: minimize surface commits and limit them to the main thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before of this patch, as explained in the usual commented-wall-of-text-longer-than-the-actual-patch-itself™, due to the multithreaded nature of the Wayland thread, it was possible to commit a surface while the renderer was doing stuff, which was _very_ wrong. Initially the consequences of such a sin weren't obvious but, now that explicit synchronization is becoming more and more common, we can't commit a buffer randomly without basically guaranteeing a nasty, nasty crash (and we should have avoided commits altogether in the first place to ensure atomic surface updates). We now only trigger a commit _in the main thread_ when low processor usage mode is on _and_ if we know that we won't be rendering anything as, due to its intermittent nature, it makes "legacy" (pre xdg_wm_base v6) frame callback based suspension quite annoying. --- platform/linuxbsd/wayland/display_server_wayland.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'platform/linuxbsd/wayland/display_server_wayland.h') diff --git a/platform/linuxbsd/wayland/display_server_wayland.h b/platform/linuxbsd/wayland/display_server_wayland.h index f02640a12e..e611533664 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.h +++ b/platform/linuxbsd/wayland/display_server_wayland.h @@ -154,6 +154,8 @@ class DisplayServerWayland : public DisplayServer { virtual void _show_window(); + void try_suspend(); + public: virtual bool has_feature(Feature p_feature) const override; -- cgit v1.2.3