Shaders: read a VALU opcode's name without a heap vector #1834

Open
github-bot wants to merge 1 commit from github-bot/gh-1834 into main AGit
Owner

@⁠slatefield on GitHub · 2026-11-24 23:08 UTC · original
slatefield:shader/valu-name-no-alloc → main · +17 −6 · 1 files · 1 commits · open

valu_dwords did name.split('_').collect::<Vec<&str>>() for every VALU instruction just to check parts.len() == 4 && parts[1] == "cvt", and fields() runs once per instruction.

now it peeks at the five tokens in place and only takes the last one with rsplit in the fallback arm. no alloc, same results.

measured on the isolated fields() loop: -8.9% at 12.1k instructions, -9.3% at 24.2k. stacked with the members() one, ir::build -5.0%. 118 lib tests pass.

outside what #1623/#1180/#1757 change.

**@⁠slatefield** on GitHub · 2026-11-24 23:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1834) `slatefield:shader/valu-name-no-alloc` → `main` · +17 −6 · 1 files · 1 commits · open `valu_dwords` did `name.split('_').collect::<Vec<&str>>()` for every VALU instruction just to check `parts.len() == 4 && parts[1] == "cvt"`, and `fields()` runs once per instruction. now it peeks at the five tokens in place and only takes the last one with `rsplit` in the fallback arm. no alloc, same results. measured on the isolated `fields()` loop: -8.9% at 12.1k instructions, -9.3% at 24.2k. stacked with the members() one, ir::build -5.0%. 118 lib tests pass. outside what #1623/#1180/#1757 change.
valu_dwords split the name into a Vec of pieces for every VALU
instruction only to ask whether it is v_cvt_<dst>_<src>, and fields()
runs once per instruction. Peek at the five pieces in place (and take
the last one with rsplit for the fallback) instead. The fields walk is
8.9-9.3% faster on 12k-24k instruction programs; with the members()
change the IR build is 5.0% faster.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:46:12 +00:00
Author
Owner

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

NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, 3f20c55 (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.

**@⁠upipibi** on GitHub · 2026-11-24 23:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7147192532) NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, `3f20c55` (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.
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 23:41 UTC · original

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: reading a VALU opcode's name without a heap allocation is exercised by existing coverage and nothing regresses.

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

**@⁠dcastell1** on GitHub · 2026-11-24 23:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7147696265) 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: reading a VALU opcode's name without a heap allocation is exercised by existing coverage and nothing regresses. Tree restored afterwards; no game data. AI-assisted (opencode).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:32 UTC · original

Automated triage for the maintainers.

Merge candidate. valu_dwords in crates/victory-shader/src/gfx10/fields.rs used to collect name.split('_') into a Vec for every VALU instruction decoded. It now matches the first five pieces of the iterator directly. I checked that it is equivalent. (Some(_), Some("cvt"), Some(dst), Some(src), None) is exactly the old parts.len() == 4 && parts[1] == "cvt". The fallback rsplit('_').next() is the old parts.last(), and the explicit arms above are unchanged. This removes a heap allocation from the decode path, with no behaviour change.

As with #1833, a translation-time measurement would show the saving, but the change is safe either way.

CI: no check runs on the head commit.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7154904141) <!-- victory-triage v1 head=3f20c559beb59ca93f7f8bda7b0bb6cc127d1297 verdict=merge-candidate at=2026-11-25T06:39:30Z --> Automated triage for the maintainers. **Merge candidate.** `valu_dwords` in `crates/victory-shader/src/gfx10/fields.rs` used to collect `name.split('_')` into a `Vec` for every VALU instruction decoded. It now matches the first five pieces of the iterator directly. I checked that it is equivalent. `(Some(_), Some("cvt"), Some(dst), Some(src), None)` is exactly the old `parts.len() == 4 && parts[1] == "cvt"`. The fallback `rsplit('_').next()` is the old `parts.last()`, and the explicit arms above are unchanged. This removes a heap allocation from the decode path, with no behaviour change. As with #1833, a translation-time measurement would show the saving, but the change is safe either way. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 12:19 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 3f20c559 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).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 12:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7162215972) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 3f20c559 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).
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/1834/head:github-bot/gh-1834'
git switch 'github-bot/gh-1834'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1834'
git switch 'github-bot/gh-1834'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1834'
git switch 'github-bot/gh-1834'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1834'
git switch 'main'
git merge --squash 'github-bot/gh-1834'
git switch 'main'
git merge --ff-only 'github-bot/gh-1834'
git switch 'main'
git merge 'github-bot/gh-1834'
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!1834
No description provided.