ID3D12Fence::SetEventOnCompletion with a NULL event returns E_NOTIMPL instead of blocking #759
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#759
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?
@Conrage on GitHub · 2026-11-24 09:39 UTC · original
crates/victory-gpu/src/fence.rs:90-95. In D3D12, a NULL event means "block until the fence reaches the value". We returnE_NOTIMPL. The comment's reason ("nothing can reach it while no GPU work runs") no longer holds, because queues and the CPU now signal fences (fence.rs:99,queue.rs:160).Proposed patch (formatted with the repo's rustfmt; not compiled or tested, since I have no Windows machine). It blocks on a
Condvarpaired with the existingwaitersmutex, whichsignalalready holds, so no wakeup is lost. The patch also updates the unit test to cover the blocking wait.AI use: found and written with Claude from reading the code at
8e79c80; not run on hardware.@Yorivel on GitHub · 2026-11-24 09:43 UTC · original
Compiled and tested on Windows 11 26300 (MSVC, Rust 1.98.1,
--test-threads=1): the patch applies to8e79c80, its updated test passes 3 of 3 runs, clippy (-D warnings) and rustfmt are clean.One gap: a list's bottom-of-pipe write (
write32/write64,list.rs) can store the value straight at the fence's address (gpu_address), which moves it withoutsignal, so theCondvaris never notified. A test that does that (Written::Value(9).writeto the fence's address while another thread waits with no event) times out after 2 s with the patch as posted.Branch with the patch plus a fix: https://github.com/Yorivel/VIctory/tree/fix/fence-blocking-wait. The wait uses
wait_timeout(1 ms) so it also sees a value written without a signal; signals still wake it at once. Both tests pass 3 of 3,cargo test -p victory-gpu --lib51 passed / 1 ignored, clippy clean,cargo xtask policyok. The module comment no longer says only signals move a fence.Not covered: such a write sets no waiting events either (the same path, before this patch); that needs fences findable by address and is left alone here.
Written with Claude Code.
@Conrage on GitHub · 2026-11-24 09:53 UTC · original
Thanks for compiling and testing it, @Yorivel. It turns out open PR #32 already covers this: blocking NULL-event waits, and also the bottom-of-pipe wake you found missing (it registers fences by value address so list writes wake waiters). Closing as a duplicate of that PR.
@AndyLatimer on GitHub · 2026-11-24 10:08 UTC · original
Open PR #32 already fixes this, including the gap @Yorivel describes and the part left out there:
SetEventOnCompletion(value, NULL)blocks on a condition variable instead of returningE_NOTIMPL(testsblocking_wait_returns_at_once_when_reached,blocking_wait_blocks_until_signalled).Written::write) wakes both a blocking wait and the events waiting on that fence (bottom_of_pipe_write_releases_blocking_wait,bottom_of_pipe_write_sets_waiting_event).direct_memory_write_sets_waiting_event).Head
9c5328dhas currentmainmerged in. Only synthetic tests; not run against the title. AI-assisted.