Skip to content

Read VCCZ after scalar writes to VCC - #3759

Draft
xiepeixuan wants to merge 2 commits into
trustno1-coder:mainfrom
xiepeixuan:auto/scalar-vccz
Draft

xiepeixuan wants to merge 2 commits into
trustno1-coder:mainfrom
xiepeixuan:auto/scalar-vccz

Conversation

@xiepeixuan

@xiepeixuan xiepeixuan commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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

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-actions github-actions Bot added pr-fix Pull request: fixes a bug shaders Shader translation, preload or pipeline building labels Nov 30, 2026
@github-actions github-actions Bot changed the title [pr-fix][shader] Read VCCZ after scalar writes to VCC Read VCCZ after scalar writes to VCC Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-fix Pull request: fixes a bug shaders Shader translation, preload or pipeline building

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant