shader: thread-0 constant LDS init and empty-wave stall guard (water mosaic fix) #187

Open
github-bot wants to merge 1 commit from github-bot/gh-186 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 22:36 UTC · original
SovietBearz0r:larp-water → main · +326 −1 · 3 files · 1 commits · open

Summary

Port of Darner's water surface mosaic fix (Issue #24), via LARP commit 9a42871 for this title. Symptom: dark 8x8 mosaic slabs on the water (most visible next to boat hulls and the horizon).

Two parts, both on by default:

  1. Thread-0 constant LDS setup (crates/victory-shader/src/emit/lower/lds_gs.rs): water_shading:CS_TransmissionVolumetrics_* sets up constant data in LDS under a v_cmpx_eq_u32 ... 128 (thread 0 of the group) that its own lane may have left early. When that guard matched (thread (0,0) present, all its data constant), the constant stores are now done for thread 0 under a flattenedThreadIdInGroup == 0 guard, so the rest of the group does not read uninitialized shared memory. VICTORY_LDS_INIT=0 turns this rewrite off for bisecting a water-render difference.
  2. Empty-wave stall guard in without_skips (crates/victory-shader/src/ir.rs): a s_cbranch_execz skip whose skipped region contains a loop that provably never ends for a wave with no lane (the console's thread-0 prefix sum over the group's waves) is kept, with the dynamic EXEC/VCC facts and cycle analysis LARP uses. Left out, the console's watchdog aborts the tile and draws the mosaic.

Ported from gamingwithhomie/larp 9a42871533c9a9e5968b8291e183c830f7e07cd5 (GPL-3.0-or-later), which ported Darner's first_thread_init and empty-EXEC loop stall guard for the same title; comments name the origin.

Verification

  • cargo test --locked -p victory-shader --lib: 323 passed, 2 ignored (includes the existing without_skips/structurisation tests and the whole emitted-shader test suite).
  • cargo clippy --locked -p victory-shader --lib -- -D warnings: clean.
  • cargo xtask policy: 442 files ok.
  • Not exercised in a game run: nothing in the tests reproduces the visual water artifact (it needs the title at the water next to boat hulls/horizon). A short in-game check at those spots is the remaining verification; VICTORY_LDS_INIT=0 is the kill switch for an A/B.

Context

One of the items from the LARP borrow review. The sibling ports are #184 (xapu conversion kinds) and #185 (Agility runtime fallback).

**@⁠SovietBearz0r** on GitHub · 2026-12-05 22:36 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/186) `SovietBearz0r:larp-water` → `main` · +326 −1 · 3 files · 1 commits · open ## Summary Port of Darner's **water surface mosaic** fix (Issue #24), via LARP commit `9a42871` for this title. Symptom: dark 8x8 mosaic slabs on the water (most visible next to boat hulls and the horizon). Two parts, both on by default: 1. **Thread-0 constant LDS setup** (`crates/victory-shader/src/emit/lower/lds_gs.rs`): `water_shading:CS_TransmissionVolumetrics_*` sets up constant data in LDS under a `v_cmpx_eq_u32 ... 128` (thread 0 of the group) that its own lane may have left early. When that guard matched (thread (0,0) present, all its data constant), the constant stores are now done for thread 0 under a `flattenedThreadIdInGroup == 0` guard, so the rest of the group does not read uninitialized shared memory. `VICTORY_LDS_INIT=0` turns this rewrite off for bisecting a water-render difference. 2. **Empty-wave stall guard in `without_skips`** (`crates/victory-shader/src/ir.rs`): a `s_cbranch_execz` skip whose skipped region contains a loop that provably never ends for a wave with no lane (the console's thread-0 prefix sum over the group's waves) is kept, with the dynamic EXEC/VCC facts and cycle analysis LARP uses. Left out, the console's watchdog aborts the tile and draws the mosaic. Ported from **gamingwithhomie/larp `9a42871533c9a9e5968b8291e183c830f7e07cd5`** (GPL-3.0-or-later), which ported Darner's `first_thread_init` and empty-EXEC loop stall guard for the same title; comments name the origin. ## Verification - `cargo test --locked -p victory-shader --lib`: **323 passed, 2 ignored** (includes the existing `without_skips`/structurisation tests and the whole emitted-shader test suite). - `cargo clippy --locked -p victory-shader --lib -- -D warnings`: clean. - `cargo xtask policy`: 442 files ok. - **Not exercised in a game run**: nothing in the tests reproduces the visual water artifact (it needs the title at the water next to boat hulls/horizon). A short in-game check at those spots is the remaining verification; `VICTORY_LDS_INIT=0` is the kill switch for an A/B. ## Context One of the items from the LARP borrow review. The sibling ports are #184 (xapu conversion kinds) and #185 (Agility runtime fallback).
Port of Darner's water mosaic fix (Issue #24), via LARP 9a42871 for the same
title:

