rayquery: collect all header PHIs updated by cur_inst in search_blk #588

Open
Nyutt wants to merge 1 commit from nyutt/rayquery-extra-hit-inst-phis into Main AGit
Contributor

What it changes

  • The problem on main: with DARNER_HW_RT=1, 14 bvh32 ray queries across 6 RTShadowTrace32* compute shaders fail lifting with bvh32: unrecognized live-out value Value(...) (PHI B<latch>:33 (V(<r>))) and fall back to the miss form (299/315 bvh32 loops lifted in the_local_shader_cache_lifts_its_ray_queries).

In those opaque bvh32 queries, search_blk (tri_accept_block) writes cur_inst (s_node_phi) into a temporary VGPR (v_mov_b32 v_tmp, s_node_phi) that both copies into the primary hit_inst_phi via a downstream move and remains live in v_tmp up to outer_header. find_updated_header_phi returned on the first header PHI it reached (hit_inst_phi), leaving v_tmp's header PHI unrecognized in classify_live_outs.

This adds find_all_updated_header_phis and records all header PHIs updated from leaf.cur_inst_vals in TriHitInfo::extra_hit_inst_phis, so classify_live_outs binds them as LiveOutKind::CommittedHitSentinel (with Some(hp) preserving init_v on skipped lanes).

How it was tested

  • Tested revision: 61cacf1 (based on origin/main c8258f9)
  • Commands and results:
    • cargo test --locked --offline -p darner-shader --lib rayquery: 7 passed, 0 failed, 2 ignored (includes new synthetic unit test find_all_updated_header_phis_collects_both_original_and_copied_header_phis).
    • cargo clippy --locked --offline -p darner-shader --all-targets -- -D warnings: 0 warnings.
    • cargo xtask policy: asset policy: 576 files ok.
    • DARNER_KNOWN_SHADERS=<local> cargo test --release --locked --offline -p darner-shader --lib the_local_shader_cache_lifts_its_ray_queries -- --ignored --nocapture (run on the 8 previously incomplete RT programs before splitting branches, with dxil.dll validation): 14/16 previously unlifted bvh32 queries now lift and validate cleanly (534b3645dd344ab2 11/12->12/12, 813783478ebb80e6 10/12->12/12, fb515ca95d694c18 34/36->36/36, 1250dc0656b3c091 33/36->36/36, a41f0b553a07e79d 9/12->12/12, ffd9788ba9fec033 31/36->34/36; lifted not validating 0).
  • Changes a default: yes, for DARNER_HW_RT=1 lifting of those 14 previously skipped bvh32 queries.
  • Gates run on that revision: crate-scoped darner-shader clippy + rayquery unit tests + cargo xtask policy (full workspace clippy/test not run on this revision).
  • Gameplay: not yet tested in live gameplay; validated via dxil.dll validator on the local shader cache.
  • Shader wave sizes tested: 32 lanes (RTX 5070 Ti).
  • Hardware dependence: likely general (DXIL lifting fix).
  • Coverage gaps: full workspace gates and live in-game visual verification not yet run on 61cacf1.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). (Validated with dxil.dll on the local shader cache; live gameplay test pending.)
  • 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: #558 (touches rayquery.rs for alpha-tested candidates in bvh32 distant shadows; orthogonal to this opaque search_blk hit_inst_phi fix).
  • Replaces or overlaps: none found
