mirror of
https://github.com/games-on-whales/gst-wayland-display.git
synced 2026-10-15 12:51:57 +00:00
[PR #59] [MERGED] fix(vulkan): keep the encode-src reuse gate effective across header copies #60
Labels
No labels
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/gst-wayland-display#60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/gst-wayland-display/pull/59
Author: @salty2011
Created: 8/19/2026
Status: ✅ Merged
Merged: 9/7/2026
Merged by: @JBailes
Base:
feat/vulkan-encode← Head:fix/encode-src-gate-header-copies📝 Commits (3)
19fbf14fix(vulkan): keep the encode-src reuse gate effective across header copies772c4b8docs: WOLF_VULKAN_RING=1 throttles the stream53c21c2docs: WOLF_VULKAN_RING=1 does not stream, whatever the sink does📊 Changes
2 files changed (+70 additions, -34 deletions)
View changed files
📝
README.md(+1 -1)📝
wayland-display-core/src/utils/vulkan_nv12.rs(+69 -33)📄 Description
Problem
Two holes in the encode-src ring, both in code I added in #45.
to_gst_buffer()returns a bare clone of the slot's cached buffer, and copy-on-write defeats the reuse gate. Any element making the header writable at refcount 2 copies it, so the cached slot buffer drops back to refcount 1 while the copy, and the encoder reading through it, still point at the same VkImage. The gate inconvert_innerthen sees the slot as free and lets the producer overwrite an image an encode is still reading.Two ways in:
gst_buffer_make_writable()on the DISCONT frame ("marking pending DISCONT"). For a live source that means start-of-stream and after a flush. Per-framedo_timestampstamping does not trigger it, sincegst_base_src_do_syncwrites PTS/DTS directly.make_writable(videorate, for one) blinds the gate on every frame.Start-of-stream is not benign either. The first encode is the slowest (warm-up, DPB allocation), and at
RING=1the next frame reuses the same slot within a frame interval, so the one guaranteed COW lands on the frame most likely still in flight.Second hole: the gate's 1s timeout logged
"reusing anyway"and then overwrote the slot. That is the exact hazard the gate exists to prevent, and atRING=1there is no other slot to fall back to.Change
to_gst_bufferhands out a fresh child header carryingGstParentBufferMetaover the slot. The meta's COPY transform re-adds itself and re-refs the parent, so header copies keep the slot non-writable until the last child drops.do_timestampaNONEto stamp without touching the shared slot. That replaces the resetconvert_innerused to do, which is removed.Scope
encode_srconly. VA, RGBx and DMABuf keep the bare clone and are byte-identical.parent.copy()is a shallow header copy:GstVulkanImageMemoryis notNO_SHAREand the range is full, so the memory is ref'd, not duplicated. Zero-copy is intact, andGST_BUFFER_COPY_METAcarries the VideoMeta the encoder needs.Verified
cargo fmtclean,cargo checkclean, 23 tests pass.No runtime reproduction of the hazard. The mechanism is source-level against 1.28 (
gstbasesrc.c,gstbuffer.c,gstvkimagememory.c) and the change has production mileage downstream, but I have not demonstrated the gate blinding on hardware. Happy to if you want it before merging.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.