Ray tracing: the builder's geometry buffers are made ready before it reads them (zero triangles) #3265

Open
atk3001 wants to merge 1 commit from upstream-pr/3265 into main
atk3001 commented 2026-11-29 21:09:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by atk3001 on 2026-11-29T21:09:21Z.


What

With VICTORY_BVH_BUILDER=1, the title has XboxBvhBuilder unpack its packed bottom-level structures
(RehydrateRaytracingAccelerationStructureBatched2X) and build others (BuildRaytracingAccelerationStructureBatched2X).
The builder's leaf stage reads the index, vertex and transform buffers through the addresses in the
geometry descs. No root argument names those addresses, so memory::ready never made their pages ready.
Pages without a copy read zero, and the fault note only helps the next frame. A structure is unpacked
once, so its triangles stay zero.

In a capture of 200 unpacked structures, compared node by node:

before after
triangle nodes all zero 72.5 % 0 %
structures with only zero triangles 73 0
triangles inside their parent box – 159,441 of 159,441

A ray that should have hit one of those triangles missed it.

  • dxr.rs: the rehydrate and batched build calls are wrapped (only with the builder on), and each names
    its triangle geometry's transform (48 bytes), index (indices * 4 + 64 KiB) and vertex
    (max(vertices, indices) * stride + 64 KiB) ranges, each at most 16 MiB. The margins are there because the title's packed
    formats read past VertexCount * stride, and index format 53 is a stream with its own header.
  • memory.rs: name_geometry holds those ranges. The next builder dispatch's ready() maps them and brings
    their data up before it runs.
  • Off with VICTORY_BVH_GEOMETRY_READY=0. Without VICTORY_BVH_BUILDER=1 nothing changes (no wrapper is installed).

Tests

  • the_geometry_of_plain_and_batched_descs_is_named: ranges from a plain desc array and from batched
    elements (80-byte stride), and the 16 MiB cap.
  • victory-gpu dxr tests: 8 passed. Clippy: no warnings in dxr.rs or memory.rs (the other warnings are already on main). Release build ok.
  • In game (RTX 5080, 1440p, -RayTracing): the BVH comparison above. The ray-traced picture looks clearly
    better. About 23 pages per frame are still read before they are ready and fixed a frame later. Those
    belong to other passes, not to the builder.

Overlap

  • No open PR touches the builder's geometry. #2108 (skip page faults for unread BVH nodes) and #3071
    (VICTORY_BVH_LOG) are near it, but they do not conflict.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5555146616 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3265). Originally posted by [atk3001](https://github.com/atk3001) on 2026-11-29T21:09:21Z. --- ## What With `VICTORY_BVH_BUILDER=1`, the title has `XboxBvhBuilder` unpack its packed bottom-level structures (`RehydrateRaytracingAccelerationStructureBatched2X`) and build others (`BuildRaytracingAccelerationStructureBatched2X`). The builder's leaf stage reads the index, vertex and transform buffers through the addresses in the geometry descs. No root argument names those addresses, so `memory::ready` never made their pages ready. Pages without a copy read zero, and the fault note only helps the next frame. A structure is unpacked once, so its triangles stay zero. In a capture of 200 unpacked structures, compared node by node: | | before | after | |---|---|---| | triangle nodes all zero | 72.5 % | 0 % | | structures with only zero triangles | 73 | 0 | | triangles inside their parent box | – | 159,441 of 159,441 | A ray that should have hit one of those triangles missed it. - `dxr.rs`: the rehydrate and batched build calls are wrapped (only with the builder on), and each names its triangle geometry's transform (48 bytes), index (`indices * 4` + 64 KiB) and vertex (`max(vertices, indices) * stride` + 64 KiB) ranges, each at most 16 MiB. The margins are there because the title's packed formats read past `VertexCount * stride`, and index format 53 is a stream with its own header. - `memory.rs`: `name_geometry` holds those ranges. The next builder dispatch's `ready()` maps them and brings their data up before it runs. - Off with `VICTORY_BVH_GEOMETRY_READY=0`. Without `VICTORY_BVH_BUILDER=1` nothing changes (no wrapper is installed). ## Tests - `the_geometry_of_plain_and_batched_descs_is_named`: ranges from a plain desc array and from batched elements (80-byte stride), and the 16 MiB cap. - `victory-gpu` dxr tests: 8 passed. Clippy: no warnings in `dxr.rs` or `memory.rs` (the other warnings are already on main). Release build ok. - In game (RTX 5080, 1440p, `-RayTracing`): the BVH comparison above. The ray-traced picture looks clearly better. About 23 pages per frame are still read before they are ready and fixed a frame later. Those belong to other passes, not to the builder. ## Overlap - No open PR touches the builder's geometry. #2108 (skip page faults for unread BVH nodes) and #3071 (`VICTORY_BVH_LOG`) are near it, but they do not conflict. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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/3265:upstream-pr/3265'
git switch 'upstream-pr/3265'

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/3265'
git switch 'upstream-pr/3265'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3265'
git switch 'upstream-pr/3265'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3265'
git switch 'main'
git merge --squash 'upstream-pr/3265'
git switch 'main'
git merge --ff-only 'upstream-pr/3265'
git switch 'main'
git merge 'upstream-pr/3265'
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
trustno1-coder/VIctory-NVIDIA!3265
No description provided.