backends/drm: support tearing with atomic modesetting
With legacy, async pageflips automatically fall back to sync pageflips when they're not possible, but with atomic modesetting the commit fails instead. To handle when that happens I adjusted how frame scheduling is decided: RenderLoop
no longer controls the presentation mode. Instead, the Compositor
suggests a presentation mode to the backend, which attempts to do it, potentially falls back to normal VSync presentation, and only afterwards tells RenderLoop
about it. If async presentation isn't possible / the atomic commits fail, the RenderLoop
thus never changes its frame scheduling behavior, instead of continuously attempting to composite and commit new frames.
Another annoyance with async atomic commits is that only FB_ID
can be changed. I didn't want to special-case tearing everywhere, so I only disable the hardware cursor and only do tearing when the situation allows for it - if KWin changes color management properties for example, that'll make it fall back to synchronous presentation for the frames it changes them in, and go back to tearing later.
This can be tested with kernel 6.8+ and https://lore.kernel.org/dri-devel/20240629152204.666748-1-contact@emersion.fr/T/#u applied on top.