Skip to content

Defer destruction of released Vulkan fence semaphores - #4681

Closed
gut0to wants to merge 1 commit into
ItsNotRexed:mainfrom
gut0to:codex/rt-fence-semaphore-lifetime
Closed

gut0to wants to merge 1 commit into
ItsNotRexed:mainfrom
gut0to:codex/rt-fence-semaphore-lifetime

Conversation

@gut0to

@gut0to gut0to commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

  • Retire released VulkanFence timeline semaphores through the device deferred-deletion queue, so already submitted queue work no longer races vkDestroySemaphore (VUID-vkDestroySemaphore-semaphore-05149).
  • Remove matching waits that have not yet been submitted when a fence is released, keeping the semaphore/value vectors aligned and preventing a later submit from using a retired fence.
  • Add a CPU-only regression for the retirement ticket.

Claimed in D3D coordination. This is distinct from D3D-481's held-batch pump issue. No game files required.

Validation

  • vk_deferred_semaphore: passed.
  • vk_fence_dispatcher_sync: passed on AMD Radeon RX 6600, driver 26.11.2, Vulkan 1.4.315.
  • git diff --check: passed.

@gut0to

gut0to commented Nov 23, 2026

Copy link
Copy Markdown
Author

Closing this duplicate: PR #4663 addresses the same released-fence semaphore lifetime bug with broader pending/held/in-flight coverage and hardware validation. Please use that PR as the implementation for this issue. My branch remains available if any piece is useful.

@gut0to gut0to closed this Nov 23, 2026

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran vk_deferred_semaphore_test at f97c71802 on Windows 11, RTX 5070 Ti: exit 0, vk_deferred_semaphore_test: ok; git diff --check clean.

VulkanFence::~VulkanFence now hands its semaphore to the deferred deletion queue (Kind::semaphore, destroyed by the queue's retire path) instead of destroying it inline, and discard_waiting_on also erases queued waits that reference the released semaphore before dropping the held batches. The new test covers the fence-release/destroy ordering. No blocking issue.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overlap: #4663 (requiemsnkrp, opened before this) makes nearly the same change — Kind::semaphore in the deletion queue, deferred destruction in ~VulkanFence, erasing attached waits — and additionally removes the held_ == 0 early return in QueueHolds::remove_fence and neutralises held Signals of the released semaphore. The two conflict in runtime/src/vulkan_backend.h (git merge-tree refs/remotes/pr/4663 refs/remotes/pr/4681 -> exit 1). #4663's handover test was verified at 0cc958d0f (layer 374 / host 372 exact, including the released-while-in-use scenario). One of the two should close or drop the overlapping backend hunk; #4663 is earlier and covers the queue-holds side.

@gut0to
gut0to deleted the codex/rt-fence-semaphore-lifetime branch November 23, 2026 04:38
@gut0to
gut0to restored the codex/rt-fence-semaphore-lifetime branch November 23, 2026 04:40
@gut0to
gut0to deleted the codex/rt-fence-semaphore-lifetime branch November 23, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants