Skip to content

Enable automatic direct scanout for fullscreen games - #11553

Closed
candrewlee14 wants to merge 2 commits into
omacom:quattrofrom
candrewlee14:feat/hyprland-direct-scanout-and-tearing
Closed

candrewlee14 wants to merge 2 commits into
omacom:quattrofrom
candrewlee14:feat/hyprland-direct-scanout-and-tearing

Conversation

@candrewlee14

@candrewlee14 candrewlee14 commented Sep 12, 2026 •

Copy link
Copy Markdown

Summary

Sets Hyprland render.direct_scanout = 2, allowing automatic direct-scanout attempts for fullscreen content identified as games. Experimental asynchronous tearing remains disabled.

Why

Direct scanout can avoid an unnecessary compositor copy when a compatible fullscreen game is the only visible surface. Mode 2 is the conservative automatic setting: Hyprland limits attempts to game content and falls back to normal composition when scanout is unavailable.

CachyOS ships the same direct_scanout = 2 Hyprland default:

Hyprland documents the setting and recommends disabling it on systems where fullscreen applications show graphical glitches:

Changes

  • default/hypr/looknfeel.lua: configure render.direct_scanout = 2 while retaining general.allow_tearing = false.
  • test/shell.d/hypr-direct-scanout-test.sh: verify automatic direct scanout is configured without enabling experimental tearing.

Verification

  • bash test/shell.d/hypr-direct-scanout-test.sh passes.
  • ./test/shell reaches and passes the new coverage. The full run has seven pre-existing environment-dependent failures (including unavailable omarchy-pkgs, /var/tmp ownership assumptions, and missing Wayland runtime coverage).
  • On a live Hyprland 0.56.2 session, hyprctl getoption render:direct_scanout reports int: 2; normal windowed applications remain composited.

@candrewlee14 candrewlee14 changed the title Enable Direct Scanout and allow async tearing for fullscreen games in Hyprland Enable automatic direct scanout for fullscreen games Sep 12, 2026
@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@llstrk

llstrk commented Oct 1, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: On Omarchy the setting mainly reaches RetroArch; the new test passes with it commented out.

Proton and SDL games are unaffected

Mode 2 scans out only fullscreen windows of content type game, set by the client or a window rule (Omarchy has none). Xwayland, SDL, Mesa's Vulkan WSI, Wine/Proton and gamescope don't send it, so their games stay composited; RetroArch does. From source, not run.

Suggested change: describe the reach as "clients that tag themselves as games, such as RetroArch", or add a content = "game" rule as CachyOS does, exposing them to open direct-scanout bugs.

The test misses a disabled setting

The grep passes when direct_scanout = 2 is commented out (stays 0) or moved under general (unknown key). So it misses edits that disable the setting but keep the text.

Suggested change: evaluate it in Lua like hyprland-default-config-test.sh (see reproducer).

Reproducer (at 5e936e3)

Run from the root of a checkout of the PR head (5e936e3). It copies test/ and
default/ to a temporary directory, edits the copy of
default/hypr/looknfeel.lua, and runs the PR's test, a Lua-evaluating
alternative and (when installed) Hyprland --verify-config on each copy.
Needs lua; the Hyprland step ran on Hyprland 0.56.2.

#!/bin/bash
# Run from the root of a checkout of the PR head (5e936e3).
# Breaks default/hypr/looknfeel.lua in two ways and shows what the PR's test,
# a Lua-evaluating test, and Hyprland's own config check say about each copy.
set -u
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT

cat >"$work/hyprland-direct-scanout-test.sh" <<'TEST'
#!/bin/bash

source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh"

require_command lua

# Evaluate the package default the way Hyprland merges it: every hl.config()
# call sets the dotted keys it names, and a later call wins.
settings=$(OMARCHY_PATH="$ROOT" lua <<'LUA'
local merged = {}

local function merge(prefix, tbl)
  for key, value in pairs(tbl) do
    local name = prefix == "" and key or prefix .. "." .. key
    if type(value) == "table" and type(next(value)) == "string" then
      merge(name, value)
    else
      merged[name] = value
    end
  end
end

hl = setmetatable({
  config = function(tbl) merge("", tbl) end,
}, {
  __index = function() return function() end end,
})

dofile(os.getenv("OMARCHY_PATH") .. "/default/hypr/looknfeel.lua")

print("render.direct_scanout=" .. tostring(merged["render.direct_scanout"]))
print("general.allow_tearing=" .. tostring(merged["general.allow_tearing"]))
LUA
)

grep -Fxq 'render.direct_scanout=2' <<<"$settings" ||
  fail "default looknfeel sets render.direct_scanout to 2" "$settings"
pass "default looknfeel sets render.direct_scanout to 2"

grep -Fxq 'general.allow_tearing=false' <<<"$settings" ||
  fail "default looknfeel keeps general.allow_tearing off" "$settings"
pass "default looknfeel keeps general.allow_tearing off"
TEST

