Read VCCZ after scalar writes to VCC #3759

Open
github-bot wants to merge 2 commits from github-bot/gh-3759 into main AGit
Owner

@⁠xiepeixuan on GitHub · 2026-11-30 06:07 UTC · original
xiepeixuan:auto/scalar-vccz → main · +60 −1 · 3 files · 2 commits · draft

Refs #1138 (triage map) and #2487 (the distinct SCC special-source/address-tracking change). No matching game issue identified.

What it changes

A shader can write VCC as scalar data, then read the scalar source src_vccz (251). The IR already records the VCC dwords read, but the emitter rejected the source when its value became live.

AMD RDNA 2 ISA, section 3.9: “VCCZ is updated every time VCC is updated: vector compares and scalar writes to VCC.” The same section specifies that only the low VCC dword contributes in Wave32. Both dwords contribute in Wave64. Section 5.2, Table 10 defines source code 251.

The new operand arm reads the available scalar VCC dword(s), compares with zero, and zero-extends the boolean to i32. It deliberately leaves tracked per-lane-mask dwords unsupported: a partial host ballot must not be substituted for the entire guest wave.

Expected effect on NVIDIA

Tier A: shader refusal. A shader that restores a numeric VCC mask and consumes its summary in a live compare can now translate. Previously the translation was refused. A missing draw or dispatch is a possible player-visible consequence; it is not measured in the game, and no particular game's shader has been identified here. This is a translator omission, not a WARP or floating-point precision difference.

How it was tested

  • GPU/profile: none; unit tests only, synthetic GFX10 words and the existing DXIL evaluator. No game assets or hardware-output oracle.
  • Regression: scalar_compare_reads_vccz_at_the_console_wave_width; four dynamic VCC-dword pairs each in Wave32 and Wave64. With only bit 63 set, the stored answer must be 1 in Wave32 and 0 in Wave64.
  • Unchanged main + test: Unsupported { offset: 44, what: "a special operand (vccz, execz, scc, lds_direct)" }; regression exit 101. Pristine main Linux suite: 295 passed, 0 failed, 2 ignored.
  • Exact fix 177fbbb0d3b9038503b231c95848d28e247188e9: regression exit 0; Linux suite 296 passed, 0 failed, 2 ignored. Restoring only the original emitter reproduces the original refusal, exit 101.
  • Windows, pristine main / exact fix: cargo check --workspace --locked passed on both. Unfiltered shader tests: 457 / 458 passed, with the same five failures and 9 ignored. Excluding only those five baseline failures gives 458 passed, 0 failed, 9 ignored, exit 0, on the fix.
  • The five unchanged Windows failures are flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, cs_sort_ray_tiles_divergent_loop_atomics_stay_wave32_with_fence_only, nv05d1_native_readlane_gpu_reference, one_console_wave_divergent_loop_lds_widens_for_one_and_two_block_loops, and one_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops.
  • Strict default Clippy: exit 101 on both exact sources, with identical primary diagnostics (unwind_copy, two unused imports, argument count, unchanged loop condition). Nothing unrelated was changed.
  • All-features Clippy and asset-policy comparison: strict all-features Clippy exits 101 with identical primary diagnostics on base and fix. Full-tree asset policy exits 1 on both, with identical output for the unchanged frame_users.rs; checking only the three changed files passes: asset policy: 3 files ok.
  • Upstream CI stopped at the same unwind_copy dead-code diagnostic present on pristine main; subsequent steps were skipped.
  • cargo test passed for the touched crate: yes on Linux; Windows has the explicitly listed baseline failures.

Checked for overlap

  • Read #1138 and its comments; searched recent 900 PR records including titles, bodies and files, all open PRs, and older PR metadata. Final repeated search: 900 recent PRs, 777 open PRs, all 1679 PR titles/bodies; 94 open PRs touching the audited files; same-function changes remain #2487, #1972, #2676, #3389 and #3566. Read the open diffs touching the modified functions.
  • #2487 changes the fallback diagnostic in Lower::operand and SCC address tracking; it does not implement VCCZ. #3440, #2389 and #1952 concern branch/wave uniformity, not operand 251.
  • #1972, #2676, #3389 and #3566 extend the test-only evaluator for other regressions. Their production fixes are distinct; the shared evaluator additions may need mechanical merging.
  • Source 1's candidate Marvisak/VIctory#1221 was not ported: #831 already has the same uniform-mask logic for a narrower path. This PR does not include that candidate.

Uses audit and cost

  • All direct callers of the dword reader were checked: scalar ALU sources; vector/modifier, mixed and packed sources; interpolation; the 64-bit fallback; and scalar memory/descriptor/buffer offsets. Behaviour changes only if a decoded source 251 reaches the reader with available scalar VCC data. Destination-register reads and every other source encoding are unchanged.
  • Wide SALU instructions with a separately unsupported high-half path, wave folding, tracked-mask paths and VCCZ branches retain their existing handling. There is no claim of general support for all VCC producers.
  • The shader-source fingerprint already covers the lowering edit; no switch or cache-key change.
  • Cost before DXIL optimisation: 2 integer instructions in Wave32 (zero comparison and zero extension); 3 in Wave64 (also one OR). No wave operation or shared memory.

Opened as a draft early so others know this is being worked on (README: 'Opening a draft pull request early works too').

AI-assisted (Codex). Not run in the game.

