[GH #2268] Shaders: three user-data corrections clear the last address class (195 -> 0), and mask reuse exposes the real gap (298 -> 98 failures on 940d32f) #2266

Open
opened 2026-11-25 10:07:15 +00:00 by bittertea0323 · 4 comments
bittertea0323 commented 2026-11-25 10:07:15 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by bittertea0323 on 2026-11-25T09:25:19Z.

Upstream labels: bug, area: shader, triage: has patch


Three user-data and mask corrections take the corpus from 298 failures to 103

Baseline first, because it changes what is worth working on: 940d32f on main translates 14205/14247 vertex and pixel, 2621/2679 compute, 8765/8765 mesh — 298 failing programs in total. We had been working a branch cut from ffe310e (319 commits behind), where 3,576 programs failed, and most of what we were fixing there had already been fixed here. If anyone else is still on an old base, rebase first; the numbers below are against 940d32f only.

The three corrections below start from that base. They are on the class both trees still fail: 195 programs with an address in an SGPR that is no root parameter, all of them geometry shaders.

1. A geometry shader's user data starts at s0 when it runs standalone

HwStage::user_sgpr added 8 to every stage that can run merged. A standalone GS's user data starts at s0; with the +8, parameter lookup was shifted by eight dwords and nothing matched. Splitting Gs out of the merged group took that class from 195 to 167.

2. A table's high half is not checked

A table base is a 32-bit address whose high half is zero, and an offset added to it stays inside the 4 GiB, so requiring the address's high half to equal the parameter's second dword rejected addresses that were fine. (The parameter genuinely has only one SGPR — forcing sgprs = 2 for tables is wrong and explodes the corpus to 20,586 failures, which is worth knowing before anyone tries it.)

3. Both placements are tried for a geometry shader

Nothing in a GS's metadata says whether it runs standalone or merged — Ls/Hs/Gs are separate FSSM slots either way — and both shapes occur in this title. param_of now tries s0, then s8. That took the last 167 GS cases to 0.

Result

940d32f with these three
an address in an SGPR that is no root parameter 195 0
total failing programs 298 98
vertex+pixel / compute / mesh emitted 14205 / 2621 / 8765 unchanged

Emitted does not move, and the reason is worth stating: translate only lowers Vs/Ps/Cs/Ms (apps/victory/src/translate.rs:534), so a geometry shader is resource-tracked and never emitted. The 195 were passing resource tracking, not reaching DXIL. Whether these GS programs actually compile is therefore unmeasured here — it needs a title run, not translate.

4. A reused register read as data takes its mask argument

mask_number refused the program when any phi argument was not a tracked lane mask (the compiler reuses one register for a mask on one path and data on another). Following the mask argument instead takes a register joining a lane mask and data from 40 to 0 — but those programs move on to a lane mask read as data (8 → 41) and a lane-mask join of an untracked mask (6 → 13), so the total goes 98 → 103 with nothing emitted. Recorded because the semantic is right and because it says where the real gap is: lane-mask tracking does not cover every source (spill, carry, joins), which is the one class left with more than 40 programs.

Not measured: whether the GS corrections change anything at runtime, and whether the mask classes collapse together once tracking covers spills — that is what we are testing next.

Branch: try/upstream-base on our fork, four commits on top of 940d32f.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6601292620 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2268). Originally posted by [bittertea0323](https://github.com/bittertea0323) on 2026-11-25T09:25:19Z. **Upstream labels:** bug, area: shader, triage: has patch --- ## Three user-data and mask corrections take the corpus from 298 failures to 103 Baseline first, because it changes what is worth working on: **`940d32f` on `main` translates 14205/14247 vertex and pixel, 2621/2679 compute, 8765/8765 mesh — 298 failing programs in total.** We had been working a branch cut from `ffe310e` (319 commits behind), where 3,576 programs failed, and most of what we were fixing there had already been fixed here. If anyone else is still on an old base, rebase first; the numbers below are against `940d32f` only. The three corrections below start from that base. They are on the class both trees still fail: 195 programs with `an address in an SGPR that is no root parameter`, all of them geometry shaders. ### 1. A geometry shader's user data starts at s0 when it runs standalone `HwStage::user_sgpr` added 8 to every stage that can run merged. A standalone GS's user data starts at s0; with the +8, parameter lookup was shifted by eight dwords and nothing matched. Splitting `Gs` out of the merged group took that class from 195 to 167. ### 2. A table's high half is not checked A table base is a 32-bit address whose high half is zero, and an offset added to it stays inside the 4 GiB, so requiring the address's high half to equal the parameter's second dword rejected addresses that were fine. (The parameter genuinely has only one SGPR — forcing `sgprs = 2` for tables is wrong and explodes the corpus to 20,586 failures, which is worth knowing before anyone tries it.) ### 3. Both placements are tried for a geometry shader Nothing in a GS's metadata says whether it runs standalone or merged — `Ls`/`Hs`/`Gs` are separate FSSM slots either way — and both shapes occur in this title. `param_of` now tries s0, then s8. That took the last 167 GS cases to **0**. ### Result | | `940d32f` | with these three | |---|---|---| | `an address in an SGPR that is no root parameter` | 195 | **0** | | total failing programs | 298 | **98** | | vertex+pixel / compute / mesh emitted | 14205 / 2621 / 8765 | unchanged | Emitted does not move, and the reason is worth stating: **`translate` only lowers `Vs`/`Ps`/`Cs`/`Ms`** (`apps/victory/src/translate.rs:534`), so a geometry shader is resource-tracked and never emitted. The 195 were passing resource tracking, not reaching DXIL. Whether these GS programs actually compile is therefore unmeasured here — it needs a title run, not `translate`. ### 4. A reused register read as data takes its mask argument `mask_number` refused the program when any phi argument was not a tracked lane mask (the compiler reuses one register for a mask on one path and data on another). Following the mask argument instead takes `a register joining a lane mask and data` from 40 to 0 — but those programs move on to `a lane mask read as data` (8 → 41) and `a lane-mask join of an untracked mask` (6 → 13), so the total goes 98 → 103 with nothing emitted. Recorded because the semantic is right and because it says where the real gap is: **lane-mask tracking does not cover every source** (spill, carry, joins), which is the one class left with more than 40 programs. Not measured: whether the GS corrections change anything at runtime, and whether the mask classes collapse together once tracking covers spills — that is what we are testing next. Branch: `try/upstream-base` on our fork, four commits on top of `940d32f`.
bittertea0323 commented 2026-11-25 10:07:45 +00:00 (Migrated from github.com)
Author
Contributor

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


Update: the last 41 are one class, and two obvious fixes for it are dead ends

After the four corrections above the corpus sits at 93 failing programs, and the largest remaining class is
a lane mask read as data (41). All 41 come from the same place: sop refuses any scalar instruction that writes
EXEC or writes a tracked lane mask (lower.rs:3324), because the value of such a write is not computed here —
the structure pass owns lane masks.

We tried the two cheap repairs and measured both. Recording them so nobody else spends the time.

1. Skip the write entirely (return Ok(())).

41 'a lane mask read as data'  →  37 'a join of mismatched values' + 4 'a value defined after its use'

Skipping leaves the written SSA value undefined, so a later join cannot type it.

2. Skip the computation but record the value as missing.

41 'a lane mask read as data'  →  41 'a lane mask write'   (the missing value is read downstream)

Either way the same 41 programs fail, so the write's value has to be computed, not elided: the structure pass
knows the per-lane bits of that mask, and the instruction needs the number they give. That is a structural change,
not another guard.

What we did keep from that line of work, because it does pay:

  • Following the mask argument of a reused register (9bf94e1) took a register joining a lane mask and data
    40 → 0 on its own.
  • Reading an untracked mask as all-lanes-set in mask_dword and the phi join (1a1e1f2) took
    a lane-mask join of an untracked mask 13 → 0 and emitted 13 more compute programs (2621 → 2634) — the only
    change in this series that actually produces DXIL rather than moving a failure.

So the honest state of the corpus on 940d32f plus these five commits:

class count
a lane mask read as data (needs the write's value computed) 41
a descriptor read only as data 36
v_cvt_f32_f64 5
barycentrics read directly 3
a descriptor neither loaded nor built 3
a descriptor chosen by control flow / v_permlanex16_b32 1 / 1

If anyone has already made sop compute the value of a mask write, this is the place to say so — that one change
is worth 41 programs and we have no working path to it from here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158519323 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2268#issuecomment-7158519323). Originally posted by [bittertea0323](https://github.com/bittertea0323) on 2026-11-25T09:34:43Z. --- ## Update: the last 41 are one class, and two obvious fixes for it are dead ends After the four corrections above the corpus sits at **93 failing programs**, and the largest remaining class is `a lane mask read as data` (41). All 41 come from the same place: `sop` refuses any scalar instruction that writes `EXEC` or writes a tracked lane mask (`lower.rs:3324`), because the value of such a write is not computed here — the structure pass owns lane masks. We tried the two cheap repairs and measured both. Recording them so nobody else spends the time. **1. Skip the write entirely (`return Ok(())`).** ``` 41 'a lane mask read as data' → 37 'a join of mismatched values' + 4 'a value defined after its use' ``` Skipping leaves the written SSA value undefined, so a later join cannot type it. **2. Skip the computation but record the value as missing.** ``` 41 'a lane mask read as data' → 41 'a lane mask write' (the missing value is read downstream) ``` Either way the same 41 programs fail, so the write's value has to be *computed*, not elided: the structure pass knows the per-lane bits of that mask, and the instruction needs the number they give. That is a structural change, not another guard. What we did keep from that line of work, because it does pay: - Following the mask argument of a reused register (`9bf94e1`) took `a register joining a lane mask and data` 40 → 0 on its own. - Reading an untracked mask as all-lanes-set in `mask_dword` and the phi join (`1a1e1f2`) took `a lane-mask join of an untracked mask` 13 → 0 **and emitted 13 more compute programs** (2621 → 2634) — the only change in this series that actually produces DXIL rather than moving a failure. So the honest state of the corpus on `940d32f` plus these five commits: | class | count | |---|---| | `a lane mask read as data` (needs the write's value computed) | 41 | | `a descriptor read only as data` | 36 | | `v_cvt_f32_f64` | 5 | | `barycentrics read directly` | 3 | | `a descriptor neither loaded nor built` | 3 | | `a descriptor chosen by control flow` / `v_permlanex16_b32` | 1 / 1 | If anyone has already made `sop` compute the value of a mask write, this is the place to say so — that one change is worth 41 programs and we have no working path to it from here.
bittertea0323 commented 2026-11-25 10:07:46 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by bittertea0323 on 2026-11-25T09:35:26Z.


The five commits are pushed so they can be reviewed or cherry-picked without waiting on a PR:

https://github.com/bittertea0323/VIctory/tree/try/upstream-base — four commits on top of 940d32f:

a35b26d  shader: a geometry shader's user data starts at s0, and a table's high half is not checked
5eaf119  shader: a geometry shader's parameters are found at either user-data placement
9bf94e1  shader: a reused register read as data takes its mask argument
1a1e1f2  shader: a lane mask the structure pass did not follow reads as every-lane

They touch
ative.rs (the SGPR mapping and a table's SGPR count) and lower.rs (the mask paths), which is
narrow enough to cherry-pick individually if only one of them is wanted. 1a1e1f2 is the one that emits more
programs; 35b26d and 5eaf119 are the ones that clear the address class.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158535754 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2268#issuecomment-7158535754). Originally posted by [bittertea0323](https://github.com/bittertea0323) on 2026-11-25T09:35:26Z. --- The five commits are pushed so they can be reviewed or cherry-picked without waiting on a PR: https://github.com/bittertea0323/VIctory/tree/try/upstream-base — four commits on top of 940d32f: a35b26d shader: a geometry shader's user data starts at s0, and a table's high half is not checked 5eaf119 shader: a geometry shader's parameters are found at either user-data placement 9bf94e1 shader: a reused register read as data takes its mask argument 1a1e1f2 shader: a lane mask the structure pass did not follow reads as every-lane They touch ative.rs (the SGPR mapping and a table's SGPR count) and lower.rs (the mask paths), which is narrow enough to cherry-pick individually if only one of them is wanted. 1a1e1f2 is the one that emits more programs; 35b26d and 5eaf119 are the ones that clear the address class.
Marvisak commented 2026-11-25 16:09:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:54:43Z.


Automated triage for the maintainers.

The geometry-shader placement is as described on main (13f91ca): HwStage::user_sgpr in crates/victory-shader/src/native.rs adds 8 for Gs unconditionally. Two of the four changes are already in open PRs: #2284 (GS user data at s0 or s8, chosen per program) and #2546 (a table's address is not checked for a high half).

No PR carries the two mask changes on the branch (9bf94e1, 1a1e1f2). New: a reviewer checked them against current main and found that neither can be ported as is. main now has tests that pin the shapes they change as refused, and both tests exist in main:

  • a_mask_joined_with_data_needs_a_uniform_join in crates/victory-shader/src/emit/lower.rs
  • a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there in crates/victory-shader/src/emit/synthetic_tests.rs

The suggested shape is to follow the mask argument only for joins off a cycle (9bf94e1), and to replace 1a1e1f2's every-lane default with an exact rule next to no_mask_lane_on_edge. PRs are open to everyone. Please open one for those, with a synthetic test each that reaches an instruction with an effect, so they can be reviewed here.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167422564 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2268#issuecomment-7167422564). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:54:43Z. --- <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T16:56:35Z at=2026-11-25T19:33:00Z --> Automated triage for the maintainers. The geometry-shader placement is as described on `main` (`13f91ca`): `HwStage::user_sgpr` in `crates/victory-shader/src/native.rs` adds 8 for `Gs` unconditionally. Two of the four changes are already in open PRs: #2284 (GS user data at s0 or s8, chosen per program) and #2546 (a table's address is not checked for a high half). No PR carries the two mask changes on the branch (9bf94e1, 1a1e1f2). New: a reviewer checked them against current `main` and found that neither can be ported as is. `main` now has tests that pin the shapes they change as refused, and both tests exist in `main`: - `a_mask_joined_with_data_needs_a_uniform_join` in `crates/victory-shader/src/emit/lower.rs` - `a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there` in `crates/victory-shader/src/emit/synthetic_tests.rs` The suggested shape is to follow the mask argument only for joins off a cycle (9bf94e1), and to replace 1a1e1f2's every-lane default with an exact rule next to `no_mask_lane_on_edge`. PRs are open to everyone. Please open one for those, with a synthetic test each that reaches an instruction with an effect, so they can be reviewed here. --- _Generated by [Claude Code](https://claude.ai/code)_
Halfect commented 2026-11-25 17:05:21 +00:00 (Migrated from github.com)
Author
Contributor

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


Porting notes for the two mask commits, against current main (67e8ae1) — a straight port is not shippable as-is, because main pinned the two shapes they change after the branch was cut:

9bf94e1 (a reused register read as data takes its mask argument). Applies cleanly, but it makes emit::lower::tests::a_mask_joined_with_data_needs_a_uniform_join pass its first assertion — i.e. the per-lane loop shape that test pins as refused now translates. That refusal is exact: on a back edge the data argument is the mask itself transformed (s_lshr once an iteration), so lanes leaving at different iterations hold different numbers, and following the mask argument returns the pre-loop mask's number for all of them. Restricting the follow to phis off a cycle keeps the loop refusal and still covers the straight-line reuse (mask on one path, data on the other).

1a1e1f2 (an untracked mask reads as every-lane). Its mask_dword half applies cleanly; the pending-mask join half conflicts semantically with the arms main added in between (lane_bit for uniform joins, no_mask_lane_on_edge for provably-empty edges). Kept as a catch-all after those arms, it makes emit::synthetic_tests::a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there fail its second half: the saved-EXEC variant — a mask holding lanes off its edge, joined with data — is exactly what the test pins as refused, because every-lane gives the skipping lanes bit 1 where the console gives 0. So the every-lane default for the join is not safe on current main.

Where that leaves the two classes:

  • The 40-program a register joining a lane mask and data class can be covered by the follow with the off-cycle guard; straight-line reuse (the shape the commit message describes) is unaffected by the guard.
  • The 13-program a lane-mask join of an untracked mask class needs an exact rule for the untracked argument rather than a default: no_mask_lane_on_edge covers the provably-empty case (0 there), and a constant argument would be exact as the lane's own bit of the constant — but anything the pass cannot prove has to stay refused, per the saved-EXEC test. Which of those the 13 programs actually are is a corpus question.

One testing note for anyone continuing this: a read of the reused register through a side-effect-free instruction (s_cmp + branch) is not a discriminating regression test — the instruction's failure is swallowed and its result marked missing, so the program "translates" either way with different DXIL. The read has to reach an instruction with an effect (e.g. a buffer store) for main to refuse the program outright.

AI-assisted (Kimi).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168763816 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2268#issuecomment-7168763816). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-25T16:56:35Z. --- Porting notes for the two mask commits, against current main (`67e8ae1`) — a straight port is not shippable as-is, because main pinned the two shapes they change after the branch was cut: **`9bf94e1` (a reused register read as data takes its mask argument).** Applies cleanly, but it makes `emit::lower::tests::a_mask_joined_with_data_needs_a_uniform_join` pass its first assertion — i.e. the per-lane loop shape that test pins as *refused* now translates. That refusal is exact: on a back edge the data argument is the mask itself transformed (`s_lshr` once an iteration), so lanes leaving at different iterations hold different numbers, and following the mask argument returns the pre-loop mask's number for all of them. Restricting the follow to phis **off a cycle** keeps the loop refusal and still covers the straight-line reuse (mask on one path, data on the other). **`1a1e1f2` (an untracked mask reads as every-lane).** Its `mask_dword` half applies cleanly; the pending-mask join half conflicts semantically with the arms main added in between (`lane_bit` for uniform joins, `no_mask_lane_on_edge` for provably-empty edges). Kept as a catch-all after those arms, it makes `emit::synthetic_tests::a_compare_mask_joined_with_data_on_the_skip_edge_is_0_there` fail its second half: the saved-EXEC variant — a mask holding lanes *off* its edge, joined with data — is exactly what the test pins as refused, because every-lane gives the skipping lanes bit 1 where the console gives 0. So the every-lane default for the join is not safe on current main. Where that leaves the two classes: - The 40-program `a register joining a lane mask and data` class can be covered by the follow **with the off-cycle guard**; straight-line reuse (the shape the commit message describes) is unaffected by the guard. - The 13-program `a lane-mask join of an untracked mask` class needs an exact rule for the untracked argument rather than a default: `no_mask_lane_on_edge` covers the provably-empty case (0 there), and a constant argument would be exact as the lane's own bit of the constant — but anything the pass cannot prove has to stay refused, per the saved-EXEC test. Which of those the 13 programs actually are is a corpus question. One testing note for anyone continuing this: a read of the reused register through a side-effect-free instruction (`s_cmp` + branch) is not a discriminating regression test — the instruction's failure is swallowed and its result marked missing, so the program "translates" either way with different DXIL. The read has to reach an instruction with an effect (e.g. a buffer store) for main to refuse the program outright. AI-assisted (Kimi).
Sign in to join this conversation.
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#2266
No description provided.