Shaders: reuse decoded instructions across range rebuilds #3357

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

@⁠borosf on GitHub · 2026-11-26 20:24 UTC · original
borosf:vibe/shader-decode-once-4b7f → main · +100 −9 · 2 files · 1 commits · open

Summary

  • Decode a program once in range::build and reuse its decoded instructions across M0-bound induction rebuilds.
  • Keep the existing move-only path for programs without v_movrel*, avoiding clone overhead in the common case.
  • Add a synthetic M0-bounded v_movreld_b32 loop regression. The cached path accepts an already-decoded stream; the legacy reference takes more than one decode/build round, and the test compares their IR and structured output.

Claim: #1633

Census timing

Warmed binaries, wall-clock median of five on this machine (CARGO_TARGET_DIR=C:\\Users\\bkora\\VIctory\\target):

cargo test --release -p victory-shader --lib --locked -- --exact emit::census_tests::every_opcode_translate_or_refuse_never_panic
version five runs (s) median
main 0.316, 0.293, 0.297, 0.290, 0.287 0.293 s
this PR 0.300, 0.368, 0.308, 0.317, 0.303 0.308 s

This all-opcode synthetic census completes its test body in 0.03–0.04 s, so Cargo/process startup dominates these wall-clock samples; it does not include a loop-heavy title shader. The change specifically removes repeated decode work for M0-bounded relative-move loops.

Verification

cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=1

Result: 301 passed, 2 failed, 3 ignored. The two failures match pristine-main Intel Arc B580 baseline failures:

  • emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros
  • emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products
cargo test -p victory-shader --lib --locked -- --exact range::tests::an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure --test-threads=1
cargo clippy -p victory-shader --all-targets --locked -- -D warnings
cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings
cargo xtask policy

All passed. cargo xtask policy: 191 files OK.

Formatting was checked without cargo fmt:

rustfmt --config-path rustfmt.toml --edition 2024 --check crates/victory-shader/src/ir.rs
rustfmt --config-path rustfmt.toml --edition 2024 --check crates/victory-shader/src/range.rs

ir.rs: 2/2 rustfmt diff hunks versus origin/main; range.rs: 0/0.

Synthetic tests only; no game data used.

**@⁠borosf** on GitHub · 2026-11-26 20:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/3357) `borosf:vibe/shader-decode-once-4b7f` → `main` · +100 −9 · 2 files · 1 commits · open ## Summary - Decode a program once in `range::build` and reuse its decoded instructions across M0-bound induction rebuilds. - Keep the existing move-only path for programs without `v_movrel*`, avoiding clone overhead in the common case. - Add a synthetic M0-bounded `v_movreld_b32` loop regression. The cached path accepts an already-decoded stream; the legacy reference takes more than one decode/build round, and the test compares their IR and structured output. Claim: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 ## Census timing Warmed binaries, wall-clock median of five on this machine (`CARGO_TARGET_DIR=C:\\Users\\bkora\\VIctory\\target`): ```powershell cargo test --release -p victory-shader --lib --locked -- --exact emit::census_tests::every_opcode_translate_or_refuse_never_panic ``` | version | five runs (s) | median | | --- | --- | --- | | `main` | 0.316, 0.293, 0.297, 0.290, 0.287 | 0.293 s | | this PR | 0.300, 0.368, 0.308, 0.317, 0.303 | 0.308 s | This all-opcode synthetic census completes its test body in 0.03–0.04 s, so Cargo/process startup dominates these wall-clock samples; it does not include a loop-heavy title shader. The change specifically removes repeated decode work for M0-bounded relative-move loops. ## Verification ```powershell cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=1 ``` Result: 301 passed, 2 failed, 3 ignored. The two failures match pristine-main Intel Arc B580 baseline failures: - `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` - `emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products` ```powershell cargo test -p victory-shader --lib --locked -- --exact range::tests::an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure --test-threads=1 cargo clippy -p victory-shader --all-targets --locked -- -D warnings cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings cargo xtask policy ``` All passed. `cargo xtask policy`: 191 files OK. Formatting was checked without `cargo fmt`: ```powershell rustfmt --config-path rustfmt.toml --edition 2024 --check crates/victory-shader/src/ir.rs rustfmt --config-path rustfmt.toml --edition 2024 --check crates/victory-shader/src/range.rs ``` `ir.rs`: 2/2 rustfmt diff hunks versus `origin/main`; `range.rs`: 0/0. Synthetic tests only; no game data used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:26:20 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 20:29 UTC · original · approved these changes

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

  • Reusing decoded instructions across range-guided IR rebuilds avoids redundant GFX10 decoding while keeping identical IR and structure output.
  • cargo test -p victory-shader --lib ir:: -- --test-threads=1: 9 passed, 0 failed.
  • cargo test -p victory-shader --lib range:: -- --test-threads=1: 4 passed, 0 failed (including an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure).
  • 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).

