d3d12: bind inline ray scenes in queue order #569

Open
smith-3 wants to merge 1 commit from upstream-pr/569 into main
smith-3 commented 2026-11-30 04:02:57 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by smith-3 on 2026-11-30T04:02:57Z.


Problem

A list can record a reflected inline ray query while a later recording advertises replacement TLAS storage for the same guest address. Rejecting the older batch leaves its downstream texture signals unexecuted. This can happen after #514 when a later list has already published a successor and another build is being recorded.

Change

Resolve the native scene at the dispatch's position in queue order. For reflected direct dispatches and dispatch-only ExecuteIndirect, record the native dispatch at submission between its original prefix and suffix. Keep that work and its scene resources alive through the queue fence. Preserve validation on paths that cannot replay the dispatch.

This draft is open for review of the queue ordering and lifetime model.

Validation

The added native regression records three generations with the same guest scene address. It checks both Dispatch and ExecuteIndirect by reading back the ray hit. The regression rejected the later batch before the change. On 29d5c3d4, the 12 native D3D12 tests selected by scene passed on an RTX 4080 SUPER using NVIDIA 570.211.01. All four tests selected by scene_publication also passed on an AMD iGPU using RADV 25.2.8.

In a ProjectScarlett run on the RTX 4080 SUPER with the existing shader cache and #563 in the integration build, the direct queue accepted the batches and the first 3D scene rendered. The run later ended in the Xid 109 tracked by #232, before we could verify player control. The independent branch targets main.

python tuxbox.py check --no-gpu on 29d5c3d4 completed with 10 passed, 0 failed. Broader GPU checks are pending.

