intersect: pin the shadow-ray stand-in for a node test with no structures #638

Open
qnjk wants to merge 1 commit from qnjk/Darner:intersect-occlusion-test into Main
Contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: nothing. This is a tests-only change (no production line is edited).

  • What it pins: Lower::bvh, with no_hit() or bvh_miss() on, gives a program whose rays are shadow rays the occluded stand-in — a box enters OCCLUDER, a triangle one node past the structure's start, and every triangle test hits just short of the ray's end — and gives every other program the plain miss (crates/darner-shader/src/emit/intersect.rs, the OCCLUSION branch around the old :258). Nothing tested that branch: shadow_ray_programs_are_told_by_name tests the name predicate only, and no test read or set OCCLUSION, so an inversion of it, or a kind comparison that stopped holding (pointer & 6 == 4 for kinds 4 and 5, pointer & 7 < 4 for kinds 0 to 3), would not have been noticed. It is the branch that decides whether a shadowed pixel is lit — the live path under DARNER_HW_RT=1.

  • This change adds intersect_tests::a_shadow_ray_that_answers_no_hit_is_occluded: it lowers the same program twice, with OCCLUSION on and off, asserts the two DXIL forms differ and that neither loads the memory directory or notes a fault, then dispatches the 32-thread record and checks what each thread gets — kinds 4 and 5 [8, NONE, NONE, NONE], kinds 0 to 3 the hit at 0.996 of the extent with weights 1, 1/4, 1/4, kinds 6 and 7 the triangle miss, and the shadow-ray state off [NONE, NONE, NONE, NONE] with the miss. It serialises with ONE_AT_A_TIME (the same lock the neighbouring valu tests take) and restores the thread-local switches in a Drop guard, so a failing assertion cannot leak them into another test.

How it was tested

  • Tested revision: 5d1f949 (one commit on c8258f9).
  • Commands and results:
    • cargo test --locked -p darner-shader --lib -- intersect — 13 passed, 0 failed.
    • cargo clippy --locked -p darner-shader --all-targets -- -D warnings passes.
    • Fail-before (tests-only, so the branch was mutated in turn): inverting OCCLUSION fails the new test on the first thread (the plain miss where the hit is), and making is_box compare with 6 instead of 4 fails it on thread 4 (the plain miss where 8 is). Each mutation was reverted with file copies, never git stash.
  • Changes a default: no. Tests only.
  • A/B result: not applicable — tests-only change.
  • Gates run on that revision:
    • Gate 1, cargo clippy --workspace --all-targets --locked -- -D warnings: passes.
    • Gate 2, cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passes.
    • Gate 3: this crate's suite is green apart from the pre-existing darner-gpu issues on this machine (#224, #150), and the full darner-shader run takes minutes because of the oracle sweep, so the change was gated by the intersect module (13 passed) plus both clippy runs.
  • Gameplay, when relevant: not applicable — tests-only change. The defect it guards against (an inverted OCCLUSION) was observed by a tester as a grid of white dots in the shade, per the finding.
  • Shader wave sizes tested, when relevant: the record is 32 threads, one per lane in the wave; the 64-lane folded shape is not exercised.
  • Hardware dependence: the dispatch half needs a device — it runs on the adapter and on WARP and skips what it cannot run, as the neighbouring no-hit test does; the lowering half needs nothing.
  • Coverage gaps: the bvh_miss route to the same stand-in is exercised only through TEST_NO_HIT; a real structure that answers "no hit" on its own is not.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
    • Not applicable: tests-only change, stated at the top.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md (cargo xtask policy: passes).
  • 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: none found. No open pull request changes crates/darner-shader/src/emit/intersect_tests.rs or intersect.rs (checked against the file list of all 189 open pull requests), and no open or closed issue mentions OCCLUSION or the shadow-ray stand-in.
  • Replaces or overlaps: none found
## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: nothing. This is a **tests-only** change (no production line is edited). - What it pins: `Lower::bvh`, with `no_hit()` or `bvh_miss()` on, gives a program whose rays are shadow rays the **occluded** stand-in — a box enters `OCCLUDER`, a triangle one node past the structure's start, and every triangle test hits just short of the ray's end — and gives every other program the plain miss (`crates/darner-shader/src/emit/intersect.rs`, the `OCCLUSION` branch around the old `:258`). Nothing tested that branch: `shadow_ray_programs_are_told_by_name` tests the name predicate only, and no test read or set `OCCLUSION`, so an inversion of it, or a kind comparison that stopped holding (`pointer & 6 == 4` for kinds 4 and 5, `pointer & 7 < 4` for kinds 0 to 3), would not have been noticed. It is the branch that decides whether a shadowed pixel is lit — the live path under `DARNER_HW_RT=1`. - This change adds `intersect_tests::a_shadow_ray_that_answers_no_hit_is_occluded`: it lowers the same program twice, with `OCCLUSION` on and off, asserts the two DXIL forms differ and that neither loads the memory directory or notes a fault, then dispatches the 32-thread record and checks what each thread gets — kinds 4 and 5 `[8, NONE, NONE, NONE]`, kinds 0 to 3 the hit at 0.996 of the extent with weights 1, 1/4, 1/4, kinds 6 and 7 the triangle miss, and the shadow-ray state off `[NONE, NONE, NONE, NONE]` with the miss. It serialises with `ONE_AT_A_TIME` (the same lock the neighbouring valu tests take) and restores the thread-local switches in a `Drop` guard, so a failing assertion cannot leak them into another test. ## How it was tested - Tested revision: `5d1f949` (one commit on `c8258f9`). - Commands and results: - `cargo test --locked -p darner-shader --lib -- intersect` — 13 passed, 0 failed. - `cargo clippy --locked -p darner-shader --all-targets -- -D warnings` passes. - Fail-before (tests-only, so the branch was mutated in turn): inverting `OCCLUSION` fails the new test on the first thread (the plain miss where the hit is), and making `is_box` compare with 6 instead of 4 fails it on thread 4 (the plain miss where `8` is). Each mutation was reverted with file copies, never `git stash`. - Changes a default: no. Tests only. - A/B result: not applicable — tests-only change. - Gates run on that revision: - Gate 1, `cargo clippy --workspace --all-targets --locked -- -D warnings`: passes. - Gate 2, `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passes. - Gate 3: this crate's suite is green apart from the pre-existing `darner-gpu` issues on this machine (#224, #150), and the full `darner-shader` run takes minutes because of the oracle sweep, so the change was gated by the `intersect` module (13 passed) plus both clippy runs. - Gameplay, when relevant: not applicable — tests-only change. The defect it guards against (an inverted `OCCLUSION`) was observed by a tester as a grid of white dots in the shade, per the finding. - Shader wave sizes tested, when relevant: the record is 32 threads, one per lane in the wave; the 64-lane folded shape is not exercised. - Hardware dependence: the dispatch half needs a device — it runs on the adapter and on WARP and skips what it cannot run, as the neighbouring no-hit test does; the lowering half needs nothing. - Coverage gaps: the `bvh_miss` route to the same stand-in is exercised only through `TEST_NO_HIT`; a real structure that answers "no hit" on its own is not. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - Not applicable: tests-only change, stated at the top. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md` (`cargo xtask policy`: passes). - [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: none found. No open pull request changes `crates/darner-shader/src/emit/intersect_tests.rs` or `intersect.rs` (checked against the file list of all 189 open pull requests), and no open or closed issue mentions `OCCLUSION` or the shadow-ray stand-in. - Replaces or overlaps: none found
`Lower::bvh`, with `no_hit()` or `bvh_miss()` on, gives a program whose rays are
shadow rays the occluded form — a box enters `OCCLUDER`, a triangle one node
past the structure's start, and every triangle test hits just short of the ray's
end — and gives every other program the plain miss. Nothing tested that branch:
`shadow_ray_programs_are_told_by_name` tests the name predicate only, and no
test read or set `OCCLUSION`, so an inversion of it, or a kind comparison that
stopped holding (`pointer & 6 == 4` for kinds 4 and 5, `pointer & 7 < 4` for
kinds 0 to 3), would not have been noticed. It is the branch that decides
whether a shadowed pixel is lit; its absence was the grid of white dots in the
shade.

The test lowers the same program twice, with `OCCLUSION` on and off, asserts the
two DXIL forms differ and that neither loads the memory directory or notes a
fault, then dispatches the 32-thread record on hardware and WARP: kinds 4 and 5
give `[8, NONE, NONE, NONE]`, kinds 0 to 3 the hit at 0.996 of the extent with
weights 1, 1/4, 1/4, kinds 6 and 7 the triangle miss, and the form with the
shadow-ray state off `[NONE, NONE, NONE, NONE]` and the miss. Inverting
`OCCLUSION` fails it on the first thread (the plain miss where the hit is), and
making `is_box` compare with 6 instead of 4 fails it on thread 4 (the plain miss
where `8` is).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TrustNo1 changed title from [pr-tests][shaders] intersect: pin the shadow-ray stand-in for a node test with no structures to intersect: pin the shadow-ray stand-in for a node test with no structures 2026-12-06 03:25:44 +00:00
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 'intersect-occlusion-test:qnjk-intersect-occlusion-test'
git switch 'qnjk-intersect-occlusion-test'

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 'qnjk-intersect-occlusion-test'
git switch 'qnjk-intersect-occlusion-test'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'qnjk-intersect-occlusion-test'
git switch 'qnjk-intersect-occlusion-test'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'qnjk-intersect-occlusion-test'
git switch 'Main'
git merge --squash 'qnjk-intersect-occlusion-test'
git switch 'Main'
git merge --ff-only 'qnjk-intersect-occlusion-test'
git switch 'Main'
git merge 'qnjk-intersect-occlusion-test'
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!638
No description provided.