Repository navigation
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Missing AMD validation, remaining device losses, and an unmet in-game toggle leave cross-vendor and runtime risks in the GPU ray walks requiring human review.
No open issues 🎉
What changed in this PR
Fixes console-format scene traversal by giving instance records parent-table entries, so short-stack walks can safely climb from masked-out instances.
Changes:
- Expands and populates the parent table for instance records.
- Updates traversal tests to use and validate those entries.
- Clarifies when walks use the table versus the record’s own parent word.
| File | Description |
|---|---|
| runtime/bvh-layout/src/tests/scene.rs | Checks instance parent entries and uses them during traversal. |
| runtime/bvh-layout/src/scene.rs | Allocates and writes parent-table entries for instances. |
| runtime/bvh-layout/src/lib.rs | Documents the two instance-parent lookup paths. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What was wrong. A console ray walk keeps 16 nodes per lane. Once that overflowed and is empty, it climbs through the structure's parent table.
write_scenegave an entry in that table to box nodes only. But a walk can climb from an instance record too: one the ray's mask leaves out is never entered, so when it was the last node, the walk looks the record up in the scene's own table, past its end. It then takes a box node's child pointer or a float of its bounds for a node pointer.What that does. A node pointer names a 64-byte block in its upper 29 bits, and the translated walks use the low 32 bits of the byte offset. So a float from 0.5 up to 2 reads as an offset in the last 128 MiB under 4 GiB from the scene. The walks' root SRV has no bounds. Four device losses with
TUXBOX_CONSOLE_STRUCTURES=1and walkfb8e97e0in flight read addresses there, above the newest structures buffer. A fifth had the same walk in flight, at an address whose memory had been freed. That is consistent with this defect, not proof of it. Other values land just above the buffer or inside it. Inside, the ray ends early, or goes round until the walk's own limit of 65,536 steps.The change. The table covers the instance records as well, 8 bytes more for each instance in the scene. A record keeps its own parent word, which a walk reads when it comes back from a structure. Nothing changes with the switch off, and no shader is recompiled.
The writer came with #525, whose description says its comparison on real scenes didn't cover the short stack and the parent table (that comparison was mine, with a plain stack walk). I found no reason there for leaving the records out of the table. @NickStallman, tell me if there was one.
The test's walk climbed from an instance through the record's word, which is why it agreed with the writer. It now climbs through the table, as the programs do.
Tested
106120cawithout the change, see below)runtime/bvh-layout, which only the D3D12 provider uses.GPU, driver and backend: RTX 4070 Ti SUPER 16 GB, NVIDIA 620.73.04, vkd3d-proton (Proton Experimental), Intel CPU.
No Lanes scenario: the writer's own tests cover it without a GPU. Without the change,
walks_find_what_testing_every_triangle_findsreads outside its buffer andtrees_are_wholefinds the first instance's entry missing.On real scenes, on the CPU. In two buffers I had dumped from the game with this writer (November 30), 1,309 of 1,309 and 1,108 of 1,108 instance entries were wrong. I then walked the first one with my own C version of the short-stack walk, 1.98 billion random rays of up to 10,000 units from near the instances:
0xf9……)It is rare, and my rays are not the title's: this says it can happen on its scenes, not how often it does.
In the game. Thirteen runs with the switch on and this change, on
6d4f1cd7with #647 rather than this branch's head. Nine walks served, the hit-shading programs running with the change of #670, default settings (ten of the runs also had the diagnostic of #567). The loss with that walk in flight didn't come back. That says little: before the change it came after 194 to 763 s of world, and only five of the thirteen runs got past 194 s, because other losses ended them first.Other losses ended all thirteen. Twelve read memory of a texture that had ended, as in #603, and one read an address that had been bound again 3 s before. No walk was in flight. In the three pairs of my off/on control with this change (the one asked for on #586), the device was lost in three runs of three with the switch on and in one of three with it off, so the nine-walk control is still not met.
The switch stays off by default. The line of
docs/ENVIRONMENT.mdthat says only four walks can be served stays too, until that control is met.Checks
No evidence JSON changes.