Shaders: lower scalar bit-field extracts through Ibfe and Ubfe #3637
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3637"
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 Ingenioeren on 2026-11-28T01:12:03Z.
Scalar
s_bfe_u32ands_bfe_i32currently emit a shift/mask sequence, with another sign-extension sequence for the signed form. Use DXILUbfe/Ibfefor widths below 32 and select a logical/arithmetic right shift for widths 32�127. The scalar instruction's seven-bit width, ignored control bits, zero-width result, and SCC stay the same. DXIL bit-field semantics.The synthetic count shader reads two runtime root constants and stores the result to a UAV. Counts include live emitted instructions and terminators:
63bcca4s_bfe_u32s_bfe_i32Validation:
cargo test --locked --offline -p victory-shader scalar_bitfield_extract -- --nocapture --test-threads=1: the instruction-count regression failed before the lowering change ([26, 33]versus[23, 23]) and passed after. The new semantic test passed before and after on RX 6750 XT and WARP: 32,768 inputs per form, every offset 0�31 and width 0�127, clean/dirty ignored bits, and both result and SCC, with zero model mismatches or adapter differences.cargo test --locked --offline -p victory-shader: baseline 300 passed / 2 failed / 3 ignored; branch 302 passed / the same 2 failed / 3 ignored. Both local validator failures areemit::rect::tests::rectangles_get_their_fourth_cornerandemit::tests::elements_sharing_a_row_keep_their_order(Pipeline State Validationmismatch).cargo test --locked --offline -p victory-shader --test resource_tracking: 3 passed, 1 ignored.cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings: passed.cargo run --locked --offline -p xtask -- policy --staged: all 3 staged files passed.cargo fmt --checkretains existing main formatting differences; comparison against main found no new formatting deviations in any changed file.git diff --checkpassed.The test-only instruction counter is identical to the one in #3632 and the earlier shader performance PRs. #2954 optimizes the vector BFE forms; this change touches the scalar caller and adds a separate helper, leaving the vector lowering unchanged. No game files, game launch, or game-performance measurement; these are DXIL instruction counts.
AI assistance: prepared with OpenAI Codex, reviewed by Ingenioeren.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-28T02:31:54Z.
Independent WARP verification for #3637 by Codex (gpt-6.2-sol).
63bcca43c6a00a758510398fa43096ce7e4f7df0and PR head8d45f077a20616923f5142836be52c8e0247b3bbmerge cleanly to treede3e689480f9e328033a9862182ce0355a3293f1.d3d10warp.dll10.0.26100.9818and SDKdxil.dll1.8.2502.11.[26, 33]against[23, 23]. Both tests passed on the merged tree at[23, 23]. The model test covered 32,768 inputs per signedness with zero result or SCC mismatches on either revision.-D warningsand staged asset policy passed.lower.rsgrew from 520,563 to 522,096 bytes, leaving 2,192 under the 524,288 limit.bitcode.rs,lower.rs, andsemantics_tests.rs. The test counter follows the writer's live layout and counts each terminator. Widths 32–127 take the arithmetic or logical shift byoffset & 31, width zero yields zero, unused control bits are ignored, and SCC remainsresult != 0. All four neighboring PRs share the counter scaffolding. Pairwise merges with #3632 and #3640 are clean. #2954 and #3564 conflict at the instruction-count test insertion inlower.rs.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-28T02:49:28Z.
Review: APPROVED
LGTM — verified on Windows (RTX 5090 + WARP):
cargo test -p victory-shader --lib scalar_bitfield_extract_all_widths_and_offsetspassed on RTX 5090 and underVICTORY_WARP=1cargo test -p victory-shader --lib bfe(bfe_signed_and_unsigned_match_rdna2) passed on RTX 5090 and underVICTORY_WARP=1cargo clippy -p victory-shader --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.