Shaders: the tiled shadow programs translate exactly on 32-lane hosts #432

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

@⁠brunofgmag on GitHub · 2026-12-06 00:48 UTC · original
brunofgmag:fix/tiled-shadows-exact → main · +862 −105 · 6 files · 1 commits · open

What it fixes

On a 32-lane host (tested on an RTX 4080 under Proton), the sun and hair shadows come out in tile-sized blocks: dark squares on foliage and plants, and stepped white edges on clothes and heads. Leaving the 8 CS_ShadowRenderTiledCascades* programs out (LARP_LEAVE_OUT) removes the blocks along with the sun shadows, so the cause is in how these programs are translated.

Nine tiled shadow programs were not in the exact form:

  • CascadesAlphaPPPC (d7db57731ada919b), MiscHairPPPC (b4b0427232707598) and MiscHairAlphaPPPC (abd7a22106898c66) fell to local waves, where each half-wave decides on its own. The cautious half of the stall guard kept 5 skips in each, so the exact stripped form was refused.
  • CascadesAlphaCBPPPC, CascadesCBPPPC, CascadesPPPC, MiscAlphaPPPC, CascadesAlphaCB and CascadesCB used Rule::LanePairs. The blocks stayed with that rule. With the six moved to STRIPPED_GONE they went away.

