Skip to content

WaylandBackend: avoid reattaching static black buffer - #2448

Merged
matte-schwartz merged 1 commit into
ValveSoftware:masterfrom
connormclaud:fix/wayland-fb-acquire-once
Sep 30, 2026
Merged

matte-schwartz merged 1 commit into
ValveSoftware:masterfrom
connormclaud:fix/wayland-fb-acquire-once

Conversation

@connormclaud

Copy link
Copy Markdown

Keep the immutable 1x1 backing buffer attached across presents.

The Wayland core protocol says: "wl_surface.commit makes the pending wl_buffer the new surface contents." Reattaching the unchanged buffer on every paint is unnecessary.

fixes: #1636

@connormclaud
connormclaud marked this pull request as ready for review September 29, 2026 20:01
@matte-schwartz

Copy link
Copy Markdown
Collaborator

I think the fix is better placed in how we track the black buffer than in CWaylandPlane::Present.

We probably want something more like:

diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp
index d53c2c4..b3a1221 100644
--- a/src/Backends/WaylandBackend.cpp
+++ b/src/Backends/WaylandBackend.cpp
@@ -980,6 +980,9 @@ namespace gamescope

         xdg_log.debugf( "buffer_release: %p", pBuffer );

+        if ( this == m_pBackend->GetBlackFb() )
+            return;
+
         OnCompositorRelease();
     }

@@ -1106,8 +1109,6 @@ namespace gamescope
                 uint32_t uCurrentPlane = 0;
                 if ( bNeedsBacking )
                 {
-                    m_pBackend->GetBlackFb()->OnCompositorAcquire();
-
                     CWaylandPlane *pPlane = &m_Planes[uCurrentPlane++];
                     pPlane->Present(
                         WaylandPlaneState

can you check if that works? that way we don't need the BufferAttachPolicy/BufferAttachResult plumbing or the last-attached-buffer tracking

The 1x1 black backing framebuffer is immutable, backend-owned, and never needs client buffer locking. Tracking acquire and release on it causes spurious "Compositor released us but we were not acquired" error spam when buffer release events arrive asynchronously from previous frames.

Fixes: ValveSoftware#1636
@connormclaud
connormclaud force-pushed the fix/wayland-fb-acquire-once branch from 3cdb8c7 to 20b80fa Compare September 30, 2026 17:09
@connormclaud

Copy link
Copy Markdown
Author

I have tested your patch works with glxgears, vkcube, Diablo 2 Resurrected and Antichamber and updated PR with it

@matte-schwartz

Copy link
Copy Markdown
Collaborator

thanks!

@matte-schwartz
matte-schwartz merged commit 175a672 into ValveSoftware:master Sep 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] xdg_backend: Compositor released us but we were not acquired. Oh no.

3 participants