Shaders: the tiled shadows and the hair shadow masks are folded by default on 32-lane hosts, so their tile votes are whole again #504

Open
ntsthay wants to merge 1 commit from ntsthay/fold-tiled-shadows into Main AGit
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

UNFOLDED_BY_DEFAULT in emit/mod.rs now holds only lightAtlas. The tiled shadow programs (CS_ShadowRenderTiled*) and the hair shadow masks (CS_GenerateShadowMasks_HairOnly) are folded by default again on 32-lane hosts. The README row of DARNER_WAVE_FOLDED_SKIP already said the default skips only the particle light atlas, so the code now matches it.

Unfolded, these programs fall to local waves, and local waves are not exact for them. CS_ShadowRenderTiledCascadesCB (be6ce5d849d51127 in 1.0.2.1) holds a vote over its 8x8 tile at 0x2420 to 0x2434. It takes v_readfirstlane of the shadow estimate, compares every lane to it with v_cmp_eq, counts the lanes that differ with s_bcnt1, and skips the PCF filtering when all 64 lanes agree. With local waves each 32-lane half votes alone. One half skips the filter and the other does not, so the sun's shadow edges on faces and roads come out in half-tile blocks, a grid that is easy to see with a low sun. Folded, one host wave holds the whole console wave and the vote counts all 64 lanes.

On the cost: the comment said these programs saved 1.3 ms of an RTX 2080 Ti's replayed frame unfolded. On an RTX 4080 the difference is within noise (below).

DARNER_WAVE_FOLDED_SKIP=lightAtlas,CS_ShadowRenderTiled,CS_GenerateShadowMasks_HairOnly brings back the old default.

How it was tested

  • Tested revision: this commit on main c8258f9.

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.

  • darner translate of the title's shaders.rpf with this commit, DARNER_HOST_WAVE=32 DARNER_WAVE_WHY=1 and no other switch, over the nine CS_ShadowRenderTiled* programs and CS_GenerateShadowMasks_HairOnly: all ten come out folded (before wave-wide) with 32-lane waves ("10 emitted of 10 compute programs"). Before, all ten were local waves (APPROXIMATE).

  • In game: RTX 4080, driver 620.73, Linux under Proton (proton-cachyos), Series S profile, DLAA, hardware RT, no frame generation. Four unattended runs of 200 s from the same daytime save, taking turns. The numbers below are median frame times after the first minute of world. The build was main d91d8e4 plus other PRs, with DARNER_WAVE_FOLDED_SKIP=lightAtlas standing in for this change:

    unfolded (old default) folded (this PR)
    run 1 37.8 ms (p99 40.7) 38.2 ms (p99 41.1)
    run 2 37.9 ms (p99 40.8) 37.9 ms (p99 40.6)

    With the fold, the blocks on faces and on road shadows were gone when I looked in play. I have not measured a 20-series card; there the 1.3 ms may still hold, and it would be worth a check by someone with one.

  • Changes a default: yes, on 32-lane hosts (NVIDIA). These programs are translated again once. Cards with 64-lane waves do not fold, so nothing changes there.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • None. #501 makes three other folded programs exact. It does not depend on this PR and touches a different part of emit/mod.rs.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none change UNFOLDED_BY_DEFAULT. DARNER_PAIR_FIRST (PAIR_FIRST_BY_DEFAULT, off by default) is another way to make the tiled shadows exact. In a census of 1.0.2.1 with DARNER_HOST_WAVE=32, the pair form only takes CS_ShadowRenderTiledCascadesCB. The other eight variants are refused with "a lane mask exchanged after its block, in a group of several console waves" and fall back to local waves, so the fold is what covers the whole family.
