Shaders: fix 16-bit VALU SDWA placement/sext and inline float constants #112
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/112"
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?
Imported from Zettrox/ztrx. Originally posted by hamdog0203 on 2026-11-25T12:15:25Z.
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).Imported from Zettrox/ztrx. Originally posted by Aniseto on 2026-11-25T15:03:41Z.
Ran the new 16-bit VALU tests at
d316e3d(clean PR head onmain90b529f):System
rust-toolchain.toml), MSVC 14.44.35207, DXIL validator 1.9.2609.5 (VICTORY_DXIL), debug buildResults
cargo test --locked -p victory-shader --lib sdwa_16bit -- --nocapture: 2 passed, 0 failed, 0 ignored, 213 filtered out (exit 0)cargo test --locked -p victory-shader --lib int16_inline_float_constants_use_f32_bits -- --nocapture: 1 passed, 0 failed, 0 ignored, 214 filtered out (exit 0)cargo test --locked -p victory-shader --lib -- --test-threads=1: 213 passed, 0 failed, 2 ignored (exit 0)What this adds
No test report exists yet in this thread, so this is the first hardware datapoint. All three new tests pass on this Blackwell wave32 part with DXIL validator 1.9.2609.5. The SDWA placement/sext and inline-constant cases are lowering tests; they do not by themselves prove a shader using them was created as a pipeline on the GPU.
Not tested
The title's shader pack, live pipeline creation, retail runs, a WARP control lane, the console compiler's DXC, release profile, AMD and Intel GPUs.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.