mirror of
https://github.com/games-on-whales/gst-wayland-display.git
synced 2026-10-15 21:02:00 +00:00
[PR #47] [MERGED] fix(vulkan): replace guessed struct offsets with a header-compiled bridge; plug two leaks #47
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#47
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/47
Author: @salty2011
Created: 7/26/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @JBailes
Base:
feat/vulkan-encode← Head:fix/vulkan-abi-bridge📝 Commits (3)
75aef9ffix(vulkan): replace guessed struct offsets with a header-compiled bridge; plug two leaks208897freview: gst_clear_object on barrier queue; drop drifted doc comment; restore fan-out gate rationaleaeaff0efix(vulkan): resolve vkDestroySemaphore through gst; drop the libvulkan link📊 Changes
6 files changed (+123 additions, -92 deletions)
View changed files
📝
Cargo.lock(+1 -0)📝
ci/README.md(+1 -0)📝
wayland-display-core/Cargo.toml(+1 -0)📝
wayland-display-core/build.rs(+16 -2)➕
wayland-display-core/src/utils/vulkan_bridge.c(+64 -0)📝
wayland-display-core/src/utils/vulkan_share.rs(+40 -90)📄 Description
The encode-src path reaches into GStreamer Vulkan structs by writing hardcoded byte offsets from Rust:
plus
#[repr(C)]overlay structs mirroringGstVulkanInstance,GstVulkanDevice,GstVulkanQueueandGstVulkanImageMemory.The comments record that the offsets were verified with an
offsetofprobe against the running headers, and they are correct today. The concern is the failure mode: if any of those structs gains or reorders a field, the result is a silent write to the wrong memory rather than a build error, and each overlay has to be re-verified by hand against every GStreamer version.This replaces both mechanisms with a small C bridge (
vulkan_bridge.c) compiled against the actual GStreamer Vulkan headers viabuild.rs, so field access is checked by the compiler and tracks the headers automatically. Two behavior changes ride along, both replacing guesses with failure:raw_handles()no longer falls back to queue family 0 whenselect_queue(GRAPHICS)returns null. It returnsNone, andGsVulkanBuf::newturns that into Vulkan output failure instead of submitting on a guessed family.recover_vk_image()returnsNoneon a null image instead of handing back a garbage handle.Both are intended. The layout and fan-out handling is unchanged.
Two leaks surfaced while moving the barrier reset into the bridge
Per-image
VkSemaphorehandle leak. Clearingbarrier.parent.semaphoreby writing the field left the timeline semaphore the allocator created undestroyed — one leaked handle per encode-src image. The bridge now callsvkDestroySemaphorebefore clearing.Per-call
GstVulkanQueueleak.gst_vulkan_device_select_queue()is transfer-full, butraw_handles()only read the queue family off the returned object and dropped the pointer, leaking one queue object per call. It is now taken withfrom_glib_fulland released once the family index has been read.Scope
Deliberately limited to the ABI-safety change and those two leaks. I also carry a separate change that makes the producer participate in
GstVulkanQueue's submission lock, which I have not included here: it was written for aVK_ERROR_DEVICE_LOST/ Xid theory on my hardware that later turned out to have a different, proven cause (a buffer-reuse gate blinded by a header copy), so I have no evidence it fixes anything and did not want to present it as a fix. Happy to open it separately if you think it is correct on principle.Build-verified on this branch's head (
43d4c25).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.