From f72aeacd6e0366b99a39996f561bf87c8ab86d41 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Mon, 8 Aug 2022 00:40:21 -0400 Subject: [PATCH] wlr_scene: Add option to disable direct scanout Closes: #3405 Supersedes: !3562 Co-authored-by: Xiao YaoBing --- docs/env_vars.md | 1 + include/wlr/types/wlr_scene.h | 1 + types/scene/wlr_scene.c | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/docs/env_vars.md b/docs/env_vars.md index 6a0a9442..e5d5d62b 100644 --- a/docs/env_vars.md +++ b/docs/env_vars.md @@ -50,6 +50,7 @@ wlroots reads these environment variables * *WLR_SCENE_DEBUG_DAMAGE*: specifies debug options for screen damage related tasks for compositors that use scenes (available options: none, rerender, highlight) +* *WLR_SCENE_DISABLE_DIRECT_SCANOUT*: disables direct scan-out for debugging. # Generic diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 85d0f94e..a8737921 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -93,6 +93,7 @@ struct wlr_scene { struct wl_listener presentation_destroy; enum wlr_scene_debug_damage_option debug_damage_option; + bool direct_scanout; }; /** A scene-graph node displaying a single surface. */ diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 68b05b7c..3c458116 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -164,6 +164,20 @@ struct wlr_scene *wlr_scene_create(void) { scene->debug_damage_option = WLR_SCENE_DEBUG_DAMAGE_NONE; } + char *disable_direct_scanout = getenv("WLR_SCENE_DISABLE_DIRECT_SCANOUT"); + if (disable_direct_scanout) { + wlr_log(WLR_INFO, "Loading WLR_SCENE_DISABLE_DIRECT_SCANOUT option: %s", disable_direct_scanout); + } + + if (!disable_direct_scanout || strcmp(disable_direct_scanout, "0") == 0) { + scene->direct_scanout = true; + } else if (strcmp(disable_direct_scanout, "1") == 0) { + scene->direct_scanout = false; + } else { + wlr_log(WLR_ERROR, "Unknown WLR_SCENE_DISABLE_DIRECT_SCANOUT option: %s", disable_direct_scanout); + scene->direct_scanout = true; + } + return scene; } @@ -1140,6 +1154,10 @@ static void check_scanout_iterator(struct wlr_scene_node *node, } static bool scene_output_scanout(struct wlr_scene_output *scene_output) { + if (!scene_output->scene->direct_scanout) { + return false; + } + if (scene_output->scene->debug_damage_option == WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT) { // We don't want to enter direct scan out if we have highlight regions