vkback: wait on our own queue at teardown, not the whole device #56

Manually merged
github merged 2 commits from github-bot/gh-56 into gh-pr/56/base 2026-12-01 09:15:55 +00:00 AGit
Owner

@⁠TheRifai on GitHub · 2026-12-01 08:43 UTC · original
TheRifai:vkback-queue-wait-idle → main · +26 −6 · 2 files · 2 commits · merged 2026-12-01 09:13 UTC

What

Issue #38: vkDeviceWaitIdle on vkback-live (presenter recreate, presenter drop, backend drop) races vkQueueBindSparse on umem's bind thread. The spec requires every queue of the device to be externally synchronized for vkDeviceWaitIdle.

Replace the three calls with queue_wait_idle on vkback's own queue (Presenter now stores d.queue). This waits for the blits/presents the code was waiting for, while leaving the sparse queue free to progress — so work held behind binds cannot deadlock the wait (making the bind thread wait for device idle could). umem's own drop waits for its binds before freeing the memory they name.

Evidence

  • cargo check -p vkback and cargo test -p vkback pass (no teardown hang in the native tests).
  • 140 s house validation on the reference card: no threading VUID and no new errors; the run survived to its timeout.
**@⁠TheRifai** on GitHub · 2026-12-01 08:43 UTC · [original](https://github.com/vktory6/VKtory/pull/56) `TheRifai:vkback-queue-wait-idle` → `main` · +26 −6 · 2 files · 2 commits · merged 2026-12-01 09:13 UTC ## What Issue #38: `vkDeviceWaitIdle` on `vkback-live` (presenter recreate, presenter drop, backend drop) races `vkQueueBindSparse` on umem's bind thread. The spec requires every queue of the device to be externally synchronized for `vkDeviceWaitIdle`. Replace the three calls with `queue_wait_idle` on vkback's own queue (Presenter now stores `d.queue`). This waits for the blits/presents the code was waiting for, while leaving the sparse queue free to progress — so work held behind binds cannot deadlock the wait (making the bind thread wait for device idle could). umem's own drop waits for its binds before freeing the memory they name. ## Evidence - `cargo check -p vkback` and `cargo test -p vkback` pass (no teardown hang in the native tests). - 140 s house validation on the reference card: no threading VUID and no new errors; the run survived to its timeout.
vkDeviceWaitIdle on vkback-live races umem's bind thread in vkQueueBindSparse
(issue #38, UNASSIGNED-Threading-MultipleThreads-Write): the call requires every
queue externally synchronized. Presenter now keeps d.queue and waits on it at
recreate and drop; VulkanBackend::drop waits on its own queue too. The sparse
queue can still progress while we wait, so queued work held behind binds does
not hang (the reason device_wait_idle could not simply be protected by a lock).

cargo check -p vkback and cargo test -p vkback pass; a house validation run has
no threading VUID and no new errors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 08:49:20 +00:00
github-bot changed target branch from main to gh-pr/56/base 2026-12-01 09:15:53 +00:00
github manually merged commit b554c36951 into gh-pr/56/base 2026-12-01 09:15:55 +00:00
Author
Owner

@⁠vktory6 on GitHub · 2026-12-01 09:13 UTC · original

Merged, thanks! Waiting for our own queue is the right fix. umem's binds run on a queue of their own (a non-graphics family with sparse binding), so the wait no longer touches the queue the bind thread uses, and nothing behind the binds can hold it up.

One commit of mine on top (b554c36): vkback's queue is also the submission thread's, so the waits must not run beside its vkQueueSubmit either (external sync). All three now hold dev::queue_lock() while they wait, as dev.rs already does for its own wait.

Check on the reference system (RX 9070 XT): tests and policy pass, and the house-scene validation run shows no new error and no threading report. The thread-safety line from #38 is off the validation list.

**@⁠vktory6** on GitHub · 2026-12-01 09:13 UTC · [original](https://github.com/vktory6/VKtory/pull/56#issuecomment-7306388321) Merged, thanks! Waiting for our own queue is the right fix. umem's binds run on a queue of their own (a non-graphics family with sparse binding), so the wait no longer touches the queue the bind thread uses, and nothing behind the binds can hold it up. One commit of mine on top (b554c36): vkback's queue is also the submission thread's, so the waits must not run beside its `vkQueueSubmit` either (external sync). All three now hold `dev::queue_lock()` while they wait, as `dev.rs` already does for its own wait. Check on the reference system (RX 9070 XT): tests and policy pass, and the house-scene validation run shows no new error and no threading report. The thread-safety line from #38 is off the validation list.
This discussion has been locked. Commenting is limited to contributors.
No description provided.