- LDS lowering: when a compute program's constant LDS setup is guarded by
  `v_cmpx_eq_u32 ... 128` (thread 0 of the group) which its own lane may have
  left early (next to boat hulls or the horizon), thread (0,0) now performs
  those constant stores anyway, under a flattenedThreadIdInGroup == 0 guard.
  Without it the tile's shared memory is uninitialized for the other threads
  and the water surface draws dark 8x8 mosaic slabs.
- IR: `without_skips` keeps an `s_cbranch_execz` skip whose skipped region
  holds a loop that cannot leave for a wave with no lane (the console's
  thread-0 prefix sum over the group's waves). Left out, the console's
  watchdog aborts the tile. Ported as the dynamic facts/cycle analysis.
Both are on by default; VICTORY_LDS_INIT=0 turns the LDS-init rewrite off for
bisecting a water-render difference.

Ported from gamingwithhomie/larp 9a42871533c9a9e5968b8291e183c830f7e07cd5
(GPL-3.0-or-later), which ported Darner's first_thread_init and empty-EXEC loop
stall guard for the same title.

Verified: `cargo test -p victory-shader --lib` (323 passed, 2 ignored);
`cargo clippy -p victory-shader --lib -- -D warnings` clean; policy clean.
Not exercised in a game run: the water surface (boat hulls / horizon) still
wants a visual check.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 22:42:16 +00:00
github-bot force-pushed github-bot/gh-186 from 121c2ce1c2 to 3be7b6f613 2026-12-05 22:59:54 +00:00 Compare
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 22:55 UTC · original

In-game smoke (RX 9070 XT, diag build, run twice with VICTORY_LDS_INIT=0 and default): both runs clean — 0 ERROR, 0 failed/invalid shader lines, 0 device removals, 3 spots, exit 0, indistinguishable pacing (48.1/42.1/40.2 off vs 47.6/41.8/40.2 on).

But the first smoke exposed a real gap, now fixed on the branch: the warm cache still served shader translations of an earlier build of the translator (same version) and hits=3899 misses=0 — VICTORY_LDS_INIT is not in the shader-cache key and TRANSLATOR_VERSION was still 20, so the new thread-0 LDS lowering was never emitted for someone with a warm cache. I bumped TRANSLATOR_VERSION 20→21 in this PR (head now 3be7b6f6), which forces the one-time retranslation that this change needs.

Consequence for the visual check: the earlier captured frames would still show the old shaders. After the bump (or with VICTORY_SHADER_FRESH=1/victory shaders), a standing/boat-water capture is needed for the mosaic A/B (VICTORY_LDS_INIT=0 vs on). Note the version bump collides with #162 and #169 (both also 20→21 from the same base) — whichever merges first, the next needs 22.

Logs: data\logs\larp-water-off.log, larp-water-on.log.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 22:55 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/186#issuecomment-7447170355) In-game smoke (RX 9070 XT, diag build, run twice with `VICTORY_LDS_INIT=0` and default): both runs clean — 0 ERROR, 0 failed/invalid shader lines, 0 device removals, 3 spots, exit 0, indistinguishable pacing (48.1/42.1/40.2 off vs 47.6/41.8/40.2 on). **But the first smoke exposed a real gap, now fixed on the branch:** the warm cache still served `shader translations of an earlier build of the translator (same version)` and `hits=3899 misses=0` — `VICTORY_LDS_INIT` is not in the shader-cache key and `TRANSLATOR_VERSION` was still 20, so the new thread-0 LDS lowering was never emitted for someone with a warm cache. I bumped `TRANSLATOR_VERSION` 20→21 in this PR (head now `3be7b6f6`), which forces the one-time retranslation that this change needs. Consequence for the visual check: the earlier captured frames would still show the old shaders. After the bump (or with `VICTORY_SHADER_FRESH=1`/`victory shaders`), a standing/boat-water capture is needed for the mosaic A/B (`VICTORY_LDS_INIT=0` vs on). Note the version bump collides with #162 and #169 (both also 20→21 from the same base) — whichever merges first, the next needs 22. Logs: `data\logs\larp-water-off.log`, `larp-water-on.log`.
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 23:44 UTC · original

In-game visual A/B done with pre-HUD captures on a warm, per-arm cache (ON = default thread-0 LDS init, OFF = VICTORY_LDS_INIT=0).

Setup: pure larp-water 3be7b6f6 (version-21 retranslation), diagnostics capture build; 25,985 shaders precompiled per arm with separate shader packs; pinned harbour route so both arms fly the same 3 spots; 9 pre-HUD frames per arm (spawn + 4 cruise_out + 4 cruise_back), e.g.
on/frame-22080 vs off/frame-20954.

Visual result: no dark 8x8 mosaic slabs in either arm — the harbour/boat view (water, islands, buoys, boats) is clean in both; no visible difference attributable to the lowering, and no regression (fps identical, 0 errors, warm-cache evidence: ON pack delta 0 bytes; OFF only grew after the last saved frame). So the fix could not be positively demonstrated on this route/GPU because the artifact did not reproduce with the unfixed lowering here — it is consistent with the change being harmless and with the Darner/LARP report, but a scene that actually shows the mosaic is still the missing proof. Captures and per-arm evidence: data\ingame-verify\water-visual.md (frames under data\ingame-verify\water-frames\on|off).

Note: VICTORY_LDS_INIT is not part of the shader-cache key, so an A/B needs separate caches (as done here); the default-on fix itself only needs the TRANSLATOR_VERSION bump already in this PR.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 23:44 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/186#issuecomment-7447809594) In-game visual A/B done with pre-HUD captures on a warm, per-arm cache (ON = default thread-0 LDS init, OFF = `VICTORY_LDS_INIT=0`). Setup: pure `larp-water` `3be7b6f6` (version-21 retranslation), diagnostics capture build; 25,985 shaders precompiled **per arm** with separate shader packs; pinned harbour route so both arms fly the same 3 spots; 9 pre-HUD frames per arm (spawn + 4 cruise_out + 4 cruise_back), e.g. [on/frame-22080](D:/Games/GTAVI/Launcher/ReVIctory_pr/data/ingame-verify/water-frames/on/marked-frame-22080.png) vs [off/frame-20954](D:/Games/GTAVI/Launcher/ReVIctory_pr/data/ingame-verify/water-frames/off/marked-frame-20954.png). **Visual result: no dark 8x8 mosaic slabs in either arm** — the harbour/boat view (water, islands, buoys, boats) is clean in both; no visible difference attributable to the lowering, and no regression (fps identical, 0 errors, warm-cache evidence: ON pack delta 0 bytes; OFF only grew after the last saved frame). So the fix could not be *positively* demonstrated on this route/GPU because the artifact did not reproduce with the unfixed lowering here — it is consistent with the change being harmless and with the Darner/LARP report, but a scene that actually shows the mosaic is still the missing proof. Captures and per-arm evidence: `data\ingame-verify\water-visual.md` (frames under `data\ingame-verify\water-frames\on|off`). Note: `VICTORY_LDS_INIT` is not part of the shader-cache key, so an A/B needs separate caches (as done here); the default-on fix itself only needs the `TRANSLATOR_VERSION` bump already in this PR.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/187/head:github-bot/gh-186'
git switch 'github-bot/gh-186'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-186'
git switch 'github-bot/gh-186'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-186'
git switch 'github-bot/gh-186'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-186'
git switch 'main'
git merge --squash 'github-bot/gh-186'
git switch 'main'
git merge --ff-only 'github-bot/gh-186'
git switch 'main'
git merge 'github-bot/gh-186'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.