Ray tracing: a copy out of a builder result page is recorded on the card, behind the builder's dispatches #4827

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

@⁠cafeoh on GitHub · 2026-12-01 10:25 UTC · original
cafeoh:fix/bvh-size-copy-on-card → main · +104 −0 · 3 files · 1 commits · open

Follow-up to #1412, closed on 11-30 because it predates v2026.11.29.01: it still happens on current main 5fabb46ea (with #718's VICTORY_BVH_SIZE_ANSWER on by default, as eleboucher and nick0451 also found there), and docs/fork-ray-tracing.md still lists the overlap.

Scope: the software structure walk only (VICTORY_BVH_BUILDER=1 without VICTORY_HW_RT). With hardware RT the title's builder is off and none of these copies happen, so #4694 users on DXR 1.1 cards are not affected either way. It matters for cards without DXR 1.1 and for anyone who keeps the walk in shaders.

What it changes

The title copies a structure's compacted size out of the slot the builder's size program writes, in the same list or the next, and places the next structure by it. Today that copy is made from the CPU's side at submission, before the size program has run on the card, so the title reads the slot's previous value (#1412: "it takes 0x1c00 bytes for C, which is B's size"), and the next structure's copy writes over it. VICTORY_BVH_SIZE_COPY=1 copies again after the list, but only where the destination has no host copy.

With this change, a title copy whose source lies in a builder result page is recorded as a CopyBufferRegion on the card at its place in the list, behind the size program's dispatch (with the barriers around it), and the destination is marked as written by the card. The CPU never reads the slot.

On by default; VICTORY_BVH_SIZE_COPY_ON_CARD=0 gives the old path. A log line counts the copies made on the card and those left to the usual path.

How it was tested

RTX 2080 Ti 11 GB, Windows 10, Ryzen 7 7800X3D, Series S, ray tracing on (software walk), DLSS off, release build, the launcher's defaults (no other switches), 89 s after the world shows, shaders and pipelines made beforehand, PresentMon, last 40 s, runs in the order with / without / with / without:

On main 5fabb46ea (this branch):

fps, last 40 s fps from the world on frames over 250 ms (from the world on) card ms/frame
with (run 1) 13.05 12.91 8 66.7
without (run 1) 9.66 9.39 20 84.9
with (run 2) 14.11 13.50 10 68.6
without (run 2) 8.10 8.31 27 121.8

Earlier, on main f5c3d2434: with 11.84 / 12.47 fps, without 10.31 / 10.47 (frames over 250 ms: 9 / 8 against 45 / 20). On e1251c319 with #4568's revert: with 16.09 / 15.94, without 13.61 / 12.92.

The counter: about 5,000 copies a run made on the card on this branch (6,000 on the release), none left over. The screen-probe trace program (CS_ScreenProbes_TraceRays) no longer grows over the run as structures overlap.

Not tested: AMD, Series X profile, DLSS on, sessions longer than about 3 minutes. Pictures: lighting looked the same at a glance; no frame-by-frame comparison.

Checked for overlap

  • Issues and PRs searched for the same copy: #1161 (VICTORY_BVH_SIZE_COPY, copies after the list, merged and off by default), #718 (answers at the builder call, on by default, does not cover every copy), #1413 (trace). #4760 changes hardware RT's postbuild sizes only. No open PR records the copy on the card.
**@⁠cafeoh** on GitHub · 2026-12-01 10:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4826) `cafeoh:fix/bvh-size-copy-on-card` → `main` · +104 −0 · 3 files · 1 commits · open Follow-up to #1412, closed on 11-30 because it predates v2026.11.29.01: it still happens on current main 5fabb46ea (with #718's `VICTORY_BVH_SIZE_ANSWER` on by default, as eleboucher and nick0451 also found there), and docs/fork-ray-tracing.md still lists the overlap. **Scope:** the software structure walk only (`VICTORY_BVH_BUILDER=1` without `VICTORY_HW_RT`). With hardware RT the title's builder is off and none of these copies happen, so #4694 users on DXR 1.1 cards are not affected either way. It matters for cards without DXR 1.1 and for anyone who keeps the walk in shaders. ## What it changes The title copies a structure's compacted size out of the slot the builder's size program writes, in the same list or the next, and places the next structure by it. Today that copy is made from the CPU's side at submission, before the size program has run on the card, so the title reads the slot's previous value (#1412: "it takes 0x1c00 bytes for C, which is B's size"), and the next structure's copy writes over it. `VICTORY_BVH_SIZE_COPY=1` copies again after the list, but only where the destination has no host copy. With this change, a title copy whose source lies in a builder result page is recorded as a `CopyBufferRegion` on the card at its place in the list, behind the size program's dispatch (with the barriers around it), and the destination is marked as written by the card. The CPU never reads the slot. On by default; `VICTORY_BVH_SIZE_COPY_ON_CARD=0` gives the old path. A log line counts the copies made on the card and those left to the usual path. ## How it was tested RTX 2080 Ti 11 GB, Windows 10, Ryzen 7 7800X3D, Series S, ray tracing on (software walk), DLSS off, release build, the launcher's defaults (no other switches), 89 s after the world shows, shaders and pipelines made beforehand, PresentMon, last 40 s, runs in the order with / without / with / without: On main 5fabb46ea (this branch): | | fps, last 40 s | fps from the world on | frames over 250 ms (from the world on) | card ms/frame | |---|---|---|---|---| | with (run 1) | 13.05 | 12.91 | 8 | 66.7 | | without (run 1) | 9.66 | 9.39 | 20 | 84.9 | | with (run 2) | 14.11 | 13.50 | 10 | 68.6 | | without (run 2) | 8.10 | 8.31 | 27 | 121.8 | Earlier, on main f5c3d2434: with 11.84 / 12.47 fps, without 10.31 / 10.47 (frames over 250 ms: 9 / 8 against 45 / 20). On e1251c319 with #4568's revert: with 16.09 / 15.94, without 13.61 / 12.92. The counter: about 5,000 copies a run made on the card on this branch (6,000 on the release), none left over. The screen-probe trace program (CS_ScreenProbes_TraceRays) no longer grows over the run as structures overlap. Not tested: AMD, Series X profile, DLSS on, sessions longer than about 3 minutes. Pictures: lighting looked the same at a glance; no frame-by-frame comparison. ## Checked for overlap - [x] Issues and PRs searched for the same copy: #1161 (`VICTORY_BVH_SIZE_COPY`, copies after the list, merged and off by default), #718 (answers at the builder call, on by default, does not cover every copy), #1413 (trace). #4760 changes hardware RT's postbuild sizes only. No open PR records the copy on the card.
The title copies a structure's compacted size out of the slot the builder's
size program writes, in the same list or the next, and places the next
structure by it. That copy was made from the CPU's side at submission,
before the size program had run on the card, so it took the slot's previous
value and the next structure's copy wrote over its neighbour (#1412).
VICTORY_BVH_SIZE_COPY=1 copies again after the list, but only where the
destination has no host copy.

