Skip to content

GPU: fence waits, direct memory-write wakes, queue timeline and host list pool - #32

Open
AndyLatimer wants to merge 13 commits into
Marvisak:mainfrom
AndyLatimer:fix/gpu-fence-and-queue-waits
Open

AndyLatimer wants to merge 13 commits into
Marvisak:mainfrom
AndyLatimer:fix/gpu-fence-and-queue-waits

Conversation

@AndyLatimer

@AndyLatimer AndyLatimer commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes the GPU fence and command-queue synchronization gaps:

  1. Blocking null-event fence waits and bottom-of-pipe wakes (fence.rs, queue.rs):
    • ID3D12Fence::SetEventOnCompletion(value, NULL) previously returned E_NOTIMPL immediately instead of blocking until the fence reached value. It now blocks on a condition variable, re-checking every 100 ms and warning every 5 s while stuck.
    • Live fences are registered by their value address so a command list's bottom-of-pipe write (Written::write, now using atomic Release stores when aligned) wakes any waiting events, blocking waits, or held queues on that fence.
  2. Queue-side fence waits (timeline.rs, queue.rs, fence.rs, list.rs, host.rs, draw.rs):
    • ID3D12CommandQueue::Wait was previously a no-op, so work submitted after a wait for a value signalled later by another queue ran too early.
    • Each queue now runs Wait, Signal, ExecuteCommandLists, Present and CopyPageMappingsBatchX in submission order through a Timeline. When not held back, work executes inline on the submitting thread as before; behind an unreached wait, the call returns immediately and the pending work runs once the fence moves (after fence locks are released).
    • If a command list is reset or dropped while a submission of it is still queued behind a wait, recording moves to a pooled or new host list (Host::acquire_list / Host::recycle_list, bounded at 64 lists), and the pending HostList keeps both its allocate_upload blocks (keep_uploads) and its dynamic descriptor slots (keep_dynamic) until execution completes. If acquiring a replacement list fails, the in-flight HostList is left untouched instead of being reset.
  3. Timeline-ordered Present and CopyPageMappingsBatchX (queue.rs, object.rs, fence.rs):
    • present snapshots plane parameters at call time, retains the presented resource via a shared object::Held wrapper (also reused by fence::Held), and presents through the queue's timeline.
    • copy_page_mappings snapshots caller-owned batch/range arrays at submission time (with checked address arithmetic) and applies mappings through the queue's timeline.
  4. Direct fence memory writes (fence.rs):
    • A lazy background watcher thread (victory-fence-watch) polls live fences every 10 ms only while at least one event or queue wait is pending and parks on a Condvar when idle, so direct CPU/shader writes to a fence's GPU address also wake registered Win32 events and held-back queues without waiting for another submission.

Left out of this PR

  • list.rs's wait_value remains a no-op until the console's comparison enum encoding and trailing parameter layout are verified against a title/SDK (to avoid introducing deadlocks).

Testing

  • cargo test -p victory-gpu: 47 passed, 0 failed (including 11 new synthetic tests covering blocking null-event waits, bottom-of-pipe wakes, direct memory-write wakes for events and held queues, two-queue Wait/Signal, held-back Present, held-back CopyPageMappingsBatchX, and pending list reset/drop/pooling).
  • cargo clippy -p victory-gpu --all-targets: 0 warnings.
  • cargo check -p victory-gpu --features diagnostics --all-targets: pass.
  • cargo xtask policy: pass (149 files).
  • Tested with synthetic unit tests only (not run against a title; no game files or console SDK used).

AndyLatimer and others added 3 commits November 24, 2026 00:20
SetEventOnCompletion(value, NULL) must block until the fence reaches the
value. It answered E_NOTIMPL at once (from when no GPU work ran), so a
title that waits this way went on before the value was reached.

A command list's bottom-of-pipe write at a fence's GPU address moved the
value without setting the events waiting for it. Live fences are now
registered by value address; Written::write wakes the fence it touched.

Blocking waits re-check the value every 100 ms and warn every 5 s while
stuck. New tests cover both paths; three of them fail on the old code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ID3D12CommandQueue::Wait did nothing, so work submitted after a wait for a value another queue signals later ran too early. Each queue now has a timeline that Wait, Signal and ExecuteCommandLists go through in order. Not held back, work runs on the submitting thread as before; behind a wait not reached yet, the call returns and the work runs on the thread that moves the fence. A list reset or dropped while a submission of it is still to run keeps its host list and upload memory until that submission completes. One synthetic two-queue test.
A present on a queue held back by a wait ran immediately, before the work preceding it. present() now reads its plane parameters at call time, holds a reference to the presented resource via a shared object::Held wrapper (also reused by fence::Held), and submits the present through the queue's timeline. One synthetic two-queue test.
@Sunkiller-qc

Copy link
Copy Markdown

Thanks for this, the timeline design is nice and the lock-order notes help a lot. I think there's a re-entrancy problem on the bottom-of-pipe path though. In Host::execute (crates/victory-gpu/src/host.rs:447) the submitted guard lives until the end of the function, and the deferred writes run at host.rs:510 while it's still held (as is the list.deferred() guard of the loop). Written::write now calls crate::fence::written (queue.rs:240), which goes wake → run_held (fence.rs:198/238) → Timeline::wake → run, and runs the held queue's Op::Run closure inline. That closure calls host.execute again, which locks self.submitted on the same thread. So a graphics queue that Waits on a fence that a compute list moves with a bottom-of-pipe write would deadlock (or panic, since std Mutex isn't re-entrant). That's exactly the case the PR targets. One fix: have written return the timelines to wake instead of running them, collect them in execute, and call run_held after submitted and the deferred() guards are dropped. A test that submits a list with a bottom-of-pipe write to a fence another queue waits on would catch it. Static review, not built or run.

CopyPageMappingsBatchX previously ran immediately even on a queue held back behind a fence wait, updating page mappings ahead of earlier queued work. It now snapshots the caller's batch and range arrays at submission time (with checked address arithmetic) and runs through the queue's timeline. One synthetic two-queue test.
Previously, moving a fence's value via a direct write to its GPU address (outside Signal or Written::write) only woke blocking null-event waits; registered Win32 events stayed unset and held-back queues waited until their next submission. A lazy background watcher thread (victory-fence-watch) now polls live fences every 10 ms only while at least one event or queue wait is pending and parks on a condvar when idle. Also switches aligned Written::write stores to atomic Release stores. Two new synthetic tests.
Detached HostLists whose submissions finished on a held-back queue are now returned to a bounded pool on Host (up to 64) and reused on subsequent list creations or pending resets. Dropping or resetting a list while a submission of it is still queued now transfers both its allocate_upload blocks and dynamic descriptor slots to the pending HostList until execution completes, and reset failure no longer resets an in-flight HostList. One new synthetic test.
@AndyLatimer AndyLatimer changed the title GPU: blocking null-event fence waits, bottom-of-pipe wakes and queue timeline GPU: fence waits, direct memory-write wakes, queue timeline and host list pool Nov 23, 2026
@DaviTostes

Copy link
Copy Markdown

The head 6e88bc0 does not compile: the merge into main left crates/victory-gpu/src/host.rs with only the last 126 lines (git shows 1 919 lines deleted against main). mod host; is present in lib.rs and the file exists, but the top of the module is gone, so everything that imports from it fails:

error[E0432]: unresolved import `crate::host::host`
  --> crates/victory-gpu/src/descriptor/host.rs:14:5
error[E0432]: unresolved import `crate::host::HostList`
  --> crates/victory-gpu/src/draw.rs:22:5
error: could not compile `victory-gpu` (lib) due to 88 previous errors
error: could not compile `victory-gpu` (lib test) due to 91 previous errors

The merge needs to be redone keeping both sides of host.rs; the timeline module is fine. I can run the fence/queue tests here (Wine + vkd3d-proton) once it builds.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

@Sunkiller-qc

Copy link
Copy Markdown

Two things on the current head (6e88bc0):

  1. The merge from main looks like it went wrong for crates/victory-gpu/src/host.rs. At 80443e8 the file has about 1,830 lines; after the merge it has 126, so Host, HostList, execute and the rest are gone (git show --stat 6e88bc0 shows host.rs | 1701 -----). That's where the -1835 in the PR stats comes from, and the crate can't build like this. Redoing the merge, or git checkout 80443e8 -- crates/victory-gpu/src/host.rs and then reapplying main's changes to that file, should fix it.

  2. The re-entrancy from my earlier comment is still there at 80443e8: Host::execute takes submitted at host.rs:499 and still runs what.write(...) at host.rs:562 with that guard and list.deferred() held. fence::written (fence.rs:335) still wakes held queues inline, and the woken work calls host.execute again. Collecting the timelines to wake and running them after both guards drop would avoid this.