**@⁠Dukestar69** on GitHub · 2026-11-26 20:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3357#pullrequestreview-6080171989) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Reusing decoded instructions across range-guided IR rebuilds avoids redundant GFX10 decoding while keeping identical IR and structure output. - `cargo test -p victory-shader --lib ir:: -- --test-threads=1`: 9 passed, 0 failed. - `cargo test -p victory-shader --lib range:: -- --test-threads=1`: 4 passed, 0 failed (including `an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure`). - `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).
Author
Owner

@⁠borosf on GitHub · 2026-11-26 20:38 UTC · original

Independent local verification at head f389683 on Windows 11 x64, Intel Arc B580 12 GB:

cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=1
cargo clippy -p victory-shader --all-targets --locked -- -D warnings
cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings
cargo test --release -p victory-shader --lib --locked -- --exact emit::census_tests::every_opcode_translate_or_refuse_never_panic   (5 runs, PR vs main)
  • Tests: 301 passed / 2 failed / 3 ignored — the 2 are the known B580 baseline (emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products), pristine main fails them too. New regression test range::tests::an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure passes.
  • Clippy: exit 0 both feature sets with -D warnings.
  • Census, 5 release runs each: PR 368/354/354/342/359 ms (mean 355.4) vs main 367/354/356/350/347 ms (mean 354.8) — delta is noise; the inner test body is ~0.03 s both, so process startup dominates. No regression; the decode-once win lands on loop-heavy title shaders the all-opcode census doesn't contain, as the PR body says.
  • Diff read: caching of the decoded stream only affects the M0-bound rebuild path in range.rs; the non-movrel path is untouched.

Synthetic tests only; no game data used.

**@⁠borosf** on GitHub · 2026-11-26 20:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3357#issuecomment-7202919030) Independent local verification at head `f389683` on Windows 11 x64, Intel Arc B580 12 GB: ``` cargo test -p victory-shader --lib --locked --no-fail-fast -- --test-threads=1 cargo clippy -p victory-shader --all-targets --locked -- -D warnings cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings cargo test --release -p victory-shader --lib --locked -- --exact emit::census_tests::every_opcode_translate_or_refuse_never_panic (5 runs, PR vs main) ``` - Tests: 301 passed / 2 failed / 3 ignored — the 2 are the known B580 baseline (`emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products`), pristine main fails them too. New regression test `range::tests::an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure` passes. - Clippy: exit 0 both feature sets with `-D warnings`. - Census, 5 release runs each: PR 368/354/354/342/359 ms (mean 355.4) vs main 367/354/356/350/347 ms (mean 354.8) — delta is noise; the inner test body is ~0.03 s both, so process startup dominates. No regression; the decode-once win lands on loop-heavy title shaders the all-opcode census doesn't contain, as the PR body says. - Diff read: caching of the decoded stream only affects the M0-bound rebuild path in `range.rs`; the non-movrel path is untouched. Synthetic tests only; no game data used.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 21:02 UTC · original · approved these changes

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

  • Decode reuse correctness: Caching the decoded instruction stream in range::build and passing it through ir::build_bounded_decoded preserves identical IR and structured control flow across M0-bounded rebuilds, while leaving non-v_movrel* programs on the existing move-only path without extra cloning.
  • Minor non-blocking test note (P3): In range::tests::an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure (crates/victory-shader/src/range.rs), legacy_decodes counts the legacy reference passes in the test closure rather than directly instrumenting range::build.
  • Checks:
    • cargo test --locked -p victory-shader --lib -- --test-threads=1 ir:: range:: structure:: resource::: 61 passed, 0 failed, 1 ignored (including an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure).
    • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean.
    • cargo xtask policy: 191 files ok; rustfmt --edition 2024: clean on changed hunks.

Synthetic tests only; no game data used.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 21:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3357#pullrequestreview-6080445745) · **approved these changes** LGTM — verified against `origin/main` (`63bcca43`) on Windows x64. - **Decode reuse correctness**: Caching the decoded instruction stream in `range::build` and passing it through `ir::build_bounded_decoded` preserves identical IR and structured control flow across M0-bounded rebuilds, while leaving non-`v_movrel*` programs on the existing move-only path without extra cloning. - **Minor non-blocking test note (P3)**: In `range::tests::an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure` (`crates/victory-shader/src/range.rs`), `legacy_decodes` counts the legacy reference passes in the test closure rather than directly instrumenting `range::build`. - **Checks**: - `cargo test --locked -p victory-shader --lib -- --test-threads=1 ir:: range:: structure:: resource::`: 61 passed, 0 failed, 1 ignored (including `an_m0_bounded_loop_decodes_once_and_keeps_its_ir_and_structure`). - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean. - `cargo xtask policy`: 191 files ok; `rustfmt --edition 2024`: clean on changed hunks. Synthetic tests only; no game data used.
This pull request can be merged automatically.
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/3357/head:github-bot/gh-3357'
git switch 'github-bot/gh-3357'

Merge

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