A title copy whose source lies in a builder result page is now recorded as
a CopyBufferRegion on the card at its place in the list, behind the
dispatches before it; the destination's host copy takes it and lands with
the list. On unless VICTORY_BVH_SIZE_COPY_ON_CARD=0. A line counts the
copies made on the card and those left to the usual path.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 10:30:34 +00:00
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 15:17 UTC · original · reviewed

AI-assisted review: I traced the new BVH result-source lookup through list recording and submission ordering. I used AI assistance and verified that this diff adds no regression test for the path.

**@⁠gut0to** on GitHub · 2026-12-01 15:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4826#pullrequestreview-6134184420) · **reviewed** AI-assisted review: I traced the new BVH result-source lookup through list recording and submission ordering. I used AI assistance and verified that this diff adds no regression test for the path.
@ -1441,1 +1441,4 @@
}
// Out of a page the structure builder stores results in: on the card,
// behind its dispatches (VICTORY_BVH_SIZE_COPY_ON_CARD).
if crate::memory::size_copy_on_card()
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 15:17 UTC · original

Could this default-on path get an end-to-end GPU regression? Its correctness depends on finding the builder result-page shadow and copying from it after the builder dispatches, with the destination reflecting that value when the list lands. The existing size-copy test covers only the older late_size_copy predicate; this diff adds no test for result_source or place_result_copy. A WARP test that writes a known size into the source, records the title copy after that write, submits, then checks the destination would catch source-offset and ordering regressions.

**@⁠gut0to** on GitHub · 2026-12-01 15:17 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4826#discussion_r4756335345) Could this default-on path get an end-to-end GPU regression? Its correctness depends on finding the builder result-page shadow and copying from it after the builder dispatches, with the destination reflecting that value when the list lands. The existing size-copy test covers only the older late_size_copy predicate; this diff adds no test for result_source or place_result_copy. A WARP test that writes a known size into the source, records the title copy after that write, submits, then checks the destination would catch source-offset and ordering regressions.
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/4827/head:github-bot/gh-4826'
git switch 'github-bot/gh-4826'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4826'
git switch 'github-bot/gh-4826'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4826'
git switch 'github-bot/gh-4826'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4826'
git switch 'main'
git merge --squash 'github-bot/gh-4826'
git switch 'main'
git merge --ff-only 'github-bot/gh-4826'
git switch 'main'
git merge 'github-bot/gh-4826'
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!4827
No description provided.