**@⁠xiepeixuan** on GitHub · 2026-11-30 06:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3759) `xiepeixuan:auto/scalar-vccz` → `main` · +60 −1 · 3 files · 2 commits · draft Refs #1138 (triage map) and #2487 (the distinct SCC special-source/address-tracking change). No matching game issue identified. ## What it changes A shader can write VCC as scalar data, then read the scalar source `src_vccz` (251). The IR already records the VCC dwords read, but the emitter rejected the source when its value became live. [AMD RDNA 2 ISA, section 3.9](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf): “VCCZ is updated every time VCC is updated: vector compares and scalar writes to VCC.” The same section specifies that only the low VCC dword contributes in Wave32. Both dwords contribute in Wave64. Section 5.2, Table 10 defines source code 251. The new operand arm reads the available scalar VCC dword(s), compares with zero, and zero-extends the boolean to i32. It deliberately leaves tracked per-lane-mask dwords unsupported: a partial host ballot must not be substituted for the entire guest wave. ## Expected effect on NVIDIA **Tier A: shader refusal.** A shader that restores a numeric VCC mask and consumes its summary in a live compare can now translate. Previously the translation was refused. A missing draw or dispatch is a possible player-visible consequence; it is **not measured in the game**, and no particular game's shader has been identified here. This is a translator omission, not a WARP or floating-point precision difference. ## How it was tested - GPU/profile: **none; unit tests only**, synthetic GFX10 words and the existing DXIL evaluator. No game assets or hardware-output oracle. - Regression: `scalar_compare_reads_vccz_at_the_console_wave_width`; four dynamic VCC-dword pairs each in **Wave32 and Wave64**. With only bit 63 set, the stored answer must be 1 in Wave32 and 0 in Wave64. - [Unchanged main + test](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46362488016/job/141660556089): `Unsupported { offset: 44, what: "a special operand (vccz, execz, scc, lds_direct)" }`; regression exit **101**. Pristine main Linux suite: **295 passed, 0 failed, 2 ignored**. - [Exact fix `177fbbb0d3b9038503b231c95848d28e247188e9`](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46362701565/job/141661236258): regression exit **0**; Linux suite **296 passed, 0 failed, 2 ignored**. Restoring only the original emitter reproduces the original refusal, exit **101**. - Windows, [pristine main](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46362488016/job/141660556478) / [exact fix](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46362701565/job/141661236486): `cargo check --workspace --locked` passed on both. Unfiltered shader tests: **457 / 458 passed**, with the **same five failures** and 9 ignored. Excluding only those five baseline failures gives **458 passed, 0 failed, 9 ignored**, exit 0, on the fix. - The five unchanged Windows failures are `flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves`, `cs_sort_ray_tiles_divergent_loop_atomics_stay_wave32_with_fence_only`, `nv05d1_native_readlane_gpu_reference`, `one_console_wave_divergent_loop_lds_widens_for_one_and_two_block_loops`, and `one_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops`. - Strict default Clippy: exit 101 on both exact sources, with identical primary diagnostics (`unwind_copy`, two unused imports, argument count, unchanged loop condition). Nothing unrelated was changed. - [All-features Clippy and asset-policy comparison](https://github.com/xiepeixuan/VIctory-NVIDIA/actions/runs/46364293662/job/141666278776): strict all-features Clippy exits 101 with identical primary diagnostics on base and fix. Full-tree asset policy exits 1 on both, with identical output for the unchanged `frame_users.rs`; checking only the three changed files passes: `asset policy: 3 files ok`. - [Upstream CI](https://github.com/trustno1-coder/VIctory-NVIDIA/actions/runs/46364170602/job/141665882378) stopped at the same `unwind_copy` dead-code diagnostic present on pristine main; subsequent steps were skipped. - `cargo test` passed for the touched crate: **yes on Linux**; Windows has the explicitly listed baseline failures. ## Checked for overlap - [x] Read #1138 and its comments; searched recent 900 PR records including titles, bodies and files, all open PRs, and older PR metadata. Final repeated search: 900 recent PRs, 777 open PRs, all 1679 PR titles/bodies; 94 open PRs touching the audited files; same-function changes remain #2487, #1972, #2676, #3389 and #3566. Read the open diffs touching the modified functions. - #2487 changes the fallback diagnostic in `Lower::operand` and SCC address tracking; it does not implement VCCZ. #3440, #2389 and #1952 concern branch/wave uniformity, not operand 251. - #1972, #2676, #3389 and #3566 extend the test-only evaluator for other regressions. Their production fixes are distinct; the shared evaluator additions may need mechanical merging. - Source 1's candidate Marvisak/VIctory#1221 was **not ported**: #831 already has the same uniform-mask logic for a narrower path. This PR does not include that candidate. ### Uses audit and cost - All direct callers of the dword reader were checked: scalar ALU sources; vector/modifier, mixed and packed sources; interpolation; the 64-bit fallback; and scalar memory/descriptor/buffer offsets. Behaviour changes only if a decoded source 251 reaches the reader with available scalar VCC data. Destination-register reads and every other source encoding are unchanged. - Wide SALU instructions with a separately unsupported high-half path, wave folding, tracked-mask paths and VCCZ branches retain their existing handling. There is no claim of general support for all VCC producers. - The shader-source fingerprint already covers the lowering edit; no switch or cache-key change. - Cost before DXIL optimisation: **2 integer instructions in Wave32** (zero comparison and zero extension); **3 in Wave64** (also one OR). No wave operation or shared memory. Opened as a draft early so others know this is being worked on (README: 'Opening a draft pull request early works too'). AI-assisted (Codex). Not run in the game.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 06:08:14 +00:00
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/3759/head:github-bot/gh-3759'
git switch 'github-bot/gh-3759'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3759'
git switch 'github-bot/gh-3759'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3759'
git switch 'github-bot/gh-3759'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3759'
git switch 'main'
git merge --squash 'github-bot/gh-3759'
git switch 'main'
git merge --ff-only 'github-bot/gh-3759'
git switch 'main'
git merge 'github-bot/gh-3759'
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/trustno1-coder--VIctory-NVIDIA!3759
No description provided.