Repository navigation
On Linux, a compressed scanout is captured correctly while no cursor shows - #11
Conversation
…shows With an Intel GPU, the video showed a pattern of dots and dark blocks in place of parts of the desktop while the mouse pointer was hidden, for example while the user typed in a terminal. With the pointer visible, the picture was correct. A compositor can scan out a framebuffer with a render-compression modifier, such as I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC. Such a framebuffer has planes after the pixel plane that hold the compression state. Intel's VAAPI driver refuses to import a buffer with that modifier. FFmpeg then imports the buffer again through the older interface, which carries no modifier, and the driver reads the compressed pixels as plain ones. The capture pipeline has two ways to the encoder. With a visible cursor, EGL imports the scanout with its modifier and all its planes, and draws it and the cursor into an RGB surface. Without a cursor, the VAAPI import of the scanout went to the encoder directly, and that import is the one that is wrong for a compressed buffer. A scanout with more planes than its pixel format now takes the EGL way also without a cursor. Other scanouts keep the direct way.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
Problem
On Linux computers with an Intel GPU, parts of the video show a pattern of dots and dark blocks in place of the desktop. Regions with fine detail, such as photos, look correct, and flat regions, such as a terminal background or a wallpaper, do not. The fault appears while the mouse pointer is hidden, and it goes away when the pointer shows again. The viewer reports no lost packets, no dropped frames and no keyframe requests during the fault, so the stream arrives complete and the encoded picture itself is wrong.
Cause
The fault is in the KMS capture pipeline, in the step that brings the scanout (the framebuffer that the display shows) to the encoder.
A compositor can scan out a framebuffer with a render-compression modifier. On the affected computers, GNOME's scanout has the format
XR30and the modifierI915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC(0x100000000000008). Such a framebuffer has planes after the pixel plane that hold the compression state of the pixels, and the pixel plane alone is not the picture.CursorVpp::composeincursor_vaapi.hhas two ways to the encoder:EGL imports the scanout with its modifier and all its planes, so the first way gives the correct picture. On the second way, Intel's VAAPI driver refuses the import, because
SetSurfaceParameterFromModifierin intel-media-driver has no case for this modifier. FFmpeg (vaapi_map_from_drm) then imports the buffer again through the older PRIME interface, which carries no modifier. The driver reads the compressed pixel plane as plain pixels, so every compressed block shows as garbage, and the fault follows the visibility of the cursor.Fix
CursorVpp::composenow takes the EGL way also without a cursor when the scanout has more planes than its pixel format: more than 2 forNV12, more than 1 for the other formats. The new functionhas_auxiliary_planesmakes that decision from the PRIME descriptor of the frame.CursorGL::composealready draws a scanout without a cursor, so it needs no change.The check is on the number of planes and not on a list of modifiers, because the extra planes are what the import without a modifier loses, for any vendor's modifier. A scanout without extra planes keeps the direct way, so computers that are not affected do not pay for the EGL step.
The limit on the cursor size (1024 pixels) still applies only to a visible cursor. The error text of a failed composition changes from "cursor EGL composition failed" to "scanout EGL composition failed", because the step now also runs without a cursor.
Testing
The test computer has an Intel N100, Ubuntu 26.04, Mesa 26.0.8 and intel-media-driver 26.1.2. On a spare virtual terminal,
kmscube -m 0x100000000000008 -f XR30shows a cube on a gray background on a scanout with the modifier above and without a cursor plane.--capture-testthen records 3 seconds, and the last frame of the recording is compared with the screen.X_TILED)X_TILED)The capture runs at up to 120 fps on this display. On the compressed scanout the EGL step costs frame rate on this GPU, and it is the same step that every frame with a visible cursor already takes. On the scanout that is not compressed, the frame rate and the bitrate (4955 and 4956 kbit/s) do not change.
The fault was first seen with version 0.4.5 on two computers with Intel Iris Xe graphics (12th and 13th generation Core), Debian 13, GNOME 48 on Wayland, Mesa 25.0.7 and intel-media-driver 25.2.3, at 2560x1440. On both, the picture was wrong with the pointer hidden and correct with the pointer visible. On one of them,
--capture-testof this change records the GNOME desktop correctly with the pointer visible, on a scanout with the modifier above, at 110.6 fps. The state with a hidden pointer was not available on that computer for this change, so the table above is the test of that state.Not in this PR
There is no automated test: the fault needs an Intel GPU and a compositor that scans out a compressed framebuffer, and the unit tests have neither.