Extract scalar and vector ALU lowering from lower.rs #84

Closed
github-bot wants to merge 1 commit from github-bot/gh-84 into main AGit
Owner

@⁠feanorsun on GitHub · 2026-11-25 13:39 UTC · original
feanorsun:refactor/shader-lower-alu → main · +3892 −3880 · 2 files · 1 commits · closed without merging

Move scalar and vector ALU lowering into emit/lower/alu.rs. The parent dispatches through sop and valu. All 52 moved method bodies match the original byte for byte.

This resolves the file-size failure listed under Known problems in the README. The split reduces lower.rs from 630,652 to 453,035 bytes. The new module is 177,971 bytes. Both fit under the existing 524,288-byte limit.

Verification

  • cargo xtask policy passed for all 185 files.
  • cargo check --locked -p victory-shader --all-targets passed with the existing int_value dead-code warning.
  • cargo test --locked -p victory-shader --lib emit::lower:: passed all 44 tests before and after the split.
  • cargo test --locked -p victory-shader --lib emit::opcode_audit::refused_opcodes -- --exact passed.
  • cargo test --locked -p xtask passed all 4 tests, including repository_passes_policy.

Verified on Windows with Rust 1.98.1 (x86_64-pc-windows-gnu). No game was launched and no GPU or D3D12 device tests were run.

**@⁠feanorsun** on GitHub · 2026-11-25 13:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/84) `feanorsun:refactor/shader-lower-alu` → `main` · +3892 −3880 · 2 files · 1 commits · closed without merging Move scalar and vector ALU lowering into `emit/lower/alu.rs`. The parent dispatches through `sop` and `valu`. All 52 moved method bodies match the original byte for byte. This resolves the file-size failure listed under **Known problems** in the README. The split reduces `lower.rs` from 630,652 to 453,035 bytes. The new module is 177,971 bytes. Both fit under the existing 524,288-byte limit. ## Verification - `cargo xtask policy` passed for all 185 files. - `cargo check --locked -p victory-shader --all-targets` passed with the existing `int_value` dead-code warning. - `cargo test --locked -p victory-shader --lib emit::lower::` passed all 44 tests before and after the split. - `cargo test --locked -p victory-shader --lib emit::opcode_audit::refused_opcodes -- --exact` passed. - `cargo test --locked -p xtask` passed all 4 tests, including `repository_passes_policy`. Verified on Windows with Rust 1.98.1 (`x86_64-pc-windows-gnu`). No game was launched and no GPU or D3D12 device tests were run.
Move the ALU instruction handlers and their private helpers into emit/lower/alu.rs so both source files fit the repository size limit.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:16 +00:00
Author
Owner

@⁠Adika713 on GitHub · 2026-11-25 15:36 UTC · original

Verified on AMD Radeon RX 6950 XT, Ryzen 5 3600, 32 GB RAM, Windows 11, Rust 1.98.1 / Cargo 1.98.1. No game data, no GPU device tests.

I used clean detached worktrees and an isolated CARGO_TARGET_DIR per tree. A clean worktree matters here: the policy test in my main checkout also sees two untracked local .log files, which are not part of this PR comparison.

Before, at upstream/main 01aadd193d57e71fb4d57810eb2fdd1bc95c950b:

cargo test -p xtask policy::tests::repository_passes_policy -- --exact --nocapture
cargo test -p xtask
  • policy test: exit 101 — test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 3 filtered out.
  • violation: POLICY: crates/victory-shader/src/emit/lower.rs: 630652 bytes exceeds the 524288-byte limit.
  • full xtask suite: exit 101 — test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out.

After, at this PR's head b5a4046:

cargo test --manifest-path F:\VIctory-Belobug-AMD\_agent_tmp\policy-84\Cargo.toml -p xtask policy::tests::repository_passes_policy -- --exact --nocapture
cargo test --manifest-path F:\VIctory-Belobug-AMD\_agent_tmp\policy-84\Cargo.toml -p xtask
  • policy test: exit 0 — test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out.
  • full xtask suite: exit 0 — test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out.
  • File sizes in this tree: lower.rs 453,035 bytes and lower/alu.rs 177,971 bytes, both under the limit.

Overlap: PR #72 head 0771808 also passes both commands (4 passed / 0 failed for xtask), with lower.rs 499,516 bytes and lower/valu.rs 131,464 bytes. I did not write a competing fix.

Not tested: the game or any shader-GPU test; no game files were used.

AI-assisted: OpenCode, model Big Pickle. No game data.

**@⁠Adika713** on GitHub · 2026-11-25 15:36 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/84#issuecomment-7167096362) Verified on AMD Radeon RX 6950 XT, Ryzen 5 3600, 32 GB RAM, Windows 11, Rust 1.98.1 / Cargo 1.98.1. No game data, no GPU device tests. I used clean detached worktrees and an isolated `CARGO_TARGET_DIR` per tree. A clean worktree matters here: the policy test in my main checkout also sees two untracked local `.log` files, which are not part of this PR comparison. Before, at `upstream/main` `01aadd193d57e71fb4d57810eb2fdd1bc95c950b`: ```powershell cargo test -p xtask policy::tests::repository_passes_policy -- --exact --nocapture cargo test -p xtask ``` - policy test: exit 101 — `test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 3 filtered out`. - violation: `POLICY: crates/victory-shader/src/emit/lower.rs: 630652 bytes exceeds the 524288-byte limit`. - full xtask suite: exit 101 — `test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out`. After, at this PR's head `b5a4046`: ```powershell cargo test --manifest-path F:\VIctory-Belobug-AMD\_agent_tmp\policy-84\Cargo.toml -p xtask policy::tests::repository_passes_policy -- --exact --nocapture cargo test --manifest-path F:\VIctory-Belobug-AMD\_agent_tmp\policy-84\Cargo.toml -p xtask ``` - policy test: exit 0 — `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out`. - full xtask suite: exit 0 — `test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out`. - File sizes in this tree: `lower.rs` 453,035 bytes and `lower/alu.rs` 177,971 bytes, both under the limit. Overlap: PR #72 head `0771808` also passes both commands (4 passed / 0 failed for xtask), with `lower.rs` 499,516 bytes and `lower/valu.rs` 131,464 bytes. I did not write a competing fix. Not tested: the game or any shader-GPU test; no game files were used. AI-assisted: OpenCode, model Big Pickle. No game data.
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-25 16:36 UTC · original

Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at b5a4046: cargo test -p victory-shader --lib --locked: 266 passed, 0 failed, 6 ignored, hardware dispatch tests included (main at 01aadd1: 266 passed). Two runs, with #140 applied on top. Without it, parallel victory-shader runs here sometimes crash inside WARP (d3d10warp.dll, STATUS_ACCESS_VIOLATION). main does that too, so it has nothing to do with this PR, but it made the first run of this PR look broken. Workspace tests only; not run in the title.

**@⁠ySKELLETONX** on GitHub · 2026-11-25 16:36 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/84#issuecomment-7168244195) Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at `b5a4046`: `cargo test -p victory-shader --lib --locked`: **266 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). Two runs, with #140 applied on top. Without it, parallel `victory-shader` runs here sometimes crash inside WARP (`d3d10warp.dll`, STATUS_ACCESS_VIOLATION). `main` does that too, so it has nothing to do with this PR, but it made the first run of this PR look broken. Workspace tests only; not run in the title.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:47 UTC · original

Checked against the game's shaders.rpf on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (b5a4046) applied to 01aadd1 and its own target dir. victory translate --validate --list --host-lanes 32-64 with a hash of every emitted program's DXIL (a local, uncommitted patch): all 25,623 emitted programs are byte for byte the same as on 01aadd1, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of 01aadd1 give the same hashes, so the comparison is deterministic. cargo test -p victory-shader --lib -- --test-threads=1: 266 passed, 0 failed, 6 ignored. Not run in the game.

**@⁠adrianmjim** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/84#issuecomment-7170003404) Checked against the game's `shaders.rpf` on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (`b5a4046`) applied to `01aadd1` and its own target dir. `victory translate --validate --list --host-lanes 32-64` with a hash of every emitted program's DXIL (a local, uncommitted patch): **all 25,623 emitted programs are byte for byte the same as on `01aadd1`**, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of `01aadd1` give the same hashes, so the comparison is deterministic. `cargo test -p victory-shader --lib -- --test-threads=1`: 266 passed, 0 failed, 6 ignored. Not run in the game.
github-bot closed this pull request 2026-11-26 12:52:01 +00:00
Author
Owner

@⁠feanorsun on GitHub · 2026-11-26 12:48 UTC · original

Closing this in favor of #72, which was opened first and brings lower.rs under the size limit with a smaller refactor. Thanks to everyone who tested both approaches.

**@⁠feanorsun** on GitHub · 2026-11-26 12:48 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/84#issuecomment-7192487528) Closing this in favor of #72, which was opened first and brings `lower.rs` under the size limit with a smaller refactor. Thanks to everyone who tested both approaches.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.