Repository navigation
Shaders: fix 16-bit VALU SDWA placement/sext and inline float constants - #112
Open
hamdog0203 wants to merge 1 commit into
Open
hamdog0203 wants to merge 1 commit into
hamdog0203 wants to merge 1 commit into
Conversation
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.
Summary
Fixes three 16-bit VALU lowering bugs in
crates/victory-shader/src/emit/lower.rs, adapted fromMarvisak/VIctory#1285(including the follow-up guard for reserveddst_unused=3withdst_sel:DWORD):UNUSED_SEXT, and reserveddst_unused=3(write_half): Previously rejected bytedst_sel(0..=3) and ignoreddst_unused = UNUSED_SEXT(1) for word targets, while allowing reserveddst_unused = 3ondst_sel:DWORD.write_halfnow delegatesdst_sel0..=5withdst_unused0..=2toplace_bits, zero-extends the low 16 bits fordst_sel:DWORD(6) withdst_unused0..=2, and rejects reserveddst_unused = 3.sext(half_src/half_int_src): Previously rejected bytesrc_sel(0..=3) and ignored SDWAsexton 16-bit operations.half_src_typednow handlessrc_sel0..=5viaselect_bits, applyingsextfor 16-bit integer sources (half_int_src).half_int_src): On GFX10, 16-bit integer VALU and compare instructions (v_cvt_f16_u16/v_cvt_f16_i16, 16-bit integer VALU ops, and 16-bit integercompare) read inline float constants as rawf32bit patterns rather thanf16values. Splittinghalf_int_src(operand) fromhalf_src(f16_operand) preservesf16inline constants forf16ops while giving 16-bit integer ops theirf32bits.Negative Control (unpatched
main90b529f)Verified in a separate detached worktree on
90b529fwith only the new tests applied:sdwa_16bit_dst_word0_sext_and_byte_placement: failed on RTX 4060 (hardware: add_sextreturned0x0000_BC00instead of0xFFFF_BC00).sdwa_16bit_src_byte_select_and_sext: failed lowering (Unsupported { offset: 36, what: "a byte select on a 16-bit operation" }).int16_inline_float_constants_use_f32_bits: failed on RTX 4060 (hardware: v_add_nc_u16(248, 0)returned0x3118instead of0xF983).Verification (at
d316e3d)Environment: Windows 11 x64 (
26200.9974), NVIDIA GeForce RTX 4060 (8 GB, Wave32, driver621.35), Microsoft WARP, Windows SDKdxil.dll(10.0.26100.0),rustc 1.98.1.cargo test --locked -p victory-shader --lib -- sdwa_16bit_dst_word0_sext_and_byte_placement sdwa_16bit_src_byte_select_and_sext int16_inline_float_constants_use_f32_bits --nocapture: 3 passed, 0 failed (validated viadxil.dlland executed on both RTX 4060 and WARP with no skips).cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings).cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings).cargo test --workspace --locked: all crates passed with 0 failures (victory1,victory_core11,victory_formats24 / 4 ignored,victory_game2,victory_gpu110 / 1 ignored,victory_hle95 +no_dll_planting1,victory_loader24 +load_probe2 +title_dlls1,victory_pe7,victory_pipeline4,victory_shader213 / 2 ignored,xtask4 includingrepository_passes_policy)..githooks/pre-commit: passed (asset policy: 2 files ok).