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

Open
slatefield wants to merge 1 commit from upstream-pr/1834 into main
slatefield commented 2026-11-24 23:08:50 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5481869778 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834). Originally posted by [slatefield](https://github.com/slatefield) on 2026-11-24T23:08:50Z. --- `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.
catminou4 commented 2026-11-24 23:52:14 +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.

VALU opcode name read without a heap vector: removes an allocation from opcode-name lookup — small perf fix.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049333146 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#pullrequestreview-6049333146). 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. VALU opcode name read without a heap vector: removes an allocation from opcode-name lookup — small perf fix.
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:23Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147192532 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7147192532). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T23:15:23Z. --- 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.
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:41:59Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147696265 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7147696265). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T23:41:59Z. --- 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).
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:54Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154904141 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7154904141). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:32:54Z. --- <!-- 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)_
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:18Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162215972 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#issuecomment-7162215972). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T12:19:18Z. --- ### 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).
fuzeofficlal commented 2026-11-26 19:29:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:29:50Z.

Review: APPROVED


Verified locally merged onto origin/main (63bcca43, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test --locked -p victory-shader --lib gfx10:: — 16 passed, 0 failed
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features) — 0 warnings
  • rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/fields.rs — clean
  • cargo xtask policy — ok (191 files ok)

Review notes

  • Verified valu_dwords across all 465 VALU opcodes in gfx10/opcodes.rs as well as >5-segment and malformed edge inputs: matching 4-segment _cvt_ via 5 .next() calls and falling back to name.rsplit('_').next() reproduces the prior Vec<&str> behavior without heap allocation.
<!-- greyfinch-sync:Marvisak/VIctory:review:6079553239 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#pullrequestreview-6079553239). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:29:50Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`63bcca43`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test --locked -p victory-shader --lib gfx10::` — **16 passed, 0 failed** - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings - `rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/fields.rs` — clean - `cargo xtask policy` — ok (`191 files ok`) ### Review notes - Verified `valu_dwords` across all 465 VALU opcodes in `gfx10/opcodes.rs` as well as >5-segment and malformed edge inputs: matching 4-segment `_cvt_` via 5 `.next()` calls and falling back to `name.rsplit('_').next()` reproduces the prior `Vec<&str>` behavior without heap allocation.
Dukestar69 commented 2026-11-27 00:08:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T00:08:59Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Reading VALU opcode names without allocating a temporary heap vector is clean and passes all gfx10::fields tests.
  • cargo test -p victory-shader --lib gfx10::fields:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081863369 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1834#pullrequestreview-6081863369). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-27T00:08:59Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Reading VALU opcode names without allocating a temporary heap vector is clean and passes all `gfx10::fields` tests. - `cargo test -p victory-shader --lib gfx10::fields:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/1834:upstream-pr/1834'
git switch 'upstream-pr/1834'

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