Shader: propagate float values across selects/phis and cache bools across dominators #1397

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

@⁠wbkepler on GitHub · 2026-11-24 17:43 UTC · original
wbkepler:shader/dxil-float-bool-prop → main · +737 −137 · 3 files · 1 commits · open

Summary

Rebased cleanly onto upstream/main (ffe310e):

  • Adds Val::F32 in emit/lower.rs and infer_float_phis so float ALU results, float inputs/interpolations, non-d16 image/typed-buffer loads, guarded float writes, float v_mov_b32/v_cndmask_b32, and float-only SSA phis stay native f32 without eager f32<->i32 bitcast roundtrips.
  • Folds identity, constant i32<->f32/undef, and bitcast(bitcast(x)) roundtrips directly in bitcode::Module::cast, and constructs f32 constants directly in Lower::fsrc.
  • Tracks DXIL block immediate dominators (dxil_idom) from ir::idoms, guarded splits, and critical edges so Lower::boolean and Lower::atom reuse dominating i1 values without leaking across non-dominating sibling blocks.
  • Adds 3 unit and hardware/WARP execution tests verifying zero-bitcast float phi/select lowering, dominator bool caching, and sibling non-dominating branch execution parity.

Verification

  • cargo clippy -p victory-shader --all-targets — passed
  • cargo test -p victory-shader — passed
  • cargo xtask policy — passed
**@⁠wbkepler** on GitHub · 2026-11-24 17:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1397) `wbkepler:shader/dxil-float-bool-prop` → `main` · +737 −137 · 3 files · 1 commits · open ## Summary Rebased cleanly onto `upstream/main` (`ffe310e`): - Adds `Val::F32` in `emit/lower.rs` and `infer_float_phis` so float ALU results, float inputs/interpolations, non-`d16` image/typed-buffer loads, guarded float writes, float `v_mov_b32`/`v_cndmask_b32`, and float-only SSA phis stay native `f32` without eager `f32<->i32` bitcast roundtrips. - Folds identity, constant `i32<->f32`/`undef`, and `bitcast(bitcast(x))` roundtrips directly in `bitcode::Module::cast`, and constructs `f32` constants directly in `Lower::fsrc`. - Tracks DXIL block immediate dominators (`dxil_idom`) from `ir::idoms`, guarded splits, and critical edges so `Lower::boolean` and `Lower::atom` reuse dominating `i1` values without leaking across non-dominating sibling blocks. - Adds 3 unit and hardware/WARP execution tests verifying zero-bitcast float phi/select lowering, dominator bool caching, and sibling non-dominating branch execution parity. ## Verification - `cargo clippy -p victory-shader --all-targets` — passed - `cargo test -p victory-shader` — passed - `cargo xtask policy` — passed
- Add Val::F32 in emit/lower.rs and infer_float_phis so float ALU results, float inputs/interpolations, non-d16 image/typed-buffer loads, guarded float writes, float v_mov_b32/v_cndmask_b32, and float-only SSA phis stay native f32 without eager f32<->i32 bitcast roundtrips.

- Fold identity, constant i32<->f32/undef, and bitcast(bitcast(x)) roundtrips directly in bitcode::Module::cast, and construct f32 constants directly in Lower::fsrc.

- Track DXIL block immediate dominators (dxil_idom) from ir::idoms, guarded splits, and critical edges so Lower::boolean and Lower::atom reuse dominating i1 values without leaking across non-dominating sibling blocks.

- Add 3 unit and hardware/WARP execution tests verifying zero-bitcast float phi/select lowering, dominator bool caching, and sibling non-dominating branch execution parity.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:23 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head a78fc2c onto main ffe310e (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: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 123, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

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

**@⁠sinan-cmyk** on GitHub · 2026-11-24 19:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1397#issuecomment-7142664786) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head a78fc2c onto `main` ffe310e (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: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 123, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

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

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1397#issuecomment-7149529996) <!-- victory-triage v1 head=a78fc2cb8f3a66de90528a2c49df59bb8a16bc4f verdict=needs-rebase at=2026-11-25T01:25:23Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1397/head:github-bot/gh-1397'
git switch 'github-bot/gh-1397'

Merge

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