gpu: builder compacted sizes reach the title's copies behind the list (VICTORY_BVH_SIZE_COPY=1, off by default) #1161
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1161"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CowboyBingus on 2026-11-28T14:34:32Z.
Summary
The title copies 8-byte compacted sizes out of the builder's size slots into its own memory with CopyBufferRegion (SC2: 4,704 such copies). VN did that copy at submission, from title memory. With
VICTORY_BVH_SIZE_COPY=1, a copy into memory with a host copy takes its bytes on the card out of the source's host copy when that copy has by-address stores kept (and is not in place), instead of out of title memory as it is at submission. A copy of at most 64 bytes into memory without a host copy (or with one in place), out of the builder's size pages (source without a host copy) or out of a host copy the shaders own, is done after the list has landed. Off by default.Fixes: no issue. Related: #689, #718.
Checked for overlap: open PR #718 addresses the same stale-size report (#689) by answering the size at the builder call; the two were measured as separate arms (see Relation).
Rebased onto main
77df871e(no conflicts). Two commits: the change (with tests forowned()andWritten::From), and a split oflate_size_copy's decision into a purelate(), with tests for it and for the size pages.How it was tested
VICTORY_BVH_BUILDER=1).32ecacfa(newer main), switch off / on, 3 runs each: pooled world-frame median 95.5 ms before, 59.8 ms after; p90 160.2 ms before, 103.7 ms after.63b902fe(older main), 4 runs each: pooled world-frame median 84.2 ms before, 50.8 ms after; p90 153.1 ms before, 98.6 ms after.What it changes
VICTORY_BVH_SIZE_COPY; only the value1turns it on.list.rsbuffer_copy: a copy that cannot be placed is checked byplace::late_size_copy. If it qualifies, it is recorded asdefer_write(to, Written::From(from), len)instead ofdefer_copy.late_size_copylooks up the host copies and passes them to a purelate(), which qualifies a copy when: the switch is on; len <= 64 bytes (LATE_MOST); the destination has no host copy (or one in place); and the source either has no host copy and lies in 4 KiB pages the builder's size programs store into (memory::in_size_pages), or has a host copy matchingowned(written, in_place, stores_kept, true).memory.rs: with the switch on,ready()recordswritten[0]'s 4 KiB page for builds that ask a size (asks_size).queue.rs: newWritten::From(u64). On write it copiesbytesbytes from that title address (copy_mappedon Windows,ptr::copyelsewhere).place.rsshaders_own: with the switch on, a source whose host copy has by-address stores kept (Shadow::stores_kept) also counts as shader-owned.host.rs:mod placebecomespub(crate).shadow.rs: newShadow::stores_kept()(readschanges_only).Why (measured)
Two trace runs (
VICTORY_BVH_TRACE=1,VICTORY_BVH_SIZES_WAIT=1,VICTORY_BVH_SIZE_COPY=1) on diagnostic builds of the branch this commit was ported from, in an early indoor scene, withVICTORY_BVH_BUILDER=1:Measurements
Window in both sets: host meter lines with more than 1000 draws/frame, from 90 s after start to run end; "world" = the line's ms/frame. Release builds, swapped one at a time into the same exe path;
VICTORY_BVH_BUILDER=1andVICTORY_NO_ACTIVATE=1in all runs.VICTORY_NO_ACTIVATEcomes from 2 local commits (window activation only), not part of this PR.Newer main:
32ecacfaBuild:
32ecacfa+ this PR's two commits (same patches as on this branch) + the 2 window-activation commits; exe md5 bcb5e0c5.32ecacfais an ancestor of77df871e, 189 commits behind it; these runs were not repeated on77df871e.With this build (exe bcb5e0c5) the builder stays off on this card without
VICTORY_LDS_WRITE_ONLY_OK=1: in 8 runs, three builder programs refused, missing=3 of=53 (#1475). So every run here also hasVICTORY_LDS_WRITE_ONLY_OK=1. Arm A: noVICTORY_BVH_SIZE_COPY. Arm B:VICTORY_BVH_SIZE_COPY=1. 6 runs, pair order A1/B1, B2/A2, A3/B3. All 6 logged "the ray-tracing structure builder runs ... pipelines=53", logged no device removal, and were stopped at the 140 s time cap (140.1-140.5 s).Per pair, B median minus A median: -74.7 (B1-A1), -10.3 (B2-A2), -25.3 (B3-A3) ms.
Older main:
63b902fe14 runs, interleaved; 13 used (U_A1 excluded, below). One more launch of a different exe was stopped at 17.5 s for taking the foreground and is not counted.
63b902fe+ the 2 window-activation commits; exe md5 969421f9801070ae),VICTORY_BVH_SIZE_ANSWERunset (on by default); md5 1215aba4655611b6, bygit patch-id),VICTORY_BVH_SIZE_COPY=1; md5 a9396168Per-run world median / p90 ms:
The first base run (U_A1, first of the chain) is excluded: world median 330.3 ms. Run ends differ: 9 runs stopped at the 140 s cap, 4 at a bright-screen stop (120.3-137.8 s), so window lengths differ. From 100 s instead of 90 s the pooled medians are 84.8 / 72.7 / 50.8 ms.
Relation to #689 and #718
#689 reports the compacted size being read back before the builder writes it, so copies use a stale size. #718 answers compacted sizes at the builder call with the maximum size the builder reported for the input shape (
VICTORY_BVH_SIZE_ANSWER). This PR instead delays the title's own size copy until the list has landed. In the older-main runs, m718 and this PR were measured as separate arms; the two together were not run.Limits
801070aesays the builder's later store into an answered slot is kept out of title memory. This PR and #718 together were not run.VICTORY_LDS_WRITE_ONLY_OK=1in both arms (#1475); it was not run on77df871e.Not established
Tests
On this branch (
77df871e+ 2 commits, tip204db2b7):cargo test -p victory-gpu --lib -j 4: 554 passed, 0 failed, 43 ignored; with--features diagnostics: 608 passed, 0 failed, 43 ignored.late()conditions andowned()truth table (place.rs), size pages recorded and found by page (memory.rs),Written::Fromcopy (queue.rs).cargo clippy -p victory-gpu --all-targets -- -D warnings(with and withoutdiagnostics) stops invictory-shaderatemit/lower.rs:2213(manual_checked_ops) andemit/lower.rs:13896(unused variable). Without-D warnings, the remaining warnings are in victory-gpuhost.rs(10800, 10843, 10903),host/send.rs,pool.rs,residency.rs,resource.rs,streamline.rs,streamline/fsr.rs.git blameputs every one of these lines on a commit in main; this branch does not change any of them.🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CowboyBingus on 2026-11-28T15:51:30Z.
Three at-once memory dumps, read offline with a BVH walker over the dumped memory.
Setup: one diagnostics exe (md5 334d3f77) that has the
VICTORY_BVH_SIZE_COPYswitch,VICTORY_BVH_BUILDER=1,VICTORY_BVH_CALLS, at-once dump triggered about 105 s after launch. The only setting that differs isVICTORY_BVH_SIZE_COPY: D0 off, D1 and D2 on.TLAS 1 (0xdb51a0000)
TLAS 2 (0xdb6119c00)
Ray set 1 starts at the middle of the top level's header bounds, so its start point differs between runs: D0's ±3.4028235e38 bounds put it at the origin (0, 0, 0); D1's and D2's start at the middle of their finite bounds. The ray-set numbers are therefore not like-for-like between D0 and D1/D2.
D0 left 2,591 title-buffer pages out of the dump; D1 and D2 left none.
Not established
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by CowboyBingus on 2026-11-29T02:37:00Z.
State of this PR:
github.com/trustno1-coder/VIctory-NVIDIA@62896483hasgithub.com/trustno1-coder/VIctory-NVIDIA@1788f111as its second parent.github.com/trustno1-coder/VIctory-NVIDIA@568c5e5d). Git dropped the fix commit as already applied, so the PR now holds one commit,github.com/trustno1-coder/VIctory-NVIDIA@73e97949: two tests incrates/victory-gpu/src/memory.rsandcrates/victory-gpu/src/host/place.rs, withlate_size_copy's decision split into a purelate()for them. GitHub reports it as mergeable.cargo test --release -p victory-gpu --lib -- sizeon that tree: 16 passed, 0 failed.Merge or close it as you prefer.
🤖 Generated with Claude Code
Pull request closed