## What it changes - The problem on main: with `DARNER_HW_RT=1`, 14 `bvh32` ray queries across 6 `RTShadowTrace32*` compute shaders fail lifting with `bvh32: unrecognized live-out value Value(...) (PHI B<latch>:33 (V(<r>)))` and fall back to the miss form (`299/315` `bvh32` loops lifted in `the_local_shader_cache_lifts_its_ray_queries`). In those opaque `bvh32` queries, `search_blk` (`tri_accept_block`) writes `cur_inst` (`s_node_phi`) into a temporary VGPR (`v_mov_b32 v_tmp, s_node_phi`) that both copies into the primary `hit_inst_phi` via a downstream move and remains live in `v_tmp` up to `outer_header`. `find_updated_header_phi` returned on the first header PHI it reached (`hit_inst_phi`), leaving `v_tmp`'s header PHI unrecognized in `classify_live_outs`. This adds `find_all_updated_header_phis` and records all header PHIs updated from `leaf.cur_inst_vals` in `TriHitInfo::extra_hit_inst_phis`, so `classify_live_outs` binds them as `LiveOutKind::CommittedHitSentinel` (with `Some(hp)` preserving `init_v` on skipped lanes). ## How it was tested - Tested revision: `61cacf1` (based on `origin/main` `c8258f9`) - Commands and results: - `cargo test --locked --offline -p darner-shader --lib rayquery`: 7 passed, 0 failed, 2 ignored (includes new synthetic unit test `find_all_updated_header_phis_collects_both_original_and_copied_header_phis`). - `cargo clippy --locked --offline -p darner-shader --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: `asset policy: 576 files ok`. - `DARNER_KNOWN_SHADERS=<local> cargo test --release --locked --offline -p darner-shader --lib the_local_shader_cache_lifts_its_ray_queries -- --ignored --nocapture` (run on the 8 previously incomplete RT programs before splitting branches, with `dxil.dll` validation): 14/16 previously unlifted `bvh32` queries now lift and validate cleanly (`534b3645dd344ab2` 11/12->12/12, `813783478ebb80e6` 10/12->12/12, `fb515ca95d694c18` 34/36->36/36, `1250dc0656b3c091` 33/36->36/36, `a41f0b553a07e79d` 9/12->12/12, `ffd9788ba9fec033` 31/36->34/36; `lifted not validating 0`). - Changes a default: yes, for `DARNER_HW_RT=1` lifting of those 14 previously skipped `bvh32` queries. - Gates run on that revision: crate-scoped `darner-shader` clippy + `rayquery` unit tests + `cargo xtask policy` (full workspace clippy/test not run on this revision). - Gameplay: not yet tested in live gameplay; validated via `dxil.dll` validator on the local shader cache. - Shader wave sizes tested: 32 lanes (RTX 5070 Ti). - Hardware dependence: likely general (DXIL lifting fix). - Coverage gaps: full workspace gates and live in-game visual verification not yet run on `61cacf1`. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). *(Validated with `dxil.dll` on the local shader cache; live gameplay test pending.)* - [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: #558 (touches `rayquery.rs` for alpha-tested candidates in `bvh32` distant shadows; orthogonal to this opaque `search_blk` `hit_inst_phi` fix). - Replaces or overlaps: none found
Author
Contributor

Live in-game AB/BA verification on cam-city60 (-Flight InGame, RTX 5070 Ti 16 GB, Ryzen 7 7800X3D, 31 GB RAM, Series X, 1080p->1440p, DLSS Quality, Frame Gen 2x, DARNER_HW_RT=1, both slots preloaded / WARM, 0 slow loads, 0 errors):

Order: M588 (c8258f9), P588 (61cacf1), P588 (61cacf1), M588 (c8258f9) — 4/4 BENCH OK.

ab.py (fast 5–65 s, median [spread]) M588 (c8258f9, 2 runs) P588 (61cacf1, 2 runs)
fps_med 23.4 [0.9] 23.6 [4.0]
fps_p10 17.7 [0.1] 17.0 [7.2]
p99_ms 82.5 [6.9] 87.9 [23.3]
over100_pct 0.2 [0.0] 0.6 [0.6]
dropped_pf 0.0 [0.0] 0.0 [0.0]
vram_peak (MB) 14015.0 [31.1] 13826.2 [86.6]
ws_peak (MB) 25430.9 [234.4] 25059.2 [136.7]

Per-run (fast 5–65 s):

  • M588 #1: 22.2 fps med, 20.1 p10, 0.2% >100 ms
  • P588 #1: 20.8 fps med, 13.5 p10, 1.0% >100 ms (one prep spike)
  • P588 #2: 24.1 fps med, 21.4 p10, 0.1% >100 ms
  • M588 #2: 22.6 fps med, 20.7 p10, 0.2% >100 ms

Result: no performance or stability regression with the 14 additional bvh32 RTShadowTrace32* queries running on hardware RT cores.

