feat(videoout): use native Wayland on Linux #3664
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3664"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-11T15:03:11Z.
What
On Linux the window now runs natively under a Wayland compositor instead of through XWayland.
CMakeLists.txt: build SDL's Wayland backend (SDL_WAYLAND ON) next to X11. SDL's defaults are kept: libwayland-client/-cursor/-egl, xkbcommon and libdecor are loaded withdlopenat run time, so the binary gains no new link-time dependencies.VideoOutDriver: on Linux, setSDL_HINT_VIDEODRIVERtowayland,x11beforeSDL_InitSubSystem(VIDEO). SDL2 lists X11 first in its bootstrap order, so without the hint it picks XWayland even in a Wayland session.WAYLAND_DISPLAY(and the session isn'twayland) or the libraries are missing, then uses X11. AnSDL_VIDEODRIVERenvironment variable still wins over the hint, soSDL_VIDEODRIVER=x11gets XWayland back. The ctest flip tests, which setSDL_VIDEODRIVER=offscreen, also keep their driver.build.yml,release.yml): installlibwayland-dev libxkbcommon-dev libegl-dev libdecor-0-dev, so the Linux release includes the backend. Without these packages configuration still succeeds and the build has X11 only.docs/dev/BUILD.md: lists the packages (Debian/Ubuntu and Fedora) and theSDL_VIDEODRIVER=x11override.Overlap: #3574 edits the same apt-get lines in both workflows and the same BUILD.md line. Whichever lands second only needs both package lists joined.
Tested
Arch Linux, KDE Plasma (Wayland), GCC, Release, RADV (RX 9070 XT), on main
a11c8f7f7.color views of several array slices are unsupported, #2102), the same as under X11.SDL_VIDEODRIVER=x11, and a run withWAYLAND_DISPLAYunset andXDG_SESSION_TYPE=x11: libX11 is loaded, libdecor is not, and the swapchain is created as before.video_out_flip_tests(lifetime, reopen, controls, overlay) withANYPS5_REQUIRE_DISPLAY=1and noSDL_VIDEODRIVER, so they run on native Wayland: all pass.ctest: 832/832 (the 5 display/device tests skip as on main).tools/check_conventions.pypasses.🤖 Generated with Claude Code
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Assisted by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-11T15:23:01Z.
All three claims that decide whether this is safe check out against the vendored SDL2.
3rdparty/SDL2/CMakeLists.txt:475-478hasSDL_WAYLANDdefaulting on for Unix andSDL_WAYLAND_SHAREDdefaulting toON— "Dynamically load Wayland support" — so the backend is resolved at runtime and a build without the packages stays X11-only.SDL_video.c:522, insideSDL_VideoInit, readsSDL_GetHint(SDL_HINT_VIDEODRIVER)and walks it withwhile (driver_attempt && *driver_attempt != 0 && !video), splitting on,at :523 and trying each bootstrap in turn — so"wayland,x11"is a bootstrap order rather than a single name, which is what makes the X11 fallback inside the same string work instead of needing separate logic. (The similarly-shaped walk at :4517 belongs toSDL_ShowSimpleMessageBox, not to video init.)SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER), beside the existingSDL_HINT_WINDOWS_DPI_AWARENESSwrite. The constructor is reachable only through the function-localstatic VideoOutDriver instanceinGet(), so C++11's thread-safe one-time initialisation makes it a single, race-free write before SDL starts at all. A video-driver hint set anywhere later would be too late, and this placement avoids that by construction.SDL_SetHintrather thanSDL_SetHintWithPriorityis also what keeps the environment override working, since a hint at normal priority loses to the same name in the environment.One thing I would ask about, because it changes behaviour for every Linux user rather than only Wayland sessions. Preferring Wayland when the session provides it is clearly right. The question is whether the default should flip in this PR or behind a documented option, given that the fallback paths are only exercised by some sessions — no
WAYLAND_DISPLAY, no libdecor, or a compositor that constrains window size differently. The description already documentsSDL_VIDEODRIVER=x11as the way back, which is what makes either choice defensible; I would just want the flip to be a deliberate decision rather than a side effect of adding the backend.The note about #3574 touching the same
apt-getlines and the sameBUILD.mdline is the right thing to have written down, and joining both package lists is the obvious resolution.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T04:33:40Z.
Tested on Hyprland (Omarchy, Arch) with an Intel GPU (Core Ultra X7 358H, Xe, Mesa 26.2.2 ANV), Release, this PR (b02ef22c6) merged onto
main37dd48308(only the workflow and BUILD.md conflicts, resolved tomainfor a local build).SDL_WAYLANDconfigures ON andSDL_VIDEO_DRIVER_WAYLANDis defined.Native Wayland, no X server and no
DISPLAYin the session, catalog releases relinked with--to-intel, 25 s each:app.elf), overlay drawnAll four were still running at 25 s; screenshots match what they draw under XWayland.
One caveat about the documented override:
SDL_VIDEODRIVERis also visible to titles that ship their own SDL. WithSDL_VIDEODRIVER=x11(and a working X server onDISPLAY), OpenRCT2 aborts at start-up withimport: no video: x11 not availablefrom its bundled SDL, while DOOM runs normally. I hit the same onmainwith the variable set for the host. So the BUILD.md line may want a note that the override can break titles with their own SDL, or the host choice could use a variable the guest doesn't read.Tested with Claude Code assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:35:16Z.
Review: DISMISSED
The change looks right and the third-party runs on KDE and Hyprland cover it. It now conflicts with
main:.github/workflows/build.ymland.github/workflows/release.yml: the apt-get line now also installslibpipewire-0.3-dev libpulse-dev libasound2-dev; keep those and appendlibwayland-dev libxkbcommon-dev libegl-dev libdecor-0-dev.docs/dev/BUILD.md: the Linux requirements line gained the audio packages; join it with the Wayland text.Please rebase on current
mainand push; it can be merged once CI is green.Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-13T16:18:52Z.
Rebased onto current
main(0214069e3) as one commit, 040d2f5a6.build.yml/release.yml: kept main's packages (libpipewire-0.3-dev libpulse-dev libasound2-dev libxrandr-dev), addedlibwayland-dev libxkbcommon-dev libegl-dev libdecor-0-dev, and kept main's mesa cache steps as they are.BUILD.md: kept main's XRandR line and joined the Wayland text into the Linux requirements line beside the audio packages.SDL_VIDEODRIVERtoo, and some of them fail to start withx11.Built locally on Linux (Release), and SDL configures with both backends:
SDL_VIDEO_DRIVER_WAYLAND(dynamic, with libdecor) andSDL_VIDEO_DRIVER_X11.tools/check_conventions.pypasses.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T05:28:09Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppL263.github/workflows/release.ymlL65Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-14T05:28:18Z.
Rebased onto current
main(e2cd21314) as040873f9d. #5580 added a Windows-onlySDL_HINT_DIRECTINPUT_ENABLEDhint at the same spot inVideoOutDriver.cpp. Both are kept: the_WIN32block and then the__linux__Wayland hint. Nothing else changed. Built locally (Release,SDL_WAYLANDON); thevideo_outtests pass (13/13) andtools/check_conventions.pypasses.