Thread safety: vkDeviceWaitIdle on vkback-live vs vkQueueBindSparse on umem-binds #38
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory#38
Loading…
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?
@tmalik1116 on GitHub · 2026-12-01 03:10 UTC · original
Finding (AGENTS.md rule 29):
vkDeviceWaitIdleon thevkback-livethread runs at the same time asvkQueueBindSparseon umem'sumem-bindsthread.vkDeviceWaitIdlerequires every queue of the device to be externally synchronized (Vulkan spec, "Threading Behavior"), and the bind thread does not hold off for it.Seen on:
19862d4(with the present fix from the linked PR, which does not touch these paths). Not seen in the next three validation runs (73ee0ab, with and without that fix): it is timing-dependent.Where (
73ee0ab): thedevice_wait_idlecalls on the live thread aregreenfield/vkback/src/present.rs:308,present.rs:837andgreenfield/vkback/src/lib.rs:4148(presenter and backend teardown, and swapchain recreate). The binds aregreenfield/umem/src/binds.rs:481andbinds.rs:490.Why it is not a one-line fix: making the bind thread wait while the device idles could hang. Queued work waits on the binds' timeline values, so the device does not go idle until the binds run (compare
texcheck.rs:20, wheredevice_wait_idlehung for a similar reason). Waiting on the live thread's own queue or fences instead of the whole device may be the way out. That is not tested.Setup: RX 6800 XT (RDNA2), Mesa 26.3.1,
vulkan-validation-layers1.4.363.1, core, thread-safety and shader checks, errors only.@vktory6 on GitHub · 2026-12-01 07:34 UTC · original
Thanks! I created a task based on your report: it's on the "Vulkan validation errors" list as a thread-safety line in
github.com/vktory6/VKtory@5169307, with your note that making the bind thread wait can hang. The other thread-safety pair (present fence and swapchain) is handled by #39.@vktory6 on GitHub · 2026-12-01 10:36 UTC · original
Fixed by #56 (
github.com/vktory6/VKtory@5507c25): teardown now waits on vkback's own queue instead of callingvkDeviceWaitIdle, so it no longer races the bind thread'svkQueueBindSparse. The line is off the validation list (github.com/vktory6/VKtory@7f11798). Closing, thanks!