Skip to content

wayland: Implement direct scanout for cropped and scaled surfaces

Robert Mader requested to merge rmader/mutter:viewport-scanout into main

Until now we only supported direct scanout to the primary plane if the buffer size perfectly matched the display size. Since display controllers usually support scaling and cropping buffers highly efficiently, try to let them do the job. This is usually helpful if wp_viewporter is used by the client or Mutter uses fractional scaling.

This has several advantages:

  • Games (e.g. SDL2 based ones) can almost always hit direct scanout paths in fullscreen mode. Notably when fractional scaling is used or the game renders in a non-native resolution (or both).
  • Video players using YUV buffer formats and wp_viewporter can easily hit direct scanout paths, making displaying video very power efficient as the 3D engine is not used at all.

Note that this still only uses the primary plane, no overlay or underlay planes, making this change comparatively low risk.


Suggested test clients:

  • gtk4 demo video player: gtk!6618 (merged)
  • weston-simple-egl -f -r / weston-simple-dmabuf-v4l -s
  • Xonotic (make sure to use the Wayland backend)
    • SDL_VIDEODRIVER=wayland xonotic-sdl
  • mpv master (with https://github.com/mpv-player/mpv/pull/12237)
    • mpv --hwdec=vaapi --vo=dmabuf-wayland sintel_trailer-1080p.mp4 --fs
    • mpv --hwdec=vaapi --vo=dmabuf-wayland --vf=format=yuv422p sintel_trailer-1080p.mp4 -fs (display controllers not supporting NV12 but YUYV like my Skylake system)
  • Gstreamer
    • gst-launch-1.0 filesrc location=sintel_trailer-1080p.mp4 ! qtdemux ! h264parse ! vah264dec ! vapostproc ! waylandsink fullscreen=1

This was tested already on an Intel, AMD, RK3399 (panfrost) and a Raspberry Pi 4B.


See also:

Fixed bug in preparation:

Edited by Robert Mader

Merge request reports

Loading