Tests: four races, the BCPack oracle, the shader key's stale names, and a loop-latch test #3061

Open
Adriwin06 wants to merge 3 commits from upstream-pr/3061 into main
Adriwin06 commented 2026-11-29 19:52:37 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Adriwin06 on 2026-11-29T19:52:37Z.


What it changes

3 small changes of the same kind, one commit each, so each can be reviewed, reverted or left out on its own:

Tests: four races, a timing test on WARP and the BCPack oracle, which fail on main or on a busy runner

  • rangelock: the reader test slept 50 ms and assumed the writer thread
    had announced its range by then. It now waits (up to 5 s) until
    state().writing shows the range, so a late-scheduled writer no
    longer fails it.
  • card_steps: the two late tests gave their memory back, and the
    other test could be handed the same pages and find them already
    learned (late has no forgetting) before it learned anything. The
    memory is now leaked (std::mem::forget) so it is never another
    test's.
  • card_steps: shared_scratch_eliminates_flight_settle_end_to_end times
    a hardware GPU; on a software adapter (WARP) it now says so and
    returns. The root-constants test still covers the fill path.
  • menu: the tests that set or clear VICTORY_MENU_FILE / VICTORY_HOME
    hold one MENU_ENV mutex, since the save note reads both and two such
    tests at once saw each other's.
  • watch: the late-fault test keeps the guard lock from queuing the
    entry through its pre-settle assertions and settles it itself, so
    another test taking the lock cannot drain the entry first.
  • bcpack: the test oracle skipped a u16 and read 31 index slots; the
    word after the widths is pixel 0's index and all 32 slots are read
    in order, the same layout as Tables::builtin (f9de61c5).

Shader cache: the key's test lists only switches the translator still reads (#479's revert)

1b4b6cd4 restored the GPU side of the reverted #479 and with it five
switch names in shader_cache: VICTORY_SCALAR_SPLITS in KEYED, and the
differential fuzzer's VICTORY_ORACLE_RUNS, _SEED, _AVOID and _OUT in the
test's NOT_TRANSLATION list. The translator's side and oracle_tests.rs
stayed reverted, so nothing in victory-shader reads any of the five:
the key took a value that changes no translation, and
shader_cache::tests::every_switch_of_the_translator_is_in_the_key fails
on main ("VICTORY_SCALAR_SPLITS is not read by the translator any
more"). The five are taken out; they go back with #479's shader side.

Shaders: a test that a block closing two loops keeps one back edge

The empty-latch fold leaves a block that is already another loop's
latch alone, since it would get two back edges, which
single_back_edges took apart for vkd3d-proton's dxil-spirv. Says so
where the fold is decided and adds a test for it.

Test: bitcode::tests::a_block_that_closes_two_loops_gets_one_back_edge.

From DoubleGhosty/cool_fox@f7d5b50 (Hasusmogus), GPL-3.0-or-later.

How it was tested

  • GPU and profile: n/a, tests only (run on an RTX 4070 SUPER and on WARP)
  • For shader changes, the wave sizes tested: the unit tests named in each commit (32- and 64-lane programs where they translate both)
  • cargo test passed for the crates it touches:
    • test-races: yes, cargo test -p victory-formats --lib -- bcpack: 15 passed (main fails 3 oracle_parity tests); cargo test -p victory-gpu --lib -- rangelock:: card_steps:: host::menu:: watch::: 97 passed, three runs in a row
    • shader-key-scalar-splits: yes, cargo test -p victory-gpu --lib -- shader_cache::: 11 passed (main fails every_switch_of_the_translator_is_in_the_key; this passes it)
    • loop-latch-test: yes, cargo test -p victory-shader --lib -- bitcode::tests::a_block_that_closes: 1 passed
  • cargo clippy --workspace --all-targets --locked: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself).
  • cargo xtask policy: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs).
  • With all eleven of my pull requests merged together: cargo clippy also with --all-features adds no finding, and cargo test --workspace --locked fails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related:
    • test-races: None found for these tests. #2792 and #2772 repair the Clippy gate, not these tests.
    • shader-key-scalar-splits: None found for VICTORY_SCALAR_SPLITS or the ORACLE names (searched the switch names and the test name).
    • loop-latch-test: None found.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5554483288 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3061). Originally posted by [Adriwin06](https://github.com/Adriwin06) on 2026-11-29T19:52:37Z. --- ## What it changes 3 small changes of the same kind, one commit each, so each can be reviewed, reverted or left out on its own: ### Tests: four races, a timing test on WARP and the BCPack oracle, which fail on main or on a busy runner - rangelock: the reader test slept 50 ms and assumed the writer thread had announced its range by then. It now waits (up to 5 s) until `state().writing` shows the range, so a late-scheduled writer no longer fails it. - card_steps: the two `late` tests gave their memory back, and the other test could be handed the same pages and find them already learned (`late` has no forgetting) before it learned anything. The memory is now leaked (`std::mem::forget`) so it is never another test's. - card_steps: shared_scratch_eliminates_flight_settle_end_to_end times a hardware GPU; on a software adapter (WARP) it now says so and returns. The root-constants test still covers the fill path. - menu: the tests that set or clear VICTORY_MENU_FILE / VICTORY_HOME hold one MENU_ENV mutex, since the save note reads both and two such tests at once saw each other's. - watch: the late-fault test keeps the guard lock from queuing the entry through its pre-settle assertions and settles it itself, so another test taking the lock cannot drain the entry first. - bcpack: the test oracle skipped a u16 and read 31 index slots; the word after the widths is pixel 0's index and all 32 slots are read in order, the same layout as `Tables::builtin` (f9de61c5). ### Shader cache: the key's test lists only switches the translator still reads (#479's revert) 1b4b6cd4 restored the GPU side of the reverted #479 and with it five switch names in shader_cache: VICTORY_SCALAR_SPLITS in KEYED, and the differential fuzzer's VICTORY_ORACLE_RUNS, _SEED, _AVOID and _OUT in the test's NOT_TRANSLATION list. The translator's side and oracle_tests.rs stayed reverted, so nothing in victory-shader reads any of the five: the key took a value that changes no translation, and shader_cache::tests::every_switch_of_the_translator_is_in_the_key fails on main ("VICTORY_SCALAR_SPLITS is not read by the translator any more"). The five are taken out; they go back with #479's shader side. ### Shaders: a test that a block closing two loops keeps one back edge The empty-latch fold leaves a block that is already another loop's latch alone, since it would get two back edges, which single_back_edges took apart for vkd3d-proton's dxil-spirv. Says so where the fold is decided and adds a test for it. Test: bitcode::tests::a_block_that_closes_two_loops_gets_one_back_edge. From DoubleGhosty/cool_fox@f7d5b50 (Hasusmogus), GPL-3.0-or-later. ## How it was tested - GPU and profile: n/a, tests only (run on an RTX 4070 SUPER and on WARP) - For shader changes, the wave sizes tested: the unit tests named in each commit (32- and 64-lane programs where they translate both) - `cargo test` passed for the crates it touches: - test-races: yes, `cargo test -p victory-formats --lib -- bcpack`: 15 passed (main fails 3 oracle_parity tests); `cargo test -p victory-gpu --lib -- rangelock:: card_steps:: host::menu:: watch::`: 97 passed, three runs in a row - shader-key-scalar-splits: yes, `cargo test -p victory-gpu --lib -- shader_cache::`: 11 passed (main fails every_switch_of_the_translator_is_in_the_key; this passes it) - loop-latch-test: yes, `cargo test -p victory-shader --lib -- bitcode::tests::a_block_that_closes`: 1 passed - `cargo clippy --workspace --all-targets --locked`: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself). - `cargo xtask policy`: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs). - With all eleven of my pull requests merged together: `cargo clippy` also with `--all-features` adds no finding, and `cargo test --workspace --locked` fails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: - test-races: None found for these tests. #2792 and #2772 repair the Clippy gate, not these tests. - shader-key-scalar-splits: None found for VICTORY_SCALAR_SPLITS or the ORACLE names (searched the switch names and the test name). - loop-latch-test: None found. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot] commented 2026-11-29 19:54:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-29T19:54:44Z.

Review: COMMENTED


The review has no active issues requiring resolution.

No open issues 🎉

What changed in this PR

This PR improves test reliability across the GPU and format crates, removes stale shader-cache switch names left after the partial revert of #479, and adds regression coverage for nested-loop latch handling.

Changes:

  • Synchronizes race-prone tests, prevents learned-memory reuse, and skips hardware timing comparisons on software adapters.
  • Corrects the BCPack test oracle to read all 32 index slots and removes unused shader switch names.
  • Documents the existing loop-latch folding restriction and adds a regression test without changing shader control-flow logic.
File Description
crates/​victory-shader/​src/​emit/​bitcode.rs Documents latch-folding constraints and tests a block closing two loops.
crates/​victory-gpu/​src/​watch.rs Holds the guard lock through pre-settle assertions to prevent interference.
crates/​victory-gpu/​src/​shader_cache.rs Removes unused scalar-split and oracle switch names.
crates/​victory-gpu/​src/​rangelock.rs Replaces a fixed sleep with a bounded wait for writer registration.
crates/​victory-gpu/​src/​host/​menu.rs Serializes tests that modify shared menu environment variables.
crates/​victory-gpu/​src/​host/​card_steps.rs Prevents learned-memory reuse and skips software-adapter timing comparisons.
crates/​victory-formats/​src/​bcpack.rs Fixes the test oracle’s index-table layout.

Review effort: Balanced

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6104527437 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3061#pullrequestreview-6104527437). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-11-29T19:54:44Z. **Review:** COMMENTED --- <!-- ccr-overview-v2 --> ### 🟢 Approval recommended The review has no active issues requiring resolution. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> This PR improves test reliability across the GPU and format crates, removes stale shader-cache switch names left after the partial revert of #479, and adds regression coverage for nested-loop latch handling. **Changes:** - Synchronizes race-prone tests, prevents learned-memory reuse, and skips hardware timing comparisons on software adapters. - Corrects the BCPack test oracle to read all 32 index slots and removes unused shader switch names. - Documents the existing loop-latch folding restriction and adds a regression test without changing shader control-flow logic. | File | Description | | ---- | ----------- | | `crates/​victory-shader/​src/​emit/​bitcode.rs` | Documents latch-folding constraints and tests a block closing two loops. | | `crates/​victory-gpu/​src/​watch.rs` | Holds the guard lock through pre-settle assertions to prevent interference. | | `crates/​victory-gpu/​src/​shader_cache.rs` | Removes unused scalar-split and oracle switch names. | | `crates/​victory-gpu/​src/​rangelock.rs` | Replaces a fixed sleep with a bounded wait for writer registration. | | `crates/​victory-gpu/​src/​host/​menu.rs` | Serializes tests that modify shared menu environment variables. | | `crates/​victory-gpu/​src/​host/​card_steps.rs` | Prevents learned-memory reuse and skips software-adapter timing comparisons. | | `crates/​victory-formats/​src/​bcpack.rs` | Fixes the test oracle’s index-table layout. | </details> <sub>Review effort: Balanced</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3061:upstream-pr/3061'
git switch 'upstream-pr/3061'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3061'
git switch 'upstream-pr/3061'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3061'
git switch 'upstream-pr/3061'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3061'
git switch 'main'
git merge --squash 'upstream-pr/3061'
git switch 'main'
git merge --ff-only 'upstream-pr/3061'
git switch 'main'
git merge 'upstream-pr/3061'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
trustno1-coder/VIctory-NVIDIA!3061
No description provided.