[pr-fix][shaders][RAYTRACING] RayQuery callbacks: sampled-slot marks queued in a callback are written inside it #105

Manually merged
TrustNo1 merged 1 commit from wutzebaer/Darner:callback-marks into main 2026-12-03 20:55:15 +00:00
Contributor

Contributor role (optional)

  • Fluxer ID: 1577979738855575553

What it changes

With hardware ray tracing and DARNER_SAMPLED_MARKS=1, four of the title's compute programs do not translate: 17829ac71aab4e8d, a1b20bc47e3c9597, afeea48bbb9913ad and e8c962358d862e3f. The emitter panics with "forward reference outside a phi" (crates/darner-shader/src/emit/bitcode.rs).

A fetch inside a RayQuery callback queues a wave-uniform sampled-slot mark, and the slot index it marks is defined inside the callback. The queue was only written at the end of the enclosing IR block. That end comes after the query, so the mark read a value from a part of the function that does not come before it.

The queued marks are now written where the callback's instructions end, for both callback kinds (Inline and Blocks), and before a section's side effects are lowered. With the marks off (the default of darner.exe) nothing is queued and nothing changes.

How it was tested

  • Tested revision: 619e417e (this change on main at 4a92569f), Windows 11, RTX 5090, debug build.
  • Commands and results:
    • darner translate --warm <file with the four hashes> <game folder> with DARNER_HW_RT=1 DARNER_BVH_MISS=1 DARNER_NAN_SCRUB=1 DARNER_SAMPLED_MARKS=1 DARNER_HOST_WAVE=32:
      • main at 4a92569f: four panics, "forward reference outside a phi".
      • this change: "4 hashes asked, 4 found: 4 translated now, 0 do not translate".
      • main with DARNER_SAMPLED_MARKS=0: all four translate, so the marks are what it takes.
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed.
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed.
    • cargo test --workspace --locked --no-fail-fast: three tests fail, and the same three fail on main at 4a92569f without this change:
      • darner-gpu: host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end (1704 passed, 1 failed, 79 ignored)
      • darner-shader: emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders and emit::wave64_tests::lds_shared_atomic_add_producer_executes_wave32_on_hardware (554 passed, 2 failed, 15 ignored)
      • every other crate passed.
  • Gameplay: not tested with the marks on. The same change has been in my own build with hardware ray tracing for two days, with the marks at their default (off), where it changes nothing.
  • Shader wave sizes tested: 32 lanes.
  • Coverage gaps: no unit test; I found no small program that queues a mark inside a callback without the title's shaders. Not tested on 64-lane hosts or on AMD and Intel cards.

Checklist

  • 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: none found (none of the 45 open pull requests changes crates/darner-shader/src/emit/rayquery.rs; no issue names the four hashes).
## Contributor role (optional) - Fluxer ID: 1577979738855575553 ## What it changes With hardware ray tracing and `DARNER_SAMPLED_MARKS=1`, four of the title's compute programs do not translate: `17829ac71aab4e8d`, `a1b20bc47e3c9597`, `afeea48bbb9913ad` and `e8c962358d862e3f`. The emitter panics with "forward reference outside a phi" (`crates/darner-shader/src/emit/bitcode.rs`). A fetch inside a RayQuery callback queues a wave-uniform sampled-slot mark, and the slot index it marks is defined inside the callback. The queue was only written at the end of the enclosing IR block. That end comes after the query, so the mark read a value from a part of the function that does not come before it. The queued marks are now written where the callback's instructions end, for both callback kinds (`Inline` and `Blocks`), and before a section's side effects are lowered. With the marks off (the default of `darner.exe`) nothing is queued and nothing changes. ## How it was tested - Tested revision: 619e417e (this change on `main` at 4a92569f), Windows 11, RTX 5090, debug build. - Commands and results: - `darner translate --warm <file with the four hashes> <game folder>` with `DARNER_HW_RT=1 DARNER_BVH_MISS=1 DARNER_NAN_SCRUB=1 DARNER_SAMPLED_MARKS=1 DARNER_HOST_WAVE=32`: - `main` at 4a92569f: four panics, "forward reference outside a phi". - this change: "4 hashes asked, 4 found: 4 translated now, 0 do not translate". - `main` with `DARNER_SAMPLED_MARKS=0`: all four translate, so the marks are what it takes. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed. - `cargo test --workspace --locked --no-fail-fast`: three tests fail, and the same three fail on `main` at 4a92569f without this change: - `darner-gpu`: `host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end` (1704 passed, 1 failed, 79 ignored) - `darner-shader`: `emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders` and `emit::wave64_tests::lds_shared_atomic_add_producer_executes_wave32_on_hardware` (554 passed, 2 failed, 15 ignored) - every other crate passed. - Gameplay: not tested with the marks on. The same change has been in my own build with hardware ray tracing for two days, with the marks at their default (off), where it changes nothing. - Shader wave sizes tested: 32 lanes. - Coverage gaps: no unit test; I found no small program that queues a mark inside a callback without the title's shaders. Not tested on 64-lane hosts or on AMD and Intel cards. ## 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. - 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 (none of the 45 open pull requests changes `crates/darner-shader/src/emit/rayquery.rs`; no issue names the four hashes).
With hardware ray tracing and DARNER_SAMPLED_MARKS=1, four of the title's
compute programs (17829ac71aab4e8d, a1b20bc47e3c9597, afeea48bbb9913ad,
e8c962358d862e3f) panicked in the emitter: "forward reference outside a
phi" (bitcode.rs). A fetch inside a RayQuery callback queues a
wave-uniform sampled-slot mark whose slot index is defined in the
callback. The queue was only written at the end of the enclosing IR
block, which comes after the query, so the mark read a value from a part
of the function that does not come before it.

The queued marks are now written where the callback's instructions end,
for both callback kinds, and before a section's side effects are
lowered. With the marks off nothing is queued and the output is
unchanged.
TrustNo1 manually merged commit fc3642e0c1 into main 2026-12-03 20:55:15 +00:00
Sign in to join this conversation.
No reviewers
No labels
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!105
No description provided.