victory-shader: make the test dispatches cheap - an event wait and reused command objects (emit suite -33% wall, -48% CPU) #1734

Open
github-bot wants to merge 3 commits from github-bot/gh-1734 into main AGit
Owner

@⁠pes7 on GitHub · 2026-11-24 21:31 UTC · original
pes7:test/fence-event-wait → main · +140 −33 · 2 files · 3 commits · open

The shader test suite spent most of its time on the harness, not on the shaders. Two things in emit::host:

  1. draw and dispatch waited for their fence by spinning, calling GetDeviceRemovedReason() on every iteration;
  2. every dispatch made a new command queue, allocator, list, fence and event.

emit::valu_tests runs hundreds of dispatches for one shader (every f16 pattern, for two opcodes, on two backends), so both costs multiply.

1. Wait on an event, not in a spin

while fence.GetCompletedValue() < 1 {
    if let Err(e) = dev.GetDeviceRemovedReason() { return Err(..) }
    std::thread::yield_now();
}

One wait helper for both call sites: create an event, SetEventOnCompletion, then WaitForSingleObject(100 ms) in a loop. The timeout is what keeps the device-removal check - a removed device never signals, so an INFINITE wait would hang the run instead of reporting it - and WAIT_FAILED returns an error rather than looping.

Same shape as the submission wait in victory-gpu/src/host.rs, which uses INFINITE because the runtime owns the device; here the check has to stay.

Interleaved A/B, 9 runs each, emit:: with --test-threads=8:

wall (median) CPU median CPU min-max
spin 9 080 ms 5 562 ms 4 266-6 047 ms
event wait 9 084 ms 4 438 ms 4 219-4 656 ms

CPU -20%, wall unchanged: the GPU work was the critical path and the machine had spare cores. Every event run stayed under 4.66 s of CPU; eight of the nine spin runs were at 4.88 s or above.

2. Make the command objects once per host

Timing the five creations alone (200 iterations, release, hardware device) gives 4.19 ms, against 8.35 ms for a whole dispatch of emit::valu_tests - half of a dispatch was spent on objects that do not depend on the dispatch's inputs.

Host now keeps them in a Reused struct (queue, allocator, list, fence, event, last fence value) and each dispatch bumps the fence value and Resets the list with its own PSO. That is safe here because the GPU tests already run one at a time (ONE_AT_A_TIME) and every dispatch waits for its fence before returning, so the allocator is never in use when it is reset.

The event is closed by Drop for Reused; draw still makes its own, since it is not on the hot path.

before after
v_cvt_norm_i16_and_u16_f16_round_the_exact_product (576 dispatches) 4.81 s 2.17 s
emit:: suite, wall 9 084 ms 6 053 ms
emit:: suite, CPU 4 438 ms 2 891 ms

Both, against the original

original this PR
emit:: wall 9 080 ms 6 053 ms (−33%)
emit:: CPU 5 562 ms 2 891 ms (−48%)
the 576-dispatch test 4.81 s 2.17 s

What this does not claim

