Repository navigation
Read VCCZ after scalar writes to VCC - #3759
Draft
xiepeixuan wants to merge 2 commits into
Draft
xiepeixuan wants to merge 2 commits into
xiepeixuan wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.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.177fbbb0d3b9038503b231c95848d28e247188e9: regression exit 0; Linux suite 296 passed, 0 failed, 2 ignored. Restoring only the original emitter reproduces the original refusal, exit 101.cargo check --workspace --lockedpassed 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.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, andone_console_wave_divergent_loop_wave_ops_widen_for_one_and_two_block_loops.unwind_copy, two unused imports, argument count, unchanged loop condition). Nothing unrelated was changed.frame_users.rs; checking only the three changed files passes:asset policy: 3 files ok.unwind_copydead-code diagnostic present on pristine main; subsequent steps were skipped.cargo testpassed for the touched crate: yes on Linux; Windows has the explicitly listed baseline failures.Checked for overlap
Lower::operandand SCC address tracking; it does not implement VCCZ. Shaders: a folded program takes every branch on a lane mask wave-wide #3440, shader: lane_uniform no longer calls lane-dependent results alike #2389 and Shaders: a skip around a loop stays only where lanes reach the scalars (#1914) #1952 concern branch/wave uniformity, not operand 251.Uses audit and cost
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.