Repository navigation
Shaders: lower SAD differences through UMax and UMin - #3640
Open
Ingenioeren wants to merge 1 commit into
Open
Ingenioeren wants to merge 1 commit into
Ingenioeren wants to merge 1 commit into
Conversation
|
Independent WARP-only verification of #3640 (AI disclosure: Claude Sonnet 5.5; physical GPU not used)
Control check. The tests don't exist on base, so I kept the PR's plumbing and tests and reverted only the SAD lowering arm to base's text.
Full
The same 4 tests fail on both, so they are pre-existing WARP limitations on base:
The difference of +2 passed is exactly the two new tests. Other checks (merged tree)
Diff review. I read every hunk and found no defects.
No game files, dumps, paths, shader names or retail hashes are included. |
Dukestar69
approved these changes
Nov 28, 2026
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on Windows (RTX 5090 + WARP):
cargo test -p victory-shader --lib sadpassed (2/2:sad_instruction_countsandsad_fields_and_wrapping_accumulators_match_the_reference— 70,861 inputs × 10 variants with 0 mismatches on RTX 5090 hardware and WARP)cargo test -p victory-shader --lib sums_of_absolute_differences_lowerpassedcargo clippy -p victory-shader --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (192 files ok)
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.
The four unsigned SAD forms now compute each field's absolute difference with DXIL UMax/UMin instead of a comparison and two selects. They also omit shifts by zero, the top field's redundant mask, and the initial zero-add. Accumulation and the high-byte form's shift still wrap at 32 bits.
Written instructions for minimal synthetic compute shaders with dynamic inputs, including setup, the UAV store and terminators:
v_sad_u8v_sad_hi_u8v_sad_u16v_sad_u32These measure DXIL size, not GPU time or frame rate. The helper lives in
emit/lower/sad.rs;lower.rsshrinks from 520,563 to 520,115 bytes, below the 524,288-byte asset-policy limit.v_msad_u8is split into its own arm with the same emitted lowering (63 instructions). Its intrinsic optimization remains in #3564. Both PRs touch the former shared arm, so whichever lands second will need a small rebase. The test-only instruction counter is byte-identical to #3600 and the other open shader performance PRs.Validation, using only synthetic shaders:
cargo test --locked --offline -p victory-shader sad_ -- --nocapture: the count regression failed before this change (55/56/37/24 against budgets 46/47/30/22), then passed after. The behavior test passed on both revisions: 70,861 inputs per form, each with and without EXEC masking, for all four SAD forms plus unchanged MSAD. RX 6750 XT and WARP produced zero CPU-model mismatches and zero adapter disagreements: 708,610 checked results per adapter/revision. Inputs cover every pair of byte values, individual field positions, unsigned boundaries, equal values, accumulator wraparound, all MSAD mask combinations, and deterministic random dwords. The CPU oracle uses byte arrays and a wide accumulator.cargo test --locked --offline -p victory-shader --no-fail-fast: baseline 300 passed / 2 failed / 3 ignored; final 302 passed / the same 2 failed / 3 ignored. The known failures areemit::rect::tests::rectangles_get_their_fourth_cornerandemit::tests::elements_sharing_a_row_keep_their_order, both rejected by the local dxil.dll for a Pipeline State Validation mismatch. Integration tests: 3 passed / 1 ignored; doc tests: 0. No checks or assertions were weakened.cargo clippy --locked --offline -p victory-shader --all-targets --all-features -- -D warnings: passed.cargo run --locked --offline -p xtask -- policy --staged: passed, 4 files OK.cargo fmt --check: retains upstream formatting failures. Comparing each changed existing file with formatted main shows identical formatting deviations; the new module and test are formatted.git diff --check: passed.The related integer min/max PR #3027 has an unresolved pipeline-compilation hang on RADV. This PR also emits UMin/UMax; the Windows tests above do not resolve that report. Linux/RADV, other GPU drivers, and game behavior were not tested. No game was launched and no game files or game-derived data were used.
AI assistance: prepared with OpenAI Codex, reviewed by Ingenioeren.