Live in-game AB/BA verification on `cam-city60` (`-Flight InGame`, RTX 5070 Ti 16 GB, Ryzen 7 7800X3D, 31 GB RAM, Series X, 1080p->1440p, DLSS Quality, Frame Gen 2x, `DARNER_HW_RT=1`, both slots preloaded / `WARM`, 0 slow loads, 0 errors): Order: `M588` (`c8258f9`), `P588` (`61cacf1`), `P588` (`61cacf1`), `M588` (`c8258f9`) — 4/4 `BENCH OK`. | `ab.py` (`fast` 5–65 s, median [spread]) | `M588` (`c8258f9`, 2 runs) | `P588` (`61cacf1`, 2 runs) | |---|---:|---:| | `fps_med` | 23.4 [0.9] | 23.6 [4.0] | | `fps_p10` | 17.7 [0.1] | 17.0 [7.2] | | `p99_ms` | 82.5 [6.9] | 87.9 [23.3] | | `over100_pct` | 0.2 [0.0] | 0.6 [0.6] | | `dropped_pf` | 0.0 [0.0] | 0.0 [0.0] | | `vram_peak` (MB) | 14015.0 [31.1] | 13826.2 [86.6] | | `ws_peak` (MB) | 25430.9 [234.4] | 25059.2 [136.7] | Per-run (`fast` 5–65 s): - `M588` #1: 22.2 fps med, 20.1 p10, 0.2% >100 ms - `P588` #1: 20.8 fps med, 13.5 p10, 1.0% >100 ms (one prep spike) - `P588` #2: 24.1 fps med, 21.4 p10, 0.1% >100 ms - `M588` #2: 22.6 fps med, 20.7 p10, 0.2% >100 ms Result: no performance or stability regression with the 14 additional `bvh32` `RTShadowTrace32*` queries running on hardware RT cores.
TrustNo1 changed title from [pr-fix][shaders][RAYTRACING] rayquery: collect all header PHIs updated by cur_inst in search_blk to rayquery: collect all header PHIs updated by cur_inst in search_blk 2026-12-06 03:26:49 +00:00
Owner

Test needed — commit 61cacf1f; what to check:

  • The problem on main: with DARNER_HW_RT=1, 14 bvh32 ray queries across 6 RTShadowTrace32* compute shaders fail lifting with bvh32: unrecognized live-out value Value(...) (PHI B<latch>:33 (V(<r>))) and fall back to the miss form (299/315 bvh32 loops lifted in the_local_shader_cache_lifts_its_ray_queries).

In those opaque bvh32 queries, search_blk (tri_accept_block) writes cur_inst (s_node_phi) into a temporary VGPR (v_mov_b32 v_tmp, s_node_phi) that both copies into the primary hit_inst_phi via a downstream move and remains live in v_tmp up to outer_header. find_updated_header_phi returned on the first header PHI it reached (hit_inst_phi), leaving v_tmp's header PHI unrecognized in classify_live_outs.

This adds find_all_updated_header_phis and records all header PHIs updated from leaf.cur_inst_vals in TriHitInfo::extra_hit_inst_phis, so classify_live_outs binds them as LiveOutKind::CommittedHitSentinel (with Some(hp) preserving init_v on skipped lanes).

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 `61cacf1f`; what to check: - The problem on main: with `DARNER_HW_RT=1`, 14 `bvh32` ray queries across 6 `RTShadowTrace32*` compute shaders fail lifting with `bvh32: unrecognized live-out value Value(...) (PHI B<latch>:33 (V(<r>)))` and fall back to the miss form (`299/315` `bvh32` loops lifted in `the_local_shader_cache_lifts_its_ray_queries`). In those opaque `bvh32` queries, `search_blk` (`tri_accept_block`) writes `cur_inst` (`s_node_phi`) into a temporary VGPR (`v_mov_b32 v_tmp, s_node_phi`) that both copies into the primary `hit_inst_phi` via a downstream move and remains live in `v_tmp` up to `outer_header`. `find_updated_header_phi` returned on the first header PHI it reached (`hit_inst_phi`), leaving `v_tmp`'s header PHI unrecognized in `classify_live_outs`. This adds `find_all_updated_header_phis` and records all header PHIs updated from `leaf.cur_inst_vals` in `TriHitInfo::extra_hit_inst_phis`, so `classify_live_outs` binds them as `LiveOutKind::CommittedHitSentinel` (with `Some(hp)` preserving `init_v` on skipped lanes). 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/588/head:nyutt/rayquery-extra-hit-inst-phis'
git switch 'nyutt/rayquery-extra-hit-inst-phis'

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 'nyutt/rayquery-extra-hit-inst-phis'
git switch 'nyutt/rayquery-extra-hit-inst-phis'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'nyutt/rayquery-extra-hit-inst-phis'
git switch 'nyutt/rayquery-extra-hit-inst-phis'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'nyutt/rayquery-extra-hit-inst-phis'
git switch 'Main'
git merge --squash 'nyutt/rayquery-extra-hit-inst-phis'
git switch 'Main'
git merge --ff-only 'nyutt/rayquery-extra-hit-inst-phis'
git switch 'Main'
git merge 'nyutt/rayquery-extra-hit-inst-phis'
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!588
No description provided.