Shaders/Lower: reject unmodeled non-VOP3P modifiers in Lower::packed16 #3032
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3032
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3032"
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?
@RVZO6 on GitHub · 2026-11-26 03:59 UTC · original
RVZO6:rvzo/packed16-modifiers-guard→main· +144 −2 · 2 files · 1 commits · openv_pk_fmac_f16is decoded as VOP2 (0x03C, supporting DPP16/SDWA) and VOP3 (0x13C, not VOP3P), wherev.neg_hiis always0andv.abs,v.opsel, orv.sdwamay be set.Lower::packed16(crates/victory-shader/src/emit/lower.rs:7311-7334) previously checked onlyv.omod != 0 || !float && (v.clamp || v.neg != 0 || v.neg_hi != 0):v.neg != 0on VOP3/DPPv_pk_fmac_f16silently negated only the low f16 half (let neg = if high { v.neg_hi } else { v.neg }withneg_hi == 0).v.abs != 0,v.opsel != 0, orv.sdwa.is_some()was silently ignored.Fail closed on
v.sdwa.is_some() || v.abs != 0 || (op == "fmac_f16" && (v.neg != 0 || v.opsel != 0))while keeping plainv_pk_fmac_f16(and DPP withoutabs/neg) and all VOP3P modifiers (v_pk_fma_f16etc.) intact. Disjoint from #2229 (DPPself.src0infmac_half). Tests live incrates/victory-shader/src/emit/lower/packed_mod_tests.rs(keepinglower.rsat520,741 B, well under the 512 KiB limit).Verification
packed16_rejects_unmodeled_fmac_and_sdwa_modifiers_while_keeping_valid_opsfailed (VOP3 v_pk_fmac_f16 with neg must be rejected).v_pk_fmac_f16withneg,abs, oropsel, and VOP2 SDWAv_pk_fmac_f16, while plain VOP2/VOP3v_pk_fmac_f16and VOP3Pv_pk_fma_f16(withneg+neg_hi+dxil.dllvalidation) continue passing.--tests+--features diagnosticsclippy,xtask policy, full workspace tests): RVZO6/VIctory CI run #45748741503 (green, combined Wave 10 check on63bcca4).AI-assisted: T3 Code (Antigravity, gemini-4-neon).
@pawrenity on GitHub · 2026-11-26 05:04 UTC · original
VERIFY-3032: verified
f618abcon NVIDIA GeForce RTX 4070, Windows 11 (MSVC toolchain, dxil.dll validator loaded).Tests
The new test
packed_mod_tests::packed16_rejects_unmodeled_fmac_and_sdwa_modifiers_while_keeping_valid_opspasses. The otherpackedtests pass too, includingvalu_tests::packed_fmac_accumulates_each_half.Full
cargo test --locked -p victory-shader: 299 passed and 3 failed. All 3 failures are known on main on this card:stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosandsynthetic_tests::gathers_at_a_level_match_the_hardware. I skippedmemory_tests::heap_direct_texture_reads_mark_their_heap_index(#2571). Theresource_trackingintegration tests pass.Mutation check: I reverted only the
packed16condition to origin/main and kept the test. The test then fails with "VOP3 v_pk_fmac_f16 with neg must be rejected".The new test only asserts
is_err(), so I added a temporary probe that runs each case on its own:negabsopselv_pk_fmac_f16, VOP3 withclamp, VOP3Pv_pk_fma_f16withnegandneg_hiSo each negative assertion fails for the intended reason, not for some unrelated lowering error.
cargo clippy --locked -p victory-shader --all-targets [--features diagnostics] -- -D warnings: clean.cargo xtask policy: ok.Trial merge onto current origin/main (
63bcca4): clean. The PR is based on it.Review (from reading the code only)
gfx10/fields.rswritesabsandopselonly for VOP3 (VOP3P writesneg_hi/opsel/opsel_hiinstead), and it maps DPP and SDWAneg/absintov.neg/v.abs. Before the fix,packed16appliedv.negto the low half only (neg_hiis 0 outside VOP3P) and ignoredabs,opselandsdwa. VOP3P never setsabsorsdwa, so the newabs/sdwaterms only affect the non-VOP3Pv_pk_fmac_f16forms. Refusing these unmodeled modifiers, instead of guessing their per-half meaning, is the safe choice. No defects found.packed_mod_tests.rsis not rustfmt-clean (2 hunks: comment alignment at :17 and a longexpectline at :99). Main already has many rustfmt diffs elsewhere in the crate.Validator::loadfails, the test silently skips DXIL validation (if let Ok).Overlap
packed16modifier condition.git merge-treeshows a textual conflict inlower.rswith this PR, so whichever lands second needs a rebase.fmac_halfDPP src0) and #2884 (round packed FMA once) both merge cleanly with this PR.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-26 06:18 UTC · original
Automated triage for the maintainers.
Lower::packed16(crates/victory-shader/src/emit/lower.rs) now refuses modifiers it does not model, instead of silently mis-lowering them. These are SDWA,abs, andneg/opselon the VOP2/VOP3 encodings ofv_pk_fmac_f16. Before this change,negthere negated only the low half, becauseneg_hiis 0 outside VOP3P, andabs,opseland SDWA were ignored. I checked against the decoder (gfx10/fields.rs):absis set only for VOP3/DPP/SDWA, never for VOP3P, andfmac_f16is never VOP3P. So the existing VOP3P modifier handling (v_pk_fma_f16withneg/neg_hi/opsel) is unaffected. The PR does not claim any new semantics; it fails closed, which is the crate's usual way of handling an unmodelled case.Things to know before merging: a title shader that does use one of these forms will now fail to translate instead of being approximated. #1142 edits the same condition and will conflict textually. The new test module is not rustfmt-clean.
CI:
checkpassing.Generated by Claude Code
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.