Repository navigation
Shaders: lower v_bfi_b32 with three bit operations - #3681
Open
Ingenioeren wants to merge 1 commit into
Open
Ingenioeren wants to merge 1 commit into
Ingenioeren wants to merge 1 commit into
Conversation
|
Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head
AI use: Claude Code (Claude Opus 5.5). |
|
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
AI-assisted (Hy4 flash). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v_bfi_b32selects bits from src1 where src0's mask is set, and src2 otherwise. Emitb ^ ((a ^ b) & m), reducing the bit-select expression from four operations to three.A synthetic shader with three dynamic root constants and a live UAV store emits 21 DXIL instructions instead of 22. This measures emitted instructions; GPU time and frame rate were not measured.
The count regression uses a
v_xor3_b32shader with the same setup as a control. With only the tests added to main63bcca4, BFI emits 22 instructions against the control's 20 and the regression fails. With this change, BFI emits 21 and the regression passes.The execution test uses an independent per-bit CPU model, single-bit and complemented masks, alternating patterns, all eight truth-table combinations at every bit position, edge dwords and deterministic random inputs. All 11,752 inputs run with a separate destination and with each source as the destination, with both full and narrowed EXEC: 94,016 results per adapter per revision. Both lowerings match the model on the RX 6750 XT and WARP, with zero adapter differences.
Validation on Windows, Rust 1.98.1, synthetic shaders only:
cargo test --locked --offline -p victory-shader bfi_selects -- --nocapture: original lowering with tests 1 passed / 1 expected count failure; final 2 passed.cargo test --locked --offline -p victory-shader --no-fail-fast: 302 passed / 2 failed / 3 ignored; the recorded unmodified-main baseline at63bcca4is 300 passed / the same 2 failed / 3 ignored. The failures arerectangles_get_their_fourth_cornerandelements_sharing_a_row_keep_their_order, both rejected by this PC's localdxil.dllwith a Pipeline State Validation mismatch. Integration: 3 passed / 1 ignored; doc tests: 0.cargo clippy --locked --offline -p victory-shader --all-targets --all-features -- -D warnings: passed before and after the lowering change.cargo run --locked --offline -p xtask -- policy --staged: passed before and after, 3 files.git diff --cached --check: passed. Rustfmt comparisons against main show identical pre-existing deviations in all three changed files.lower.rsis 521,423 bytes, below the 524,288-byte policy limit.The test-only instruction counter is identical to the one in #3600/#3632/#3637/#3640. Those PRs optimize other instructions; this change retains the existing source reads and guarded destination write.
Not tested: Linux/RADV, other hardware, or game rendering/performance. No game files were used. This does not establish a fix for device removal or the integer-min/max compiler hang reported on #3027.
AI assistance: prepared with OpenAI Codex, reviewed by Ingenioeren.