WIP: Commit alpha-tested candidates in the 32-bit walks' lifted queries (distant shadows) #558

Draft
Yorivel wants to merge 2 commits from Yorivel/Darner:pr/rq-distant-shadow-alpha into Main
Contributor

Contributor role (optional)

  • Fluxer ID: 1577734278060445696

What it changes

  • The problem on main: read from the code and from the translator's output, not seen in the game yet. With hardware RT, the four distant-shadow programs (CS_RTDistantShadowTrace32_Tiled a1b20bc47e3c9597, …LeakPlug32_Tiled e8c962358d862e3f, …TraceTemporalUpsample4X32_Tiled 17829ac71aab4e8d, …LeakPlugTemporalUpsample4X32_Tiled afeea48bbb9913ad) are lifted with a candidate callback (DARNER_HW_RT_WHY=1: cb=true, a Mask commit decision), but their DXIL has no CommitNonOpaqueTriangleHit: each Proceed loop is empty. The flags are 0x10/0x14, without FORCE_OPAQUE, so every non-opaque (alpha-tested) candidate is dropped. Alpha-tested casters should have no distant shadow.

The 32-bit walk tells box nodes from triangles with v_cmp_eq_u32 vcc, 4, node & 6 before the node test, and runs the triangle path, with the alpha test in it, under !vcc. eval_pre_callback_lane_bit has no rule for that compare, so its default ("active lane guard") binds it to true. The callback's commit condition becomes select i1 true, i1 false, X, always false, and the clean-up passes then remove the commit. With DARNER_SHADER_OPT=0 the commits are still there behind that false condition, so the clean-up passes are not at fault.

The fix: node_kind_compare evaluates a comparison of a constant with the node pointer's type bits (v_and_b32 …, 6|7, node) for the triangle types 0 to 3 a candidate has. It binds the compare only when all four types agree (here: "box" is false). Every other compare keeps its existing rule.

