Fixes from other forks and upstream: translator, textures, lifetimes #29

Merged
TaynanGT merged 21 commits from upstream-pr/29 into main 2026-11-26 13:23:36 +00:00
TaynanGT commented 2026-11-26 13:14:23 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-26T13:14:23Z.


Fixes from other forks and upstream, plus lifetime and cache fixes of our own. Builds on #27.

Translator

  • 9bb7dbff (port of upstream 0665a0e8, with QB): a wave64 ds_bpermute_b32 permutes within each 32-lane half. It is no longer refused as "a lane permute across two host waves", so the wave64 programs that used it now translate on 32-lane hosts.
  • 8f40c451 (lower.rs part of f6a09d3b, with fxceless): v_mad_legacy/v_mac_legacy run as an FMA with denormals flushed and the zero-factor rule.
  • c125c0c0 (Garu667, #1261): console lanes in groups of several host waves take their thread ids from a group counter. In a 2-D group the old rounding wrote 32 of 64 slots on a 4090; this writes all 64. VICTORY_THREAD_TICKET joins the shader cache key.
  • 90143cef (Garu667, #1287): the loose-LDS fallback, on by default as its author left it. VICTORY_WAVE_LDS_LOOSE and VICTORY_SCC_LOCAL_ANY join the cache key. Our base has no "wide_last" block, so only the fallback came over; 5cf8960c drops a duplicate s_mov_b64 literal fold it added.
  • 037c5315 (rayane-creato1r, upstream #2812): a comparison sampler replaces the filter's reduction instead of OR-ing 0x80 into it.
  • 8fe3ccdd (Bartosz, upstream #3158): v_fmac_f32 in VOP3 applies abs/neg to its accumulator.
  • 17e3e2c8 (shh, upstream #3187): sections() keeps scanning past an unmatched saveexec.
  • d4b32ea6, 1ca0454a: tests only. The base doesn't have the s_andn2 discard pattern behind upstream #2306, and loads and stores of a heap texture share one descriptor here, so the twin-SRV bug seen elsewhere can't happen; both tests pin that.

Textures and formats

  • 8d56dd95 (RVZO6, upstream #3111): BC7 channel rotation only in modes 4 and 5.
  • 724e9527 (fxceless, #1210): a view moved to the first level with memory keeps the title's ResourceMinLODClamp.
  • 7ae1afce (gomeaw, avatarmanz #150): texture readback destinations stay pending until their flight lands.
  • 898c40cb (feanorsun, avatarmanz #198): the idle texture sweep restarts when its cursor passes the last texture.
  • 00a21ef4 (kripotker, part of avatarmanz #206): under PC memory pressure, idle texture copies go after 5 s.
  • 26aeded1: a sparse read that only hits holes keeps the digest of the staged texels.

Lifetimes and caches

  • 18bc367d (kripotker, part of avatarmanz #206): the placed-view shape index is keyed by the shape's hash. The padding part of #206 is already in #27.
  • 4d6a7449: a slot flip keeps the record its upload was made for; the key is read at selection and checked again at the flip.
  • 2a267adb: waits and signals held back keep a reference to their fence until their last use (FenceRef).
  • f31db60c: a translation whose cache write fails still reaches the caller; a failed translation is still an error.

Measured

RTX 4090, Ryzen 9 9950X3D, Series S profile, 30 minutes in the world, against main after #27:

main (#27) this branch
fps median / p10 / 1% low 20.5 / 17.6 / 11.2 21.6 / 18.6 / 15.5
ms per frame 48.8 46.3
private memory, median / max 27.2 / 27.4 GB 25.0 / 25.2 GB
card memory max 12.5 GB 10.1 GB
compute shaders that don't translate 6 3

No errors and no new kinds of warning (96 warnings against 111). Captures along the route show no black screen or new artefacts; the square blocks in clouds are still there.

Checks

ci-local.ps1: clippy with and without all features clean; 963 tests passed, 0 failed, 47 ignored. The merge with main gives the same tree that was tested.

🤖 Generated with Claude Code

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5510688485 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/29). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-26T13:14:23Z. --- Fixes from other forks and upstream, plus lifetime and cache fixes of our own. Builds on #27. ## Translator - `9bb7dbff` (port of upstream 0665a0e8, with QB): a wave64 `ds_bpermute_b32` permutes within each 32-lane half. It is no longer refused as "a lane permute across two host waves", so the wave64 programs that used it now translate on 32-lane hosts. - `8f40c451` (lower.rs part of f6a09d3b, with fxceless): `v_mad_legacy`/`v_mac_legacy` run as an FMA with denormals flushed and the zero-factor rule. - `c125c0c0` (Garu667, #1261): console lanes in groups of several host waves take their thread ids from a group counter. In a 2-D group the old rounding wrote 32 of 64 slots on a 4090; this writes all 64. `VICTORY_THREAD_TICKET` joins the shader cache key. - `90143cef` (Garu667, #1287): the loose-LDS fallback, on by default as its author left it. `VICTORY_WAVE_LDS_LOOSE` and `VICTORY_SCC_LOCAL_ANY` join the cache key. Our base has no "wide_last" block, so only the fallback came over; `5cf8960c` drops a duplicate `s_mov_b64` literal fold it added. - `037c5315` (rayane-creato1r, upstream #2812): a comparison sampler replaces the filter's reduction instead of OR-ing 0x80 into it. - `8fe3ccdd` (Bartosz, upstream #3158): `v_fmac_f32` in VOP3 applies abs/neg to its accumulator. - `17e3e2c8` (shh, upstream #3187): `sections()` keeps scanning past an unmatched saveexec. - `d4b32ea6`, `1ca0454a`: tests only. The base doesn't have the `s_andn2` discard pattern behind upstream #2306, and loads and stores of a heap texture share one descriptor here, so the twin-SRV bug seen elsewhere can't happen; both tests pin that. ## Textures and formats - `8d56dd95` (RVZO6, upstream #3111): BC7 channel rotation only in modes 4 and 5. - `724e9527` (fxceless, #1210): a view moved to the first level with memory keeps the title's `ResourceMinLODClamp`. - `7ae1afce` (gomeaw, avatarmanz #150): texture readback destinations stay pending until their flight lands. - `898c40cb` (feanorsun, avatarmanz #198): the idle texture sweep restarts when its cursor passes the last texture. - `00a21ef4` (kripotker, part of avatarmanz #206): under PC memory pressure, idle texture copies go after 5 s. - `26aeded1`: a sparse read that only hits holes keeps the digest of the staged texels. ## Lifetimes and caches - `18bc367d` (kripotker, part of avatarmanz #206): the placed-view shape index is keyed by the shape's hash. The padding part of #206 is already in #27. - `4d6a7449`: a slot flip keeps the record its upload was made for; the key is read at selection and checked again at the flip. - `2a267adb`: waits and signals held back keep a reference to their fence until their last use (`FenceRef`). - `f31db60c`: a translation whose cache write fails still reaches the caller; a failed translation is still an error. ## Measured RTX 4090, Ryzen 9 9950X3D, Series S profile, 30 minutes in the world, against main after #27: | | main (#27) | this branch | |---|---|---| | fps median / p10 / 1% low | 20.5 / 17.6 / 11.2 | 21.6 / 18.6 / 15.5 | | ms per frame | 48.8 | 46.3 | | private memory, median / max | 27.2 / 27.4 GB | 25.0 / 25.2 GB | | card memory max | 12.5 GB | 10.1 GB | | compute shaders that don't translate | 6 | 3 | No errors and no new kinds of warning (96 warnings against 111). Captures along the route show no black screen or new artefacts; the square blocks in clouds are still there. ## Checks `ci-local.ps1`: clippy with and without all features clean; 963 tests passed, 0 failed, 47 ignored. The merge with main gives the same tree that was tested. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chatgpt-codex-connector[bot] commented 2026-11-26 13:14:39 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:14:39Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T13:17:22.033639Z 5cf8960 PR opened
🔒 Security Review ✅ Completed 2026-11-26T13:19:04.072025Z 5cf8960 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7193070267 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/29#issuecomment-7193070267). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T13:14:39Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5cf8960c2b6877ea727313927d745a6f57033127","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":"5cf8960c2b6877ea727313927d745a6f57033127","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} --> <!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"5cf8960c2b6877ea727313927d745a6f57033127","mergeGateEnabled":false,"pullRequestNumber":29,"repository":"TaynanGT/Vice-Tay","status":"completed"} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T13:17:22.033639Z">2026-11-26T13:17:22.033639Z</relative-time> | `5cf8960` | PR opened | | 🔒 **Security Review** | ✅ **Completed** <relative-time datetime="2026-11-26T13:19:04.072025Z">2026-11-26T13:19:04.072025Z</relative-time> | `5cf8960` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot] commented 2026-11-26 13:17:19 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:17:19Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cf8960c2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6074785414 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/29#pullrequestreview-6074785414). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T13:17:19Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5cf8960c2b` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot] commented 2026-11-26 13:17:19 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T13:17:19Z.

Code review location: crates/victory-shader/src/emit/lower.rs; line 2593

@@ -2557,7 +2580,22 @@ impl<'a> Lower<'a> {
             Input::FrontFace => (13, 0),
             Input::ThreadIdInGroup(c) => return self.thread_id(c),
             Input::GroupId(c) => return self.compute_id("groupId.i32", 94, c),
-            Input::GroupInfo => return Val::Missing("the thread-group info SGPR"),
+            // bits 0-5 the group's waves, 6-11 this wave's index (Mesa's `tg_size`)
+            Input::GroupInfo => {
+                let StageIo::Cs(cs) = self.x.native.io else {
+                    return Val::Missing("the thread-group info SGPR");
+                };
+                let wave: u32 = if self.x.native.wave64 { 64 } else { 32 };
+                let threads = cs.threads.iter().product::<u32>();
+                let (e, i32t) = (self.s.entry, self.s.t.i32);
+                let flat = self.s.op(e, "flattenedThreadIdInGroup.i32", Attr::ReadNone, i32t, 96, &[]);
+                let w = self.s.m.i32(wave.trailing_zeros());
+                let index = self.s.m.bin(e, Bin::LShr, flat, w);

P2 Badge Derive group-info wave indices from the relabelled console threads

For compute shaders that read the group-info SGPR and use console-lane operations in a multi-wave group, this derives the wave index from physical host thread IDs, while thread_id() derives console thread IDs from the new ticket counter. These mappings can disagree even in a one-dimensional group because tickets are allocated in arrival order. In the 32×2 NVIDIA layout described by the new regression test, the physical flattened IDs can also produce different wave indices within a single host wave, although this input represents a scalar SGPR. Shaders using that index to select per-wave LDS or output regions can consequently address the wrong region. Derive the index from the same console-thread mapping used by thread_id() and the wave-exchange helpers.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4708891404 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/29#discussion_r4708891404). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T13:17:19Z. **Code review location:** `crates/victory-shader/src/emit/lower.rs`; line 2593 ~~~~diff @@ -2557,7 +2580,22 @@ impl<'a> Lower<'a> { Input::FrontFace => (13, 0), Input::ThreadIdInGroup(c) => return self.thread_id(c), Input::GroupId(c) => return self.compute_id("groupId.i32", 94, c), - Input::GroupInfo => return Val::Missing("the thread-group info SGPR"), + // bits 0-5 the group's waves, 6-11 this wave's index (Mesa's `tg_size`) + Input::GroupInfo => { + let StageIo::Cs(cs) = self.x.native.io else { + return Val::Missing("the thread-group info SGPR"); + }; + let wave: u32 = if self.x.native.wave64 { 64 } else { 32 }; + let threads = cs.threads.iter().product::<u32>(); + let (e, i32t) = (self.s.entry, self.s.t.i32); + let flat = self.s.op(e, "flattenedThreadIdInGroup.i32", Attr::ReadNone, i32t, 96, &[]); + let w = self.s.m.i32(wave.trailing_zeros()); + let index = self.s.m.bin(e, Bin::LShr, flat, w); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Derive group-info wave indices from the relabelled console threads** For compute shaders that read the group-info SGPR and use console-lane operations in a multi-wave group, this derives the wave index from physical host thread IDs, while `thread_id()` derives console thread IDs from the new ticket counter. These mappings can disagree even in a one-dimensional group because tickets are allocated in arrival order. In the 32×2 NVIDIA layout described by the new regression test, the physical flattened IDs can also produce different wave indices within a single host wave, although this input represents a scalar SGPR. Shaders using that index to select per-wave LDS or output regions can consequently address the wrong region. Derive the index from the same console-thread mapping used by `thread_id()` and the wave-exchange helpers. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
TaynanGT commented 2026-11-27 01:33:55 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T01:33:55Z.


I opened #108 for the group-info finding. On relabelled waves the translator now derives the wave index from the same base as the console thread IDs. The draft extends the 32 × 2 hardware regression to check the group-info word for every thread, and uses a new translator cache version.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7207390990 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/29#issuecomment-7207390990). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T01:33:55Z. --- I opened #108 for the group-info finding. On relabelled waves the translator now derives the wave index from the same base as the console thread IDs. The draft extends the 32 × 2 hardware regression to check the group-info word for every thread, and uses a new translator cache version.
TaynanGT commented 2026-11-29 19:11:30 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:11:30Z.

Code review location: crates/victory-shader/src/emit/lower.rs; line 2593

@@ -2557,7 +2580,22 @@ impl<'a> Lower<'a> {
             Input::FrontFace => (13, 0),
             Input::ThreadIdInGroup(c) => return self.thread_id(c),
             Input::GroupId(c) => return self.compute_id("groupId.i32", 94, c),
-            Input::GroupInfo => return Val::Missing("the thread-group info SGPR"),
+            // bits 0-5 the group's waves, 6-11 this wave's index (Mesa's `tg_size`)
+            Input::GroupInfo => {
+                let StageIo::Cs(cs) = self.x.native.io else {
+                    return Val::Missing("the thread-group info SGPR");
+                };
+                let wave: u32 = if self.x.native.wave64 { 64 } else { 32 };
+                let threads = cs.threads.iter().product::<u32>();
+                let (e, i32t) = (self.s.entry, self.s.t.i32);
+                let flat = self.s.op(e, "flattenedThreadIdInGroup.i32", Attr::ReadNone, i32t, 96, &[]);
+                let w = self.s.m.i32(wave.trailing_zeros());
+                let index = self.s.m.bin(e, Bin::LShr, flat, w);

The current GroupInfo lowering derives its index from wave_base() when waves are relabelled, falling back to flattenedThreadIdInGroup only otherwise. That aligns the index with the console thread mapping. I still want native multi-wave execution coverage before treating the behavior as validated.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732760666 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/29#discussion_r4732760666). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:11:30Z. **Code review location:** `crates/victory-shader/src/emit/lower.rs`; line 2593 ~~~~diff @@ -2557,7 +2580,22 @@ impl<'a> Lower<'a> { Input::FrontFace => (13, 0), Input::ThreadIdInGroup(c) => return self.thread_id(c), Input::GroupId(c) => return self.compute_id("groupId.i32", 94, c), - Input::GroupInfo => return Val::Missing("the thread-group info SGPR"), + // bits 0-5 the group's waves, 6-11 this wave's index (Mesa's `tg_size`) + Input::GroupInfo => { + let StageIo::Cs(cs) = self.x.native.io else { + return Val::Missing("the thread-group info SGPR"); + }; + let wave: u32 = if self.x.native.wave64 { 64 } else { 32 }; + let threads = cs.threads.iter().product::<u32>(); + let (e, i32t) = (self.s.entry, self.s.t.i32); + let flat = self.s.op(e, "flattenedThreadIdInGroup.i32", Attr::ReadNone, i32t, 96, &[]); + let w = self.s.m.i32(wave.trailing_zeros()); + let index = self.s.m.bin(e, Bin::LShr, flat, w); ~~~~ --- The current GroupInfo lowering derives its index from wave_base() when waves are relabelled, falling back to flattenedThreadIdInGroup only otherwise. That aligns the index with the console thread mapping. I still want native multi-wave execution coverage before treating the behavior as validated.
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
TaynanGT/Vice-Tay!29
No description provided.