shader: follow known 16-bit VGPR halves across half ops, phis, and exports (#455) #464
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/464"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Sheffy007 on 2026-11-27T21:24:32Z.
Closes #455
Refs #4, #258
Problem
When
v_fma_mixlo_f16orv_fma_mixhi_f16writes one 16-bit half over a VGPR whose other half has no host form (such as av_interp_p1ll_f16scratch register or a barycentric input),Lowerrecords the known half inlow16orhigh16while leavingVal::Missinginvals. However:high16had no source lookup helper, andlow16/high16were not consulted byv_fma_mix*(op_sel_hihigh half),v_pack_b32_f16,v_pk_*, 16-bit VALU high-half sources, SDWA selects, half-shifts/half-masks/v_bfi_b32/v_bfe_*/v_perm_b32,a16/d16image and LDS half accesses, or unguardedv_mov_b32/v_cndmask_b32copies.write_halfandlow_halfzeroed the kept half instead of preservinglow16/high16when completing a register, andreset_for_rect_cornerdid not clearhigh16.Lower::exportneither clippedTarget::Colorchannels toOSG1'scolsnor consultedlow16/high16on compressed exports (exp ... compron GFX10 enables register pairs viaen0x3or0xfeven for 1- or 3-channel targets).fill_phisrefused joins of known-half values whose transitive readers only read that half, andoverwritten_movreld_edgeonly matched"barycentrics read directly"and not"the first half of an interpolation".Changes
crates/victory-shader/src/emit/lower.rs,lower/rect.rs:half16_src,value_half,src_half, andphi_half_only/only_reads_half, and clearhigh16inreset_for_rect_corner.low16/high16acrossv_fma_mix*,v_pack_b32_f16,v_pk_*,half_src,v_fmac_f16/v_mac_f16, SDWA selects,v_lshlrev_b32/v_lshrrev_b32/v_ashrrev_i32(>= 16), half-maskv_and_b32/v_and_or_b32/v_lshl_add_u32/v_lshl_or_b32/v_bfi_b32/v_bfe_*/v_perm_b32,a16/d16image and LDS half accesses, unguardedv_mov_b32/v_cndmask_b32copies, and half-onlyfill_phisjoins.low16/high16inwrite_halfandlow_half, and extendoverwritten_movreld_edgeto"the first half of an interpolation".Target::Colorexports to[col, col + cols), readvalue_halfforhalfexports, and pad the trailing odd half of guessed 1-/3-channelexp ... comprpairs (// Guess:, documented indocs/native-host.md).export_tests::compressed_exports_and_half_ops_follow_known_16bit_halvesexport_tests::half_only_phis_and_overwritten_movreld_loops_translate_while_other_half_reads_refuseshader_tests::known_16bit_halves_draw_across_mix_pack_joins_and_odd_compressed_exports(Metal GPU execution)Verification
cargo test -p victory-hle -p victory -p victory-gpu -p victory-metal -p victory-shader -p xtaskcargo clippy --workspace --all-targets --target x86_64-pc-windows-gnullvm -- -D warningscargo clippy --workspace --all-targets --all-features --target x86_64-pc-windows-gnullvm -- -D warningscargo xtask policycc @Olima34
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T23:02:33Z.
Thanks for this PR! An offline check of
f880ac60, with no game run:On current main (
b998bb65) + #464: tests pass (victory-gpu on arm64, plus victory-hle, victory, xtask and victory-shader). Windows clippy (x86_64-pc-windows-gnullvm,-D warnings) is clean, andcargo xtask policypasses.Corpus sweep (
examples/sweep+tools/corpus/compare.sh, main → main + #464), on two local shader sets:Compute and vertex shaders are unchanged. All changed outputs are in pixel shaders, which fits the export and half-op changes.
Merging:
preview/graphics-2026-11-28branch (b3c1a1b0).pixel_4ced2d9a4b14e6cc,pixel_ef85b8efcc24a3b6andpixel_ecc384d4a7ffd3e0. Outputs changed for 53 shaders on A and 124 on B.I haven't checked the rendering of the changed outputs, since no game run was done.
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.