[pr-fix][rendering][shaders] A guarded quad read counts a helper neighbour as present, as the console's whole-quad mode does (DARNER_QUAD_HELPERS, on) #466

Manually merged
TrustNo1 merged 1 commit from damalama487/Darner:pr-quad-helpers into main 2026-12-05 04:51:44 +00:00
Contributor

Refs #434

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: water shows a herringbone of dark/NaN pixels along every tile's diagonal (capture 44, queue 1, DrawInstanced 5178, PSO 378, pixel (1291, 373); also seen from the angles of captures 33 and 55), and car headlights at night break the lit road into dark streaks (issue #434).

quad_read_guarded (crates/darner-shader/src/emit/lower.rs) keeps a quad neighbour's value only when waveActiveBallot names that lane. The ballot leaves helper lanes out, while the console's whole-quad mode has them in EXEC. So when the source lane of a DPP/quad read is a helper lane, the read fell back to this lane's own value. In 5178 the pixel shader builds a normal from the quad's differences: with the neighbour replaced by itself the difference is 0, the cross product is 0, rsqrt(0) is inf and 0 × inf is NaN (%705 = 0 → %706 = inf → %707 = NaN → %710, %712 in the DXIL of that PSO).

This PR counts a helper source as present: a quad read of the source's own isHelperLane says whether it is a helper, and then its value is taken. DARNER_QUAD_HELPERS=0 gives the old behaviour (the ballot only). The switch is read by the translator, so it is added to KEYED in shader_cache.rs (60 → 61) and a change of it builds shaders anew.