That it fixes the flaky v_cvt_norm_i16_and_u16_f16_round_the_exact_product (#1633). I tried to make the flake show up by running two full suites in parallel, four rounds per variant: 0/16 failures in both, so the link is unproven and I am not claiming it.

Scope

draw and dispatch are #[cfg(test)], so nothing in the game changes: this is the shader test suite's time. crates/victory-shader/Cargo.toml gains Win32_Security and Win32_System_Threading for the optional windows dependency - CreateEventW sits behind both, and victory-gpu already enables them.

Checks

cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, cargo test --workspace --locked, cargo xtask policy.

To reproduce: build the test binary with and without the change (target/release/deps/victory_shader-*.exe) and run them alternately, TotalProcessorTime for CPU and the reported time for the 576-dispatch test.

What it gives (to decide the merge): the shader test host waits for its fence on an event instead of spinning, and makes its queue, allocator, list and fence once per host: the victory-shader suite took 199 s before the rebase and 115 s after it (302 tests), with the same device-removal reporting.

State: MERGEABLE, CI check green, rebased onto today's main (f3578e3).

Risk: test-only code; a wedged device is still reported instead of waited for.

**@⁠pes7** on GitHub · 2026-11-24 21:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734) `pes7:test/fence-event-wait` → `main` · +140 −33 · 2 files · 3 commits · open The shader test suite spent most of its time on the *harness*, not on the shaders. Two things in `emit::host`: 1. `draw` and `dispatch` waited for their fence by spinning, calling `GetDeviceRemovedReason()` on every iteration; 2. every dispatch made a new command queue, allocator, list, fence and event. `emit::valu_tests` runs hundreds of dispatches for one shader (every f16 pattern, for two opcodes, on two backends), so both costs multiply. ## 1. Wait on an event, not in a spin ```rust while fence.GetCompletedValue() < 1 { if let Err(e) = dev.GetDeviceRemovedReason() { return Err(..) } std::thread::yield_now(); } ``` One `wait` helper for both call sites: create an event, `SetEventOnCompletion`, then `WaitForSingleObject(100 ms)` in a loop. The timeout is what keeps the device-removal check - a removed device never signals, so an `INFINITE` wait would hang the run instead of reporting it - and `WAIT_FAILED` returns an error rather than looping. Same shape as the submission wait in `victory-gpu/src/host.rs`, which uses `INFINITE` because the runtime owns the device; here the check has to stay. Interleaved A/B, 9 runs each, `emit::` with `--test-threads=8`: | | wall (median) | CPU median | CPU min-max | |---|---:|---:|---:| | spin | 9 080 ms | 5 562 ms | 4 266-6 047 ms | | event wait | 9 084 ms | **4 438 ms** | 4 219-4 656 ms | CPU **-20%**, wall unchanged: the GPU work was the critical path and the machine had spare cores. Every event run stayed under 4.66 s of CPU; eight of the nine spin runs were at 4.88 s or above. ## 2. Make the command objects once per host Timing the five creations alone (200 iterations, release, hardware device) gives **4.19 ms**, against **8.35 ms** for a whole dispatch of `emit::valu_tests` - half of a dispatch was spent on objects that do not depend on the dispatch's inputs. `Host` now keeps them in a `Reused` struct (`queue`, `allocator`, `list`, `fence`, `event`, last fence value) and each dispatch bumps the fence value and `Reset`s the list with its own PSO. That is safe here because the GPU tests already run one at a time (`ONE_AT_A_TIME`) and every dispatch waits for its fence before returning, so the allocator is never in use when it is reset. The event is closed by `Drop for Reused`; `draw` still makes its own, since it is not on the hot path. | | before | after | |---|---:|---:| | `v_cvt_norm_i16_and_u16_f16_round_the_exact_product` (576 dispatches) | 4.81 s | **2.17 s** | | `emit::` suite, wall | 9 084 ms | **6 053 ms** | | `emit::` suite, CPU | 4 438 ms | **2 891 ms** | ## Both, against the original | | original | this PR | |---|---:|---:| | `emit::` wall | 9 080 ms | **6 053 ms** (−33%) | | `emit::` CPU | 5 562 ms | **2 891 ms** (−48%) | | the 576-dispatch test | 4.81 s | **2.17 s** | ## What this does **not** claim That it fixes the flaky `v_cvt_norm_i16_and_u16_f16_round_the_exact_product` (#1633). I tried to make the flake show up by running two full suites in parallel, four rounds per variant: **0/16 failures in both**, so the link is unproven and I am not claiming it. ## Scope `draw` and `dispatch` are `#[cfg(test)]`, so nothing in the game changes: this is the shader test suite's time. `crates/victory-shader/Cargo.toml` gains `Win32_Security` and `Win32_System_Threading` for the optional `windows` dependency - `CreateEventW` sits behind both, and `victory-gpu` already enables them. ## Checks `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, `cargo test --workspace --locked`, `cargo xtask policy`. To reproduce: build the test binary with and without the change (`target/release/deps/victory_shader-*.exe`) and run them alternately, `TotalProcessorTime` for CPU and the reported time for the 576-dispatch test. --- **What it gives (to decide the merge):** the shader test host waits for its fence on an event instead of spinning, and makes its queue, allocator, list and fence once per host: the `victory-shader` suite took 199 s before the rebase and **115 s** after it (302 tests), with the same device-removal reporting. **State:** MERGEABLE, CI `check` green, rebased onto today's `main` (`f3578e3`). **Risk:** test-only code; a wedged device is still reported instead of waited for.
`draw` and `dispatch` poll `fence.GetCompletedValue()` and call
`GetDeviceRemovedReason` on every iteration while a thread spins. One
event per submission, `SetEventOnCompletion`, and `WaitForSingleObject`
in 100 ms slices: the same device-removal report, no CPU burned while the
GPU works, and no device call in a hot loop.

