Shaders: in the console flow, a lane-mask join takes no lane from an edge that brings a descriptor's address or format (on #439) #3830

Open
redNSF wants to merge 85 commits from upstream-pr/3830 into main
redNSF commented 2026-11-29 12:08:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by redNSF on 2026-11-29T12:08:39Z.


Stacked on #439 (the console flow in halves); the last commit is this change. It needs nothing from #3683 and merges with it without conflicts.

Problem. Ten rtdirectionalshadows:CS_RTShadowTrace32HQ* programs (wave32, 32 threads) read a named lane under the lanes' own branches, so they take the console flow on every host. There they stop with "a descriptor's address or format read as data". Nothing in them reads a descriptor's address: the console compiler reuses a register. In CS_RTShadowTrace32HQ:

010764  s_load_dwordx8 s[16:23], s[4:5], 0x540   ; an image's descriptor
015064  s_cbranch_execz label_15144              ; after s_and_saveexec_b32 s12, s78
0150d4    v_cmp_ne_u32 s16, s3, 0                ; s16 is now a lane mask
015144  s_mov_b32 exec_lo, s12                   ; join: the mask, or what s16 held before
0151a8  s_cbranch_execz label_15204              ; after s_and_saveexec_b32 s0, s78
0151cc    v_cndmask_b32 v9, 1.0, 0, s16          ; read under the same guard

The join at 0x15144 is a lane-mask join, and so are the joins before it that pass the old s16 along; the one at 0x11294 takes the descriptor's first dword. In the console flow a lane-mask join takes a number along an edge as the lane's own bit of it (Structured::other), and that dword has no host value (descriptor_data leaves addresses and formats missing), so the program was refused.

