From b0b5f78d5ddacee698fc3c7303ba4681d88ac010 Mon Sep 17 00:00:00 2001 From: xXJsonDeruloXx Date: Sat, 3 Oct 2026 15:10:32 -0400 Subject: [PATCH] Upload shared-memory pixels again when client buffers are reused --- .../patches/0115-private-shm-commits.patch | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/tools/gamescope/patches/0115-private-shm-commits.patch b/tools/gamescope/patches/0115-private-shm-commits.patch index 1bbc1e75f..e2bbee37e 100644 --- a/tools/gamescope/patches/0115-private-shm-commits.patch +++ b/tools/gamescope/patches/0115-private-shm-commits.patch @@ -1,14 +1,53 @@ diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp -index 18b799e..fe0a712 100644 +index 18b799e..26cf64e 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp -@@ -8504,6 +8504,12 @@ void update_wayland_res(CommitDoneList_t *doneCommits, steamcompmgr_win_t *w, Re +@@ -1850,19 +1850,20 @@ import_commit ( + commit->fifo = false; + } + +- if ( gamescope::OwningRc pTexture = s_BufferMemos.LookupVulkanTexture( buf ) ) +- { +- // Going from OwningRc -> Rc now. +- commit->vulkanTex = pTexture; +- return commit; +- } +- + struct wlr_dmabuf_attributes dmabuf = {0}; ++ const bool bHasDmabuf = wlr_buffer_get_dmabuf( buf, &dmabuf ); + gamescope::OwningRc pBackendFb; +- if ( wlr_buffer_get_dmabuf( buf, &dmabuf ) ) ++ if ( bHasDmabuf ) + { ++ if ( gamescope::OwningRc pTexture = s_BufferMemos.LookupVulkanTexture( buf ) ) ++ { ++ commit->vulkanTex = pTexture; ++ return commit; ++ } + pBackendFb = GetBackend()->ImportDmabufToBackend( &dmabuf ); + } ++ // A dma-buf image aliases its backing storage. A wl_shm texture is a private copy: ++ // upload each commit, since clients reuse the same buffer with different pixels. + + gamescope::OwningRc pOwnedTexture = vulkan_create_texture_from_wlr_buffer( buf, std::move( pBackendFb ) ); + +@@ -1873,7 +1874,8 @@ import_commit ( + + commit->vulkanTex = pOwnedTexture; + +- s_BufferMemos.MemoizeBuffer( buf, std::move( pOwnedTexture ) ); ++ if ( bHasDmabuf ) ++ s_BufferMemos.MemoizeBuffer( buf, std::move( pOwnedTexture ) ); + + return commit; + } +@@ -8504,6 +8506,12 @@ void update_wayland_res(CommitDoneList_t *doneCommits, steamcompmgr_win_t *w, Re { fence = dup( dmabuf.fd[0] ); } + else if ( !newCommit->vulkanTex->externalImage() ) + { -+ // wl_shm uploads wait for their copy to finish in vulkan_texture_from_wlr_buffer. ++ // wl_shm uploads wait for their copy to finish in vulkan_create_texture_from_wlr_buffer. + // A private swapchain texture has no dma-buf to poll; it is already ready. + bKnownReady = true; + }