Repository navigation
Shaders: restore 16-bit compares reading the low halves whatever op_sel says - #224
Merged
Merged
Conversation
… RDNA2 does Previously `half_src` applied VOP3 `op_sel` bits to every 16-bit operation, causing 16-bit compares (`v_cmp_*` and `v_cmpx_*` on f16, u16, and i16) to read the high half when `op_sel` was set. As measured on gfx1036 (RDNA2) across 146 cases in #833 (VGPR, SGPR, literal, inline-constant sources, wave32/wave64, and `v_cmpx_*_e64`), RDNA2 hardware ignores VOP3 `op_sel` on 16-bit compares and always compares the low halves, while non-compare 16-bit ops such as `v_add_nc_u16` still honour `op_sel`. Ignore VOP3 `op_sel` in `half_src` (which `half_fsrc` calls as well) for `v_cmp*` instructions except `v_cmp_class*` (not measured), while keeping SDWA word selects intact, and add an end-to-end VALU test covering f16/u16/i16 compares, `v_cmpx_lt_f16`, and `v_add_nc_u16` as a control. Co-Authored-By: Gemini 4 Neon <noreply@google.com>
(cherry picked from commit f459735)
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
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.
What
A regression, not a new idea: commit
a8aa1d1cb(merged as Scarlight #16 / VIctory #926, BastienRodz) madev_cmp*_u16/i16/f16read the low halves whatever VOP3op_selsays, as RDNA2 does, with its test. Both the condition and the tests disappeared when the VALU integer operations moved to their own module (94d02c71b);half_src(crates/victory-shader/src/emit/lower.rs) honoursop_selfor every 16-bit operation again, so a compare with a sourceop_selset reads the wrong half and branches the wrong way.This restores
a8aa1d1cband its follow-upf45973553verbatim (git cherry-pick -x, author swarm kept):op_selis ignored forv_cmp*other thanv_cmp_class, the SDWA word select still applies. Route: fxceless/victory-fork PR #1036 reports the same class independently.Gates
cargo xwin clippy --target x86_64-pc-windows-msvc --workspace --all-targets -- -D warnings: clean.cmp16_ignores_op_sel_as_rdna2_doesandcmp16_sdwa_preserves_word_selects—2 passed; 0 failed.shaders-dump: 751/751 ok, DXIL identical to the base report of 23:28Z (0 of 751 changed).victory-run: 2912 rows, 2909 ok, 3 dxil-spirv timeouts (the same baseline), 0 of 2912 DXIL changed — no program in either dump setsop_selon a 16-bit compare, so the fix changes the class, not a count.cargo xtask policy:asset policy: 255 files ok;git grep -iE "gta ?(vi|6)|grand theft|rockstar"empty.Off switch
None: this restores the behaviour Scarlight already shipped in #16; a switch could only turn the bug back on.
Not tested in a game run.
Summary by CodeRabbit