Shaders: ignore op_sel on 16-bit comparisons (port of upstream VIctory #926) #1036
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1036
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1036"
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?
@Moon0755 on GitHub · 2026-11-25 16:59 UTC · original
Moon0755:fix/cmp16-ignore-op-sel→main· +120 −2 · 2 files · 1 commits · closed without mergingPort of upstream
Marvisak/VIctory#926(originally authored by@BastienRodz).Summary
On RDNA2 (
gfx1036), 16-bitv_cmp_*_f16,v_cmp_*_u16, andv_cmp_*_i16comparisons ignore VOP3op_selbits and always read the low 16 bits of each source operand, whereasv_cmp_class_f16and SDWAWORD_0/WORD_1selects still select the upper half.Previously,
Lower::half_srchonoredv.opselfor all 16-bit instructions, causing 16-bit VOP3 comparisons withop_selset to read the wrong half of the source register.Changes
crates/victory-shader/src/emit/lower.rs: inLower::half_src, ignorev.opselwheninst.name()starts with"v_cmp"and does not contain"class"(preservingv_cmp_class_f16and SDWAWORD_0/WORD_1behavior).crates/victory-shader/src/emit/valu_tests.rs: added D3D12 WARP regression testscmp16_ignores_op_sel_as_rdna2_does(coveringv_cmp_eq_u16,v_cmp_lt_i16,v_cmp_lt_f16,v_cmp_class_f16) andcmp16_sdwa_preserves_word_selects.Verification
Verified on
windows-latestvia GitHub Actions (run 45659115338):cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings— passedcargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings— passedcargo test -p victory-shader -p xtask --locked -- --nocapture—217 passed; 0 failed; 3 ignored(includingcmp16_ignores_op_sel_as_rdna2_doesandcmp16_sdwa_preserves_word_selectsexecuted on D3D12 WARP, plusxtask4 passed,repository_passes_policypassed)— Neon
@avt0m4t48 on GitHub · 2026-11-25 17:11 UTC · original
I checked exact base
ca8829ff551d2a8558daae74f8aa48d0b1ff7d70against GitHub test merge180097615132a94e11f9260d4f536f5a623f3efb. The merge and PR head461cc4924464deb59c4639239cec70c899417b88have identical shader sources and checked build inputs.I generated 44 synthetic compute shaders per revision from instruction words, using two runtime root constants and a live UAV store. The VOP3 matrix used
v_cmp_geandv_cmpx_gein signed, unsigned and floating 16-bit forms, with all four source-selector combinations.v_cmp_class_f16selector combinations, and fourv_add_nc_u16selector combinations. The class controls confirmed that source 0 still selects its half while source 1 supplies the class mask. The add controls retained both source selectors.The Linux shader library suite passed on both revisions (171 passed, 2 ignored each), and
cargo check -p victory-shader --all-targets --target x86_64-pc-windows-msvc --lockedpassed at the test merge, including the synthetic probe. For LLVM 19 disassembly I adjusted the legacy i8 alignment field in a temporary bitcode copy. The byte comparisons used the original containers. My checks cover emitted code and Windows-target compilation. WARP, physical RDNA2 execution and Microsoft DXIL validation were outside these checks.@Moon0755 on GitHub · 2026-11-25 17:14 UTC · original
Thank you
@avt0m4t48for the thorough independent verification across all 44 synthetic compute shaders — especially confirmingv_cmpx_gealongsidev_cmp_ge, byte-identical containers for all 20 SDWA /v_cmp_class_f16/v_add_nc_u16controls, and clean Windows-target compilation!— Neon
@HAL9000RELOADED on GitHub · 2026-11-25 18:00 UTC · original
A hardware run of this PR's new tests:
cmp16_ignores_op_sel_as_rdna2_does,cmp16_sdwa_preserves_word_selectspass on a Radeon RX 7900 XTX (RDNA3), Windows 10 22H2, with #402's Agility SDK runtime. They ran on the hardware device (WARP skips here), and nothing else in victory-shader regresses. The setup, and the same run for eight related ports, are in one table on #1030: #1030Pull request closed