Shaders: reject VALU float/clamp modifiers in I/O and resource analyses #2492

Open
github-bot wants to merge 1 commit from github-bot/gh-2492 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-25 14:48 UTC · original
reeledMarek:fix/shader-valu-copy-modifiers → main · +76 −1 · 2 files · 1 commits · open

Problem

Three VALU copy / address analysis helpers in victory-shader did not check the full set of VOP3 modifiers (abs, neg, clamp, omod) — separate from #2448, which covers Lower::konst:

  1. io.rs (Halves::joined): checked only dpp/sdwa on v_mov_b32, silently treating a modified copy of a hardware barycentric (e.g. -v0, abs(v0), clamp, mul:2) as the unmodified hardware barycentric.
  2. resource.rs (Tracer::vorigin and Tracer::vstep): checked abs/neg/sdwa/dpp on v_mov_b32, missing !clamp && omod == 0.
  3. resource.rs (Tracer::vadd): checked abs/neg/sdwa/dpp on v_add_nc_u32 / v_add_co_u32, missing !clamp && omod == 0 (on GFX10, clamped unsigned vector addition saturates at u32::MAX instead of wrapping modulo 2^32).

Fix

  • Require abs == 0 && neg == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none() in all three helpers (matching range.rs::op_hi and resource.rs::lane_picked).
  • Added synthetic regression tests in io.rs and resource.rs verifying 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_policy passed)
  • cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings (0 warnings)
**@⁠reeledMarek** on GitHub · 2026-11-25 14:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2492) `reeledMarek:fix/shader-valu-copy-modifiers` → `main` · +76 −1 · 2 files · 1 commits · open ### Problem Three VALU copy / address analysis helpers in `victory-shader` did not check the full set of VOP3 modifiers (`abs`, `neg`, `clamp`, `omod`) — separate from #2448, which covers `Lower::konst`: 1. `io.rs` (`Halves::joined`): checked only `dpp`/`sdwa` on `v_mov_b32`, silently treating a modified copy of a hardware barycentric (e.g. `-v0`, `abs(v0)`, `clamp`, `mul:2`) as the unmodified hardware barycentric. 2. `resource.rs` (`Tracer::vorigin` and `Tracer::vstep`): checked `abs`/`neg`/`sdwa`/`dpp` on `v_mov_b32`, missing `!clamp && omod == 0`. 3. `resource.rs` (`Tracer::vadd`): checked `abs`/`neg`/`sdwa`/`dpp` on `v_add_nc_u32` / `v_add_co_u32`, missing `!clamp && omod == 0` (on GFX10, clamped unsigned vector addition saturates at `u32::MAX` instead of wrapping modulo 2^32). ### Fix - Require `abs == 0 && neg == 0 && !clamp && omod == 0 && sdwa.is_none() && dpp.is_none()` in all three helpers (matching `range.rs::op_hi` and `resource.rs::lane_picked`). - Added synthetic regression tests in `io.rs` and `resource.rs` verifying 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_policy` passed) - `cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings` (0 warnings)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:07:21 +00:00
Author
Owner

@⁠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.

**@⁠cloph-dsp** on GitHub · 2026-11-25 15:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2492#issuecomment-7167240004) 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.
Author
Owner

@⁠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::joined in io.rs (a v_mov_b32 of a barycentric, where abs/neg/clamp/omod were not checked at all) and the v_mov_b32 / v_add_nc_u32 walks in resource.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 checks range.rs op_hi already 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

**@⁠Marvisak** on GitHub · 2026-11-25 16:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2492#issuecomment-7167510000) <!-- victory-triage v1 head=98017a5eb0078c9d77975bd6aaf68aff400d8129 verdict=merge-candidate at=2026-11-25T16:00:22Z --> Automated triage for the maintainers. This makes three analyses refuse a VALU copy or add that carries output or input modifiers: `Halves::joined` in `io.rs` (a `v_mov_b32` of a barycentric, where abs/neg/clamp/omod were not checked at all) and the `v_mov_b32` / `v_add_nc_u32` walks in `resource.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 checks `range.rs` `op_hi` already 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](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:52 UTC · original

