mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
fix(gamescope): a pending scanout wait keeps its forwarded buffer alive
Patch 0147 waits for scanout on a forwarded client buffer with a raw pointer to its CWaylandFb. If the buffer was shown again and the next host release found scanout already over, that release dropped the last reference while the earlier wait was still queued, and the wait then called OnScanoutDone on a freed buffer. The wait now holds a reference until it finishes.
This commit is contained in:
1 parent
7ce53ccbed
commit
1e74d236a5
3 files changed
+25
-6
No files matched your search
@@ -494,5 +494,6 @@ gamescope returned the buffer to the client on that release, and a client whose
|
||||
fences attached to a dma-buf then drew into it while the display was still scanning it out, which showed as black
|
||||
tiles in compressed buffers. A forwarded client buffer now stays held until `poll(POLLOUT)` on its dma-buf reports
|
||||
that the display has finished with it, on a waiter thread so nothing else blocks. A release that arrives after the
|
||||
buffer was shown again is dropped, so the later release decides. Composite output images keep the 0146 path, and a
|
||||
buffer was shown again is dropped, so the later release decides. A pending wait holds its own reference on the
|
||||
buffer, since that later release can drop the host's reference before the wait ends. Composite output images keep the 0146 path, and a
|
||||
host that waits for the fence itself releases buffers that are already idle, so nothing changes there.
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp
|
||||
index 12f0f50..a0fedd4 100644
|
||||
index 12f0f50..d9db2e6 100644
|
||||
--- a/src/Backends/WaylandBackend.cpp
|
||||
+++ b/src/Backends/WaylandBackend.cpp
|
||||
@@ -3,24 +3,28 @@
|
||||
@@ -31,7 +31,7 @@ index 12f0f50..a0fedd4 100644
|
||||
#include <libdecor.h>
|
||||
|
||||
#include "wlr_begin.hpp"
|
||||
@@ -485,44 +489,82 @@ namespace gamescope
|
||||
@@ -485,44 +489,86 @@ namespace gamescope
|
||||
|
||||
// One backing plane plus every layer steamcompmgr can hand us.
|
||||
CWaylandPlane m_Planes[k_nMaxLayers + 1];
|
||||
@@ -78,8 +78,12 @@ index 12f0f50..a0fedd4 100644
|
||||
+ , m_nFd{ nFd }
|
||||
+ , m_ulAcquireSerial{ ulAcquireSerial }
|
||||
+ {
|
||||
+ // A later acquire and release can drop the compositor's reference before this wait ends.
|
||||
+ m_pFb->IncRef();
|
||||
+ }
|
||||
+
|
||||
+ ~CWaylandScanoutRelease() { m_pFb->DecRef(); }
|
||||
+
|
||||
+ int GetFD() override { return m_nFd; }
|
||||
+ void OnPollOut() override { Finish(); }
|
||||
+ void OnPollHangUp() override { Finish(); }
|
||||
@@ -115,7 +119,7 @@ index 12f0f50..a0fedd4 100644
|
||||
~CWaylandInputThread();
|
||||
|
||||
bool Init( CWaylandBackend *pBackend );
|
||||
@@ -969,73 +1011,108 @@ namespace gamescope
|
||||
@@ -969,73 +1015,108 @@ namespace gamescope
|
||||
.action = WAYLAND_NULL(),
|
||||
};
|
||||
const zwp_primary_selection_source_v1_listener CWaylandBackend::s_PrimarySelectionSourceListener =
|
||||
@@ -235,7 +239,7 @@ index 12f0f50..a0fedd4 100644
|
||||
, m_pBackend( pBackend )
|
||||
, m_Planes{ this, this, this, this, this, this, this, this, this }
|
||||
{
|
||||
@@ -2349,25 +2426,26 @@ namespace gamescope
|
||||
@@ -2349,25 +2430,26 @@ namespace gamescope
|
||||
pDmaBuf->format,
|
||||
0u );
|
||||
|
||||
|
||||
@@ -136,10 +136,21 @@ int main( int argc, char **argv ) {
|
||||
assert( fb.refs == 2 );
|
||||
d.scanning();
|
||||
fb.Wayland_Buffer_Release( fb.m_pHostBuffer );
|
||||
assert( fb.refs == 2 && fb.m_bCompositorAcquired );
|
||||
assert( fb.refs == 3 && fb.m_bCompositorAcquired );
|
||||
d.done();
|
||||
fire();
|
||||
assert( fb.refs == 1 && !fb.m_bCompositorAcquired && xdg_log.oh_no == 0 );
|
||||
} else if ( which == "stale-wait-keeps-buffer" ) {
|
||||
fb.client = true;
|
||||
fb.OnCompositorAcquire();
|
||||
d.scanning();
|
||||
fb.Wayland_Buffer_Release( fb.m_pHostBuffer );
|
||||
fb.OnCompositorAcquire();
|
||||
d.done();
|
||||
fb.Wayland_Buffer_Release( fb.m_pHostBuffer );
|
||||
assert( fb.refs == 2 && !fb.m_bCompositorAcquired );
|
||||
fire();
|
||||
assert( fb.refs == 1 && xdg_log.oh_no == 0 );
|
||||
} else if ( which == "client-idle" ) {
|
||||
fb.client = true;
|
||||
fb.OnCompositorAcquire();
|
||||
@@ -214,6 +225,9 @@ class ForwardedBufferScanoutTest(unittest.TestCase):
|
||||
def test_buffer_shown_again_waits_for_its_next_release(self):
|
||||
self.scenario("shown-again")
|
||||
|
||||
def test_pending_wait_keeps_the_buffer_after_a_later_release(self):
|
||||
self.scenario("stale-wait-keeps-buffer")
|
||||
|
||||
def test_buffer_without_dmabuf_is_released_at_once(self):
|
||||
self.scenario("no-dmabuf")
|
||||
|
||||
|
||||
Reference in new issue
Block a user