How it was tested

  • Tested revision: branch commit 7a6fb1df on main d91d8e4d. Gates 1 and 2 ran on this same diff on main 47d21cd3; the three files it touches are byte-identical in 47d21cd3 and d91d8e4d (d91d8e4d only changes F2). Gate 3 ran on 7a6fb1df itself (the branch's source archive, sha256 434fb17b…). The game ran this same change on top of main 47d21cd3 plus other open PRs (not main alone).

  • Commands and results:

    • cargo clippy --workspace --all-targets --locked -- -D warnings (target x86_64-pc-windows-msvc) → ok, 0 warnings
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (same target) → ok, 0 warnings
    • cargo xtask policy → asset policy: 564 files ok
    • cargo test --workspace --locked on 7a6fb1df, Windows 11, RTX 4070 Ti SUPER, debug profile (run with --offline --no-fail-fast) → 3411 passed, 2 failed, 121 ignored. Both failures fail the same with DARNER_QUAD_HELPERS=0 and with it unset (rerun from the built test binaries), so they do not come from this change:
      • darner-gpu host::packed_present_tests::packed_float_single_planes_are_presented: "frame 0 (R8G8B8A8_UNORM) was not presented" — the run was in a service session (session 0) with no desktop to present to.
      • darner-shader emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders: DXIL validation "Not all elements of output SV_Depth were written" — the fixture's own problem, fixed by #227 (also reported in #456).
      • The quad tests pass, including pixel_quad_edge_dpp_and_guarded_swizzle_match_on_gpu and divergent_broadcast_quad_read_is_guarded.
  • Changes a default: yes, for every card (guarded quad reads in pixel shaders).

  • A/B result: the same build and the same switches, the two runs' switch lines in the play log differing only in DARNER_QUAD_HELPERS=0 (A) against unset (B). Series X profile, 3840x2160 output (2560x1440 scene, DLSS Quality), frame generation x2, hardware ray tracing, RTX 4070 Ti SUPER.

    A (DARNER_QUAD_HELPERS=0, as on main) B (unset, this PR)
    water tile diagonals herringbone of thin dark lines gone
    headlights on a night road (#434) dark horizontal streaks and blocks in the lit area gone

    Water, 1:1 crops (A left, B right; the two shots are of the same spot at different times of day, so B is darker overall):
    Water A/B, 1:1 crop

    Headlights on a night road, 1:1 crops (A left, B right):
    Headlights A/B, 1:1 crop

    Whole frames, half size: water, road.

  • Gates run on that revision: 1 and 2 (clippy) and 3 (cargo test --workspace --locked) as above.

  • Gameplay: RTX 4070 Ti SUPER 16 GB, i7-12700KF, Series X profile; first with a 2560x1440 picture on a 3840x2160 screen, DLSS Quality, no frame generation; then the A/B above at 3840x2160 output with frame generation x2. Hardware ray tracing in both.

  • Shader wave sizes tested: 32 lanes (NVIDIA).

  • Hardware dependence: likely general (helper lanes and the ballot behave the same on every card), untested on AMD and Intel.

  • Coverage gaps: the water A/B shots are not of the same light. The DXIL values of %705–%712 in capture 44's pixel before and after are not included. With the change, small dark dots stay under headlights on a rough road; the player sees them as what is left of the old wrong shadow, not a new artefact (not measured). The gaps between wooden slats are not fixed by it.

Checklist

  • I ran this change in the game.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related: issue #434 (headlights break the lit road into rectangles and streaks) — this PR removes them in the A/B above; not marked "Fixes" because #434 also reports it with ray tracing off, which was not run.
  • Replaces or overlaps: none found (searched "quad", "helper", "helper lane", "ballot", "WaveActiveBallot", "QUAD_HELPERS", "water", open and closed).

🤖 Generated with Claude Code

Refs #434 ## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: water shows a herringbone of dark/NaN pixels along every tile's diagonal (capture 44, queue 1, DrawInstanced 5178, PSO 378, pixel (1291, 373); also seen from the angles of captures 33 and 55), and car headlights at night break the lit road into dark streaks (issue #434). `quad_read_guarded` (`crates/darner-shader/src/emit/lower.rs`) keeps a quad neighbour's value only when `waveActiveBallot` names that lane. The ballot leaves helper lanes out, while the console's whole-quad mode has them in EXEC. So when the source lane of a DPP/quad read is a helper lane, the read fell back to this lane's own value. In 5178 the pixel shader builds a normal from the quad's differences: with the neighbour replaced by itself the difference is 0, the cross product is 0, `rsqrt(0)` is inf and `0 × inf` is NaN (`%705` = 0 → `%706` = inf → `%707` = NaN → `%710`, `%712` in the DXIL of that PSO). This PR counts a helper source as present: a quad read of the source's own `isHelperLane` says whether it is a helper, and then its value is taken. `DARNER_QUAD_HELPERS=0` gives the old behaviour (the ballot only). The switch is read by the translator, so it is added to `KEYED` in `shader_cache.rs` (60 → 61) and a change of it builds shaders anew. ## How it was tested - Tested revision: branch commit 7a6fb1df on `main` d91d8e4d. Gates 1 and 2 ran on this same diff on `main` 47d21cd3; the three files it touches are byte-identical in 47d21cd3 and d91d8e4d (d91d8e4d only changes F2). Gate 3 ran on 7a6fb1df itself (the branch's source archive, sha256 `434fb17b…`). The game ran this same change on top of `main` 47d21cd3 plus other open PRs (not `main` alone). - Commands and results: - `cargo clippy --workspace --all-targets --locked -- -D warnings` (target x86_64-pc-windows-msvc) → ok, 0 warnings - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (same target) → ok, 0 warnings - `cargo xtask policy` → `asset policy: 564 files ok` - `cargo test --workspace --locked` on 7a6fb1df, Windows 11, RTX 4070 Ti SUPER, debug profile (run with `--offline --no-fail-fast`) → 3411 passed, 2 failed, 121 ignored. Both failures fail the same with `DARNER_QUAD_HELPERS=0` and with it unset (rerun from the built test binaries), so they do not come from this change: - `darner-gpu` `host::packed_present_tests::packed_float_single_planes_are_presented`: "frame 0 (R8G8B8A8_UNORM) was not presented" — the run was in a service session (session 0) with no desktop to present to. - `darner-shader` `emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders`: DXIL validation "Not all elements of output SV_Depth were written" — the fixture's own problem, fixed by #227 (also reported in #456). - The quad tests pass, including `pixel_quad_edge_dpp_and_guarded_swizzle_match_on_gpu` and `divergent_broadcast_quad_read_is_guarded`. - Changes a default: yes, for every card (guarded quad reads in pixel shaders). - A/B result: the same build and the same switches, the two runs' switch lines in the play log differing only in `DARNER_QUAD_HELPERS=0` (A) against unset (B). Series X profile, 3840x2160 output (2560x1440 scene, DLSS Quality), frame generation x2, hardware ray tracing, RTX 4070 Ti SUPER. | | A (`DARNER_QUAD_HELPERS=0`, as on main) | B (unset, this PR) | |---|---|---| | water tile diagonals | herringbone of thin dark lines | gone | | headlights on a night road (#434) | dark horizontal streaks and blocks in the lit area | gone | Water, 1:1 crops (A left, B right; the two shots are of the same spot at different times of day, so B is darker overall): ![Water A/B, 1:1 crop](https://git.gtahub.st/attachments/a9e22a75-dcf0-4f15-b2b1-007de95c4b09) Headlights on a night road, 1:1 crops (A left, B right): ![Headlights A/B, 1:1 crop](https://git.gtahub.st/attachments/f72df140-005d-4ebc-b294-192422860c58) Whole frames, half size: [water](https://git.gtahub.st/attachments/5346b86f-49a3-4ae1-aaad-6b9f64ac4019), [road](https://git.gtahub.st/attachments/4b52d821-3500-4c89-9a6d-b9b1b57d6ab8). - Gates run on that revision: 1 and 2 (clippy) and 3 (`cargo test --workspace --locked`) as above. - Gameplay: RTX 4070 Ti SUPER 16 GB, i7-12700KF, Series X profile; first with a 2560x1440 picture on a 3840x2160 screen, DLSS Quality, no frame generation; then the A/B above at 3840x2160 output with frame generation x2. Hardware ray tracing in both. - Shader wave sizes tested: 32 lanes (NVIDIA). - Hardware dependence: likely general (helper lanes and the ballot behave the same on every card), untested on AMD and Intel. - Coverage gaps: the water A/B shots are not of the same light. The DXIL values of `%705`–`%712` in capture 44's pixel before and after are not included. With the change, small dark dots stay under headlights on a rough road; the player sees them as what is left of the old wrong shadow, not a new artefact (not measured). The gaps between wooden slats are not fixed by it. ## Checklist - [x] I ran this change in the game. - [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. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related: issue #434 (headlights break the lit road into rectangles and streaks) — this PR removes them in the A/B above; not marked "Fixes" because #434 also reports it with ray tracing off, which was not run. - Replaces or overlaps: none found (searched "quad", "helper", "helper lane", "ballot", "WaveActiveBallot", "QUAD_HELPERS", "water", open and closed). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
quad_read_guarded kept a quad neighbour's value only when waveActiveBallot named
that lane. The ballot leaves helper lanes out, while the console's whole-quad mode
has them in EXEC, so a helper source fell back to this lane's own value. In the
water (capture 44, DrawInstanced 5178, PSO 378) that made a normal from a zero
cross product: rsqrt(0) * 0 = NaN along every tile's diagonal.

A helper source now counts as present, told by a quad read of its own
isHelperLane. DARNER_QUAD_HELPERS=0 keeps the ballot only. The switch is read by
the translator, so it is in the shader cache key (KEYED 60 -> 61).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
damalama487 changed title from WIP: [pr-fix][rendering][shaders] A guarded quad read counts a helper neighbour as present, as the console's whole-quad mode does (DARNER_QUAD_HELPERS, on) to [pr-fix][rendering][shaders] A guarded quad read counts a helper neighbour as present, as the console's whole-quad mode does (DARNER_QUAD_HELPERS, on) 2026-12-05 02:18:50 +00:00
TrustNo1 manually merged commit 4f31c95b46 into main 2026-12-05 04:51:44 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!466
No description provided.