<!-- greyfinch-sync:brcly/TuxBox:issue:5558751281 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/569). Originally posted by [smith-3](https://github.com/smith-3) on 2026-11-30T04:02:57Z. --- ## Problem A list can record a reflected inline ray query while a later recording advertises replacement TLAS storage for the same guest address. Rejecting the older batch leaves its downstream texture signals unexecuted. This can happen after #514 when a later list has already published a successor and another build is being recorded. ## Change Resolve the native scene at the dispatch's position in queue order. For reflected direct dispatches and dispatch-only ExecuteIndirect, record the native dispatch at submission between its original prefix and suffix. Keep that work and its scene resources alive through the queue fence. Preserve validation on paths that cannot replay the dispatch. This draft is open for review of the queue ordering and lifetime model. ## Validation The added native regression records three generations with the same guest scene address. It checks both Dispatch and ExecuteIndirect by reading back the ray hit. The regression rejected the later batch before the change. On `29d5c3d4`, the 12 native D3D12 tests selected by `scene` passed on an RTX 4080 SUPER using NVIDIA 570.211.01. All four tests selected by `scene_publication` also passed on an AMD iGPU using RADV 25.2.8. In a ProjectScarlett run on the RTX 4080 SUPER with the existing shader cache and #563 in the integration build, the direct queue accepted the batches and the first 3D scene rendered. The run later ended in the Xid 109 tracked by #232, before we could verify player control. The independent branch targets main. `python tuxbox.py check --no-gpu` on `29d5c3d4` completed with 10 passed, 0 failed. Broader GPU checks are pending.
brcly commented 2026-11-30 04:12:02 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:02Z.


Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase.

  • Formatting: the whole workspace is now formatted with rustfmt (see the new rustfmt.toml).
  • Lints: every crate denies unwrap(), lossy as casts and undocumented unsafe outside tests.
  • CI: it now also runs cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.

The least painful way is to format your branch first, so the rebase only shows real changes:

git fetch origin
git checkout origin/main -- rustfmt.toml
cargo fmt --all && git commit -am "rustfmt"
git rebase origin/main

Then run python tuxbox.py check --no-gpu, which now includes the format step.

If clippy flags something new:

  • A cast: use From for widening, TryFrom for narrowing, and a mask for bit fields.
  • An unwrap(): use ?, or expect with the reason it can't fail.
  • An unsafe block: it needs a // SAFETY: comment.

CONTRIBUTING's "Code checks" section lists the commands. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7268557777 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/569#issuecomment-7268557777). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:12:02Z. --- Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase. - **Formatting:** the whole workspace is now formatted with rustfmt (see the new `rustfmt.toml`). - **Lints:** every crate denies `unwrap()`, lossy `as` casts and undocumented `unsafe` outside tests. - **CI:** it now also runs `cargo fmt --check`, rustdoc with warnings denied, and Miri on the providers' unit tests. The least painful way is to format your branch first, so the rebase only shows real changes: ```sh git fetch origin git checkout origin/main -- rustfmt.toml cargo fmt --all && git commit -am "rustfmt" git rebase origin/main ``` Then run `python tuxbox.py check --no-gpu`, which now includes the format step. If clippy flags something new: - **A cast:** use `From` for widening, `TryFrom` for narrowing, and a mask for bit fields. - **An `unwrap()`:** use `?`, or `expect` with the reason it can't fail. - **An `unsafe` block:** it needs a `// SAFETY:` comment. CONTRIBUTING's "Code checks" section lists the commands. Thanks!
NickStallman commented 2026-11-30 04:20:59 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T04:20:59Z.


@smith-3 thanks for this. #566 (ours, opened an hour or so before) is for the same crash, so let's not both go in without thinking about it. What I have:

  • The trace: in our run 81a the refused list had captured the scene, a later list rebuilt it at the same guest address (which moved it: the new one outgrew the 64 KiB-rounded storage), the rebuild was submitted, and then the captured list was refused. Three lists that had captured it before the rebuild's submission passed. On RTX 5090, all five of our runs that got as far as the story (78b, 79a, 79c, 80a, 81a) ended in this refusal, and @3kynox reports the same three frames in the crash on an RTX 4070 Ti SUPER.
  • #566 keeps the storage: a top-level build in title memory gets room for 4 times its instances (at least 2,048), so a grown rebuild stays at its address and lists see the rebuilt scene. 2 game runs since with no refusal (1 and 19 minutes in the world). One that outgrows the room is still moved and refused.
  • Yours resolves the scene at the dispatch's place in queue order, so it also handles one that does outgrow the room, at a larger change in the recording and submission path.

They look compatible to me (yours would take what #566 doesn't), but I haven't tried them together. I don't mind which goes in, or yours replacing mine; #566 is small and could be the first step. If you have a run where a scene outgrows 4 times its instances, that would be the case that decides it. I'm happy to run your draft on our RTX 5090 next to #566, in the same build, and say what both do; tell me if that would help. Both need main's reformat first.

<!-- greyfinch-sync:brcly/TuxBox:comment:7268694688 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/569#issuecomment-7268694688). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T04:20:59Z. --- @smith-3 thanks for this. #566 (ours, opened an hour or so before) is for the same crash, so let's not both go in without thinking about it. What I have: - **The trace:** in our run 81a the refused list had captured the scene, a later list rebuilt it at the same guest address (which moved it: the new one outgrew the 64 KiB-rounded storage), the rebuild was submitted, and then the captured list was refused. Three lists that had captured it before the rebuild's submission passed. On RTX 5090, all five of our runs that got as far as the story (78b, 79a, 79c, 80a, 81a) ended in this refusal, and @3kynox reports the same three frames in the crash on an RTX 4070 Ti SUPER. - **#566** keeps the storage: a top-level build in title memory gets room for 4 times its instances (at least 2,048), so a grown rebuild stays at its address and lists see the rebuilt scene. 2 game runs since with no refusal (1 and 19 minutes in the world). One that outgrows the room is still moved and refused. - **Yours** resolves the scene at the dispatch's place in queue order, so it also handles one that does outgrow the room, at a larger change in the recording and submission path. They look compatible to me (yours would take what #566 doesn't), but I haven't tried them together. I don't mind which goes in, or yours replacing mine; #566 is small and could be the first step. If you have a run where a scene outgrows 4 times its instances, that would be the case that decides it. I'm happy to run your draft on our RTX 5090 next to #566, in the same build, and say what both do; tell me if that would help. Both need main's reformat first.
akimfomin commented 2026-11-30 06:09:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by akimfomin on 2026-11-30T06:09:08Z.


I ran a source-only Windows DXR check for this queue-ordering case from VIctory-NVIDIA-Lab. A direct producer and a compute consumer on RTX 4070 Ti SUPER gave 39 expected results across three fenced scene generations. Selecting the older scene changed two answers. -LateBinding also passed when I recorded ExecuteIndirect first and filled the TLAS root SRV in a per-dispatch argument buffer before submission. This exercises the binding mechanism with generated geometry. The guest-address lookup and gameplay crash still need separate checks. Are there producer/consumer fence cases you would like covered in an independent Windows test?

Pinned sources and commands.

<!-- greyfinch-sync:brcly/TuxBox:comment:7270355233 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/569#issuecomment-7270355233). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-30T06:09:08Z. --- I ran a source-only Windows DXR check for this queue-ordering case from VIctory-NVIDIA-Lab. A direct producer and a compute consumer on RTX 4070 Ti SUPER gave 39 expected results across three fenced scene generations. Selecting the older scene changed two answers. `-LateBinding` also passed when I recorded `ExecuteIndirect` first and filled the TLAS root SRV in a per-dispatch argument buffer before submission. This exercises the binding mechanism with generated geometry. The guest-address lookup and gameplay crash still need separate checks. Are there producer/consumer fence cases you would like covered in an independent Windows test? [Pinned sources and commands](https://github.com/akimfomin/VIctory-NVIDIA-Lab/tree/60615c35c01294726477197cc023dd81a1002448/tools/rt-material-check).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/569:upstream-pr/569'
git switch 'upstream-pr/569'

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 'upstream-pr/569'
git switch 'upstream-pr/569'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/569'
git switch 'upstream-pr/569'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/569'
git switch 'main'
git merge --squash 'upstream-pr/569'
git switch 'main'
git merge --ff-only 'upstream-pr/569'
git switch 'main'
git merge 'upstream-pr/569'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
brcly/TuxBox!569
No description provided.