Repository navigation
Shaders: lower v_med3_f32 through ordered integer keys - #3608
Ingenioeren wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verification of #3608: PASS, with a file-size caveat. Environment: native Windows 11, WARP only (no hardware GPU;
|
|
I reproduced the file-size issue with the exact current heads I moved the FP32 median helper into On app-local WARP 1.0.22, all three median tests passed. The matrix reported zero mismatches across 54,872 input triples for each of 20 modifier settings, and the instruction-count test still expects 65 DXIL instructions. Both exp tests passed on If taking the module move, please retain the Git author, or use |
Moves Lower::med3_f32 unchanged into emit/lower/med3.rs, wired like emit/lower/bvh.rs, so lower.rs keeps room under the 524,288-byte source limit (523,938 -> 521,171 bytes). No behaviour change. Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @andrewpozdnakov7-jpg for reproducing the overflow and for the module move. I took it into this PR as d06df15 (with you as co-author):
|
|
Hardware run on AMD: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head
AI use: Claude Code (Claude Opus 5.5). |
v_med3_f32now lowers its numeric median through signed-integer ordered keys and DXIL IMin/IMax. The minimal dynamic-input synthetic compute shader shrinks from 89 to 65 written DXIL instructions: 24 fewer (26.97%), including loads, the UAV store and terminators. This measures DXIL size; runtime throughput was not benchmarked.Reversing the negative half of the f32 bit patterns orders numbers exactly, including
-0 < +0. Denormal operands map directly to their signed-zero keys. NaNs sort above every number; any NaN selects the minimum of the numeric operands, matching the existing med3 rule. Three NaNs retain the original two-FMin chain. The transform back to float bits is exact. Existing source modifiers, output modifiers and guards surround this lowering; it adds no wave operations. The f16 path keeps its existing helper.The DXIL specification defines the signed integer min/max and floating minNum behavior used here. Searches of open upstream PRs for
v_med3_f32,IMin,IMaxand med3 performance found no PR covering this optimization; #3027 covers integer-source forms.The test-only
Module::written_instructionsandLowered.instructionscounter helper is byte-identical to #3525/#3564/#3592/#3600, copied from #3600'sfix/perf-v-perm-b32-dxilbranch and checked against all four branch versions.Validation:
cargo test --locked --offline -p victory-shader v_med3_f32_instruction_count -- --nocapture: written first; failed on the original lowering with actual 89 versus expected 65.cargo test --locked --offline -p victory-shader med3_f32 -- --nocapture: 3 passed, 0 failed after implementation. The new runtime test compares 54,872 input triples over 20 modifier settings on both the RX 6750 XT and WARP: zero CPU-reference mismatches and zero adapter disagreements. It covers signed zeros, positive/negative denormals, ordinary and extreme finite values, infinities, quiet/signalling NaNs in every source, abs/neg, clamp and all output multipliers, across multiple waves.cargo test --locked --offline -p victory-shader: baseline 300 passed, 2 failed, 3 ignored; after 302 passed, 2 failed, 3 ignored. Both runs fail onlyemit::rect::tests::rectangles_get_their_fourth_cornerandemit::tests::elements_sharing_a_row_keep_their_order, with the local dxil.dll errorContainer part 'Pipeline State Validation' does not match expected for module.No tests were weakened or disabled.cargo clippy --locked --offline -p victory-shader --all-targets -- -D warnings: passed.cargo fmt --check: fails on pristine upstream main and this branch with the same 925 pre-existing formatting hunks; normalized hunk contents are identical, with only line numbers/checkout roots differing. The new code was formatted; unrelated formatting changes were excluded.cargo run --locked --offline -p xtask -- policy --staged: passed, 3 files OK.git diff --check: passed.Execution coverage is limited to this RX 6750 XT and WARP. Other GPUs/drivers and game behavior were not tested. All shader inputs are synthetic; no game was launched and no game files or game-derived content were used.
AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.