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

Open
github-bot wants to merge 1 commit from github-bot/gh-3265 into main AGit
Owner

@⁠atk3001 on GitHub · 2026-11-29 21:09 UTC · original
atk3001:pr/rt-geometry-ready → main · +128 −4 · 2 files · 1 commits · open

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

**@⁠atk3001** on GitHub · 2026-11-29 21:09 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3265) `atk3001:pr/rt-geometry-ready` → `main` · +128 −4 · 2 files · 1 commits · open ## 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)
With VICTORY_BVH_BUILDER=1 the builder's leaf stage reads index, vertex
and transform buffers through the addresses in the geometry descs. No
root argument names them, so their pages read zero; a structure is
unpacked once, so its triangles stayed zero (72.5 % of the unpacked
triangle nodes in a capture, 0 % with this).

The rehydrate and batched build calls are wrapped (builder on only) and
name those ranges; the next builder dispatch's ready() maps them and
brings their data up. Off with VICTORY_BVH_GEOMETRY_READY=0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 21:10:06 +00:00
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/3265/head:github-bot/gh-3265'
git switch 'github-bot/gh-3265'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3265'
git switch 'github-bot/gh-3265'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3265'
git switch 'github-bot/gh-3265'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3265'
git switch 'main'
git merge --squash 'github-bot/gh-3265'
git switch 'main'
git merge --ff-only 'github-bot/gh-3265'
git switch 'main'
git merge 'github-bot/gh-3265'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3265
No description provided.