The 100 ms timeout is what keeps that check: a removed device never
signals, so an INFINITE wait would hang the run instead of reporting it.
`WAIT_FAILED` returns an error rather than looping.

Interleaved A/B, 9 runs each, `emit::` with --test-threads=8:

    wall           9 080 ms  ->  9 084 ms
    CPU (median)   5 562 ms  ->  4 438 ms   -20%

Every event run stayed under 4.66 s of CPU; eight of the nine spin runs
were at 4.88 s or above.

`draw` and `dispatch` are `#[cfg(test)]`, so nothing in the game changes.
Cargo.toml gains Win32_Security and Win32_System_Threading for the
optional windows dependency (CreateEventW sits behind both); victory-gpu
already enables them.

cargo test --workspace --locked; both clippy configurations with
-D warnings; cargo xtask policy.
A dispatch made a new queue, allocator, list, fence and event every call.
Making those five costs 4.19 ms of an 8.35 ms dispatch (200 iterations,
release, hardware device), and emit::valu_tests runs hundreds of
dispatches for one shader: every f16 pattern, two opcodes, two backends.

Keep them in `Host`, bump the fence value per dispatch, and reset the list
with the dispatch's own PSO. That is safe here because the GPU tests run
one at a time (ONE_AT_A_TIME) and every dispatch waits for its fence, so
the allocator is never in use when it is reset. `Drop for Reused` closes
the event; `draw` still makes its own, since it is not on this path.

    v_cvt_norm_i16_and_u16_f16_round_the_exact_product   4.81 s -> 2.17 s
    emit:: suite, wall                                  9 084 -> 6 053 ms
    emit:: suite, CPU                                   4 438 -> 2 891 ms

Together with the event wait, against the original code: emit:: wall
9 080 -> 6 053 ms and CPU 5 562 -> 2 891 ms.

cargo test --workspace --locked; both clippy configurations with
-D warnings; cargo xtask policy.
Two things the triage found in the `Reused` cache.

The allocator was never reset, so it kept the memory of every dispatch
recorded since the host was made - hundreds per `valu_tests` case.
`ID3D12CommandAllocator::Reset` now runs before the list is reset, which
is safe because the previous dispatch waited for its fence. It costs
nothing measurable: four interleaved pairs of the `emit` suite gave
10.5 s of CPU with the reset against 11.1 s without it.

An error between `list.Reset` and `Close` left the cached list recording,
so the next dispatch's `Reset` failed too and one bad case turned every
later GPU test on that host into a failure with a misleading message.
`Reused` now notes that a recording is open and is thrown away instead of
reused if it is.

cargo test --workspace --locked; both clippy configurations with
-D warnings; cargo xtask policy.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:43:16 +00:00
Author
Owner

@⁠pes7 on GitHub · 2026-11-24 22:03 UTC · original

@⁠catminou4 - thank you, and one thing changed after your run at 21:41: there is a second commit now (head 90ebae3, and the PR title says "reused command objects"). Your approval covered the event wait only, so this is what is new, in case you want to look again.

A dispatch also made a new command queue, allocator, list, fence and event on every call. Making those five costs 4.19 ms of an 8.35 ms dispatch (200 iterations, release, hardware device), and emit::valu_tests runs hundreds of dispatches for one shader - v_cvt_norm_i16_and_u16_f16_round_the_exact_product alone is 576.

Host keeps them in a Reused struct now, bumps the fence value per dispatch and Resets the list with its own PSO. Safe here because the GPU tests already run one at a time (ONE_AT_A_TIME) and every dispatch waits for its fence before returning, so the allocator is never in use when it is reset. Drop for Reused closes the event; draw still makes its own, since it is not on that path.

before after
the 576-dispatch test 4.81 s 2.17 s
emit:: suite, wall 9 084 ms 6 053 ms
emit:: suite, CPU 4 438 ms 2 891 ms

Against the original code that is wall 9 080 -> 6 053 ms and CPU 5 562 -> 2 891 ms. cargo test --workspace reports 4.98 s for this crate's lib tests instead of 8.69 s.

Nothing else changed, and it is still #[cfg(test)] only. Both clippy configurations with -D warnings, cargo test --workspace --locked and cargo xtask policy pass on the head.

**@⁠pes7** on GitHub · 2026-11-24 22:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7145748445) @⁠catminou4 - thank you, and one thing changed after your run at `21:41`: there is a second commit now (head `90ebae3`, and the PR title says "reused command objects"). Your approval covered the event wait only, so this is what is new, in case you want to look again. A dispatch also made a new command queue, allocator, list, fence and event on every call. Making those five costs **4.19 ms of an 8.35 ms dispatch** (200 iterations, release, hardware device), and `emit::valu_tests` runs hundreds of dispatches for one shader - `v_cvt_norm_i16_and_u16_f16_round_the_exact_product` alone is 576. `Host` keeps them in a `Reused` struct now, bumps the fence value per dispatch and `Reset`s the list with its own PSO. Safe here because the GPU tests already run one at a time (`ONE_AT_A_TIME`) and every dispatch waits for its fence before returning, so the allocator is never in use when it is reset. `Drop for Reused` closes the event; `draw` still makes its own, since it is not on that path. | | before | after | |---|---:|---:| | the 576-dispatch test | 4.81 s | **2.17 s** | | `emit::` suite, wall | 9 084 ms | **6 053 ms** | | `emit::` suite, CPU | 4 438 ms | **2 891 ms** | Against the original code that is wall 9 080 -> 6 053 ms and CPU 5 562 -> 2 891 ms. `cargo test --workspace` reports 4.98 s for this crate's lib tests instead of 8.69 s. Nothing else changed, and it is still `#[cfg(test)]` only. Both clippy configurations with `-D warnings`, `cargo test --workspace --locked` and `cargo xtask policy` pass on the head.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:05 UTC · original

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 0d4ea57 (on main 70564ae). cargo test -p victory-shader --locked: 206 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures on main, not this PR. Wall time for that run: 24 s. A tree without this change (#1757 on the same base, same machine, run right after) took 53 s for 208 tests, consistent with the speed-up described here.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 23:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7146993634) NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `0d4ea57` (on `main` `70564ae`). `cargo test -p victory-shader --locked`: 206 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures on `main`, not this PR. Wall time for that run: 24 s. A tree without this change (#1757 on the same base, same machine, run right after) took 53 s for 208 tests, consistent with the speed-up described here. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:16 UTC · original · edited 2026-11-26 00:22 UTC

Automated triage for the maintainers.

Merge candidate. Still a test-only speed-up of the GPU test host in crates/victory-shader/src/emit/host.rs. The fence wait uses an event (wait) and still checks GetDeviceRemovedReason on each 100 ms timeout and after the wait. Host::dispatch keeps its queue, allocator, list, fence and event in Reused, resets the allocator before list.Reset, and drops the objects if a previous recording never reached its fence. All of the new code is #[cfg(test)]. The Cargo.toml change only adds two features of windows, which is already a dependency.

On your reply: the new head (7d6cff9) is a rebase onto today's main. I checked that all three constructors (new on its WARP and hardware branches, and from_device) initialise reused, and that main's create_device/WARP setup is kept unchanged. The rest matches what was reviewed at 34965a8.

CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7150528413) · edited 2026-11-26 00:22 UTC <!-- victory-triage v1 head=7d6cff93e0804f983f389686744fc304213853fd verdict=merge-candidate at=2026-11-26T00:22:06Z --> Automated triage for the maintainers. **Merge candidate.** Still a test-only speed-up of the GPU test host in `crates/victory-shader/src/emit/host.rs`. The fence wait uses an event (`wait`) and still checks `GetDeviceRemovedReason` on each 100 ms timeout and after the wait. `Host::dispatch` keeps its queue, allocator, list, fence and event in `Reused`, resets the allocator before `list.Reset`, and drops the objects if a previous recording never reached its fence. All of the new code is `#[cfg(test)]`. The `Cargo.toml` change only adds two features of `windows`, which is already a dependency. On your reply: the new head (`7d6cff9`) is a rebase onto today's `main`. I checked that all three constructors (`new` on its WARP and hardware branches, and `from_device`) initialise `reused`, and that main's `create_device`/WARP setup is kept unchanged. The rest matches what was reviewed at `34965a8`. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Damokles2 on GitHub · 2026-11-25 12:18 UTC · original

Hi @⁠pes7,

While investigating D3D12 device-loss handling, I noticed that fuses_fmad() still has a similar gap on both upstream main and your current PR head.

If GetCompletedValue() returns UINT64_MAX after device removal, the polling loop can exit and reach readback without explicitly checking the removal reason.

Since fuses_fmad() also runs during production adapter initialization, it appears to be outside the current test-only scope of #1734.

Would you prefer to include this small post-wait check in your PR, or would you be comfortable with me investigating and preparing a separate follow-up?

The finding is based on source inspection and Microsoft's documented fence behavior. I haven't reproduced native device removal yet.

AI-assisted investigation using Codex.

**@⁠Damokles2** on GitHub · 2026-11-25 12:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7162205763) Hi @⁠pes7, While investigating D3D12 device-loss handling, I noticed that `fuses_fmad()` still has a similar gap on both upstream main and your current PR head. If `GetCompletedValue()` returns `UINT64_MAX` after device removal, the polling loop can exit and reach readback without explicitly checking the removal reason. Since `fuses_fmad()` also runs during production adapter initialization, it appears to be outside the current test-only scope of #1734. Would you prefer to include this small post-wait check in your PR, or would you be comfortable with me investigating and preparing a separate follow-up? The finding is based on source inspection and Microsoft's documented fence behavior. I haven't reproduced native device removal yet. AI-assisted investigation using Codex.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 12:46 UTC · original

Both fixed in 34965a8 - thank you, the first one was a real leak.

  1. The allocator is reset now, before the list: r.alloc.Reset().map_err(err)? inside the same unsafe block, after the previous dispatch's fence and before list.Reset. Measured cost, in case anyone wonders: four interleaved pairs of the emit suite, middle two averaged - 10.5 s of CPU with the reset against 11.1 s without, i.e. nothing, and the memory of hundreds of recordings per valu_tests case no longer accumulates.

  2. A failed recording is dropped instead of reused. Reused carries recording: Cell<bool>, set just before list.Reset and cleared only once wait has returned, so "open list / allocator in use" is exactly the state that skips reuse:

// A dispatch that failed between `Reset` and its fence left the list
// recording and the allocator in use: make new ones rather than fail
// every later dispatch with a second, misleading error.
if reused.as_ref().is_some_and(|r| r.recording.get()) {
    *reused = None;
}

A case that fails now fails once, and the next dispatch starts from a fresh queue/allocator/list/fence/event.

@⁠Damokles2 - on fuses_fmad(): a separate PR, please. It runs during adapter initialisation, which is outside everything this one touches (all of it is #[cfg(test)]), and it is your finding with the reasoning behind it - better as its own change with its own reviewer than folded in here. Your reading matches what wait does in this PR, for what it is worth: it does not consult GetCompletedValue() at all, it waits on an event that a removed device never signals and checks GetDeviceRemovedReason on each timeout, exactly because a removed fence reports UINT64_MAX and would let a value comparison pass.

**@⁠pes7** on GitHub · 2026-11-25 12:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7162834168) Both fixed in `34965a8` - thank you, the first one was a real leak. 1. **The allocator is reset now**, before the list: `r.alloc.Reset().map_err(err)?` inside the same `unsafe` block, after the previous dispatch's fence and before `list.Reset`. Measured cost, in case anyone wonders: four interleaved pairs of the `emit` suite, middle two averaged - **10.5 s of CPU with the reset against 11.1 s without**, i.e. nothing, and the memory of hundreds of recordings per `valu_tests` case no longer accumulates. 2. **A failed recording is dropped instead of reused.** `Reused` carries `recording: Cell<bool>`, set just before `list.Reset` and cleared only once `wait` has returned, so "open list / allocator in use" is exactly the state that skips reuse: ```rust // A dispatch that failed between `Reset` and its fence left the list // recording and the allocator in use: make new ones rather than fail // every later dispatch with a second, misleading error. if reused.as_ref().is_some_and(|r| r.recording.get()) { *reused = None; } ``` A case that fails now fails once, and the next dispatch starts from a fresh queue/allocator/list/fence/event. @⁠Damokles2 - on `fuses_fmad()`: a separate PR, please. It runs during adapter initialisation, which is outside everything this one touches (all of it is `#[cfg(test)]`), and it is your finding with the reasoning behind it - better as its own change with its own reviewer than folded in here. Your reading matches what `wait` does in this PR, for what it is worth: it does not consult `GetCompletedValue()` at all, it waits on an event that a removed device never signals and checks `GetDeviceRemovedReason` on each timeout, exactly because a removed fence reports `UINT64_MAX` and would let a value comparison pass.
Author
Owner

@⁠Damokles2 on GitHub · 2026-11-25 12:53 UTC · original

Thanks for confirming the finding and clarifying the scope! I'll prepare a separate PR for the fuses_fmad() device-loss handling, keeping the change focused on the probe and its error propagation.

**@⁠Damokles2** on GitHub · 2026-11-25 12:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7162988997) Thanks for confirming the finding and clarifying the scope! I'll prepare a separate PR for the `fuses_fmad()` device-loss handling, keeping the change focused on the probe and its error propagation.
Author
Owner

@⁠pes7 on GitHub · 2026-11-25 22:22 UTC · original

Rebased onto today's main (f3578e3). Three hunks needed a hand, all from #181's WARP work that landed meanwhile:

  • Host now had a warp field, so the reused objects sit beside it (reused: Mutex<Option<Reused>>), and every constructor (new's WARP branch, its hardware branch, from_device) initialises them;
  • the WARP host construction moved into create_device/static WARP, so this branch's own device setup is gone (main's is kept) and only the reused objects remain of it;
  • the new mod tests block from #181 is kept as it is.

All three commits are there (cceb602, 5b1b9cf, 7d6cff9), and cargo test --release -p victory-shader passes: 302 tests, 3 ignored, in 115 s (the same suite took 199 s before the rebase, so the win this PR describes still holds on today's main).

**@⁠pes7** on GitHub · 2026-11-25 22:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#issuecomment-7176278309) Rebased onto today's `main` (`f3578e3`). Three hunks needed a hand, all from #181's WARP work that landed meanwhile: - `Host` now had a `warp` field, so the reused objects sit beside it (`reused: Mutex<Option<Reused>>`), and every constructor (`new`'s WARP branch, its hardware branch, `from_device`) initialises them; - the WARP host construction moved into `create_device`/`static WARP`, so this branch's own device setup is gone (main's is kept) and only the reused objects remain of it; - the new `mod tests` block from #181 is kept as it is. All three commits are there (`cceb602`, `5b1b9cf`, `7d6cff9`), and `cargo test --release -p victory-shader` passes: 302 tests, 3 ignored, in **115 s** (the same suite took 199 s before the rebase, so the win this PR describes still holds on today's `main`).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 21:41 UTC · original · approved these changes

Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows.

Emit test harness: wait() on the fence now uses SetEventOnCompletion + WaitForSingleObject(100ms) with a GetDeviceRemovedReason check per timeout instead of spinning — a removed device is reported rather than hung, and the event handle is closed on every path except the wedged one (deliberately leaked, one handle, run is ending anyway). Windows-only test code; macOS compile unaffected.

**@⁠catminou4** on GitHub · 2026-11-24 21:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#pullrequestreview-6047860924) · **approved these changes** Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Windows-gated execution/hardware tests only run on Windows. Emit test harness: wait() on the fence now uses SetEventOnCompletion + WaitForSingleObject(100ms) with a GetDeviceRemovedReason check per timeout instead of spinning — a removed device is reported rather than hung, and the event handle is closed on every path except the wedged one (deliberately leaked, one handle, run is ending anyway). Windows-only test code; macOS compile unaffected.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 17:23 UTC · original · approved these changes

Verified head 7d6cff93e0804f983f389686744fc304213853fd merged onto main (63bcca43) on Windows 11 (Ryzen 9 9950X, RTX 5090 + WARP, Rust 1.98.1 MSVC, and D3D12 Debug Layer).

  • Clean merge onto main (and clean co-merge with #1493 in emit/host.rs).
  • cargo xtask policy (191 files ok), cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features), and emit::rect:: / v_med3_ / v_fract_ tests (6/6, covering both Host::draw and Host::dispatch) all pass.
  • Back-to-back A/B timing of v_cvt_norm_i16_and_u16_f16_round_the_exact_product (576 dispatches, debug build, hardware + WARP): 33.05 s on main (33,181 ms wall) vs 1.41 s with this PR (1,773 ms wall).
  • Verified with the D3D12 Debug Layer (ID3D12InfoQueue) on both RTX 5090 and WARP:
    • 20 consecutive alternating-PSO dispatches on a single Host produced zero new warnings/errors (only main's pre-existing ID=1328 on View::RawUav).
    • Mid-recording failure recovery (triggering a CreateCommittedResource error after list.Reset / before list.Close, leaving r.recording == true, then running a valid dispatch on the same Host) cleanly dropped and recreated Reused, returned the expected output, and produced zero Debug Layer warnings/errors on both adapters.
  • Process handle count (GetProcessHandleCount, without Debug Layer): +0 handles across 60 reused dispatches on both RTX 5090 (358 -> 358) and WARP (304 -> 304), and +0 across 20 full Host::new -> dispatch -> drop cycles on WARP (299 -> 299), confirming Drop for Reused closes the event handle cleanly.

Minor non-blocking nit: in Host::draw (emit/host.rs:1355-1358), if queue.Signal(&fence, 1) fails, event is returned past CloseHandle(event); creating event after queue.Signal avoids leaking the handle on that error path.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 17:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1734#pullrequestreview-6078300086) · **approved these changes** Verified head `7d6cff93e0804f983f389686744fc304213853fd` merged onto `main` (`63bcca43`) on Windows 11 (Ryzen 9 9950X, RTX 5090 + WARP, Rust 1.98.1 MSVC, and D3D12 Debug Layer). - Clean merge onto `main` (and clean co-merge with `#1493` in `emit/host.rs`). - `cargo xtask policy` (`191 files ok`), `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`), and `emit::rect::` / `v_med3_` / `v_fract_` tests (6/6, covering both `Host::draw` and `Host::dispatch`) all pass. - Back-to-back A/B timing of `v_cvt_norm_i16_and_u16_f16_round_the_exact_product` (576 dispatches, debug build, hardware + WARP): **`33.05 s`** on `main` (`33,181 ms` wall) vs **`1.41 s`** with this PR (`1,773 ms` wall). - Verified with the D3D12 Debug Layer (`ID3D12InfoQueue`) on both RTX 5090 and WARP: - 20 consecutive alternating-PSO dispatches on a single `Host` produced zero new warnings/errors (only `main`'s pre-existing `ID=1328` on `View::RawUav`). - Mid-recording failure recovery (triggering a `CreateCommittedResource` error after `list.Reset` / before `list.Close`, leaving `r.recording == true`, then running a valid dispatch on the same `Host`) cleanly dropped and recreated `Reused`, returned the expected output, and produced zero Debug Layer warnings/errors on both adapters. - Process handle count (`GetProcessHandleCount`, without Debug Layer): `+0` handles across 60 reused dispatches on both RTX 5090 (`358 -> 358`) and WARP (`304 -> 304`), and `+0` across 20 full `Host::new` -> `dispatch` -> `drop` cycles on WARP (`299 -> 299`), confirming `Drop for Reused` closes the event handle cleanly. Minor non-blocking nit: in `Host::draw` (`emit/host.rs:1355-1358`), if `queue.Signal(&fence, 1)` fails, `event` is returned past `CloseHandle(event)`; creating `event` after `queue.Signal` avoids leaking the handle on that error path.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1734/head:github-bot/gh-1734'
git switch 'github-bot/gh-1734'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1734'
git switch 'github-bot/gh-1734'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1734'
git switch 'github-bot/gh-1734'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1734'
git switch 'main'
git merge --squash 'github-bot/gh-1734'
git switch 'main'
git merge --ff-only 'github-bot/gh-1734'
git switch 'main'
git merge 'github-bot/gh-1734'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1734
No description provided.