Change. In fill_phis, in the console flow, an edge of a lane-mask join whose value is such a missing descriptor dword gives the join no lane. This is an assumption, marked shortcut: in the code: a descriptor's address or format bits are not a lane mask the title's code reads; a register holds them at a mask join only because the compiler reused it. A program that really tested lanes against those bits would now see no lane along that edge. (#1597 makes the same assumption for joins of descriptor dwords with data in the per-lane form; this is not that change and does not need it.) The per-lane form is untouched, and so is every program that translated before: the edge was refused until now.

Effect. Grand Theft Auto VI, translate --list, compared program by program: compute programs that translate go from 2,593 (#439) to 2,603 of 2,682 with --host-lanes 32-32, and from 2,658 to 2,668 with default lanes. The same ten are gained in both and none are lost: CS_RTShadowTrace32HQ, TemporalHQ and TemporalHQ_OneOver2RPP with their FarOnly forms, and HQ and TemporalHQ in _Tiled and _TiledFarOnly. Three programs of the family stay refused for other reasons ("a lane mask read as data" twice, "a constant buffer's descriptor read as data" once).

With --validate on #439 alone the ten are emitted but not validated: the SDK validator here rejects them for the implicit-level sample in compute ("Entry function performs some operation that is incompatible with the shader stage"), as it does 735 other compute programs on #439, the family's 1/4-rate forms among them. Merged with #2999 and #3735 (which make those samples explicit) all ten validate, as do all 2,615 compute programs that translate there.

Tests (RTX 3060, 32-lane waves only):

  • New a_compare_mask_joined_with_a_descriptor_dword_in_the_console_flow (waterfall_tests): a wave32 program with the title's shape. A buffer's descriptor is loaded into s[8:11] and used; under s_and_saveexec and s_cbranch_execz a v_cmp_ne_u32 writes s8; a v_cndmask_b32 reads s8 under the same guard later; a v_readlane_b32 asks for the console flow. Refused before with the title's reason; exact on the card, all 32 lanes (the lanes under the guard take the compare's value, the others keep theirs). Skipped on adapters without 32-lane waves (WARP).
  • cargo test -p victory-shader --lib on WARP: the same 4 synthetic_tests fail here as on #439 alone.

Not run in the title: this PR claims that the ten programs translate, and that the join behaves as the test checks on this card.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5550554974 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3830). Originally posted by [redNSF](https://github.com/redNSF) on 2026-11-29T12:08:39Z. --- Stacked on #439 (the console flow in halves); the last commit is this change. It needs nothing from #3683 and merges with it without conflicts. **Problem.** Ten `rtdirectionalshadows:CS_RTShadowTrace32HQ*` programs (wave32, 32 threads) read a named lane under the lanes' own branches, so they take the console flow on every host. There they stop with "a descriptor's address or format read as data". Nothing in them reads a descriptor's address: the console compiler reuses a register. In `CS_RTShadowTrace32HQ`: ``` 010764 s_load_dwordx8 s[16:23], s[4:5], 0x540 ; an image's descriptor 015064 s_cbranch_execz label_15144 ; after s_and_saveexec_b32 s12, s78 0150d4 v_cmp_ne_u32 s16, s3, 0 ; s16 is now a lane mask 015144 s_mov_b32 exec_lo, s12 ; join: the mask, or what s16 held before 0151a8 s_cbranch_execz label_15204 ; after s_and_saveexec_b32 s0, s78 0151cc v_cndmask_b32 v9, 1.0, 0, s16 ; read under the same guard ``` The join at 0x15144 is a lane-mask join, and so are the joins before it that pass the old s16 along; the one at 0x11294 takes the descriptor's first dword. In the console flow a lane-mask join takes a number along an edge as the lane's own bit of it (`Structured::other`), and that dword has no host value (`descriptor_data` leaves addresses and formats missing), so the program was refused. **Change.** In `fill_phis`, in the console flow, an edge of a lane-mask join whose value is such a missing descriptor dword gives the join no lane. This is an assumption, marked `shortcut:` in the code: a descriptor's address or format bits are not a lane mask the title's code reads; a register holds them at a mask join only because the compiler reused it. A program that really tested lanes against those bits would now see no lane along that edge. (#1597 makes the same assumption for joins of descriptor dwords with data in the per-lane form; this is not that change and does not need it.) The per-lane form is untouched, and so is every program that translated before: the edge was refused until now. **Effect.** Grand Theft Auto VI, `translate --list`, compared program by program: compute programs that translate go from 2,593 (#439) to 2,603 of 2,682 with `--host-lanes 32-32`, and from 2,658 to 2,668 with default lanes. The same ten are gained in both and none are lost: `CS_RTShadowTrace32HQ`, `TemporalHQ` and `TemporalHQ_OneOver2RPP` with their `FarOnly` forms, and `HQ` and `TemporalHQ` in `_Tiled` and `_TiledFarOnly`. Three programs of the family stay refused for other reasons ("a lane mask read as data" twice, "a constant buffer's descriptor read as data" once). With `--validate` on #439 alone the ten are emitted but not validated: the SDK validator here rejects them for the implicit-level `sample` in compute ("Entry function performs some operation that is incompatible with the shader stage"), as it does 735 other compute programs on #439, the family's 1/4-rate forms among them. Merged with #2999 and #3735 (which make those samples explicit) all ten validate, as do all 2,615 compute programs that translate there. **Tests** (RTX 3060, 32-lane waves only): - New `a_compare_mask_joined_with_a_descriptor_dword_in_the_console_flow` (`waterfall_tests`): a wave32 program with the title's shape. A buffer's descriptor is loaded into s[8:11] and used; under `s_and_saveexec` and `s_cbranch_execz` a `v_cmp_ne_u32` writes s8; a `v_cndmask_b32` reads s8 under the same guard later; a `v_readlane_b32` asks for the console flow. Refused before with the title's reason; exact on the card, all 32 lanes (the lanes under the guard take the compare's value, the others keep theirs). Skipped on adapters without 32-lane waves (WARP). - `cargo test -p victory-shader --lib` on WARP: the same 4 `synthetic_tests` fail here as on #439 alone. Not run in the title: this PR claims that the ten programs translate, and that the join behaves as the test checks on this card.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3830:upstream-pr/3830'
git switch 'upstream-pr/3830'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3830'
git switch 'upstream-pr/3830'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3830'
git switch 'upstream-pr/3830'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3830'
git switch 'main'
git merge --squash 'upstream-pr/3830'
git switch 'main'
git merge --ff-only 'upstream-pr/3830'
git switch 'main'
git merge 'upstream-pr/3830'
git push origin 'main'
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!3830
No description provided.