Static review, not built or run.

AndyLatimer and others added 3 commits November 24, 2026 02:11
The merge of main (6e88bc0) kept only the last 126 lines of
crates/victory-gpu/src/host.rs, so the crate did not build. This is the
file as the merge should have left it: both sides' additions kept (the
held lists' kept uploads and descriptor slots, Send and Sync, and main's
diagnostics timestamps).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Host::execute did the lists' bottom-of-pipe writes holding its
`submitted` lock and the lists' `deferred` guards. A write at a fence a
held-back queue waits for ran that queue's work inline (fence::written ->
Timeline::wake), and the work calls Host::execute again: a deadlock on
`submitted` (std's Mutex is not re-entrant), in the case the queue
timeline is for (a graphics queue waiting on a compute list's write).

Written::write and fence::written now return the woken queues (Woken,
must_use); execute collects them and runs them after dropping its locks.
Without a host GPU, list writes still run them at once (no lock held).
Reported in review by Sunkiller-qc. 1 new test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AndyLatimer

Copy link
Copy Markdown
Contributor Author

Thanks for both reviews. Both points are fixed on the new head 8fd82c9:

  1. Broken merge (6e88bc0 kept only the last 126 lines of host.rs): b14bac3 restores the file as the merge should have left it, keeping both sides' additions (this PR's kept uploads/descriptor slots and Send/Sync, and main's diagnostics timestamps). d2da283 then merges current main (d2a4bae) with no conflicts.
  2. Re-entrancy on the bottom-of-pipe path (8fd82c9): Written::write and fence::written now return the woken queues instead of running them, as a #[must_use] Woken. Host::execute collects them while it does the writes and runs them after dropping submitted and the deferred() guards. Without a host GPU, defer_write writes at once and runs them right away, with no lock held there. The new test bottom_of_pipe_writes_leave_woken_work_to_the_writer holds a lock that the woken work takes. It fails on the old code ("ran inside the write").

Testing on 8fd82c9 (Windows 11):

  • cargo test --workspace: 276 passed, 4 ignored.
  • cargo clippy --workspace --all-targets: no new warnings (the two left, in xmem.rs and host.rs:267, are on main).
  • cargo clippy -p victory --features diagnostics: clean.
  • cargo xtask policy: pass.

Synthetic tests only, not run against a title.

@DaviTostes

Copy link
Copy Markdown

Re-checked the new head 8fd82c9 after the repair merge: the build is fixed and the suite runs.

  • host.rs is back to 2 151 lines (it was 126 on 6e88bc0), and the Windows test build compiles.
  • Under Wine 11.22 + vkd3d-proton 3.1 (AMD RX 9060 XT, RADV 26.3.1) with a native Microsoft d3dcompiler_47: 53 passed, 2 failed, 1 ignored.
  • The two failures are environment-only: a_rejected_blob_gives_an_empty_library (vkd3d needs a non-empty blob) and Wine/vkd3d: deferred uploads are skipped because VirtualQuery() reports mapped memory as MEM_FREE #128 (VirtualQuery sees vkd3d-mapped memory as MEM_FREE). The ignored test is a benchmark.
  • The fence/queue paths this PR changes are exercised by that run.

No game data used.

@aycow

aycow commented Nov 24, 2026

Copy link
Copy Markdown

@AndyLatimer All eight fence-module tests passed here at 8fd82c9. For a future #595 composition, I think the guest queue timeline and native submission completion should stay separate. Your Woken handoff is relevant because a queue wake can re-enter Host::execute. #595 currently runs completion callbacks under its entries and finishing locks. Deferring the public wake until those locks and the submitting guard are released would avoid a re-entrant lock path. I checked the source path and the standalone tests. A merged test remains open. #595 compatibility results

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested on Windows 11 MSVC (rustc 1.98.1):

  • cargo test -p victory-gpu: 55 passed, 0 failed, 1 ignored (all 11 new queue timeline, fence blocking wait, and bottom-of-pipe wake tests pass cleanly)
  • cargo xtask policy: 152 files ok

Confirmed: the Woken handoff successfully resolves the re-entrancy issue on the bottom-of-pipe path by collecting timelines and running woken work only after the submitting mutex and deferred write guards are dropped.

# Conflicts:
#	crates/victory-gpu/src/list.rs
@AndyLatimer

Copy link
Copy Markdown
Contributor Author

I merged current main (58fed37) into the branch; the new head is 9c5328d. The only conflict was in list.rs, in two copy paths that main gave a texture upload (#671/#680). I kept main's code, with &list because host_list returns an Arc on this branch. Results:

  • cargo test -p victory-gpu --lib: 61 passed, 1 ignored.
  • cargo check -p victory-gpu --features diagnostics --all-targets passes.
  • cargo test --workspace --exclude victory-shader --no-fail-fast: 230 passed, 0 failed.

victory-shader is left out because its tests do not compile on main itself: lower.rs:6963 calls lowers(&words) with one argument where it now takes two. That breakage is on main and has nothing to do with this branch.

@DeerSilver

Copy link
Copy Markdown

Tested head 9c5328d merged onto main ffe310e (clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1: pass. No game files: the test suite only.

  • The PR's new tests pass. The ones that use the host GPU ran on the RTX 5060 (DXGI adapter 0 on this laptop, so the host-device helpers return a device and the tests don't take their early return):
    • blocking_wait_returns_at_once_when_reached
    • blocking_wait_blocks_until_signalled
    • bottom_of_pipe_write_releases_blocking_wait
    • bottom_of_pipe_write_sets_waiting_event
    • direct_memory_write_sets_waiting_event
    • released_fences_leave_the_registry
    • bottom_of_pipe_writes_leave_woken_work_to_the_writer
    • pending_list_reset_and_drop_keep_uploads_and_recycle_host_list
    • work_after_a_wait_runs_once_the_other_queue_signals
    • present_runs_after_a_queues_wait
    • page_mappings_run_after_a_queues_wait
    • direct_memory_write_wakes_held_queue
  • cargo test --workspace --locked: 354 passed, 0 failed, 6 ignored, against 342 passed / 6 ignored on main.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.

AI-assisted (Claude Code).

@contatopablow-spec

contatopablow-spec commented Nov 24, 2026 •

Copy link
Copy Markdown

CPU-only regression: a satisfied queue wait is lost if the fence is rewound before its deferred wake.

Verified at PR head 9c5328d4ef91c56bb10bea6474f6f802b9d4d652. Microsoft's Multi-engine synchronization / Fences explicitly states that an outstanding wait satisfied by one signal stays satisfied even when a racing lower signal leaves the fence below the requested value. New waits should still use the new lower value.

wake_locked removes a satisfied queue registration and returns its timeline, but Timeline::run rechecks the current value via wait_on_gpu. If the value is rewound between these steps, the already satisfied wait is registered again. The deferred-wake path makes the interleaving particularly easy to reproduce without threads, sleeps or GPU work.

Add this test inside fence.rs's existing mod tests (uses its existing imports):

#[test]
fn queue_wait_survives_rewind_before_deferred_wake() {
    use crate::timeline::{Op, Timeline};
    let f = new_fence(0);
    let queue = Arc::new(Timeline::default());
    let ran = Arc::new(AtomicU64::new(0));
    queue.submit(Op::Wait(Held::new(f), 1));
    let seen = ran.clone();
    queue.submit(Op::Run(Box::new(move || {
        seen.fetch_add(1, Ordering::SeqCst);
    })));
    assert_eq!(ran.load(Ordering::SeqCst), 0);
    let woken = {
        let obj = fence(f);
        let waiters = obj.waiters.lock().unwrap();
        obj.value.store(1, Ordering::Release);
        wake(obj, waiters)
    };
    assert_eq!(woken.len(), 1);
    assert_eq!(signal(f, 0), S_OK);
    run_held(woken);
    let observed = ran.load(Ordering::SeqCst);
    // Drain even on the buggy path before asserting.
    assert_eq!(signal(f, 1), S_OK);
    drop(queue);
    release_fence(f);
    assert_eq!(observed, 1, "satisfied wait was lost on rewind");
}

Command: cargo test --offline --locked -p victory-gpu --lib queue_wait_survives_rewind_before_deferred_wake -- --nocapture --test-threads=1

Observed left: 0, right: 1, exit 101. Both existing controls (work_after_a_wait_runs_once_the_other_queue_signals, bottom_of_pipe_writes_leave_woken_work_to_the_writer) passed, exit 0. Windows 11, Rust 1.98.1. Only a 33-line test addition; no production change or GPU dispatch.

Suggested direction: latch satisfaction per registered wait under the fence lock, separate from resuming a timeline outside locks. Do not replace the fence's current value with a historical maximum, as that would incorrectly satisfy new waits after a rewind. The null-event CPU wait path deserves a separate review. No claim this interleaving occurs in a title or causes #1317; this is an API-semantics regression. No game data. AI-assisted review/test (ChatGPT).


Follow-up: queue-wait completion latch implementation and tests. Published exact incremental commit on 9c5328d4ef91c56bb10bea6474f6f802b9d4d652: contatopablow-spec@8d87065

Each registered front wait has a per-wait completion latch; the registry holds weak references to both latch and timeline. The fence scan marks that exact wait satisfied under the registration mutex before removing it. Signal serializes its value store and scan with registration, and the timeline consumes the front wait's latch or the current fence value under that lock. Delayed/repeated wakes cannot release a later wait. Work still runs outside fence/host locks; existing deferred Woken interface and lock ordering are retained. No dependencies or new unsafe code.

Validation at the pinned PR head: original regression RED (exit 101) -> GREEN (0). Added controls for a fresh wait after rewind, repeated/stale wake with another pending wait on the same fence, and dropping a held queue. Fence tests 12/12, queue tests 8/8 (independently repeated in the publication worktree), GPU crate library 65 passed, one existing benchmark ignored. Default and diagnostics GPU Clippy with -D warnings, changed-file rustfmt, diff and asset policy (153 files), staged policy all passed. Windows, Rust 1.98.1. Full workspace test compilation was blocked by existing victory-shader/src/emit/lower.rs:6963 E0061 (missing rsrc2 argument to lowers), reproduced separately with unchanged shader sources.

Independent review checked exact wait identity, queue lifetime and lock order. Scope limitations: transient raw/bottom-of-pipe writes may still be missed between observation scans; null-event CPU waits and mixed-width accesses are outside this patch. No gameplay or new GPU dispatch, and no claim that this defect explains #1317. AI-assisted implementation, tests and review (ChatGPT/Codex). Sharing the incremental commit here rather than opening a competing PR against main.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/fence.rs, crates/victory-gpu/src/host.rs, crates/victory-gpu/src/list.rs, crates/victory-gpu/src/queue.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge-candidate) was for an older state of main.


Generated by Claude Code

justlovett0 pushed a commit to justlovett0/VIctory that referenced this pull request Nov 25, 2026
In its Series S mode the title renders at 1280x720 and calls the console's
FidelityFX upscaler (`ffxDispatch` of amd_fidelityfx_loader_xbox.dll) to make
the 1920x1080 output. The loader and upscaler are the title's own DLLs and
run, but the upscaler's passes are compute pipelines in a container that is
not translated ("falling back to NewBE" in the title's log), so the output
was never written: the world was black behind the interface.

The executable's import of `ffxDispatch` is now bound to ours. An upscale
dispatch (type 0x10001, the public FidelityFX API's layout) is recorded as
`victory_gpu::list::upscale_stretch` of its colour input into its output;
any other dispatch, and an upscale that could not be stretched, goes to the
title's DLL. The DLL is not registered as an HLE module: that kept the
title's own from loading and left its other three entry points missing.

Measured on an RTX 3050 8 GB, Windows 11, release build, on top of the
R9G9B9E5 stand-in (Marvisak#32): the Series S world renders (opening cutscene), 0.4
to 1.2 s a frame with peaks of 3 s, the card about a quarter busy, 7 GB of
video memory, no host error in a five-minute run. Series X is not affected
in the run made (it does not dispatch the upscaler).

Not done: temporal accumulation, sharpening, use of the depth and motion
inputs. No test yet. Only the opening cutscene was looked at.
PastiiJay added a commit to PastiiJay/klbf-lab-beta that referenced this pull request Nov 25, 2026
Code tree of fxceless/victory-fork 4e17478 (all rendering work by its author and
the VIctory contributors) with, on top:
- AMD fixes: skip of 39f0e9aeb156a61c, 32-lane programs per half wave and NaN/Inf
  filter, configurable texture upload queue, VIctory Marvisak#1599
- upstream VIctory Marvisak#334 (buffer-state tracking) and Marvisak#1271 (globally coherent glc UAVs)
- fork PRs Marvisak#95, Marvisak#71, Marvisak#32, Marvisak#86; VIctory Marvisak#1696, Marvisak#1338, Marvisak#1291, Marvisak#1732
- DirectStorage page lists read at the title's submit (analysis by JappertjeV, klbf-lab#3)
- offline pipeline pre-build that saves as it goes and skips driver-crashing pipelines
- Series S plane composition, VICTORY_FFX_SIMPLE, scripted keys in release builds
- docs/klbf/skip-amd.txt: AMD skip list used for our runs
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 25, 2026
In its Series S mode the title renders at 1280x720 and calls the console's
FidelityFX upscaler (`ffxDispatch` of amd_fidelityfx_loader_xbox.dll) to make
the 1920x1080 output. The loader and upscaler are the title's own DLLs and
run, but the upscaler's passes are compute pipelines in a container that is
not translated ("falling back to NewBE" in the title's log), so the output
was never written: the world was black behind the interface.

The executable's import of `ffxDispatch` is now bound to ours. An upscale
dispatch (type 0x10001, the public FidelityFX API's layout) is recorded as
`victory_gpu::list::upscale_stretch` of its colour input into its output;
any other dispatch, and an upscale that could not be stretched, goes to the
title's DLL. The DLL is not registered as an HLE module: that kept the
title's own from loading and left its other three entry points missing.

Measured on an RTX 3050 8 GB, Windows 11, release build, on top of the
R9G9B9E5 stand-in (Marvisak#32): the Series S world renders (opening cutscene), 0.4
to 1.2 s a frame with peaks of 3 s, the card about a quarter busy, 7 GB of
video memory, no host error in a five-minute run. Series X is not affected
in the run made (it does not dispatch the upscaler).

Not done: temporal accumulation, sharpening, use of the depth and motion
inputs. No test yet. Only the opening cutscene was looked at.
AndyLatimer and others added 2 commits November 25, 2026 10:11
# Conflicts:
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/list.rs
`wake_locked` took a satisfied queue's registration off the fence, but
the queue resumed later (`run_held`, with no lock held) and checked the
fence's value again in `wait_on_gpu`. A signal that set the fence back
below the value in between registered the wait again, and the work
behind it waited for a value already reached. D3D12: a wait a signal
satisfied stays satisfied; new waits use the lower value.

Each wait now has a ticket, its place in the queue's submission order,
kept with its registration. The fence releases the ticket under its lock
(`Timeline::release`, a `fetch_max`), and `wait_on_gpu` takes a released
ticket as reached under the same lock. Later waits have later tickets,
so a stale or repeated wake releases none of them. New waits still
compare with the current value.

Test by contatopablow-spec (review on Marvisak#32): fails without the latch
(left: 0, right: 1), passes with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AndyLatimer

Copy link
Copy Markdown
Contributor Author

Merged main (940d32f) at e980aa3 and fixed the rewind regression @contatopablow-spec found, in b48fbc6.

Merge. host.rs takes main's Presentation. The diagnostics frame dump runs after submitted is dropped and before the woken queues run, so it still shows what this submission drew. Kept upload blocks are list::Upload now, since main moved list upload memory into [4 GiB, 2^40). external.rs passes &host.

Fix. Each queue wait has a ticket (its place in the queue's submission order), kept with its fence registration. wake_locked releases the ticket under the fence's lock (Timeline::release, a fetch_max), and wait_on_gpu treats a released ticket as reached under the same lock. Later waits have later tickets, so a stale or repeated wake releases none of them. New waits still compare with the current value. This is smaller than the latch in 8d87065: no per-wait Arc, and no change to Signal's locking. The semantics are the same for your test, which is in fence.rs with credit. It fails without the check (left 0, right 1) and passes with it.

Not changed: the blocking wait (SetEventOnCompletion with a null event) still compares the current value in its loop. That is the separate case you pointed out.

Checks (Windows 11, NVIDIA, Rust 1.98.1):

For #1023, which builds on this: wait_on_gpu now takes the wait's ticket (fence.wait_on_gpu(value, s.done + 1, self) in Timeline::run).

alesanfe pushed a commit to alesanfe/VIctory that referenced this pull request Nov 26, 2026
…arvisak#32) (Marvisak#43)

Host::new logs the DXGI adapter (name, vendor) once per adapter. Tests that
lack a compiler or device now go through test_skip::skip, which prints a
VICTORY TEST SKIPPED line and, with VICTORY_STRICT_TESTS=1, fails instead.

(cherry picked from commit b4180ea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants