Shaders: v_pk_fmac_f16 multiplies the DPP-selected lane #2264

Closed
Calvix2k wants to merge 2 commits from upstream-pr/2266 into main
Calvix2k commented 2026-11-25 09:22:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T09:22:24Z.


Fixes #2228.

Problem

Lower::valu computes the source 0 a DPP16/DPP8 instruction selects and stores it in self.src0; the source readers (fsrc, src, half_src, v_cndmask_b32) take it from there. Lower::fmac_half called self.operand(inst, &op) directly, so v_pk_fmac_f16 with DPP multiplied the executing lane's own src0 for both packed halves — the cross-lane value was dropped although the DPP lane read was emitted.

Change

fmac_half uses self.src0 for source 0 when it is set, like the other readers; the high-half extraction and the 16-bit arithmetic around it are unchanged.

Verification

GPU test packed_fmac_multiplies_the_dpp_selected_lane: a v_pk_fmac_f16 with row_shr:1 and bound_ctrl, where lane 0's shifted source is out of its row, so the DPP source is zero and the product is 0 * 2.0. With the old read the result is 2.0 * 2.0. Skipped on this host (no SM 6.6 device; #1991 is not in this branch) and executed in CI.

cargo clippy -p victory-shader --all-targets -- -D warnings clean, cargo xtask policy 2 files ok. The rest of the suite here still shows the known no-device environment failures.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601240348 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T09:22:24Z. --- Fixes #2228. ## Problem `Lower::valu` computes the source 0 a DPP16/DPP8 instruction selects and stores it in `self.src0`; the source readers (`fsrc`, `src`, `half_src`, `v_cndmask_b32`) take it from there. `Lower::fmac_half` called `self.operand(inst, &op)` directly, so `v_pk_fmac_f16` with DPP multiplied the executing lane's own src0 for both packed halves — the cross-lane value was dropped although the DPP lane read was emitted. ## Change `fmac_half` uses `self.src0` for source 0 when it is set, like the other readers; the high-half extraction and the 16-bit arithmetic around it are unchanged. ## Verification GPU test `packed_fmac_multiplies_the_dpp_selected_lane`: a `v_pk_fmac_f16` with `row_shr:1` and `bound_ctrl`, where lane 0's shifted source is out of its row, so the DPP source is zero and the product is `0 * 2.0`. With the old read the result is `2.0 * 2.0`. Skipped on this host (no SM 6.6 device; #1991 is not in this branch) and executed in CI. `cargo clippy -p victory-shader --all-targets -- -D warnings` clean, `cargo xtask policy` 2 files ok. The rest of the suite here still shows the known no-device environment failures.
DenRakEiw commented 2026-11-25 10:07:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T09:42:30Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib packed_fmac_multiplies_the_dpp_selected_lane — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix reading the DPP-selected lane in v_pk_fmac_f16, verified on hardware and WARP. (Note for triage: overlaps #2229.)

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055166967 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#pullrequestreview-6055166967). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T09:42:30Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib packed_fmac_multiplies_the_dpp_selected_lane` — passed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean fix reading the DPP-selected lane in `v_pk_fmac_f16`, verified on hardware and WARP. (Note for triage: overlaps #2229.) AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 10:07:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:43:12Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — v_pk_fmac_f16 with DPP now multiplies the DPP-selected lane's src0 (follow-up to #2229). The new test is hardware-gated (needs an SM 6.6 device) so it no-ops here; lowering compiles and the suite stays green on macOS.

<!-- greyfinch-sync:Marvisak/VIctory:review:6055176619 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#pullrequestreview-6055176619). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:43:12Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — v_pk_fmac_f16 with DPP now multiplies the DPP-selected lane's src0 (follow-up to #2229). The new test is hardware-gated (needs an SM 6.6 device) so it no-ops here; lowering compiles and the suite stays green on macOS.
Calvix2k commented 2026-11-25 11:05:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T10:09:55Z.


Hardware run of the DPP case on an RX 7800 XT (RDNA3), Windows 10 19045 with SM 6.6 via the Agility runtime for the test binaries (#486): packed_fmac_multiplies_the_dpp_selected_lane passes on the card.

That closes the half CI could not cover: with the fix, lane 0's row_shr:1 source is the bound-control zero and the product is 0; without it the same program computes 2.0 * 2.0. The WARP skip stays as stated (WARP refuses a pipeline for this program here too).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159313654 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#issuecomment-7159313654). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T10:09:55Z. --- Hardware run of the DPP case on an **RX 7800 XT (RDNA3), Windows 10 19045** with SM 6.6 via the Agility runtime for the test binaries (#486): `packed_fmac_multiplies_the_dpp_selected_lane` **passes** on the card. That closes the half CI could not cover: with the fix, lane 0's `row_shr:1` source is the bound-control zero and the product is 0; without it the same program computes `2.0 * 2.0`. The WARP skip stays as stated (WARP refuses a pipeline for this program here too).
sinan-cmyk commented 2026-11-25 11:05:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T10:25:21Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 1483d373 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,917 on main, 23,917 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159672431 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#issuecomment-7159672431). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T10:25:21Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 1483d373 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,917 on `main`, 23,917 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Calvix2k commented 2026-11-25 13:02:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T12:19:56Z.


That measurement is the right one for what this PR is, and no count change is the expected result: the fix does not make a program translate that did not — it changes a value the translated program emits. v_pk_fmac_f16 with DPP was reading self.src0 (the executing lane's own operand) instead of the lane the DPP selected, so the same programs translated before and after and only their output differs.

So 25,889 programs with 23,917 validated on both heads is exactly the "rejects nothing" evidence I want on record, and the value itself is checked where it can be: a_dpp_packed_fmac_reads_the_lane_the_dpp_selects runs the instruction on the card (RX 7800 XT, and the PR reports the RTX too) against the DPP selector's lane.

Thanks for running it — with the metric stated as narrowly as you stated it, it is a useful data point rather than a misleading one.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162229960 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#issuecomment-7162229960). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T12:19:56Z. --- That measurement is the right one for what this PR is, and no count change is the expected result: the fix does not make a program translate that did not — it changes a *value* the translated program emits. `v_pk_fmac_f16` with DPP was reading `self.src0` (the executing lane's own operand) instead of the lane the DPP selected, so the same programs translated before and after and only their output differs. So 25,889 programs with 23,917 validated on both heads is exactly the "rejects nothing" evidence I want on record, and the value itself is checked where it can be: `a_dpp_packed_fmac_reads_the_lane_the_dpp_selects` runs the instruction on the card (RX 7800 XT, and the PR reports the RTX too) against the DPP selector's lane. Thanks for running it — with the metric stated as narrowly as you stated it, it is a useful data point rather than a misleading one.
Marvisak commented 2026-11-25 14:07:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:31:39Z.


Automated triage for the maintainers.

Merge candidate (worth a look; small). fmac_half in emit/lower.rs read source 0 with self.operand, ignoring the DPP-selected value valu stores in self.src0, which src, fsrc and half_src already use. It now takes self.src0 for k == 0 the same way. The new hardware test (row_shr:1 + bound_ctrl, expecting 0 rather than 2.0*2.0) is reported passing on an RX 7800 XT; CI check passes, though WARP skips the test. Nit: valu_tests.rs now ends without a trailing newline.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163905109 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#issuecomment-7163905109). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:31:39Z. --- <!-- victory-triage v1 head=1483d373052428c90903b5e87c1a486f48cc32a7 verdict=merge-candidate at=2026-11-25T13:45:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look; small).** `fmac_half` in `emit/lower.rs` read source 0 with `self.operand`, ignoring the DPP-selected value `valu` stores in `self.src0`, which `src`, `fsrc` and `half_src` already use. It now takes `self.src0` for `k == 0` the same way. The new hardware test (`row_shr:1` + `bound_ctrl`, expecting 0 rather than 2.0*2.0) is reported passing on an RX 7800 XT; CI `check` passes, though WARP skips the test. Nit: `valu_tests.rs` now ends without a trailing newline. --- _Generated by [Claude Code](https://claude.ai/code)_
rminzao commented 2026-11-25 15:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rminzao on 2026-11-25T14:53:53Z.


Same one-line fix as #2229, which was opened about an hour earlier, so one of the two can be closed. The fix is the same in both; I ran each PR's test on the three devices of a hybrid laptop:

Test Intel UHD (16-lane waves) RTX 4050 Laptop (595.97) WARP
#2229 packed_fmac_dpp_reads_the_swizzled_lane, with the fix pass pass pass
#2229, on main's lower.rs fails (own-lane product) fails (own-lane product) —
#2266 packed_fmac_multiplies_the_dpp_selected_lane, with the fix panics: compute_pipeline failed: The parameter is incorrect pass panics, same error
#2266, on main's lower.rs panics (same) fails (0x44004400: 2.0 × 2.0 in both halves) —

The test's own comment expects WARP to refuse the pipeline, but it only skips when Host::new fails, so it fails instead of skipping on WARP (VICTORY_WARP=1) and on any host whose waves are narrower than 32 lanes. row_shr is a cross-lane op, so the compute program declares the console's wave of 32. #2229 uses a quad permute in a pixel shader, which runs at any wave size, so it checks the fix on every device here.

Checked on Windows 11 against heads 754e60e (#2229) and 1483d37 (#2266). AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7165986589 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#issuecomment-7165986589). Originally posted by [rminzao](https://github.com/rminzao) on 2026-11-25T14:53:53Z. --- Same one-line fix as #2229, which was opened about an hour earlier, so one of the two can be closed. The fix is the same in both; I ran each PR's test on the three devices of a hybrid laptop: | Test | Intel UHD (16-lane waves) | RTX 4050 Laptop (595.97) | WARP | |---|---|---|---| | #2229 `packed_fmac_dpp_reads_the_swizzled_lane`, with the fix | pass | pass | pass | | #2229, on `main`'s `lower.rs` | fails (own-lane product) | fails (own-lane product) | — | | #2266 `packed_fmac_multiplies_the_dpp_selected_lane`, with the fix | **panics**: `compute_pipeline failed: The parameter is incorrect` | pass | **panics**, same error | | #2266, on `main`'s `lower.rs` | panics (same) | fails (`0x44004400`: 2.0 × 2.0 in both halves) | — | The test's own comment expects WARP to refuse the pipeline, but it only skips when `Host::new` fails, so it fails instead of skipping on WARP (`VICTORY_WARP=1`) and on any host whose waves are narrower than 32 lanes. `row_shr` is a cross-lane op, so the compute program declares the console's wave of 32. #2229 uses a quad permute in a pixel shader, which runs at any wave size, so it checks the fix on every device here. _Checked on Windows 11 against heads 754e60e (#2229) and 1483d37 (#2266). AI-assisted._
upstream-sync closed this pull request 2026-11-25 17:03:47 +00:00
Calvix2k commented 2026-11-25 17:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T16:35:07Z.


Closing in favour of #2229, which is the earlier PR for #2228 and is the better-tested one: rminzao's table shows it passing on Intel UHD (16-lane waves), the RTX 4050 and WARP, with the same one-line fix, while this PR's test panics on any host whose waves are narrower than 32 (the compute program declares the console's wave). The test here could be fixed, but there is no reason for two PRs for the same line; #2229 carries it.

Thanks for the three-device run — it is exactly the comparison that settles it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168214369 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#issuecomment-7168214369). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T16:35:07Z. --- Closing in favour of #2229, which is the earlier PR for #2228 and is the better-tested one: rminzao's table shows it passing on Intel UHD (16-lane waves), the RTX 4050 and WARP, with the same one-line fix, while this PR's test panics on any host whose waves are narrower than 32 (the compute program declares the console's wave). The test here could be fixed, but there is no reason for two PRs for the same line; #2229 carries it. Thanks for the three-device run — it is exactly the comparison that settles it.
fyernald commented 2026-11-25 18:01:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-25T17:33:05Z.

Review: COMMENTED


Tested on RTX 3080 (617.42), Windows 10 (19045) plus WARP, main 67e8ae1 + #486 + #2596 (the suite crashes on NVIDIA without #2596, #2571). cargo test -p victory-shader --lib --locked -- --test-threads=1: 268 passed, 3 failed (the #1835 ones, also on the base). packed_fmac_multiplies_the_dpp_selected_lane passes.

This is the same change as #2229, which was opened an hour earlier: self.src0 for k == 0 in the packed-operand read. Only one of the two should land, and #2229 has the larger test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6062132733 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2266#pullrequestreview-6062132733). Originally posted by [fyernald](https://github.com/fyernald) on 2026-11-25T17:33:05Z. **Review:** COMMENTED --- Tested on **RTX 3080 (617.42), Windows 10 (19045)** plus WARP, `main` `67e8ae1` + #486 + #2596 (the suite crashes on NVIDIA without #2596, #2571). `cargo test -p victory-shader --lib --locked -- --test-threads=1`: 268 passed, 3 failed (the #1835 ones, also on the base). `packed_fmac_multiplies_the_dpp_selected_lane` passes. This is the same change as #2229, which was opened an hour earlier: `self.src0` for `k == 0` in the packed-operand read. Only one of the two should land, and #2229 has the larger test.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2264
No description provided.