Shaders: drop a wave64 mask whose low dword is seen with two high dwords #660

Open
coderanonymus wants to merge 1 commit from upstream-pr/660 into main
coderanonymus commented 2026-11-24 06:24:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by coderanonymus on 2026-11-24T06:24:29Z.


What

In wave64 a lane mask is an SGPR pair. Structurisation tracks masks by the pair, but it exports Structured::masks, highs and active by the low dword alone. When code rewrites only the high dword, two pairs share one low dword, and lowering finds the wrong pair's mask.

  • Select and carry-in. v_cmp_eq_u32 vcc, 0, v0; s_mov_b32 vcc_hi, 0; v_cndmask_b32 v1, 0, v2, vcc: masks[vcc_lo] was still the compare. The select picked src1 by the compare's bit in lanes 32-63, where the hardware has VCC_HI = 0 and picks src0. emit returned Ok. v_add_co_ci_u32 reads its carry-in the same way.
  • EXEC. s_mov_b32 exec_hi, 0; v_mov_b32 v1, 7; buffer_store_dword ...: the guard is Opaque(exec_lo), and lowering took the high dword of EXEC on entry. Lanes 32-63 stored, although the new EXEC disables them. emit returned Ok. With an s_mov_b64 s[2:3], exec first, main already refuses the same program ("a lane mask whose lanes depend on its own value").

The code changes are in structure.rs:

  • finish leaves a low dword out of masks, highs and active when it was seen with two high dwords. Lowering then refuses what reads it ("a select on an untracked mask", "a carry-in from an untracked mask", or for the EXEC case "a hardware SGPR input") when that low dword has no value of its own (EXEC, compare results). See "Still open" for one that holds a number.
  • step records the carry-in pair of v_*_co_ci_u32. Before, it was never recorded, so the check above could not see it. It is only recorded, not resolved through mask as the v_cndmask_b32 condition is, so a carry-in on a join of compares is still refused, as on main.
  • join records the pairs it takes over back edges. Lowering looks phi arguments up by low dword too, and those pairs never go through mask.

emit/mod.rs gets a stores_v1 test helper, two tests, and a doc comment update.

Still open, marked as a shortcut: in mask: Atom::Opaque names its pair by the low dword. Lowering takes the high dword written beside it. This is wrong for a mask whose halves were written apart when the low dword holds a number: two s_mov_b32, or s_mov_b64 s[4:5], k then s_mov_b32 s5, 0, where lowering takes the stale s5. So the PR does not refuse every wave64 mask whose high dword was rewritten alone. When the low dword has no value (EXEC, compare results), lowering now refuses. The full fix is an opaque atom that carries both dwords, which needs a change to emit/lower.rs. I left that out of this PR.

In wave32 both halves of a key are the same value, so no low dword is ever split and no mask is dropped. Wave32 is unchanged.

Found in review, not fixed here (it is on main too): a select on a join of compares after a divergent branch translates wrongly. In v_cmp_eq_u32 vcc, 0, v0; s_andn1_saveexec_b64 s[2:3], vcc; s_cbranch_execz; v_cmp_eq_u32 vcc, 1, v0; s_or_b64 exec, exec, s[2:3]; v_cndmask_b32 v1, 0, v2, vcc, the join resolves to a per-lane phi. Lane 0 skips the inner block, so the phi gives it the first compare's bit. The hardware has 0 there whenever some lane runs the inner block, because VOPC clears the bits of inactive lanes. This is why the carry-in is only recorded: resolving it the same way turned main's refusal of the carry-in version into this wrong code. Compiled code is unlikely to hit it: LLVM merges an i1 across such a join with s_andn2 / s_and / s_or on EXEC, which the per-lane join already gets right. A check at the join that refused the raw form also refused LLVM's own if/else lowering and uniform branches inside a divergent if, so a fix needs a different model of mask joins, not a check. I left it.

Overlap with open PRs:

  • #69 rewrites the same v_cndmask_b32 block in step and fixes the select case another way (a select mask keyed by the select's destination, from the exact pair it reads). Whichever lands second needs a rebase there.
  • #385 changes how join handles back edges. The back-edge recording here sits in the loop it changes, so the two may conflict.
  • #320 and #439 add an others export keyed by (lo, _). It needs the same split filter as masks.

Rebased on main (ffe310e)

main now builds paired_masks (exact pairs, for the waterfall proof) from the same map. finish takes it before dropping split low dwords: an exact pair stays right when its low dword is split, so the waterfall proof sees the same pairs as before. The stores_v1 test helper now passes the structure to resource::track, which takes it since main changed.

After the rebase: cargo test -p victory-shader 100 passed; cargo clippy -p victory-shader --all-targets --all-features --target x86_64-pc-windows-msvc -- -D warnings clean.

Verification

All run on Linux. The target dir is shared, so I passed --config profile.dev.package.<crate>.codegen-units=251 (for each workspace crate built) to force a fresh build of this worktree.

  • New tests, on unmodified main (tests only):
    cargo test -p victory-shader --lib -- a_mask_ a_carry_in
    • structure::tests::a_mask_whose_high_dword_is_rewritten_is_not_the_compare FAILED: 0x2020480: vcc_hi was zeroed after the compare, left and right both Some((Lane(Value(5)), Bool(0), Bool(1))). The carry-in program fails the same way.
    • structure::tests::a_mask_joined_over_a_back_edge_with_a_rewritten_high_dword_is_not_the_compare FAILED: left and right both Some((Lane(Value(16)), Bool(0), Bool(1))).
    • emit::tests::a_mask_whose_high_dword_is_rewritten_is_refused FAILED: the vcc_hi select program translated, and so did the vcc_hi carry-in program (checked on its own). The exec_hi program also translated (Ok). Its last program (exec_hi after s_mov_b64 s[2:3], exec) already refuses on main, so it adds no regression coverage; it stays as a guard.
    • emit::tests::a_carry_in_from_a_divergent_join_is_refused passes on main (it refuses with "a carry-in from an untracked mask"). It fails if the carry-in goes through mask like the select (emit returns Ok), which is what it guards.
  • emit::tests::an_exec_high_write_does_not_overflow_the_stack (existing) now goes another way: the guard's low dword is split and has no mask, so the v_mov_b32 no longer needs the mask's own value. emit still returns Ok, since nothing with a side effect reads it. I updated its doc comment.
  • With the fix: all 4 new tests pass. If I remove the back-edge recording, the loop test fails. If I remove the carry-in recording, the structure and emit carry-in cases fail.
  • cargo test -p victory-formats -p victory-shader -p victory-pipeline -p victory-core -p xtask: all pass (victory-shader 60 passed).
  • cargo clippy -p victory-shader --tests --target x86_64-pc-windows-msvc: no warnings.
  • rustfmt --edition 2024 --check on both touched files: clean.

Not run: Windows-only crates and tests, and no game shaders. How often console code writes one half of a mask outside a whole-wave section was not measured.

No game data used.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575994275 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660). Originally posted by [coderanonymus](https://github.com/coderanonymus) on 2026-11-24T06:24:29Z. --- ## What In wave64 a lane mask is an SGPR pair. Structurisation tracks masks by the pair, but it exports `Structured::masks`, `highs` and `active` by the low dword alone. When code rewrites only the high dword, two pairs share one low dword, and lowering finds the wrong pair's mask. - Select and carry-in. `v_cmp_eq_u32 vcc, 0, v0; s_mov_b32 vcc_hi, 0; v_cndmask_b32 v1, 0, v2, vcc`: `masks[vcc_lo]` was still the compare. The select picked src1 by the compare's bit in lanes 32-63, where the hardware has VCC_HI = 0 and picks src0. `emit` returned Ok. `v_add_co_ci_u32` reads its carry-in the same way. - EXEC. `s_mov_b32 exec_hi, 0; v_mov_b32 v1, 7; buffer_store_dword ...`: the guard is `Opaque(exec_lo)`, and lowering took the high dword of EXEC on entry. Lanes 32-63 stored, although the new EXEC disables them. `emit` returned Ok. With an `s_mov_b64 s[2:3], exec` first, `main` already refuses the same program ("a lane mask whose lanes depend on its own value"). The code changes are in `structure.rs`: - `finish` leaves a low dword out of `masks`, `highs` and `active` when it was seen with two high dwords. Lowering then refuses what reads it ("a select on an untracked mask", "a carry-in from an untracked mask", or for the EXEC case "a hardware SGPR input") when that low dword has no value of its own (EXEC, compare results). See "Still open" for one that holds a number. - `step` records the carry-in pair of `v_*_co_ci_u32`. Before, it was never recorded, so the check above could not see it. It is only recorded, not resolved through `mask` as the `v_cndmask_b32` condition is, so a carry-in on a join of compares is still refused, as on `main`. - `join` records the pairs it takes over back edges. Lowering looks phi arguments up by low dword too, and those pairs never go through `mask`. `emit/mod.rs` gets a `stores_v1` test helper, two tests, and a doc comment update. Still open, marked as a `shortcut:` in `mask`: `Atom::Opaque` names its pair by the low dword. Lowering takes the high dword written beside it. This is wrong for a mask whose halves were written apart when the low dword holds a number: two `s_mov_b32`, or `s_mov_b64 s[4:5], k` then `s_mov_b32 s5, 0`, where lowering takes the stale `s5`. So the PR does not refuse every wave64 mask whose high dword was rewritten alone. When the low dword has no value (EXEC, compare results), lowering now refuses. The full fix is an opaque atom that carries both dwords, which needs a change to `emit/lower.rs`. I left that out of this PR. In wave32 both halves of a key are the same value, so no low dword is ever split and no mask is dropped. Wave32 is unchanged. Found in review, not fixed here (it is on `main` too): a select on a join of compares after a divergent branch translates wrongly. In `v_cmp_eq_u32 vcc, 0, v0; s_andn1_saveexec_b64 s[2:3], vcc; s_cbranch_execz; v_cmp_eq_u32 vcc, 1, v0; s_or_b64 exec, exec, s[2:3]; v_cndmask_b32 v1, 0, v2, vcc`, the join resolves to a per-lane phi. Lane 0 skips the inner block, so the phi gives it the first compare's bit. The hardware has 0 there whenever some lane runs the inner block, because VOPC clears the bits of inactive lanes. This is why the carry-in is only recorded: resolving it the same way turned `main`'s refusal of the carry-in version into this wrong code. Compiled code is unlikely to hit it: LLVM merges an i1 across such a join with `s_andn2` / `s_and` / `s_or` on EXEC, which the per-lane join already gets right. A check at the join that refused the raw form also refused LLVM's own if/else lowering and uniform branches inside a divergent if, so a fix needs a different model of mask joins, not a check. I left it. Overlap with open PRs: - #69 rewrites the same `v_cndmask_b32` block in `step` and fixes the select case another way (a select mask keyed by the select's destination, from the exact pair it reads). Whichever lands second needs a rebase there. - #385 changes how `join` handles back edges. The back-edge recording here sits in the loop it changes, so the two may conflict. - #320 and #439 add an `others` export keyed by `(lo, _)`. It needs the same split filter as `masks`. ## Rebased on main (ffe310e) `main` now builds `paired_masks` (exact pairs, for the waterfall proof) from the same map. `finish` takes it before dropping split low dwords: an exact pair stays right when its low dword is split, so the waterfall proof sees the same pairs as before. The `stores_v1` test helper now passes the structure to `resource::track`, which takes it since main changed. After the rebase: `cargo test -p victory-shader` 100 passed; `cargo clippy -p victory-shader --all-targets --all-features --target x86_64-pc-windows-msvc -- -D warnings` clean. ## Verification All run on Linux. The target dir is shared, so I passed `--config profile.dev.package.<crate>.codegen-units=251` (for each workspace crate built) to force a fresh build of this worktree. - New tests, on unmodified `main` (tests only): `cargo test -p victory-shader --lib -- a_mask_ a_carry_in` - `structure::tests::a_mask_whose_high_dword_is_rewritten_is_not_the_compare` FAILED: `0x2020480: vcc_hi was zeroed after the compare`, left and right both `Some((Lane(Value(5)), Bool(0), Bool(1)))`. The carry-in program fails the same way. - `structure::tests::a_mask_joined_over_a_back_edge_with_a_rewritten_high_dword_is_not_the_compare` FAILED: left and right both `Some((Lane(Value(16)), Bool(0), Bool(1)))`. - `emit::tests::a_mask_whose_high_dword_is_rewritten_is_refused` FAILED: the vcc_hi select program translated, and so did the vcc_hi carry-in program (checked on its own). The `exec_hi` program also translated (Ok). Its last program (`exec_hi` after `s_mov_b64 s[2:3], exec`) already refuses on `main`, so it adds no regression coverage; it stays as a guard. - `emit::tests::a_carry_in_from_a_divergent_join_is_refused` passes on `main` (it refuses with "a carry-in from an untracked mask"). It fails if the carry-in goes through `mask` like the select (emit returns Ok), which is what it guards. - `emit::tests::an_exec_high_write_does_not_overflow_the_stack` (existing) now goes another way: the guard's low dword is split and has no mask, so the `v_mov_b32` no longer needs the mask's own value. `emit` still returns Ok, since nothing with a side effect reads it. I updated its doc comment. - With the fix: all 4 new tests pass. If I remove the back-edge recording, the loop test fails. If I remove the carry-in recording, the structure and emit carry-in cases fail. - `cargo test -p victory-formats -p victory-shader -p victory-pipeline -p victory-core -p xtask`: all pass (victory-shader 60 passed). - `cargo clippy -p victory-shader --tests --target x86_64-pc-windows-msvc`: no warnings. - `rustfmt --edition 2024 --check` on both touched files: clean. Not run: Windows-only crates and tests, and no game shaders. How often console code writes one half of a mask outside a whole-wave section was not measured. No game data used. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
LAKSHYA-cmd-tech commented 2026-11-24 06:54:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:27:16Z.

Review: APPROVED


LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. All 73 tests in ictory-shader passed cleanly, including the new unit tests verifying that rewriting the high dword of an SGPR pair drops stale wave64 lane masks and prevents silent miscompilations on split mask pairs.

<!-- greyfinch-sync:Marvisak/VIctory:review:6034657529 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#pullrequestreview-6034657529). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:27:16Z. **Review:** APPROVED --- LGTM! Tested on Windows 11 with MSVC Rust 1.98.1. All 73 tests in ictory-shader passed cleanly, including the new unit tests verifying that rewriting the high dword of an SGPR pair drops stale wave64 lane masks and prevents silent miscompilations on split mask pairs.
fuzeofficlal commented 2026-11-24 06:56:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T06:43:44Z.


I tested the remaining opaque numeric-mask case on d92ebe9. A synthetic Wave64 compute program writes two scalar words, rewrites only the high word, and ANDs the pair into EXEC before a per-lane output store. Both baseline shaders pass SDK DXIL validation. On the Radeon iGPU the readback matches 32/64 lanes in each case, because lanes 32–63 use the old high word.

Keeping both SSA word identities in the opaque guard gives 64/64 expected values for both variants. At lanes 31/32, clearing the high word changes 7/7 to 7/0, and setting it changes 0/0 to 0/7. Both candidates pass SDK DXIL validation. The serial shader suite reports 74 passed, including the earlier refusal tests and a new structural test distinguishing two guards with the same low word.

Incremental source change on this head

<!-- greyfinch-sync:Marvisak/VIctory:comment:7124230241 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#issuecomment-7124230241). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T06:43:44Z. --- I tested the remaining opaque numeric-mask case on `d92ebe9`. A synthetic Wave64 compute program writes two scalar words, rewrites only the high word, and ANDs the pair into EXEC before a per-lane output store. Both baseline shaders pass SDK DXIL validation. On the Radeon iGPU the readback matches 32/64 lanes in each case, because lanes 32–63 use the old high word. Keeping both SSA word identities in the opaque guard gives 64/64 expected values for both variants. At lanes 31/32, clearing the high word changes `7/7` to `7/0`, and setting it changes `0/0` to `0/7`. Both candidates pass SDK DXIL validation. The serial shader suite reports 74 passed, including the earlier refusal tests and a new structural test distinguishing two guards with the same low word. [Incremental source change on this head](https://github.com/fuzeofficlal/VIctory/commit/498cfa1707f38cfe2ffd42ae683f8041cf24e5b4)
catminou4 commented 2026-11-24 10:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T09:37:34Z.

Review: APPROVED


Merges cleanly with main; macOS arm64, rustc 1.98.1, cargo test -p victory-shader --locked with the PR merged into main 8e79c80 → 74 passed / 0 failed / 1 ignored.

This fixes a real soundness hole: a wave64 mask whose low dword is read with two different high dwords (one rewritten alone via s_mov_b32 exec_hi/vcc_hi) used to make lowering recurse until stack overflow. The seen set in Lanes now records pairs mask doesn't resolve (carry-ins, back-edge joins), and finish drops any low dword observed with two high dwords from masks/active, so lowering refuses the instruction instead of taking the wrong pair's lanes 32-63.

I checked the carry-in path: _co_ci_ masks are recorded in seen rather than resolved through mask(), which is what keeps a divergent join a refusal instead of an unsound per-lane phi — the comment explains exactly that. Tests cover the direct rewrite, the rewritten EXEC high dword with a saved EXEC, and the loop back-edge join. The two new structure.rs tests assert the mask is not the compare's lane atom, which is the right invariant.

One nit: the shortcut comment at mask() (~line 665) says "Give the atom both dwords when such code turns up" — fine as a documented limitation, and the refusal path makes it safe rather than wrong.

<!-- greyfinch-sync:Marvisak/VIctory:review:6036818610 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#pullrequestreview-6036818610). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T09:37:34Z. **Review:** APPROVED --- Merges cleanly with main; macOS arm64, rustc 1.98.1, `cargo test -p victory-shader --locked` with the PR merged into main `8e79c80` → **74 passed / 0 failed / 1 ignored**. This fixes a real soundness hole: a wave64 mask whose low dword is read with two different high dwords (one rewritten alone via `s_mov_b32 exec_hi`/`vcc_hi`) used to make lowering recurse until stack overflow. The `seen` set in `Lanes` now records pairs `mask` doesn't resolve (carry-ins, back-edge joins), and `finish` drops any low dword observed with two high dwords from `masks`/`active`, so lowering refuses the instruction instead of taking the wrong pair's lanes 32-63. I checked the carry-in path: `_co_ci_` masks are recorded in `seen` rather than resolved through `mask()`, which is what keeps a divergent join a refusal instead of an unsound per-lane phi — the comment explains exactly that. Tests cover the direct rewrite, the rewritten EXEC high dword with a saved EXEC, and the loop back-edge join. The two new `structure.rs` tests assert the mask is *not* the compare's lane atom, which is the right invariant. One nit: the shortcut comment at `mask()` (~line 665) says "Give the atom both dwords when such code turns up" — fine as a documented limitation, and the refusal path makes it safe rather than wrong.
rpmaster2 commented 2026-11-24 11:04:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-24T11:02:39Z.


Independent test on RDNA4: this PR alone, on main @58fed37, diag build, DRED on, 300 s from an identical restored save.

Counting unique stage/hash pairs whose pipelines are dropped with shader does not translate:

build unique refused of which graphic stages
main (two runs) 472, 440 65 (26 mesh, 34 pixel, 5 vertex)
main + this PR 33 0 - all compute

Both mask reasons disappear entirely with this PR: a select on an untracked mask (95-96 log lines on main) and a lane mask holding lanes elsewhere read as data (80-81) go to 0. Remaining reasons here: a descriptor read only as data (24 lines), a structured buffer of unknown stride (8), a descriptor's address or format read as data (1).

Interesting detail: the 33 hashes left are exactly the same set that #585 alone leaves, even though #585 only touches emit/lower.rs and this PR touches emit/mod.rs and structure.rs. So on this title the two PRs each unblock the same set from different sides; either one is enough to get every pixel/vertex/mesh shader translated.

What this PR does not change: the world is still black (6 black-frame warnings, ~1 fps, 150 draws/frame) and the run still loses the device at frame 1143 with the same page fault ... inside freed [texture ...] signature that every main run shows. So it is not a stability fix, only a translation one.

Note on method: my first run of this PR stayed in the front end and measured nothing (16 draws/frame, 30 fps); the numbers above are from a retry with later key timings that reached the world. Not tested: cargo test, clippy, other GPUs.

No game data: counts, shader hashes, driver version and error strings only.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129580262 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#issuecomment-7129580262). Originally posted by [rpmaster2](https://github.com/rpmaster2) on 2026-11-24T11:02:39Z. --- Independent test on RDNA4: this PR alone, on `main` @58fed37, diag build, DRED on, 300 s from an identical restored save. Counting unique `stage/hash` pairs whose pipelines are dropped with `shader does not translate`: | build | unique refused | of which graphic stages | | --- | --- | --- | | `main` (two runs) | 472, 440 | 65 (26 mesh, 34 pixel, 5 vertex) | | `main` + this PR | 33 | 0 - all compute | Both mask reasons disappear entirely with this PR: `a select on an untracked mask` (95-96 log lines on main) and `a lane mask holding lanes elsewhere read as data` (80-81) go to 0. Remaining reasons here: `a descriptor read only as data` (24 lines), `a structured buffer of unknown stride` (8), `a descriptor's address or format read as data` (1). Interesting detail: the 33 hashes left are exactly the same set that #585 alone leaves, even though #585 only touches `emit/lower.rs` and this PR touches `emit/mod.rs` and `structure.rs`. So on this title the two PRs each unblock the same set from different sides; either one is enough to get every pixel/vertex/mesh shader translated. What this PR does not change: the world is still black (6 black-frame warnings, ~1 fps, 150 draws/frame) and the run still loses the device at frame 1143 with the same `page fault ... inside freed [texture ...]` signature that every `main` run shows. So it is not a stability fix, only a translation one. Note on method: my first run of this PR stayed in the front end and measured nothing (16 draws/frame, 30 fps); the numbers above are from a retry with later key timings that reached the world. Not tested: `cargo test`, clippy, other GPUs. No game data: counts, shader hashes, driver version and error strings only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.
qntic commented 2026-11-24 12:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qntic on 2026-11-24T11:13:18Z.


tested on rx 6600 xt. the select pattern after vcc_hi = 0 silently produces incorrect values in 16 out of 64 lanes on main. with this pr the unsafe translation is correctly rejected instead of producing incorrect results.

hardware tests:
https://github.com/qntic/VIctory/tree/hwtest/compute-lanes

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129815330 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#issuecomment-7129815330). Originally posted by [qntic](https://github.com/qntic) on 2026-11-24T11:13:18Z. --- tested on rx 6600 xt. the select pattern after vcc_hi = 0 silently produces incorrect values in 16 out of 64 lanes on main. with this pr the unsafe translation is correctly rejected instead of producing incorrect results. hardware tests: https://github.com/qntic/VIctory/tree/hwtest/compute-lanes
rpmaster2 commented 2026-11-24 12:04:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rpmaster2 on 2026-11-24T11:43:30Z.


Correction to my earlier comment: offline translation shows no change from this PR, so the in-game difference I reported is not evidence for it and I withdraw that claim.

victory translate --pipelines over the whole dump (26,148 programs, same input per build):

build vertex+pixel compute mesh
main @58fed37 12,236 of 14,013 1,440 of 2,581 8,163 of 8,506
main + this PR 12,236 1,440 8,163

The in-game "440 -> 33 refused" I posted came from runs that covered different amounts of world content (a main run reached 2,220 draws/frame at frame 1500, this PR's run 152 draws/frame at frame 1171), so fewer shaders were requested and fewer failures appear. Not something this PR can take credit for.

No regression either: the same programs emit, and the one world run I have ended the same way as main (device removed at frame 1143, page fault inside a freed texture), so on this host it changes neither coverage nor stability.

If your intent is the wave64 mask pairs, the remaining mask refusals offline are a lane mask holding lanes elsewhere read as data (285 programs) and a lane mask read as data (266), plus 22 a lane-mask join of an untracked mask - so there is still room, but this title's failing set is dominated by other reasons.

No game data: counts, driver version and error strings only.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7130465313 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#issuecomment-7130465313). Originally posted by [rpmaster2](https://github.com/rpmaster2) on 2026-11-24T11:43:30Z. --- Correction to my earlier comment: offline translation shows **no change** from this PR, so the in-game difference I reported is not evidence for it and I withdraw that claim. `victory translate --pipelines` over the whole dump (26,148 programs, same input per build): | build | vertex+pixel | compute | mesh | | --- | --- | --- | --- | | `main` @58fed37 | 12,236 of 14,013 | 1,440 of 2,581 | 8,163 of 8,506 | | `main` + this PR | 12,236 | 1,440 | 8,163 | The in-game "440 -> 33 refused" I posted came from runs that covered different amounts of world content (a `main` run reached 2,220 draws/frame at frame 1500, this PR's run 152 draws/frame at frame 1171), so fewer shaders were requested and fewer failures appear. Not something this PR can take credit for. No regression either: the same programs emit, and the one world run I have ended the same way as `main` (device removed at frame 1143, page fault inside a freed texture), so on this host it changes neither coverage nor stability. If your intent is the wave64 mask pairs, the remaining mask refusals offline are `a lane mask holding lanes elsewhere read as data` (285 programs) and `a lane mask read as data` (266), plus 22 `a lane-mask join of an untracked mask` - so there is still room, but this title's failing set is dominated by other reasons. No game data: counts, driver version and error strings only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.
molodayamama commented 2026-11-24 14:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by molodayamama on 2026-11-24T14:03:25Z.


Independent Windows check of d92ebe9c9dc9eda57fdf54681a2b21f4058a4265 (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).

  • cargo test -p victory-shader --locked --lib a_mask_whose_high_dword_is_rewritten -- --test-threads=1 --nocapture: 2 passed.
  • cargo test -p victory-shader --locked --lib a_mask_joined_over_a_back_edge -- --test-threads=1 --nocapture: 1 passed.
  • cargo test -p victory-shader --locked --lib a_carry_in_from_a_divergent_join -- --test-threads=1 --nocapture: 1 passed.

The shader fixtures checked that rewriting a high dword invalidates the corresponding mask through a later use and across a loop back edge. The divergent carry-in refusal also passed.

Only source-built synthetic fixtures were used. AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7133767211 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#issuecomment-7133767211). Originally posted by [molodayamama](https://github.com/molodayamama) on 2026-11-24T14:03:25Z. --- Independent Windows check of `d92ebe9c9dc9eda57fdf54681a2b21f4058a4265` (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64). - `cargo test -p victory-shader --locked --lib a_mask_whose_high_dword_is_rewritten -- --test-threads=1 --nocapture`: 2 passed. - `cargo test -p victory-shader --locked --lib a_mask_joined_over_a_back_edge -- --test-threads=1 --nocapture`: 1 passed. - `cargo test -p victory-shader --locked --lib a_carry_in_from_a_divergent_join -- --test-threads=1 --nocapture`: 1 passed. The shader fixtures checked that rewriting a high dword invalidates the corresponding mask through a later use and across a loop back edge. The divergent carry-in refusal also passed. Only source-built synthetic fixtures were used. AI-assisted verification.
Marvisak commented 2026-11-25 02:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:24:23Z.


Automated triage for the maintainers.

Needs work. The fix is worth having, but it needs a rebase for a new export on main.

What it does: in structure.rs (Lanes::finish), a low dword seen with two high dwords is dropped from masks, highs and active. Carry-in pairs (step) and back-edge pairs (join) are also recorded. Lowering then refuses a wave64 mask whose high dword was rewritten alone (s_mov_b32 vcc_hi/exec_hi) instead of reading lanes 32-63 from the stale pair. This only adds refusals. The thread backs it with an RX 6600 XT hardware run showing the silent miscompile on main, and an offline corpus run with no coverage change.

Blocking: since this branch was cut, main merged #1221, which adds Structured::other. It is exported by low dword in finish and is now read when lowering a v_cndmask_b32. Your description already names this case ("an others export keyed by (lo, _) needs the same split filter"). It still merges cleanly, but self.other is not filtered there, so a split low dword can still reach the select through other. Please rebase, apply the split filter to other, and confirm a_mask_whose_high_dword_is_rewritten_is_refused still passes on the result.

CI: no checks have run on this head.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149511889 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/660#issuecomment-7149511889). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:24:23Z. --- <!-- victory-triage v1 head=19b02ece91ef5a85748408de0d84a24dace71b49 verdict=needs-work at=2026-11-25T01:24:21Z --> Automated triage for the maintainers. **Needs work.** The fix is worth having, but it needs a rebase for a new export on `main`. What it does: in `structure.rs` (`Lanes::finish`), a low dword seen with two high dwords is dropped from `masks`, `highs` and `active`. Carry-in pairs (`step`) and back-edge pairs (`join`) are also recorded. Lowering then refuses a wave64 mask whose high dword was rewritten alone (`s_mov_b32 vcc_hi/exec_hi`) instead of reading lanes 32-63 from the stale pair. This only adds refusals. The thread backs it with an RX 6600 XT hardware run showing the silent miscompile on `main`, and an offline corpus run with no coverage change. Blocking: since this branch was cut, `main` merged #1221, which adds `Structured::other`. It is exported by low dword in `finish` and is now read when lowering a `v_cndmask_b32`. Your description already names this case ("an `others` export keyed by `(lo, _)` needs the same split filter"). It still merges cleanly, but `self.other` is not filtered there, so a split low dword can still reach the select through `other`. Please rebase, apply the `split` filter to `other`, and confirm `a_mask_whose_high_dword_is_rewritten_is_refused` still passes on the result. CI: no checks have run on this head. --- _Generated by [Claude Code](https://claude.ai/code)_
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/660:upstream-pr/660'
git switch 'upstream-pr/660'

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/660'
git switch 'upstream-pr/660'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/660'
git switch 'upstream-pr/660'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/660'
git switch 'main'
git merge --squash 'upstream-pr/660'
git switch 'main'
git merge --ff-only 'upstream-pr/660'
git switch 'main'
git merge 'upstream-pr/660'
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
Marvisak/VIctory!660
No description provided.