Shaders: fold selects with constant conditions #3747
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3747"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:38:01Z.
When a DXIL select already has a known Boolean condition, use the chosen operand directly. This uses the same integer-constant interpretation as the control-flow builder. The existing liveness pass can then omit computations reachable only through the unused operand. Dynamic and undefined conditions still emit a select.
On Windows WARP with Agility 1.620.2, all 29,736 output words matched main and the expected values. The seven generated cases cover both constant conditions, source sign modifiers, an arithmetic input used only by the unchosen arm, a chain of 12 selects, and a dynamic condition.
The committed bitcode test covers true, false, and an undefined condition. The bitcode, lowerer and VALU tests, both select semantic tests, strict shader Clippy and the asset policy passed.
Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:41:40Z.
Windows CI passed on
981f8b2, including both Clippy configurations and the workspace tests. All 29,736 generated output words matched on Windows WARP. The 12-select probe went from 50 to 34 DXIL instructions, and the dynamic probe stayed at 40. The committed unit test verifies both constant choices and that an undefined condition still emits a select.The next step is maintainer review. Please retain the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change into another commit.AI-assisted with OpenAI Codex.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T14:50:31Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
981f8b277c79a0aa1731f97b06d01b299b5aaab1, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-shader --lib -- emit::bitcode::tests::a_constant_select_uses_only_the_chosen_value --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 305 filtered, exit 0.git grep -Ffor the test name on the base returned no match (test is new on this PR);git diff --check 63bcca4 HEADclean (1 file, +24).CARGO_TARGET_DIR(never shared) withCARGO_BUILD_JOBS=2.AI-assisted (Hy4 flash).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T21:36:12Z.
Combined 07afa54 keeps this PR at
981f8b2and #3796 atd8dba2cas direct parents. It applies both folds in one place and associates the constant-branch test's documentation with that test.The constant-condition and identical-value regressions both passed. The distinct-value dynamic control still emitted 2,052 bytes. The identical-value shader emitted 1,984 bytes. Across both fixtures, all 32 WARP readbacks matched the expected values. The two established select semantics tests also passed with signed app-local WARP and SDK DXIL validation. All 14 active bitcode tests, both strict shader Clippy configurations and the asset policy passed.
The combined branch is available for maintainer review. Please retain the Git authors on cherry-pick or rebase, or include Co-authored-by: andrewpozdnakov7-jpg [email protected] if folding the changes into another commit.
AI-assisted with OpenAI Codex.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.