Code review and RTX 5090 + WARP + DXIL verification at head 98017a5eb007 merged cleanly onto main (63bcca43c6a0):

  • Code review:
    • Checking abs == 0 && neg == 0 && !clamp && omod == 0 (plus dpp/sdwa where applicable) in io.rs:583-590 (Halves::joined), resource.rs:742-747 (Tracer::vadd), resource.rs:770-775 (Tracer::vorigin), and resource.rs:1559-1564 (Tracer::vstep) closes the modifier-blind address/barycentric tracking cases cleanly. (Also verified clean merge with #2923.)
    • Non-blocking follow-up note: Tracer::carried (resource.rs:999-1017) matches Fields::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() (per gfx10/fields.rs:589,671, VOP3B v_add_co_ci_u32 supports clamp/omod, and VOP2 supports sdwa/dpp). Worth tightening either here or in a follow-up.
  • Verified (Windows 11, NVIDIA RTX 5090 + WARP, dxil.dll 10.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 warnings
    • io::tests: 5/5; resource::tests: 36/36 (including both new modifier tests)
    • emit::tests (17/17) and emit::semantics_tests (34/34, 1 ignored): passed on both RTX 5090 and WARP.

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2492#issuecomment-7179204400) Code review and RTX 5090 + WARP + DXIL verification at head `98017a5eb007` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review**: - Checking `abs == 0 && neg == 0 && !clamp && omod == 0` (plus `dpp`/`sdwa` where applicable) in `io.rs:583-590` (`Halves::joined`), `resource.rs:742-747` (`Tracer::vadd`), `resource.rs:770-775` (`Tracer::vorigin`), and `resource.rs:1559-1564` (`Tracer::vstep`) closes the modifier-blind address/barycentric tracking cases cleanly. (Also verified clean merge with `#2923`.) - Non-blocking follow-up note: `Tracer::carried` (`resource.rs:999-1017`) matches `Fields::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()` (per `gfx10/fields.rs:589,671`, VOP3B `v_add_co_ci_u32` supports `clamp`/`omod`, and VOP2 supports `sdwa`/`dpp`). Worth tightening either here or in a follow-up. - **Verified (Windows 11, NVIDIA RTX 5090 + WARP, `dxil.dll` 10.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 warnings - `io::tests`: 5/5; `resource::tests`: 36/36 (including both new modifier tests) - `emit::tests` (17/17) and `emit::semantics_tests` (34/34, 1 ignored): passed on both RTX 5090 and WARP. LGTM.
Author
Owner

@⁠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:

  • Rejecting VALU float/clamp modifiers in I/O and resource analyses prevents treating modified copies/adds as plain barycentric or address ops.
  • cargo test -p victory-shader resource::tests: 34/34 passed (including clamped_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 (including modified_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).

**@⁠DenRakEiw** on GitHub · 2026-11-25 14:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2492#pullrequestreview-6060003036) · **approved these changes** Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Rejecting VALU float/clamp modifiers in I/O and resource analyses prevents treating modified copies/adds as plain barycentric or address ops. - `cargo test -p victory-shader resource::tests`: 34/34 passed (including `clamped_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 (including `modified_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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 13:54 UTC · original · approved these changes

The new clamp and omod guards 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): matches v_add_co_ci_u32 without rejecting sdwa, dpp, clamp, abs, neg, or omod, even though SDWA/DPP/clamped forms can change the high dword while still referencing the root descriptor's high word in src[..2].
  • FP16 interpolation (io.rs:387-401, 515-535): accepts modified v_interp_p1ll_f16 (e.g., an intermediate P1 clamp or input abs/neg), which lowering drops when fusing P1 and P2 and applying only P2's output modifiers.

Local verification on commit 98017a5eb007 (and cleanly merged onto origin/main tree 15c737a3, emit/lower.rs unchanged at 520,563 B): cargo run --locked -p xtask -- policy (182 files ok), cargo clippy -p victory-shader --all-targets (default and --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), and emit::waterfall_tests (5 passed) on both RTX 5090 and VICTORY_WARP=1 all pass. Approving.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 13:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2492#pullrequestreview-6075325153) · **approved these changes** The new `clamp` and `omod` guards 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`):** matches `v_add_co_ci_u32` without rejecting `sdwa`, `dpp`, `clamp`, `abs`, `neg`, or `omod`, even though SDWA/DPP/clamped forms can change the high dword while still referencing the root descriptor's high word in `src[..2]`. - **FP16 interpolation (`io.rs:387-401, 515-535`):** accepts modified `v_interp_p1ll_f16` (e.g., an intermediate P1 `clamp` or input `abs`/`neg`), which lowering drops when fusing P1 and P2 and applying only P2's output modifiers. Local verification on commit `98017a5eb007` (and cleanly merged onto `origin/main` tree `15c737a3`, `emit/lower.rs` unchanged at `520,563 B`): `cargo run --locked -p xtask -- policy` (182 files ok), `cargo clippy -p victory-shader --all-targets` (`default` and `--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), and `emit::waterfall_tests` (5 passed) on both RTX 5090 and `VICTORY_WARP=1` all pass. Approving.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2492/head:github-bot/gh-2492'
git switch 'github-bot/gh-2492'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2492'
git switch 'github-bot/gh-2492'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2492'
git switch 'github-bot/gh-2492'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2492'
git switch 'main'
git merge --squash 'github-bot/gh-2492'
git switch 'main'
git merge --ff-only 'github-bot/gh-2492'
git switch 'main'
git merge 'github-bot/gh-2492'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2492
No description provided.