Changes

  • ir.rs: three fixes ported from VIctory commit 077f9da (the one that fixed Lucia's stepped shoulder in the prison scene):
    • an early-out written as s_cbranch_execnz over a far jump (s_getpc_b64/s_add_u32/s_addc_u32/s_setpc_b64) to the end of the program is left out like an s_cbranch_execz one;
    • without_skips(deep) follows scalar phis that only pass one value on;
    • unspill pairs parked scalars per lane.
  • by_hash.rs: a new LOOPS_OPEN list. Programs in it that are also in STRIPPED_GONE drop the cautious half of the stall guard, since their marks already end every loop for a wave with no lane left. It is keyed by hash, so CS_TV_Tiled (the water program the guard was written for) and everything else keep the guard. A first version that relaxed it for every STRIPPED_GONE program hung the GPU (Xid 109) within minutes, with CS_RayPrePass_Alpha in flight.
  • whole.rs / stripped_gone.rs: the six lane-pair entries move to STRIPPED_GONE.
  • ir/tests.rs: 12 tests on synthetic programs for the three ported fixes and the guard list.

Census

The whole of shaders.rpf (26,084 programs) was translated with translate --list at LARP_HOST_MAX_WAVE=32, before and after. Nothing became refused. Exactly 12 of 25,694 DXIL files change: the nine shadow programs (now 93 to 265 group barriers each, where the approximate forms had 1) and three GpuParticleEmit programs, from the unspill pairing.

In game

RTX 4080, Proton, Series X profile: the blocks on foliage, plants, clothes and heads are gone. 17 minutes of play with no device removal (the run ended by running out of system RAM with vkd3d-proton's breadcrumbs on, which keep a trace of every command list). The squares on water are a separate issue and are not touched here.

cargo test -p larp-shader passes. cargo clippy -p larp-shader --all-targets -- -D warnings reports nothing in the files this changes (it has 7 findings on main in other files).

**@⁠brunofgmag** on GitHub · 2026-12-06 00:48 UTC · [original](https://github.com/gamingwithhomie/larp/pull/432) `brunofgmag:fix/tiled-shadows-exact` → `main` · +862 −105 · 6 files · 1 commits · open ## What it fixes On a 32-lane host (tested on an RTX 4080 under Proton), the sun and hair shadows come out in tile-sized blocks: dark squares on foliage and plants, and stepped white edges on clothes and heads. Leaving the 8 `CS_ShadowRenderTiledCascades*` programs out (`LARP_LEAVE_OUT`) removes the blocks along with the sun shadows, so the cause is in how these programs are translated. Nine tiled shadow programs were not in the exact form: - `CascadesAlphaPPPC` (d7db57731ada919b), `MiscHairPPPC` (b4b0427232707598) and `MiscHairAlphaPPPC` (abd7a22106898c66) fell to local waves, where each half-wave decides on its own. The cautious half of the stall guard kept 5 skips in each, so the exact stripped form was refused. - `CascadesAlphaCBPPPC`, `CascadesCBPPPC`, `CascadesPPPC`, `MiscAlphaPPPC`, `CascadesAlphaCB` and `CascadesCB` used `Rule::LanePairs`. The blocks stayed with that rule. With the six moved to `STRIPPED_GONE` they went away. ## Changes - `ir.rs`: three fixes ported from VIctory commit 077f9da (the one that fixed Lucia's stepped shoulder in the prison scene): - an early-out written as `s_cbranch_execnz` over a far jump (`s_getpc_b64`/`s_add_u32`/`s_addc_u32`/`s_setpc_b64`) to the end of the program is left out like an `s_cbranch_execz` one; - `without_skips(deep)` follows scalar phis that only pass one value on; - `unspill` pairs parked scalars per lane. - `by_hash.rs`: a new `LOOPS_OPEN` list. Programs in it that are also in `STRIPPED_GONE` drop the cautious half of the stall guard, since their marks already end every loop for a wave with no lane left. It is keyed by hash, so `CS_TV_Tiled` (the water program the guard was written for) and everything else keep the guard. A first version that relaxed it for every `STRIPPED_GONE` program hung the GPU (Xid 109) within minutes, with `CS_RayPrePass_Alpha` in flight. - `whole.rs` / `stripped_gone.rs`: the six lane-pair entries move to `STRIPPED_GONE`. - `ir/tests.rs`: 12 tests on synthetic programs for the three ported fixes and the guard list. ## Census The whole of `shaders.rpf` (26,084 programs) was translated with `translate --list` at `LARP_HOST_MAX_WAVE=32`, before and after. Nothing became refused. Exactly 12 of 25,694 DXIL files change: the nine shadow programs (now 93 to 265 group barriers each, where the approximate forms had 1) and three `GpuParticleEmit` programs, from the `unspill` pairing. ## In game RTX 4080, Proton, Series X profile: the blocks on foliage, plants, clothes and heads are gone. 17 minutes of play with no device removal (the run ended by running out of system RAM with vkd3d-proton's breadcrumbs on, which keep a trace of every command list). The squares on water are a separate issue and are not touched here. `cargo test -p larp-shader` passes. `cargo clippy -p larp-shader --all-targets -- -D warnings` reports nothing in the files this changes (it has 7 findings on main in other files).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-06 01:02:34 +00:00
Author
Owner

@⁠brunofgmag on GitHub · 2026-12-06 01:09 UTC · original

This is the blocky sun shadow of #204 and #340. Both report the tile-shaped shadow blocks with rt_directional_shadows at its default, and a workaround that changes that setting (high in #204, low in #340), which moves the sun shadow off these tiled programs. With this PR the default setting renders without the blocks.

**@⁠brunofgmag** on GitHub · 2026-12-06 01:09 UTC · [original](https://github.com/gamingwithhomie/larp/pull/432#issuecomment-7448952889) This is the blocky sun shadow of #204 and #340. Both report the tile-shaped shadow blocks with `rt_directional_shadows` at its default, and a workaround that changes that setting (`high` in #204, `low` in #340), which moves the sun shadow off these tiled programs. With this PR the default setting renders without the blocks.
Author
Owner

@⁠vanya890 on GitHub · 2026-12-06 01:21 UTC · original

Possible direct cross-reference: issue #372 reports the same tile/checkerboard-shaped shadow flicker on an RTX 4080 Laptop (Windows 11, NVIDIA 621.24, Series S), with a second report from an RX 9070 XT on Linux. The symptom is reduced on v1.1.5 but remains visible around nearby hair. This PR's 32-lane tiled-shadow fix looks like a strong match, although the issue logs do not yet confirm the wave path. Could you check whether #372 is covered by the same programs and mention it in the PR if confirmed?

**@⁠vanya890** on GitHub · 2026-12-06 01:21 UTC · [original](https://github.com/gamingwithhomie/larp/pull/432#issuecomment-7449118367) Possible direct cross-reference: issue #372 reports the same tile/checkerboard-shaped shadow flicker on an RTX 4080 Laptop (Windows 11, NVIDIA 621.24, Series S), with a second report from an RX 9070 XT on Linux. The symptom is reduced on v1.1.5 but remains visible around nearby hair. This PR's 32-lane tiled-shadow fix looks like a strong match, although the issue logs do not yet confirm the wave path. Could you check whether #372 is covered by the same programs and mention it in the PR if confirmed?
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/432/head:github-bot/gh-432'
git switch 'github-bot/gh-432'

Merge

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