Shaders: reject VALU float/clamp modifiers in I/O and resource analyses #2492
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!2492
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2492"
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?
@reeledMarek on GitHub · 2026-11-25 14:48 UTC · original
reeledMarek:fix/shader-valu-copy-modifiers→main· +76 −1 · 2 files · 1 commits · openProblem
Three VALU copy / address analysis helpers in
victory-shaderdid not check the full set of VOP3 modifiers (abs,neg,clamp,omod) — separate from #2448, which coversLower::konst:io.rs(Halves::joined): checked onlydpp/sdwaonv_mov_b32, silently treating a modified copy of a hardware barycentric (e.g.-v0,abs(v0),clamp,mul:2) as the unmodified hardware barycentric.resource.rs(Tracer::voriginandTracer::vstep): checkedabs/neg/sdwa/dpponv_mov_b32, missing!clamp && omod == 0.resource.rs(Tracer::vadd): checkedabs/neg/sdwa/dpponv_add_nc_u32/v_add_co_u32, missing!clamp && omod == 0(on GFX10, clamped unsigned vector addition saturates atu32::MAXinstead of wrapping modulo 2^32).Fix
abs == 0 && neg == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none()in all three helpers (matchingrange.rs::op_hiandresource.rs::lane_picked).io.rsandresource.rsverifying unmodified VOP3 forms still succeed while each modified form is rejected / kept opaque.Verification
cargo test -p victory-shader --locked(146 passed, 0 failed)cargo test -p xtask --locked(repository_passes_policypassed)cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings(0 warnings)@cloph-dsp on GitHub · 2026-11-25 15:41 UTC · original
Independent local validation for PR #2492 (Windows, Rust 1.100.0/MSVC, head
98017a5, no game data):cargo test --locked -p victory-shader --lib-> 249 passed, 0 failed, 3 ignored, exit 0 (90.60s). CPU-only regression run; the synthetic compare-bound scenario was not replayed. AI-assisted (Hy4 flash). GPU/driver: N/A for CPU tests.@Marvisak on GitHub · 2026-11-25 16:00 UTC · original
Automated triage for the maintainers.
This makes three analyses refuse a VALU copy or add that carries output or input modifiers:
Halves::joinedinio.rs(av_mov_b32of a barycentric, where abs/neg/clamp/omod were not checked at all) and thev_mov_b32/v_add_nc_u32walks inresource.rs(clamp and omod not checked). The result is only more conservative: a modified copy is no longer taken for the plain value, and a clamped add, which saturates according to the public RDNA2 ISA, is no longer split into base plus offset. This matches the checksrange.rsop_hialready makes. I checked the hand-encoded VOP3 words in the new tests (opcode, clamp bit, abs/neg/omod fields). CI: passing.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 00:52 UTC · original
Code review and RTX 5090 + WARP + DXIL verification at head
98017a5eb007merged cleanly ontomain(63bcca43c6a0):abs == 0 && neg == 0 && !clamp && omod == 0(plusdpp/sdwawhere applicable) inio.rs:583-590(Halves::joined),resource.rs:742-747(Tracer::vadd),resource.rs:770-775(Tracer::vorigin), andresource.rs:1559-1564(Tracer::vstep) closes the modifier-blind address/barycentric tracking cases cleanly. (Also verified clean merge with#2923.)Tracer::carried(resource.rs:999-1017) matchesFields::Valu(f)on"v_add_co_ci_u32"without checking!f.clamp && f.omod == 0 && f.abs == 0 && f.neg == 0 && f.sdwa.is_none() && f.dpp.is_none()(pergfx10/fields.rs:589,671, VOP3Bv_add_co_ci_u32supportsclamp/omod, and VOP2 supportssdwa/dpp). Worth tightening either here or in a follow-up.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo test -p xtask --locked: 6/6;cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default +--features diagnostics): 0 warningsio::tests: 5/5;resource::tests: 36/36 (including both new modifier tests)emit::tests(17/17) andemit::semantics_tests(34/34, 1 ignored): passed on both RTX 5090 and WARP.LGTM.
@DenRakEiw on GitHub · 2026-11-25 14:58 UTC · original · approved these changes
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:cargo test -p victory-shader resource::tests: 34/34 passed (includingclamped_vector_add_and_modified_vector_copy_are_not_plain_address_ops).cargo test -p victory-shader io::tests: 5/5 passed on RTX 5090 and WARP (includingmodified_barycentric_copy_is_not_treated_as_plain_barycentric).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 13:54 UTC · original · approved these changes
The new
clampandomodguards cleanly keep saturating adds and modified moves out of the plain-copy (io.rs:581-595,resource.rs:748-761, 1486-1500) and plain-add (resource.rs:714-735) paths without rejecting valid integer instructions, and the added tests cover them well.Two pre-existing modifier gaps worth noting for follow-up (not blocking this PR):
Tracer::carried()(resource.rs:969-979): matchesv_add_co_ci_u32without rejectingsdwa,dpp,clamp,abs,neg, oromod, even though SDWA/DPP/clamped forms can change the high dword while still referencing the root descriptor's high word insrc[..2].io.rs:387-401, 515-535): accepts modifiedv_interp_p1ll_f16(e.g., an intermediate P1clampor inputabs/neg), which lowering drops when fusing P1 and P2 and applying only P2's output modifiers.Local verification on commit
98017a5eb007(and cleanly merged ontoorigin/maintree15c737a3,emit/lower.rsunchanged at520,563 B):cargo run --locked -p xtask -- policy(182 files ok),cargo clippy -p victory-shader --all-targets(defaultand--all-features),io::tests(5 passed),resource::tests(34 passed on PR head, 36 merged),emit::lower::tests(21 passed on PR head, 33 merged), andemit::waterfall_tests(5 passed) on both RTX 5090 andVICTORY_WARP=1all pass. Approving.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.