larp's hand-written replacements of these programs commit their alpha test's candidates (https://git.gtahub.st/recklessfish/CNF-Larp, shaders/replace), which is what pointed here. No code is taken from it.

How it was tested

  • Tested revision: 59256a1 on main c8258f9 (6883c23 the fix; 59256a1 lists the new test's switch in the shader cache's switch test).
  • Commands and results:
    • The 16 programs DARNER_HW_RT lifts in my runs, taken from my local game files (darner translate --warm) and translated with hardware RT, before and after: the four distant-shadow programs go from 0 commits to 3, 5, 3 and 5. The other 12 programs translate byte-identically.
    • New ignored test rayquery_tests::the_distant_shadows_commit_their_alpha_tested_candidates, which reads a local copy of a1b20bc47e3c9597 (DARNER_HWRT_DISTANT_SHADOW, never in the repository, like the file's other local-program tests). It checks that all 4 walks are lifted and at least 4 commits are left after the clean-up passes (dxc -dumpbin), and validates with dxil.dll. It fails on main (0 commits) and passes with the change.
  • Changes a default: no (only DARNER_HW_RT lifting of these programs).
  • A/B result: not yet. An in-game before/after of distant shadows from trees and foliage (same spot, hardware RT) will follow; WIP until then.
  • Gates run: cargo xtask policy ok; gate 1 and gate 2 (--all-features) ok on 6883c23. Gate 3 (cargo test --workspace --locked --no-fail-fast) on 6883c23: every crate ok except darner-gpu 1822 passed / 1 failed, shader_cache::tests::every_switch_of_the_translator_is_in_the_key, which flagged the new test's DARNER_HWRT_DISTANT_SHADOW; 59256a1 lists it with DARNER_HWRT_SHADER and that test passes, cargo clippy -p darner-gpu --all-targets --locked -- -D warnings ok. (An earlier gate-3 run under load also failed three watch tests, which pass on main alone and passed in the rerun: not this change.)
  • Gameplay: not yet (RTX 4090, Series X profile, 1440p, hardware RT planned).
  • Shader wave sizes tested: 32 lanes (the test's host wave).
  • Hardware dependence: likely general (translation only).
  • Coverage gaps: no in-game check yet. Only the 16 programs lifted in my runs were compared, not a full cache.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). In-game check to follow.
  • 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 PRs: #535 (another RT shadow translation fix, in lower.rs; no overlap with rayquery.rs).
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: 1577734278060445696 ## What it changes - The problem on main: read from the code and from the translator's output, not seen in the game yet. With hardware RT, the four distant-shadow programs (`CS_RTDistantShadowTrace32_Tiled` `a1b20bc47e3c9597`, `…LeakPlug32_Tiled` `e8c962358d862e3f`, `…TraceTemporalUpsample4X32_Tiled` `17829ac71aab4e8d`, `…LeakPlugTemporalUpsample4X32_Tiled` `afeea48bbb9913ad`) are lifted with a candidate callback (`DARNER_HW_RT_WHY=1`: `cb=true`, a `Mask` commit decision), but their DXIL has **no `CommitNonOpaqueTriangleHit`**: each `Proceed` loop is empty. The flags are 0x10/0x14, without `FORCE_OPAQUE`, so every non-opaque (alpha-tested) candidate is dropped. Alpha-tested casters should have no distant shadow. The 32-bit walk tells box nodes from triangles with `v_cmp_eq_u32 vcc, 4, node & 6` before the node test, and runs the triangle path, with the alpha test in it, under `!vcc`. `eval_pre_callback_lane_bit` has no rule for that compare, so its default ("active lane guard") binds it to true. The callback's commit condition becomes `select i1 true, i1 false, X`, always false, and the clean-up passes then remove the commit. With `DARNER_SHADER_OPT=0` the commits are still there behind that false condition, so the clean-up passes are not at fault. The fix: `node_kind_compare` evaluates a comparison of a constant with the node pointer's type bits (`v_and_b32 …, 6|7, node`) for the triangle types 0 to 3 a candidate has. It binds the compare only when all four types agree (here: "box" is false). Every other compare keeps its existing rule. larp's hand-written replacements of these programs commit their alpha test's candidates (https://git.gtahub.st/recklessfish/CNF-Larp, `shaders/replace`), which is what pointed here. No code is taken from it. ## How it was tested - Tested revision: 59256a1 on main c8258f9 (6883c23 the fix; 59256a1 lists the new test's switch in the shader cache's switch test). - Commands and results: - The 16 programs `DARNER_HW_RT` lifts in my runs, taken from my local game files (`darner translate --warm`) and translated with hardware RT, before and after: the four distant-shadow programs go from 0 commits to 3, 5, 3 and 5. **The other 12 programs translate byte-identically.** - New ignored test `rayquery_tests::the_distant_shadows_commit_their_alpha_tested_candidates`, which reads a local copy of `a1b20bc47e3c9597` (`DARNER_HWRT_DISTANT_SHADOW`, never in the repository, like the file's other local-program tests). It checks that all 4 walks are lifted and at least 4 commits are left after the clean-up passes (`dxc -dumpbin`), and validates with `dxil.dll`. **It fails on main** (0 commits) and passes with the change. - Changes a default: no (only `DARNER_HW_RT` lifting of these programs). - A/B result: not yet. An in-game before/after of distant shadows from trees and foliage (same spot, hardware RT) will follow; WIP until then. - Gates run: `cargo xtask policy` ok; gate 1 and gate 2 (`--all-features`) ok on 6883c23. Gate 3 (`cargo test --workspace --locked --no-fail-fast`) on 6883c23: every crate ok except `darner-gpu` 1822 passed / 1 failed, `shader_cache::tests::every_switch_of_the_translator_is_in_the_key`, which flagged the new test's `DARNER_HWRT_DISTANT_SHADOW`; 59256a1 lists it with `DARNER_HWRT_SHADER` and that test passes, `cargo clippy -p darner-gpu --all-targets --locked -- -D warnings` ok. (An earlier gate-3 run under load also failed three `watch` tests, which pass on main alone and passed in the rerun: not this change.) - Gameplay: not yet (RTX 4090, Series X profile, 1440p, hardware RT planned). - Shader wave sizes tested: 32 lanes (the test's host wave). - Hardware dependence: likely general (translation only). - Coverage gaps: no in-game check yet. Only the 16 programs lifted in my runs were compared, not a full cache. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). In-game check to follow. - [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 PRs: #535 (another RT shadow translation fix, in `lower.rs`; no overlap with `rayquery.rs`). - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The 32-bit walk tells box nodes from triangles with `node & 6 == 4` before
the node test and runs its triangle path, and the alpha test of a
non-opaque candidate in it, under the opposite. Prebinding that bit as an
active-lane guard (true) made the callback's commit condition always
false, so the lifted RayQuery never committed a non-opaque candidate: the
distant shadows (CS_RTDistantShadowTrace32_Tiled and its LeakPlug /
TemporalUpsample variants) lost every alpha-tested caster.

A comparison of a constant with the node pointer's type bits is now
evaluated for the triangle types (0 to 3) a candidate has. The four
distant-shadow programs commit again (0 -> 3/5/3/5 commits); the other
twelve lifted programs of a local cache translate byte-identically.

Pointed at by larp's hand-written replacements of these programs
(https://git.gtahub.st/recklessfish/CNF-Larp, shaders/replace).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from WIP: [pr-fix][shaders][RAYTRACING] Commit alpha-tested candidates in the 32-bit walks' lifted queries (distant shadows) to WIP: Commit alpha-tested candidates in the 32-bit walks' lifted queries (distant shadows) 2026-12-06 03:27:08 +00:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/rq-distant-shadow-alpha:Yorivel-pr/rq-distant-shadow-alpha'
git switch 'Yorivel-pr/rq-distant-shadow-alpha'

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 'Yorivel-pr/rq-distant-shadow-alpha'
git switch 'Yorivel-pr/rq-distant-shadow-alpha'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'Yorivel-pr/rq-distant-shadow-alpha'
git switch 'Yorivel-pr/rq-distant-shadow-alpha'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'Yorivel-pr/rq-distant-shadow-alpha'
git switch 'Main'
git merge --squash 'Yorivel-pr/rq-distant-shadow-alpha'
git switch 'Main'
git merge --ff-only 'Yorivel-pr/rq-distant-shadow-alpha'
git switch 'Main'
git merge 'Yorivel-pr/rq-distant-shadow-alpha'
git push origin 'Main'
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!558
No description provided.