## Contributor role (optional) - Fluxer ID: ## What it changes `UNFOLDED_BY_DEFAULT` in `emit/mod.rs` now holds only `lightAtlas`. The tiled shadow programs (`CS_ShadowRenderTiled*`) and the hair shadow masks (`CS_GenerateShadowMasks_HairOnly`) are folded by default again on 32-lane hosts. The README row of `DARNER_WAVE_FOLDED_SKIP` already said the default skips only the particle light atlas, so the code now matches it. Unfolded, these programs fall to local waves, and local waves are not exact for them. `CS_ShadowRenderTiledCascadesCB` (`be6ce5d849d51127` in 1.0.2.1) holds a vote over its 8x8 tile at 0x2420 to 0x2434. It takes `v_readfirstlane` of the shadow estimate, compares every lane to it with `v_cmp_eq`, counts the lanes that differ with `s_bcnt1`, and skips the PCF filtering when all 64 lanes agree. With local waves each 32-lane half votes alone. One half skips the filter and the other does not, so the sun's shadow edges on faces and roads come out in half-tile blocks, a grid that is easy to see with a low sun. Folded, one host wave holds the whole console wave and the vote counts all 64 lanes. On the cost: the comment said these programs saved 1.3 ms of an RTX 2080 Ti's replayed frame unfolded. On an RTX 4080 the difference is within noise (below). `DARNER_WAVE_FOLDED_SKIP=lightAtlas,CS_ShadowRenderTiled,CS_GenerateShadowMasks_HairOnly` brings back the old default. ## How it was tested - Tested revision: this commit on main `c8258f9`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `darner translate` of the title's `shaders.rpf` with this commit, `DARNER_HOST_WAVE=32 DARNER_WAVE_WHY=1` and no other switch, over the nine `CS_ShadowRenderTiled*` programs and `CS_GenerateShadowMasks_HairOnly`: all ten come out `folded (before wave-wide)` with 32-lane waves ("10 emitted of 10 compute programs"). Before, all ten were local waves (APPROXIMATE). - In game: RTX 4080, driver 620.73, Linux under Proton (proton-cachyos), Series S profile, DLAA, hardware RT, no frame generation. Four unattended runs of 200 s from the same daytime save, taking turns. The numbers below are median frame times after the first minute of world. The build was main `d91d8e4` plus other PRs, with `DARNER_WAVE_FOLDED_SKIP=lightAtlas` standing in for this change: | | unfolded (old default) | folded (this PR) | |---|---|---| | run 1 | 37.8 ms (p99 40.7) | 38.2 ms (p99 41.1) | | run 2 | 37.9 ms (p99 40.8) | 37.9 ms (p99 40.6) | With the fold, the blocks on faces and on road shadows were gone when I looked in play. I have not measured a 20-series card; there the 1.3 ms may still hold, and it would be worth a check by someone with one. - Changes a default: yes, on 32-lane hosts (NVIDIA). These programs are translated again once. Cards with 64-lane waves do not fold, so nothing changes there. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - None. #501 makes three other folded programs exact. It does not depend on this PR and touches a different part of `emit/mod.rs`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none change `UNFOLDED_BY_DEFAULT`. `DARNER_PAIR_FIRST` (`PAIR_FIRST_BY_DEFAULT`, off by default) is another way to make the tiled shadows exact. In a census of 1.0.2.1 with `DARNER_HOST_WAVE=32`, the pair form only takes `CS_ShadowRenderTiledCascadesCB`. The other eight variants are refused with "a lane mask exchanged after its block, in a group of several console waves" and fall back to local waves, so the fold is what covers the whole family.
ntsthay changed title from Shaders: the tiled shadows and the hair shadow masks are folded by default on 32-lane hosts, so their tile votes are whole again to [pr-fix][shaders] Shaders: the tiled shadows and the hair shadow masks are folded by default on 32-lane hosts, so their tile votes are whole again 2026-12-05 05:32:06 +00:00
TrustNo1 changed title from [pr-fix][shaders] Shaders: the tiled shadows and the hair shadow masks are folded by default on 32-lane hosts, so their tile votes are whole again to Shaders: the tiled shadows and the hair shadow masks are folded by default on 32-lane hosts, so their tile votes are whole again 2026-12-06 03:27:53 +00:00
Owner

Test needed — commit 4302b88f; what to check:

UNFOLDED_BY_DEFAULT in emit/mod.rs now holds only lightAtlas. The tiled shadow programs (CS_ShadowRenderTiled*) and the hair shadow masks (CS_GenerateShadowMasks_HairOnly) are folded by default again on 32-lane hosts. The README row of DARNER_WAVE_FOLDED_SKIP already said the default skips only the particle light atlas, so the code now matches it.

Unfolded, these programs fall to local waves, and local waves are not exact for them. CS_ShadowRenderTiledCascadesCB (be6ce5d849d51127 in 1.0.2.1) holds a vote over its 8x8 tile at 0x2420 to 0x2434. It takes v_readfirstlane of the shadow estimate, compares every lane to it with v_cmp_eq, counts the lanes that differ with s_bcnt1, and skips the PCF filtering when all 64 lanes agree. With local waves each 32-lane half votes alone. One half skips the filter and the other does not, so the sun's shadow edges on faces and roads come out in half-tile blocks, a grid that is easy to see with a low sun. Folded, one host wave holds the whole console wave and the vote counts all 64 lanes.

On the cost: the comment said these programs saved 1.3 ms of an RTX 2080 Ti's replayed frame unfolded. On an RTX 4080 the difference is with

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `4302b88f`; what to check: `UNFOLDED_BY_DEFAULT` in `emit/mod.rs` now holds only `lightAtlas`. The tiled shadow programs (`CS_ShadowRenderTiled*`) and the hair shadow masks (`CS_GenerateShadowMasks_HairOnly`) are folded by default again on 32-lane hosts. The README row of `DARNER_WAVE_FOLDED_SKIP` already said the default skips only the particle light atlas, so the code now matches it. Unfolded, these programs fall to local waves, and local waves are not exact for them. `CS_ShadowRenderTiledCascadesCB` (`be6ce5d849d51127` in 1.0.2.1) holds a vote over its 8x8 tile at 0x2420 to 0x2434. It takes `v_readfirstlane` of the shadow estimate, compares every lane to it with `v_cmp_eq`, counts the lanes that differ with `s_bcnt1`, and skips the PCF filtering when all 64 lanes agree. With local waves each 32-lane half votes alone. One half skips the filter and the other does not, so the sun's shadow edges on faces and roads come out in half-tile blocks, a grid that is easy to see with a low sun. Folded, one host wave holds the whole console wave and the vote counts all 64 lanes. On the cost: the comment said these programs saved 1.3 ms of an RTX 2080 Ti's replayed frame unfolded. On an RTX 4080 the difference is with Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
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/504/head:ntsthay/fold-tiled-shadows'
git switch 'ntsthay/fold-tiled-shadows'

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 'ntsthay/fold-tiled-shadows'
git switch 'ntsthay/fold-tiled-shadows'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'ntsthay/fold-tiled-shadows'
git switch 'ntsthay/fold-tiled-shadows'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'ntsthay/fold-tiled-shadows'
git switch 'Main'
git merge --squash 'ntsthay/fold-tiled-shadows'
git switch 'Main'
git merge --ff-only 'ntsthay/fold-tiled-shadows'
git switch 'Main'
git merge 'ntsthay/fold-tiled-shadows'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!504
No description provided.