mirror of
https://github.com/games-on-whales/gst-wayland-display.git
synced 2026-10-15 21:02:00 +00:00
[PR #48] [MERGED] feat(vulkan): own the GstVulkanInstance/Device per element instead of process-globals #49
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#49
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/48
Author: @salty2011
Created: 7/26/2026
Status: ✅ Merged
Merged: 8/19/2026
Merged by: @JBailes
Base:
feat/vulkan-encode← Head:fix/per-element-vulkan-device📝 Commits (1)
672d603feat(vulkan): own the GstVulkanInstance/Device per element instead of process-globals📊 Changes
5 files changed (+231 additions, -124 deletions)
View changed files
📝
gst-plugin-wayland-display/src/waylandsrc/imp.rs(+18 -9)📝
wayland-display-core/src/comp/mod.rs(+16 -1)📝
wayland-display-core/src/lib.rs(+13 -0)📝
wayland-display-core/src/utils/allocator/mod.rs(+4 -2)📝
wayland-display-core/src/utils/vulkan_share.rs(+180 -112)📄 Description
Problem
The owned
GstVulkanInstance+GstVulkanDevicelive in two process-globalOnceLockslots, so everywaylanddisplaysrcin a process shares whichever one was minted first. That means:target_minor, ignoring their own.DEVICE_LOSTcorrupts all N.Change
VulkanShareper element, cloned once into that element's compositor thread. Same pattern as the existingapp_surface_commits/renderer_degradedArcs.gst.vulkan.{instance,device}with it. Ownership alone retires it: theArcdrops when the element is finalized, so N sessions no longer leak N devices.ensure_owned_deviceis byte-identical to the old global path, no vendor branch, RADV unchanged. C bridge untouched.Rebased onto
b49f7c0as a single commit now that #46 and #47 have landed.Your review points
Fan-out topology. Inside this crate, every buffer is minted on its own element's device (
set_caps->ensure_owned_device, ring built from the same share). Which device the encoder adopts is the embedder's context wiring, since the encoder is in a separate pipeline across interpipe.handle_set_contextnow keeps the device this element already holds and warns if a different one is offered. Your bin-fanout path is what convinced me: GstBin fans a have-context to every child, so two sources in one bin is enough, no mis-wired embedder needed. The cross-device pairing is refused in the crate rather than left to the embedder to check.Ordering contract worth stating: inject a device before caps negotiation or not at all.
set_capsmints eagerly, so a later injection is refused.stop()/start().
clear()is gone. Per-element ownership plus the compositor thread join already retire everything that matters atstop(), so it only made release earlier, and it was the sole source of the desync caveat this PR previously pushed onto embedders. What remains afterstop()is a bareVkDevice+VkInstanceheld until the element is finalized.Feature-gate. I believe this is already true on base, so I've left it:
Cargo.tomldeclaresgstreamer-vulkanfeatures = ["v1_28"]unconditionally, andutils/mod.rsdeclaresvulkan_share/vulkan_nv12unconditionally. A CUDA-only gst-1.24 build fails before this PR. The only new requirement was headers + a C compiler, documented inci/README.mdby #47. Say the word if you still want avulkanfeature.target_minor after an absorbed device. Left as-is, documented. The slot records no provenance, so the short-circuit cannot tell a self-minted device from an injected one. When they differ the encoder is already bound to the injected device, and re-minting on the requested node would split producer and encoder across two
VkDevices, which is worse than honouring the wrong node.Also done: tautological test dropped ·
repr(C)overlay doc claim fixed ·comp/mod.rsdoc drift fixed · lock order documented onensure_owned_device(only method holding both, so the inverse order can't arise) ·lib.rsfive-second comment deleted, that path cannot produce a VULKAN video info.Not needed:
new_ret_no_selfdoesn't fire (clippy exemptsnewreturningArc<Self>) ·raw_handlesis byte-identical to base, so the family-0 point is moot.Verified
cargo fmtclean ·checkandcheck --features cudaclean · rustdoc no broken links · 23 tests pass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.