Repository navigation
feat(linux/kms): turn the stream upright when the compositor rotates the screen - #6234
Draft
miguelangel-nubla wants to merge 1 commit into
Draft
miguelangel-nubla wants to merge 1 commit into
miguelangel-nubla wants to merge 1 commit into
Conversation
…the screen A compositor that rotates a screen without the plane's hardware rotation (GNOME on amdgpu, for one) scans out a framebuffer with the picture already turned, and KMS captures it as it is: a portrait desktop streamed on its side (SunshineStream#3203). The Wayland output transform (viewport.transform, from wl_output) says how the picture is turned. When the captured plane isn't rotated by the hardware, the EGL conversion passes (VAAPI, CUDA) now sample the capture turned back: a rotation uniform in Scene.vert and ConvertUV.vert, with the letterbox sized for the upright picture. The display reports the upright size, and its own transform stays 0: the stream is upright, so absolute input maps onto the logical (xdg-output) size as it is, unlike wlgrab's sideways capture (SunshineStream#6020). Encoders that can't turn the picture (Vulkan, the RAM path) log a warning and stream it as captured, as before. Flipped transforms are left alone.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
On Linux, a compositor can rotate a screen in two ways: with the plane's hardware rotation, or by drawing the desktop already turned into a normal landscape framebuffer. GNOME on amdgpu does the latter (here, a 4K TV mounted in portrait and set to "Rotate right"). KMS capture reads that framebuffer as it is, so the stream shows the desktop on its side.
The Wayland output transform says how the picture is turned, and Sunshine already keeps it (
viewport.transform, from #6020). With this change, KMS capture uses it when the captured plane isn't rotated by the hardware:egl::sws_t, used by VAAPI and the CUDA GL path) sample the capture turned back. Arotationuniform (quarter turns) is added toScene.vertandConvertUV.vert; the cursor pass, drawn onto the capture before the conversion, keeps its default of 0. The letterbox is sized for the upright picture.transformstays 0. The picture is already upright, so absolute input maps onto the logical (xdg-output) size as it is, without the point rotation fix(linux/wlr): map absolute mouse input on rotated outputs #6020 added for wlgrab's sideways capture.The rule (transform and plane rotation to quarter turns) is a small free function,
platf::kms::upright_quarter_turns(), so it can be unit tested without a GPU.Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
tests/unit/platform/linux/test_kmsgrab_rotation.cpp(KmsGrabRotation.*) forupright_quarter_turns(): each transform turned back, reflection bits ignored, a hardware-rotated plane not turned, flipped and unknown transforms left alone.master(13ca613) withscripts/linux_build.sh(no CUDA) in an Ubuntu 26.04 amd64 container and rantest_sunshineunder Xvfb: 1019 tests, 1012 passed, 7 skipped, 0 failed (before the new tests: 1013, 1006, 7, 0).master, where fix(linux/wlr): map absolute mouse input on rotated outputs #6020 already keeps the transform). Before: the stream is on its side. After: Sunshine logsScreen rotated by the compositor (output transform 3): turning the stream upright, 2160x3840, the stream is upright, and an absolute mouse lands where pointed. With the Vulkan encoder it logs the warning and streams as before.egl::sws_tconversion), and rotations other than 270 on real hardware.uv.lock) reports no changes for the touched files.Type of Change
Checklist
AI Usage
See our AI usage policy.