fix(capture/mutter): restore zero-copy + sync via dmabuf implicit fence
ci / web (push) Failing after 42s
apple / swift (push) Failing after 1m5s
ci / rust (push) Failing after 1m10s
ci / docs-site (push) Failing after 44s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 5s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 5s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 5s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 5s
deb / build-publish (push) Successful in 2m54s
docker / deploy-docs (push) Successful in 18s
rpm / build-publish (push) Successful in 5m13s

The previous attempt (8531135) dropped zero-copy on Mutter+NVIDIA for a sticky
CPU/SHM fallback that (a) still listed SPA_DATA_DmaBuf in its buffer types, so
Mutter kept handing dmabufs that got mmap-read UNsynced — making the flashing
worse, not better — and (b) hinged on producer explicit sync, which Mutter+NVIDIA
cannot do (`error alloc buffers` / no cogl sync_fd, confirmed in worker-3 logs).

Revert the capture restructure to the original zero-copy dmabuf path, and fix the
NVIDIA stale-frame race the RIGHT way for a producer that can't do explicit sync:
the consumer snapshots the dmabuf's implicit fence (DMA_BUF_IOCTL_EXPORT_SYNC_FILE)
and waits the producer's render before sampling (new dmabuf_fence module, ioctl
number unit-tested). Covers the GPU import and the CPU mmap read. Logs once whether
a render was actually in flight (waited=true → the driver fences and the race is
closed; false → no implicit fence, so we learn zero-copy still needs SHM here).

drm_sync (the explicit-sync primitive) is kept and verified but marked unused —
no targeted compositor produces a usable sync_fd today; ready to wire in when one
does. The Bug-2 input fix (held-key release on disconnect) from 8531135 is kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-13 09:28:17 +00:00
parent 8531135bb7
commit 92c6da9546
9 changed files with 277 additions and 443 deletions
@@ -83,7 +83,6 @@ impl VirtualDisplay for GamescopeDisplay {
point_injector_at_eis();
tracing::info!(node_id, "gamescope: attaching to existing PipeWire node");
return Ok(VirtualOutput {
mutter: false,
node_id,
remote_fd: None,
preferred_mode: Some((mode.width, mode.height, mode.refresh_hz)),
@@ -108,7 +107,6 @@ impl VirtualDisplay for GamescopeDisplay {
"gamescope virtual output ready"
);
Ok(VirtualOutput {
mutter: false,
node_id,
remote_fd: None,
preferred_mode: Some((mode.width, mode.height, mode.refresh_hz)),
@@ -138,7 +136,6 @@ fn create_managed_session(client: &str, mode: Mode) -> Result<VirtualOutput> {
"gamescope session: reusing the running session (same mode — no Steam restart)"
);
return Ok(VirtualOutput {
mutter: false,
node_id,
remote_fd: None,
preferred_mode: Some((mode.width, mode.height, mode.refresh_hz)),
@@ -165,7 +162,6 @@ fn create_managed_session(client: &str, mode: Mode) -> Result<VirtualOutput> {
"gamescope session: launched gamescope-session-plus at the client's mode"
);
Ok(VirtualOutput {
mutter: false,
node_id,
remote_fd: None,
preferred_mode: Some((mode.width, mode.height, mode.refresh_hz)),
@@ -104,7 +104,6 @@ impl VirtualDisplay for KwinDisplay {
mode.refresh_hz
};
Ok(VirtualOutput {
mutter: false,
node_id,
remote_fd: None,
preferred_mode: Some((mode.width, mode.height, achieved_hz)),
@@ -85,7 +85,6 @@ impl VirtualDisplay for MutterDisplay {
"Mutter virtual monitor ready"
);
Ok(VirtualOutput {
mutter: true,
node_id,
remote_fd: None,
preferred_mode: Some((mode.width, mode.height, mode.refresh_hz)),
@@ -123,7 +123,6 @@ impl VirtualDisplay for WlrootsDisplay {
"sway headless output ready"
);
Ok(VirtualOutput {
mutter: false,
node_id,
remote_fd: Some(fd),
preferred_mode: Some((mode.width, mode.height, mode.refresh_hz)),