Upload shared-memory pixels again when client buffers are reused

This commit is contained in:
xXJsonDeruloXx committed 2026-10-03 15:10:32 -04:00
1 parent feb1fb1faa
commit b0b5f78d5d
1 file changed
+42 -3
@@ -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<CVulkanTexture> 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<gamescope::IBackendFb> pBackendFb;
- if ( wlr_buffer_get_dmabuf( buf, &dmabuf ) )
+ if ( bHasDmabuf )
{
+ if ( gamescope::OwningRc<CVulkanTexture> 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<CVulkanTexture> 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;
+ }