check() { # label sed-args...
  local label=$1
  shift
  rm -rf "$work/repo"
  mkdir "$work/repo"
  cp -R test default "$work/repo/"
  chmod -R u+w "$work/repo"
  [[ $# -gt 0 ]] && sed -i "$@" "$work/repo/default/hypr/looknfeel.lua"
  cp "$work/hyprland-direct-scanout-test.sh" "$work/repo/test/shell.d/"

  echo "=== $label"
  diff default/hypr/looknfeel.lua "$work/repo/default/hypr/looknfeel.lua"
  echo "--- PR test (hypr-direct-scanout-test.sh)"
  (cd "$work/repo" && bash test/shell.d/hypr-direct-scanout-test.sh 2>&1)
  echo "exit=$?"
  echo "--- Lua-evaluating test (hyprland-direct-scanout-test.sh)"
  (cd "$work/repo" && bash test/shell.d/hyprland-direct-scanout-test.sh 2>&1)
  echo "exit=$?"
  if command -v Hyprland >/dev/null; then
    echo "--- Hyprland --verify-config"
    printf 'dofile("%s/repo/default/hypr/looknfeel.lua")\n' "$work" >"$work/check.lua"
    Hyprland --verify-config -c "$work/check.lua" 2>&1 | sed -n '/Config parsing result/,$p' | sed "s|$work|<tmp>|g" | grep -v '^$'
  fi
}

check "PR head, unchanged"
check "direct_scanout line commented out" 's/^    direct_scanout = 2,$/    -- direct_scanout = 2,/'
check "direct_scanout moved under general" -e '/^  render = {$/,/^  },$/d' -e 's/^    allow_tearing = false,$/&\n    direct_scanout = 2,/'

Output (Hyprland 0.56.2, Lua 5.5.1):

=== PR head, unchanged
--- PR test (hypr-direct-scanout-test.sh)
ok - direct scanout is automatic for fullscreen game content
ok - direct scanout does not enable experimental tearing
exit=0
--- Lua-evaluating test (hyprland-direct-scanout-test.sh)
ok - default looknfeel sets render.direct_scanout to 2
ok - default looknfeel keeps general.allow_tearing off
exit=0
--- Hyprland --verify-config
======== Config parsing result:
config ok
=== direct_scanout line commented out
24c24
<     direct_scanout = 2,
---
>     -- direct_scanout = 2,
--- PR test (hypr-direct-scanout-test.sh)
ok - direct scanout is automatic for fullscreen game content
ok - direct scanout does not enable experimental tearing
exit=0
--- Lua-evaluating test (hyprland-direct-scanout-test.sh)
render.direct_scanout=nil
general.allow_tearing=false
not ok - default looknfeel sets render.direct_scanout to 2
exit=1
--- Hyprland --verify-config
======== Config parsing result:
config ok
=== direct_scanout moved under general
18a19
>     direct_scanout = 2,
22,25d22
<   render = {
<     -- Attempt direct scanout automatically for fullscreen game content.
<     direct_scanout = 2,
<   },
--- PR test (hypr-direct-scanout-test.sh)
ok - direct scanout is automatic for fullscreen game content
ok - direct scanout does not enable experimental tearing
exit=0
--- Lua-evaluating test (hyprland-direct-scanout-test.sh)
render.direct_scanout=nil
general.allow_tearing=false
not ok - default looknfeel sets render.direct_scanout to 2
exit=1
--- Hyprland --verify-config
======== Config parsing result:
<tmp>/repo/default/hypr/looknfeel.lua:6: unknown config key 'general.direct_scanout'
Details
  • Verified: Hyprland 0.56.2 --verify-config on the head's looknfeel.lua reports config ok and reads back render.direct_scanout=2 (default 0) and general.allow_tearing=false.
  • Verified: the patch merges cleanly onto the current quattro tip; open PRs Keep the cursor in place when switching workspaces #7899, Pulse the fingerprint glyph and flag a rejected scan #12291 and Make locked Hyprland groups follow the theme #13565 edit other hunks of looknfeel.lua.
  • Verified: a user can opt out with hl.config({ render = { direct_scanout = 0 } }) in ~/.config/hypr/looknfeel.lua, which loads after the defaults. Hyprland 0.56.2's Lua config rejects the string form ("auto"), so examples need integers.
  • Hyprland 0.56.2's Lua config does not range-check the value (direct_scanout = 3 verifies as config ok), and the unanchored grep also accepts direct_scanout = 20.
  • Reach source (0.56.2): Monitor.cpp:2030-2041 and Window.cpp:1756-1770. The CachyOS config the PR cites pairs mode 2 with content = "game" rules for steam_app.*|gamescope (in its windowrules.lua). Such a tag also changes other game-keyed behaviour (no_break_fs_vrr, the DRM content type sent to the monitor).
  • How to confirm the reach (true fullscreen, nothing else blocking scanout such as a screen share): with a Proton game fullscreen, hyprctl -j monitors should list "CONTENT" in directScanoutBlockedBy; with RetroArch fullscreen, directScanoutTo should be non-zero.
  • Optional: open Hyprland discussion Prevent mise wrappers recursing when ~/.local/bin precedes mise in PATH (#14831) #14843 reports black screens under direct scanout for some native-Wayland games on NVIDIA and some AMD GPUs (one commenter: with Vulkan), which matches RetroArch's Omarchy setup (Vulkan driver, forced fullscreen). Not reproduced; one fullscreen RetroArch check would settle it.
  • Optional: name the file hyprland-direct-scanout-test.sh; the 11 existing hyprland-* tests use that prefix and no test uses hypr-.

Review information

Test scope: Source and sandbox runs on Hyprland 0.56.2 at 5e936e3; no live session, GPU or game.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for this. Closing because the default is going the other way: direct_scanout = 1 shipped in 4.6.0-rc2 and caused a modeset flash on NVIDIA and AMD (#20683) and a black fullscreen on Apple Silicon (#21072), so #21211 returns it to Hyprland's default of 0, and 2 would still flash for games that set the content-type hint. Anyone who wants scanout can set it in their own looknfeel.lua. Closed at the maintainer's request; checked by Opus 5.5 in Claude Code.

@omarchybot omarchybot closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants