Shaders: walk a live set's registers a bit at a time #1831

Merged
slatefield merged 1 commit from upstream-pr/1833 into main 2026-11-25 21:51:49 +00:00
slatefield commented 2026-11-24 23:08:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slatefield on 2026-11-24T23:08:48Z.


members() bit-tests all 385 register slots and returns the few that are live, twice per block. a 1651 block shader = 1.27M tests per translation for nothing.

now it walks the 7 u64 words by their lowest set bit (trailing_zeros, bits &= bits - 1), same register order out. the set only ever gets bits from insert(reg), so nothing past 385 can be set.

measured (min of 5, alternating binaries, taskset): ir::build -4.5% on 12.1k and 24.2k instruction synthetic GFX10 programs, range::build -4.1%. 118 lib tests pass.

not #369 (CFG traversal) or #1757 (operand arena).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6593251104 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1833). Originally posted by [slatefield](https://github.com/slatefield) on 2026-11-24T23:08:48Z. --- `members()` bit-tests all 385 register slots and returns the few that are live, twice per block. a 1651 block shader = 1.27M tests per translation for nothing. now it walks the 7 u64 words by their lowest set bit (`trailing_zeros`, `bits &= bits - 1`), same register order out. the set only ever gets bits from `insert(reg)`, so nothing past 385 can be set. measured (min of 5, alternating binaries, taskset): ir::build -4.5% on 12.1k and 24.2k instruction synthetic GFX10 programs, range::build -4.1%. 118 lib tests pass. not #369 (CFG traversal) or #1757 (operand arena).
catminou4 commented 2026-11-25 00:06:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:52:14Z.

Review: APPROVED


Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows.

Live set registers walked a bit at a time: replaces per-register iteration with bit-scan liveness — perf refactor in the liveness analysis.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049332973 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1833#pullrequestreview-6049332973). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:52:14Z. **Review:** APPROVED --- Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (70564ae), cargo test -p victory-shader --locked → 118 passed, 0 failed. GPU execution tests are #[cfg(all(test, windows))] and run only on Windows. Live set registers walked a bit at a time: replaces per-register iteration with bit-scan liveness — perf refactor in the liveness analysis.
upipibi commented 2026-11-25 00:06:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T23:15:22Z.


NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, f52b800 (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, so there are no new failures.

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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147192092 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7147192092). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T23:15:22Z. --- NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, `f52b800` (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`, so there are no new failures. AI-assisted (Claude Code). Synthetic tests only.
dcastell1 commented 2026-11-25 00:06:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T23:42:01Z.


Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace
342 passed; 0 failed; 6 ignored   (exit 0)

Same count as the baseline: walking a live set's registers a bit at a time changes no verdict here.

Tree restored afterwards; no game data. AI-assisted (opencode).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147696871 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7147696871). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T23:42:01Z. --- Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace 342 passed; 0 failed; 6 ignored (exit 0) ``` Same count as the baseline: walking a live set's registers a bit at a time changes no verdict here. Tree restored afterwards; no game data. AI-assisted (opencode).
Marvisak commented 2026-11-25 07:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:32:51Z.


Automated triage for the maintainers.

Merge candidate. members in crates/victory-shader/src/ir.rs walked all 385 register indices and tested a bit for each. It now visits only the set bits, word by word, with trailing_zeros. I checked that it is equivalent. The order is the same, ascending index, which the callers rely on ("in Reg order"). RegSet is [u64; REGS.div_ceil(64)], and bits past REGS are never set, so the extra 63 bit positions in the last word yield nothing. The change is small and local, on a path the liveness analysis runs for every instruction.

No measurement is given. A before/after time for translate over a pack would show how much it saves.

CI: no check runs on the head commit.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154903184 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7154903184). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:32:51Z. --- <!-- victory-triage v1 head=f52b80061522e913e69e61d9092704bed3d1325f verdict=merge-candidate at=2026-11-25T06:39:00Z --> Automated triage for the maintainers. **Merge candidate.** `members` in `crates/victory-shader/src/ir.rs` walked all 385 register indices and tested a bit for each. It now visits only the set bits, word by word, with `trailing_zeros`. I checked that it is equivalent. The order is the same, ascending index, which the callers rely on ("in `Reg` order"). `RegSet` is `[u64; REGS.div_ceil(64)]`, and bits past `REGS` are never set, so the extra 63 bit positions in the last word yield nothing. The change is small and local, on a path the liveness analysis runs for every instruction. No measurement is given. A before/after time for `translate` over a pack would show how much it saves. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 13:02:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T12:19:22Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head f52b8006 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162217473 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7162217473). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T12:19:22Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head f52b8006 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 22:03:11 +00:00
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!1831
No description provided.