Ray tracing: the title's structure builder runs without crashing it (dispatches by thread counts, title memory by address made ready); node tests answer no hit while it is off (stacked on #854 and #993) #994

Open
github-bot wants to merge 61 commits from github-bot/gh-994 into main AGit
Owner

@⁠PiloteCode on GitHub · 2026-11-25 15:24 UTC · original
PiloteCode:pr/ray-tracing → main · +12382 −1786 · 58 files · 61 commits · open

Stacked on #993 (the second translator PR), which is itself stacked on #854. This PR's commits are the 21 after README: geometry stages, loops as the console runs them, .... It needs that PR in two places:

  • the group base: a dispatch by thread counts is composed with the base the host gives a split dispatch;
  • the test host's bounded root UAVs.

Where the builder stands

Until now, the title died about a frame after the structure builder's first frame, on pointers of all ones read from its own objects. The cause was the layer's: it took the builder's dispatches by thread counts for group counts (below).

With the fix, in runs of our tree on an RTX 5090:

  • 420 s of save gameplay with the builder on (VICTORY_BVH_BUILDER=1, its trace on): no fault and no card loss. Every stage ran, none was dropped (Dec 2,516, Leaf 2,516, Box32 7,446, Box16 14,719, ReloadTriangles and Refit 26,144 each, Construct 5,618, LoadInstances 2,032 dispatches), about 200 builder dispatches a frame once the world was up. In the window scene, the hair's light is steady with the builder on. With it off, it changed from run to run: dark in two runs, lit in one, because the passes walked whatever lay in memory.
  • Two more runs had the builder on by default, an opening cutscene and a gameplay run from the save: no exception and no device loss.

This PR keeps the builder opt-in, as on main (VICTORY_BVH_BUILDER=1), for its cost:

  • 88 ms more card time a frame in the window scene (160 ms against 72);
  • the opening cutscene's frame median went from 385 ms to 752 ms between two successive builds of our tree, the second with the builder on by default (it had other changes too).

Whether the traced passes light as the console's do is still to be compared picture by picture.

What changes

Dispatches by thread counts run only those threads (list.rs, draw.rs, pipeline.rs, shader_cache.rs, emit/lower.rs)

DispatchX(x, y, z, flags) passes the console's dispatch initiator bits as its flags. The builder sets USE_THREAD_DIMENSIONS (0x20; 0x8020 for its wave32 programs) on its header copies (DecompressHeader), its box rehydration of pre-built structures (Box32Rehydration, Box16Rehydration) and its triangle reloads (ReloadTriangles, ReloadProcedurals). There, x, y and z count threads: the last group is cut short, and no thread past the count is launched. The layer ran them as group counts.

The box stages rebuild one level of a tree a dispatch, in place, one node a thread: group g writes its 64 nodes at g x 8 KiB (4 KiB for 16-bit boxes), and a lane count read off EXEC (WaveAllBitCount) places each node's payload. In the first frame of a crashing run they ran 272,948 and 47,026 groups where 5,983 and 4,217 were wanted, and wrote 2.2 GiB of empty nodes past their levels. Where that was put back, it lay over the title's own objects, which share those pages at a CPU view 24 GiB lower. Every crash site of that run lies inside such an overrun.

dispatch_x now makes groups of the program's console size out of the counts. Where a last group is cut short:

  • The pipeline runs a form of its program translated for that (victory_shader::emit::translate_thread_limited), made at its first such dispatch and cached under a key of its own.
  • The host passes the counts in a user-data word (USER_THREAD_LIMIT, RootType::Other(0x105)), only along a dimension whose groups are more than one thread wide.
  • The threads past the counts leave in the entry block. So the wave operations, a ballot of EXEC on entry and the title's barriers count the launched threads only, as on the console. A thread that leaves is taken to stop holding up the group's barriers, as an exited thread does on NVIDIA's and AMD's GPUs.
  • The two host waves of a console wave64 program that exchange first tell each other whether they have a launched thread. One with none leaves whole, its exchange dword holding 0, and a reduction's join takes the other half alone.
  • A thread's console id is its group's first thread plus its index, with the group base of #993 (a dispatch split past 65,535 groups is counted right too).
  • The paired and approximate forms are refused, since a host thread holding two console lanes cannot leave for one of them. A builder stage without the form turns the builder off.

The plain translation is untouched: only dispatches by thread counts whose last group is cut short use the second form.

Title memory by address made ready for the builder (list.rs, memory.rs, host.rs, queue.rs, pipeline.rs, draw.rs)

  • List upload memory where shaders reach it. The builder hands its stages the addresses of tables it writes into list upload memory (allocate_upload); its header stage reads its records through them. The layer gave out blocks of the process heap at 1.5-1.8 TiB, beyond the console's 40 bits and the directory of title memory by address (below 128 GiB): the records read as zeros and no structure header was written. Upload memory now comes from 4 MiB chunks of one 512 MiB write-watched reservation between 4 GiB and 128 GiB. Each chunk is a window of memory outside buffers, copied when a list that names it is submitted. Larger requests still come from the heap.

  • The addresses in the records of upload memory are named. The leaf rehydration reads 48-byte D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC records through a root SRV in upload memory, and loads vertices and indices through the addresses in them, which no root argument names. In one run, 638 of the 2,139 such addresses lay in no copy when the stage ran, and those leaves read zeros. Before such a dispatch, the block of upload memory each root SRV points into is looked through (16 KiB at most) for 8-byte title addresses, which are named like the dispatch's own.

  • Copies by address declared written only for address stores. A program that reaches title memory by address declared every numbered copy written as soon as it could store anywhere. Only a program that can store through a raw address now does (a flat or global store or atomic, not to scratch, or code not all known). Of the builder's 52 programs, 11 store that way.

  • Copies kept current where named. Each list that ran such a program refreshed all 1,023 numbered windows (4 GiB) and, if it could store, declared them all written. With the builder's dispatches bound and not run, that alone made a median of 975 ms a frame, against 353 without the builder. Now:

    • a list refreshes the copies just numbered, those its dispatches name and the upload memory's, and declares the first two written;
    • low dwords of address pairs are no longer also taken as addresses in 256-byte units (717 of the 802 windows named in the builder's first frame were such dwords);
    • there are 2,047 numbers, since the first frame ran out of the 1,023.

    VICTORY_MEMORY_ALL=1 restores the old way.

  • The structures' sizes are copied on the card. The title copies each structure's compacted size out of the builder's buffer with CopyBufferRegion, in the list that computed it. Done on the CPU at submission, the copy took what the buffer held before the list's shaders ran. In a list whose shaders store by address, a copy whose source those shaders declared written now runs on the card behind them, and its destination is declared written. Other title copies stay on the CPU. VICTORY_CARD_TITLE_COPIES=0 turns this off.

  • Remaps after the flights. CopyPageMappingsBatchX maps pool pages at once, while the console does it behind the work sent before. A remap now first waits for the flights in the air whose declared writes touch its range, so their writes are not put back into pages mapped there since. VICTORY_REMAP_LAND=0 turns this off.

View addresses read from the view heap by slot (descriptor/host.rs, draw.rs, emit/lower.rs)

Four sun-shadow trace programs (shadowmask:CS_TraceShadowRays at full, half, quarter and eighth resolution) take their structure's address out of a buffer descriptor they pick from the view heap at a computed index. They stopped at "a descriptor read only as data". The host keeps, per view heap, a table of each slot's view address (SLOT_VIEW_ADDRESSES, a root SRV beside the strides), and such a load reads it. The fifth (FullAdaptive) now stops further on, at a lane mask read as data.

Node tests answer no hit while the builder does not run (emit/intersect.rs, pipeline.rs, draw.rs)

The title's ray-traced passes run whether or not anything built their structures. With the builder off, they walked whatever bytes lay where the structures would be: screen-aligned dark tiles on sunlit hair, lit squares in shadow, and hair dark in some runs and lit in others.

A program with a node test now reads a host word (USER_STRUCTURES, RootType::Other(0x106)): 1 while the builder runs whole, 0 before its first dispatch, without VICTORY_BVH_BUILDER=1, or once it is turned off. While it is 0, every node test answers no hit without reading the node: rays escape, and shadow rays find no occluder. VICTORY_BVH_NO_HIT=0 lets them walk memory, as before.

Diagnostics (diagnostics builds)

  • VICTORY_BVH_TRACE=<file>, written unbuffered so that a crashing run keeps it. One line per:
    • dispatch of the builder and of programs that reach title memory by address;
    • read of upload memory;
    • range put back into title memory;
    • page mapping, copy and read-back.
  • VICTORY_BVH_DRY=1 binds the builder's dispatches without running them.
  • VICTORY_BVH_CHECK=<hash>[,<hash>] walks the structures that the header stage, and the in-place rebuild's header stage, start, once their headers are put back. It reports bad nodes: bounds not finite, inverted or outside the parent's, nodes outside the structure or reached twice.
  • VICTORY_CRASH_MEMORY=1 adds to a crash report the title memory around each register that holds a title address, and one pointer further.

Switches

Switch Default Effect
VICTORY_BVH_BUILDER off, as on main =1 runs the builder
VICTORY_BVH_NO_HIT on =0: node tests walk memory while the builder does not run, as before
VICTORY_MEMORY_ALL off =1: every numbered copy refreshed and declared written, as before
VICTORY_CARD_TITLE_COPIES on =0: the title's buffer copies all on the CPU, as before
VICTORY_REMAP_LAND on =0: remaps do not wait for flights
VICTORY_BVH_TRACE, VICTORY_BVH_DRY, VICTORY_BVH_CHECK, VICTORY_CRASH_MEMORY off diagnostics, above

Tested

The branch was checked as it is. The card was reserved for other work, so the tests ran on the software adapter:

  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 264 passed, 5 failed, 2 ignored. The five are the ones that fail on #854's head merged with main on the software adapter (see #993). The tests that need the title's builder DLL skip.
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 188 passed, 1 failed, 6 ignored. The failure is depth_bounds_pipeline_loads_and_filters_draws, as on #854's head: WARP does not reject the pixels outside the depth bounds.
  • cargo test -p victory and cargo test -p victory-loader: passed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo build --release -p victory, cargo build --profile diag -p victory --features diagnostics and cargo xtask policy: pass.

Offline census over the title's whole shader pack, as for #993 (victory translate --validate --list, VICTORY_HOST_MAX_WAVE=32, CPU only: no pipelines): 25,952 of 25,953 programs translate and validate, against #993's 25,948. The four sun-shadow trace programs are the difference (compute 2,733 of 2,734). The one left is the FullAdaptive shadow-mask trace (a lane mask read as data). All 52 builder programs validate.

New tests:

  • a program that numbers its threads, dispatched by thread counts in groups of 32 and of 64 (wave64): every thread inside the counts stores and none past them does, while the plain form runs the whole last group;
  • a console wave64 program cut short at 6, 32, 45 and 97 threads reads its launched lanes as a number and each lane's rank among them, and the upper host wave of a group cut at 32 or fewer gives no lanes to the exchanges;
  • the root signatures the layer makes of the builder's programs, translated for thread counts, stay within D3D12's 64 dwords;
  • with the word at 0, node tests over title memory and over a host buffer give no hit and leave masked threads alone; with 1, they give the reference's results;
  • with VICTORY_TEST_BVH_DLL pointing at the title's XboxBvhBuilder.dll (skipped when unset), the builder's wave64 programs run in their picked and paired forms on the same inputs, and agree. With the same switch, 49 of the 52 programs translate for thread counts and validate; the three paired prefix sums are refused.

The shader tests now keep one device per adapter for the whole test process. Two card test sessions had died in the driver (an access violation in nvwgf2umx.dll on a driver thread, reading freed memory) after a test made and dropped its device.

Overlaps with open pull requests

  • #646 handles USE_THREAD_DIMENSIONS too: groups by div_ceil, and a user-data word (USER_DISPATCH_THREADS, RootType::Other(0x104), 0 for no cap) read by the prologue of every spilled compute program. On wave64-on-wave32 hosts and in programs with barriers, #646 keeps every thread alive and predicates memory accesses, ballots and reductions. Here:

    • the cut-short last group runs a second translation of its program, made only when needed;
    • its unlaunched threads leave at entry, also in programs with barriers (an exited thread stops holding up a barrier on NVIDIA's and AMD's GPUs);
    • the two host waves of a console wave tell each other whether they have a launched thread;
    • the paired forms are refused;
    • the thread ids are composed with the group base of split dispatches.

    #646 uses 0x104, which #993 and #834 use for the group base: one of them needs another code.

  • #916 is the same change as "copies by address declared written only for address stores" (stores_by_address in pipeline.rs).

  • #935 adds a crates/victory-gpu/src/bvhtrace.rs of its own under the same VICTORY_BVH_TRACE switch, crash-report memory dumps, and a quarantine that holds. Its runs crashed 3 to 12 s after the builder's first frame. The overrun of the dispatches by thread counts, fixed here, explains such crashes. Whichever goes in second needs a merge of bvhtrace.rs and crash.rs.

  • #738 and #749 keep a table of view addresses by heap slot as well. #738 uses the same slot (SLOT_VIEW_ADDRESSES, 252) and also widens complement masks, which makes the fifth shadow-mask program translate. #749 keeps addresses, lengths and strides.

  • #814 and #905 (live ray tracing) carry view addresses, a thread-count word and title-memory write-back changes of their own.

  • #823 and #601 give the whole builder pipelines on 32-lane GPUs in other ways (#854 does it with the paired form). #579 drops chosen builder pipelines (diagnostics). #607 saves the second directory lookup of a 128-byte box node.

  • #911 caps constant buffer views at 64 KiB. With the builder on, main needs it (or an equivalent cap): without it a 1.3 MB view removed the device on an RTX 4070 about 36 s after the builder's pipelines were ready, and with it the same run went on (tested by rafaconvaitis below). Our tree has the cap.

Not tested

  • A run of this exact branch in the title: the card was reserved. The runs above were of our tree, which had these changes and others.
  • Pictures against the console's: whether the traced passes light right with the builder on.
  • The frame cost of the builder without its trace, beyond the opening cutscene's median.
  • GPUs with 64-lane waves (AMD), where the builder's wave64 programs run without the paired form and the thread-count form has not been run; Intel; Linux/Proton.
**@⁠PiloteCode** on GitHub · 2026-11-25 15:24 UTC · [original](https://github.com/fxceless/victory-fork/pull/994) `PiloteCode:pr/ray-tracing` → `main` · +12382 −1786 · 58 files · 61 commits · open **Stacked on #993 (the second translator PR), which is itself stacked on #854.** This PR's commits are the 21 after `README: geometry stages, loops as the console runs them, ...`. It needs that PR in two places: - the group base: a dispatch by thread counts is composed with the base the host gives a split dispatch; - the test host's bounded root UAVs. ## Where the builder stands Until now, the title died about a frame after the structure builder's first frame, on pointers of all ones read from its own objects. The cause was the layer's: it took the builder's dispatches by thread counts for group counts (below). With the fix, in runs of our tree on an RTX 5090: - **420 s of save gameplay with the builder on** (`VICTORY_BVH_BUILDER=1`, its trace on): no fault and no card loss. Every stage ran, none was dropped (Dec 2,516, Leaf 2,516, Box32 7,446, Box16 14,719, ReloadTriangles and Refit 26,144 each, Construct 5,618, LoadInstances 2,032 dispatches), about 200 builder dispatches a frame once the world was up. In the window scene, the hair's light is steady with the builder on. With it off, it changed from run to run: dark in two runs, lit in one, because the passes walked whatever lay in memory. - **Two more runs had the builder on by default**, an opening cutscene and a gameplay run from the save: no exception and no device loss. This PR keeps the builder **opt-in, as on `main`** (`VICTORY_BVH_BUILDER=1`), for its cost: - 88 ms more card time a frame in the window scene (160 ms against 72); - the opening cutscene's frame median went from 385 ms to 752 ms between two successive builds of our tree, the second with the builder on by default (it had other changes too). Whether the traced passes light as the console's do is still to be compared picture by picture. ## What changes ### Dispatches by thread counts run only those threads (`list.rs`, `draw.rs`, `pipeline.rs`, `shader_cache.rs`, `emit/lower.rs`) `DispatchX(x, y, z, flags)` passes the console's dispatch initiator bits as its flags. The builder sets `USE_THREAD_DIMENSIONS` (0x20; 0x8020 for its wave32 programs) on its header copies (DecompressHeader), its box rehydration of pre-built structures (Box32Rehydration, Box16Rehydration) and its triangle reloads (ReloadTriangles, ReloadProcedurals). There, x, y and z count threads: the last group is cut short, and no thread past the count is launched. The layer ran them as group counts. The box stages rebuild one level of a tree a dispatch, in place, one node a thread: group g writes its 64 nodes at g x 8 KiB (4 KiB for 16-bit boxes), and a lane count read off EXEC (`WaveAllBitCount`) places each node's payload. In the first frame of a crashing run they ran 272,948 and 47,026 groups where 5,983 and 4,217 were wanted, and wrote 2.2 GiB of empty nodes past their levels. Where that was put back, it lay over the title's own objects, which share those pages at a CPU view 24 GiB lower. Every crash site of that run lies inside such an overrun. `dispatch_x` now makes groups of the program's console size out of the counts. Where a last group is cut short: - The pipeline runs a form of its program translated for that (`victory_shader::emit::translate_thread_limited`), made at its first such dispatch and cached under a key of its own. - The host passes the counts in a user-data word (`USER_THREAD_LIMIT`, `RootType::Other(0x105)`), only along a dimension whose groups are more than one thread wide. - The threads past the counts leave in the entry block. So the wave operations, a ballot of EXEC on entry and the title's barriers count the launched threads only, as on the console. A thread that leaves is taken to stop holding up the group's barriers, as an exited thread does on NVIDIA's and AMD's GPUs. - The two host waves of a console wave64 program that exchange first tell each other whether they have a launched thread. One with none leaves whole, its exchange dword holding 0, and a reduction's join takes the other half alone. - A thread's console id is its group's first thread plus its index, with the group base of #993 (a dispatch split past 65,535 groups is counted right too). - The paired and approximate forms are refused, since a host thread holding two console lanes cannot leave for one of them. A builder stage without the form turns the builder off. The plain translation is untouched: only dispatches by thread counts whose last group is cut short use the second form. ### Title memory by address made ready for the builder (`list.rs`, `memory.rs`, `host.rs`, `queue.rs`, `pipeline.rs`, `draw.rs`) - **List upload memory where shaders reach it.** The builder hands its stages the addresses of tables it writes into list upload memory (`allocate_upload`); its header stage reads its records through them. The layer gave out blocks of the process heap at 1.5-1.8 TiB, beyond the console's 40 bits and the directory of title memory by address (below 128 GiB): the records read as zeros and no structure header was written. Upload memory now comes from 4 MiB chunks of one 512 MiB write-watched reservation between 4 GiB and 128 GiB. Each chunk is a window of memory outside buffers, copied when a list that names it is submitted. Larger requests still come from the heap. - **The addresses in the records of upload memory are named.** The leaf rehydration reads 48-byte `D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC` records through a root SRV in upload memory, and loads vertices and indices through the addresses in them, which no root argument names. In one run, 638 of the 2,139 such addresses lay in no copy when the stage ran, and those leaves read zeros. Before such a dispatch, the block of upload memory each root SRV points into is looked through (16 KiB at most) for 8-byte title addresses, which are named like the dispatch's own. - **Copies by address declared written only for address stores.** A program that reaches title memory by address declared every numbered copy written as soon as it could store anywhere. Only a program that can store through a raw address now does (a flat or global store or atomic, not to scratch, or code not all known). Of the builder's 52 programs, 11 store that way. - **Copies kept current where named.** Each list that ran such a program refreshed all 1,023 numbered windows (4 GiB) and, if it could store, declared them all written. With the builder's dispatches bound and not run, that alone made a median of 975 ms a frame, against 353 without the builder. Now: - a list refreshes the copies just numbered, those its dispatches name and the upload memory's, and declares the first two written; - low dwords of address pairs are no longer also taken as addresses in 256-byte units (717 of the 802 windows named in the builder's first frame were such dwords); - there are 2,047 numbers, since the first frame ran out of the 1,023. `VICTORY_MEMORY_ALL=1` restores the old way. - **The structures' sizes are copied on the card.** The title copies each structure's compacted size out of the builder's buffer with `CopyBufferRegion`, in the list that computed it. Done on the CPU at submission, the copy took what the buffer held before the list's shaders ran. In a list whose shaders store by address, a copy whose source those shaders declared written now runs on the card behind them, and its destination is declared written. Other title copies stay on the CPU. `VICTORY_CARD_TITLE_COPIES=0` turns this off. - **Remaps after the flights.** `CopyPageMappingsBatchX` maps pool pages at once, while the console does it behind the work sent before. A remap now first waits for the flights in the air whose declared writes touch its range, so their writes are not put back into pages mapped there since. `VICTORY_REMAP_LAND=0` turns this off. ### View addresses read from the view heap by slot (`descriptor/host.rs`, `draw.rs`, `emit/lower.rs`) Four sun-shadow trace programs (`shadowmask:CS_TraceShadowRays` at full, half, quarter and eighth resolution) take their structure's address out of a buffer descriptor they pick from the view heap at a computed index. They stopped at "a descriptor read only as data". The host keeps, per view heap, a table of each slot's view address (`SLOT_VIEW_ADDRESSES`, a root SRV beside the strides), and such a load reads it. The fifth (FullAdaptive) now stops further on, at a lane mask read as data. ### Node tests answer no hit while the builder does not run (`emit/intersect.rs`, `pipeline.rs`, `draw.rs`) The title's ray-traced passes run whether or not anything built their structures. With the builder off, they walked whatever bytes lay where the structures would be: screen-aligned dark tiles on sunlit hair, lit squares in shadow, and hair dark in some runs and lit in others. A program with a node test now reads a host word (`USER_STRUCTURES`, `RootType::Other(0x106)`): 1 while the builder runs whole, 0 before its first dispatch, without `VICTORY_BVH_BUILDER=1`, or once it is turned off. While it is 0, every node test answers no hit without reading the node: rays escape, and shadow rays find no occluder. `VICTORY_BVH_NO_HIT=0` lets them walk memory, as before. ### Diagnostics (diagnostics builds) - `VICTORY_BVH_TRACE=<file>`, written unbuffered so that a crashing run keeps it. One line per: - dispatch of the builder and of programs that reach title memory by address; - read of upload memory; - range put back into title memory; - page mapping, copy and read-back. - `VICTORY_BVH_DRY=1` binds the builder's dispatches without running them. - `VICTORY_BVH_CHECK=<hash>[,<hash>]` walks the structures that the header stage, and the in-place rebuild's header stage, start, once their headers are put back. It reports bad nodes: bounds not finite, inverted or outside the parent's, nodes outside the structure or reached twice. - `VICTORY_CRASH_MEMORY=1` adds to a crash report the title memory around each register that holds a title address, and one pointer further. ## Switches | Switch | Default | Effect | |---|---|---| | `VICTORY_BVH_BUILDER` | off, as on `main` | `=1` runs the builder | | `VICTORY_BVH_NO_HIT` | on | `=0`: node tests walk memory while the builder does not run, as before | | `VICTORY_MEMORY_ALL` | off | `=1`: every numbered copy refreshed and declared written, as before | | `VICTORY_CARD_TITLE_COPIES` | on | `=0`: the title's buffer copies all on the CPU, as before | | `VICTORY_REMAP_LAND` | on | `=0`: remaps do not wait for flights | | `VICTORY_BVH_TRACE`, `VICTORY_BVH_DRY`, `VICTORY_BVH_CHECK`, `VICTORY_CRASH_MEMORY` | off | diagnostics, above | ## Tested The branch was checked as it is. The card was reserved for other work, so the tests ran on the software adapter: - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 264 passed, 5 failed, 2 ignored. The five are the ones that fail on #854's head merged with `main` on the software adapter (see #993). The tests that need the title's builder DLL skip. - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 188 passed, 1 failed, 6 ignored. The failure is `depth_bounds_pipeline_loads_and_filters_draws`, as on #854's head: WARP does not reject the pixels outside the depth bounds. - `cargo test -p victory` and `cargo test -p victory-loader`: passed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo build --release -p victory`, `cargo build --profile diag -p victory --features diagnostics` and `cargo xtask policy`: pass. Offline census over the title's whole shader pack, as for #993 (`victory translate --validate --list`, `VICTORY_HOST_MAX_WAVE=32`, CPU only: no pipelines): 25,952 of 25,953 programs translate and validate, against #993's 25,948. The four sun-shadow trace programs are the difference (compute 2,733 of 2,734). The one left is the FullAdaptive shadow-mask trace (a lane mask read as data). All 52 builder programs validate. New tests: - a program that numbers its threads, dispatched by thread counts in groups of 32 and of 64 (wave64): every thread inside the counts stores and none past them does, while the plain form runs the whole last group; - a console wave64 program cut short at 6, 32, 45 and 97 threads reads its launched lanes as a number and each lane's rank among them, and the upper host wave of a group cut at 32 or fewer gives no lanes to the exchanges; - the root signatures the layer makes of the builder's programs, translated for thread counts, stay within D3D12's 64 dwords; - with the word at 0, node tests over title memory and over a host buffer give no hit and leave masked threads alone; with 1, they give the reference's results; - with `VICTORY_TEST_BVH_DLL` pointing at the title's `XboxBvhBuilder.dll` (skipped when unset), the builder's wave64 programs run in their picked and paired forms on the same inputs, and agree. With the same switch, 49 of the 52 programs translate for thread counts and validate; the three paired prefix sums are refused. The shader tests now keep one device per adapter for the whole test process. Two card test sessions had died in the driver (an access violation in `nvwgf2umx.dll` on a driver thread, reading freed memory) after a test made and dropped its device. ## Overlaps with open pull requests - **#646** handles `USE_THREAD_DIMENSIONS` too: groups by `div_ceil`, and a user-data word (`USER_DISPATCH_THREADS`, `RootType::Other(0x104)`, 0 for no cap) read by the prologue of every spilled compute program. On wave64-on-wave32 hosts and in programs with barriers, #646 keeps every thread alive and predicates memory accesses, ballots and reductions. Here: - the cut-short last group runs a second translation of its program, made only when needed; - its unlaunched threads leave at entry, also in programs with barriers (an exited thread stops holding up a barrier on NVIDIA's and AMD's GPUs); - the two host waves of a console wave tell each other whether they have a launched thread; - the paired forms are refused; - the thread ids are composed with the group base of split dispatches. #646 uses `0x104`, which #993 and #834 use for the group base: one of them needs another code. - **#916** is the same change as "copies by address declared written only for address stores" (`stores_by_address` in `pipeline.rs`). - **#935** adds a `crates/victory-gpu/src/bvhtrace.rs` of its own under the same `VICTORY_BVH_TRACE` switch, crash-report memory dumps, and a quarantine that holds. Its runs crashed 3 to 12 s after the builder's first frame. The overrun of the dispatches by thread counts, fixed here, explains such crashes. Whichever goes in second needs a merge of `bvhtrace.rs` and `crash.rs`. - **#738** and **#749** keep a table of view addresses by heap slot as well. #738 uses the same slot (`SLOT_VIEW_ADDRESSES`, 252) and also widens complement masks, which makes the fifth shadow-mask program translate. #749 keeps addresses, lengths and strides. - **#814** and **#905** (live ray tracing) carry view addresses, a thread-count word and title-memory write-back changes of their own. - **#823** and **#601** give the whole builder pipelines on 32-lane GPUs in other ways (#854 does it with the paired form). **#579** drops chosen builder pipelines (diagnostics). **#607** saves the second directory lookup of a 128-byte box node. - **#911** caps constant buffer views at 64 KiB. With the builder on, `main` needs it (or an equivalent cap): without it a 1.3 MB view removed the device on an RTX 4070 about 36 s after the builder's pipelines were ready, and with it the same run went on (tested by rafaconvaitis below). Our tree has the cap. ## Not tested - A run of this exact branch in the title: the card was reserved. The runs above were of our tree, which had these changes and others. - Pictures against the console's: whether the traced passes light right with the builder on. - The frame cost of the builder without its trace, beyond the opening cutscene's median. - GPUs with 64-lane waves (AMD), where the builder's wave64 programs run without the paired form and the thread-count form has not been run; Intel; Linux/Proton.
`cargo clippy --workspace --all-targets -- -D warnings` (CI) fails on 9376fd6
with this toolchain: unnecessary_sort_by in draw.rs, the bench's
depth_written in indirect.rs never read, and placed_filler_twins unused
without the diagnostics feature. No code changes.
Over the title's shader pack (`victory translate --validate --pipelines`
on an RTX 5090, 32-lane waves), 25,682 of 25,953 programs translate,
validate and get a pipeline, against 25,452 on 9376fd6 (compute 2,729
against 2,695, mesh 8,694 against 8,657, pixel 12,067 against 11,947,
vertex 2,192 against 2,153). Of the 271 left, 195 are the unused voxel
geometry stages and 71 the mesh programs below, valid once linked.

- Wave64 compute programs on 32-lane hosts in a paired form: each console
  wave runs as one host wave, each thread two of its lanes (n and n + 32);
  every per-lane branch is taken by the whole wave with EXEC as each
  lane's guard, and lane reads, permutes, lane masks and reductions take
  both halves through the host wave's own operations. Tried after every
  other form for a program the host refuses (it asks for 64-lane waves)
  or that does not translate: 28 programs (screen-space tracing tiles,
  particles, decal trails, hair shadow masks, alpha resolve, three
  structure-builder programs, a cascade shadow program). Tried before the
  per-half forms that are approximate: 36 programs in which each half-wave
  counted, ORed or elected over its own 32 lanes now run as on the
  console. VICTORY_WAVE_PAIRS=0 turns it off. The allocation idiom also
  takes a base with a multiply-add (three lens-flare scans keep their
  per-half form, which is exact for them).
- Mesh programs whose outputs pass D3D12's 32 KiB as translated alone (71:
  pedestrian, vehicle and prop transforms, 65 to 71 components for 128
  vertices; NVIDIA builds them, the validator refuses them) are
  translated again with the pixel program of the pipeline
  (emit::link_mesh): the mesh program writes only what the pixel program
  reads, which declares only the inputs it reads. pipeline/host.rs makes
  such a pipeline from the linked pair (once per pair, same root signature
  and bindings; VICTORY_MESH_LINK=0 turns it off). `victory translate`
  with VICTORY_PAIRS links and validates pairs as the runtime does: 710
  pairs (each of the 71 with the ten pixel programs that read most of its
  outputs) link, validate and get a pipeline.
- One interpolation mode per signature register (70 programs: a float the
  console declared nointerpolation beside an integer or the front face);
  signature rows in the validator's order (72 programs); a level-of-detail
  query of an array texture leaves the layer undefined.
- An immediate sampler chosen by a uniform branch: the block is copied for
  each way in (ir::split_joins; the terrain programs).
- Pixel programs ordered by primitive (POPS) go past the console's wait and
  use rasterizer-ordered views (ten cut-out programs).
- A 16-bit write over a first interpolation half reads that half as zero
  (eight deferred and decal programs). The write of zero over every first
  half (v_interp_p1_f32, v_interp_p1ll_f16) is left out: with it, 59 pixel
  programs that translated came out changed and none more translated; the
  retry with first-half pairs stays.
- Whole-wave sections that a jump splits are joined into one block (the
  water optical depth program), tried first for a program whose permutes
  no followed section holds; elsewhere the v_permlane16/x16 lowering
  stands.
- 64-bit floats and their wave sums (five water volumetrics programs),
  one implementation of the two that existed (float64.rs): both dwords of
  a sum from one host wave operation (in place of Red64F/ActiveF64, which
  summed each dword on its own), v_add_f64, v_mul_f64, v_cvt_f64_f32, and
  the IEEE v_cvt_f32_f64 on integers. Its unused flush-to-zero twin and
  ignored test are left out.
- Descriptors read only for their size, one implementation of the two
  (descriptor_data.rs): a buffer with a used-resource entry gets the
  title's view, structured where its elements are whole dwords (a raw
  handle of such a view answered 2 records where it holds 9 on the RTX
  5090); VICTORY_DESC_WHY stays.
- A subtraction on group-shared memory (ds_sub, or ds_add of 0 - x) is a
  compare-exchange loop: NVIDIA's compiler refuses the pipeline otherwise
  (E_OUTOFMEMORY; DXC's own InterlockedAdd(g, -x) too). The weather
  particle update gets a pipeline.
- A lane mask parked in two VGPR lanes that also hold single scalars comes
  back as the mask (ir::with_shared_slots; the voxelization program).
- Loops of programs that test rays against tree nodes stop at 1,024
  iterations (the compute limit is 4,096): with the title's builder off, a
  walk follows whatever memory holds. Shadow mask 11.7 -> 2.4 ms a frame
  in timing runs of the opening of the gameplay.

The allocation-idiom check (idiom.rs), descriptors read as data
(descriptor_data.rs) and 64-bit floats (float64.rs) are modules of their
own, so that lower.rs stays under the asset policy's 512 KiB a file.

Tests: each new form is run on the card against what the console's 64
lanes give; the linked signatures, the LDS subtraction loop, the shared
slots, the joined sections and the descriptor sizes have tests of their
own.
The whole pack on an RTX 5090 (32-lane waves): 25,682 of 25,953 programs
translate, validate and get a pipeline, against 25,452 at 9376fd6. All 52
structure-builder programs translate (three in the paired form); switched
on in game runs, the builder crashed the title about 80 s into the
gameplay, so it stays off.
The shader tests' host can now bind a root UAV as a table of one raw view
(`Root::Uav`, and `Root::UavAlias` for a destination that is its source,
as the title rehydrates its structures in place) for a root signature from
`Host::compute_pipeline_bounded`, as the layer binds root UAVs: an access
past the buffer's end is dropped. An unbounded root UAV let random inputs
write past the buffers and remove the device. The views' contents come
back after the heap's UAVs, in the order of the roots.
The limits of translated loops were literals in count_iteration, and the
switch set one limit for every stage. Now they are named per stage
(pixel 128, vertex and mesh 256, compute 4,096, ray tracing 1,024, as
before) and the switch can set one stage alone (`stage:n` pairs) or all
(one number); the shader cache keys on all four. The documentation says
what a lane at the limit does: where the loop branches back on a
condition it leaves the loop and goes on; where it jumps back it leaves
the program (a pixel discards).
With the switch, every program with a counted loop gets a root UAV of
ours (u252, space 1) and each lane that reaches a loop's limit adds one
to that loop's record: the lanes that left the loop and went on, and the
lanes the limit took out of the program, by the loop's first code byte.
The host binds each program a range of one shared buffer of its own at
its first draw and logs the records that grew every five seconds, by
stage and hash. A helper lane of a pixel shader writes nothing, so it is
never counted. Off by default: it adds a root parameter to every
program with a loop. Part of the shader cache key.

First run, the opening cutscene from a new game (8 minutes, 254 programs
with counted loops drawn): only the three environment BRDF integration
programs reached a limit, all 65,536 texels of each table in each of
their six loops; no lane of any program was taken out.
The console runs a pixel program's helper lanes as lanes of EXEC (the
program starts with s_wqm), so a waterfall loop over descriptors serves a
helper lane in a pass of its own, with its own descriptor. The host's
wave operations leave helper lanes out (SM 6.6) and give them undefined
results: a helper lane whose value no other lane of its wave held never
met it as the first lane, went round the translated loop to the iteration
limit (with the loop's samples each pass) and left with what the loop
computes never set, which its quad's derivatives then read. The
character skin and cloth program (94d281151ca58b4f) samples its material
layers in nine such nested loops.

A first-lane read in a pixel program now gives a helper lane its own
value; since scalar code made of such a read may then differ in helper
lanes, every heap handle of such a program is created non-uniform.

Test: a waterfall over each pixel's own number, with the count of the
lane across the quad's x read through a quad permute. On the RTX 5090
the helper lane's count was 0 (never served) before, 1 now; WARP
agrees.
The iteration limit is for loops whose end the data decides (a count
read from memory the host has not got yet). A loop whose exit is a
scalar counter that starts at a constant, moves by a constant step each
pass and is compared with a constant (at its bottom, or at its top with
a jump back) runs as often as the console's, up to 65,536 passes: its
limit becomes its own count.

The title's environment BRDF integration tables (PS_IntegrateEnvBRDF,
the Beckmann and thin-film variants) integrate 1,024 samples a texel,
two or four a pass, in six loops of 256 or 512 passes. At the pixel
limit of 128 every one of the 65,536 texels of each table stopped at a
half or a quarter of its samples (loop notes, opening cutscene), and the
tables, which every specular reflection reads, held a half or a quarter
of their values. Translated now with limits of 256 and 512.

Tests: the count analysis on synthetic loops (bottom and top tests,
four adds a pass, counts the data bounds or that never meet their
constant), and a compute loop of 5,000 passes that runs past the
compute limit on the GPU and WARP.
Where two host waves run one console wave of 64 lanes, they exchange
first lanes, masks and LDS order through group barriers, only in blocks
every lane runs (`all_lane_blocks`): no per-lane branch's region, the
blocks a branch reaches that do not post-dominate it. A loop each lane
leaves on its own (its back edge or a break on the lane's own bit) has
blocks that post-dominate the branch, its own among them, yet only the
lanes that stayed run them again: a waterfall loop in one block was
taken for code every lane runs and got two host waves' exchange of the
first lane, four group barriers a pass, which lanes that had left met
at other barriers. In the projected-decal classification
(CS_ProjDecalReduceClassification_Scalarized, 1f1fbd86759b3da2) lanes
then never met their descriptor and ran to the compute limit of 4,096
passes: 77 lanes in each of five loops, 44, 19 and 1 in three more, in
seven minutes of the gameplay's opening (loop notes); those lanes lost
their loads. A loop a lane branch leaves is now part of that branch's
region (natural loops of the lane exits).

Of the 1,085 compute programs seen in the title's runs, two translate
differently: the decal classification takes each host wave on its own
(approximate: the tile's sums are each half's; the exact paired form is
tried after the approximate ones), and CS_SortRayTiles (a1bf269d5b19f025)
keeps its form with its LDS ordered by group barriers at the loop's
ends. Test: the waterfall's block is not every lane's, a scalar loop
around a lane branch still is.
lower.rs had grown past the asset policy's 512 KiB per file (533,966
bytes; `cargo xtask policy` refused it). The limits by stage, the count
and its test on back edges and the loop notes move to emit/loops.rs, the
regions of lane branches (blocks every lane runs, the natural loops they
leave) to emit/regions.rs, both child modules of the lowering. No change
in what is emitted; lower.rs is 520,593 bytes.
A loop that goes round by jumps back alone has its exit test elsewhere in
its body; at the limit its jump back could only end the lane (a pixel
discarded, a mesh or compute lane stopped before its writes). Its exit
tests now take the limit too, so a lane at the limit leaves there and
goes on with the program, as one does at a branch back; the jump back
still ends a lane whose way round passes no exit test.

With the limits raised to 1,024 / 4,096 / 65,536 (VICTORY_SHADER_LOOP_LIMIT,
loop notes) the opening cutscene lost the card again, 9 minutes in, and
the notes named loops of that kind that never end: PS_Textured_Eight
(b37565055f2f7d3b, 1af4a50c7fb40c97), whose search of its shadow
cascades reads its cascade count as 0 (the count minus one never stops
it), 10,441 pixels taken out at 1,024 (holes in what it draws); and the
projected-decal resolve's walk of its decal bits (c4183d3cbee28e8e, in
the approximate one-host-wave form), 10,381 lanes at 65,536. The limits
stay where they were; the comment records why.

The loop limit's helpers (`limit_of`, the exit test, the search for such
loops) live in emit/loops.rs. Tests: a loop closed by a jump goes on
with s6 at the limit; one whose way round skips its exit still ends the
lane.
With loop notes (VICTORY_LOOP_NOTES=1) every program with a counted loop
binds the notes as a root UAV. A vertex or mesh program that binds a UAV
must say so (ShaderFlags bit 16, SFI0 0x4); without it the validator
refused 62 of the 801 vertex and mesh programs of a game run translated
with notes ("Flags must match usage"); with it they all validate (but
the two whose outputs pass 32 KiB, as without notes). The runtime does
not validate, so the game ran them as they were.

Test: a vertex program writing the notes' UAV validates.
For an A/B of what the fix changes on screen: with the switch at 0, helper
lanes of pixel programs read the host wave's first lane in the title's
first-lane reads again, as before. On by default; part of the shader cache
key (the build script lists every VICTORY_ switch the translator reads).
The opening cutscene run with the limits raised to 1,024 / 4,096 / 65,536
did not lose the card to a long loop: Windows reset it 2.5 s after a
Parsec session ended (09:54:32 disconnect, 09:54:34 "Resetting TDR"), as
in the day's other losses. The limits stay where they are for the reason
the loop notes give: no loop needs more, and the ones that reach them
never end (PS_Textured_Eight's cascade search, the decal resolve).
The clamp of indirect records counts, per list, the compute records that
ask for more groups in x than one dispatch runs (up to 93,648 in the runs
of this morning, cut to 65,535: the rest never run), but not whose they
are. At recording, the arguments are now read where title memory has them
(the card writes them, so this is an earlier frame's copy-back), and the
first record over the limit of each program is logged with its counts.
One host dispatch runs at most 65,535 groups in a dimension; the console
runs more. The title's depth-of-field blur asks for up to 115,200 groups in
x every frame of a defocused shot (2 x 57,600: one group per 8x8 tile of
each of its two layers at 2560x1440; the clamp of indirect records counted
81,064 to 115,200 asked, 0.3 to 3.5 records a frame cut, in the opening's
first minutes), and the clamp cut the record to 65,535: the groups past it
never ran. The tiles of the second layer past that point stayed unblurred,
which shows as blocks: in the kitchen shot the blinds are blurred above a
row and, in that row, left of a column, sharp everywhere after it, the
shape of a tile list in reading order cut after its 65,535th tile.

- Translator: a compute program's group id in x adds a user-data dword the
  host computes, USER_GROUP_BASE (0x104), as the host's other words are
  given (not for programs with a spilled user-data table, whose root
  signature is close to the host's 64 dwords).
- Direct dispatches of more than 65,535 groups in x run as several, each
  told its first group by a root constant.
- Indirect dispatches of such programs are clamped as split dispatches (a
  kind of the clamp's own): each record becomes four records of the base
  and the counts, at most 65,535 groups in x each (up to 262,140 in all),
  run through a command signature that sets the base and dispatches; the
  records past a count buffer's count come out empty, and every one runs.

Tests: on the software adapter, a record of 100,000 groups runs each group
from 0 to 99,999 once and a record past the count runs none; the clamped
records and the budget charged are checked. A compute program reading its
group id in x asks for the base; one reading y does not. The 3,418 shaders
of this morning's runs translate with the change (warm-up, 94 s).
A split dispatch's command signature is cached by the address of the root
signature it was made for (with the root parameter and dword of the group
base). D3D12 does not say that a command signature holds a reference to
its root signature: with the root signature released and another made at
the same address, the cache would hand out a signature made for the first,
and ExecuteIndirect with a command signature of another root signature is
undefined. The cache now keeps the root signature alive with it, so an
address in the cache names one root signature for the whole run. Few root
signatures run split dispatches (the screen-probe final gather's and the
meshlet culling's in the general tests), so nothing much is kept.
A program that counts its groups from a base is named once (info) when
its indirect dispatch asks for more than 65,535 groups in x, and run as
several; one that asks for more than runs even so is still a warning.
It runs nothing whatever its x (one such record, 6,062,079 x 0 x 0, was
named in the opening run of the split dispatches).
With VICTORY_SHADER_CENSUS, `victory translate` now writes `form=` for each
console wave64 compute program translated for a host of 32-lane waves:
paired, local (each host wave on its own), local-any (approximate),
exchange (two host waves meeting at group barriers), halves (two host
waves with nothing to exchange) or wave64 (refused by such a host); empty
for every other program. The lowering names its form, and each program
emitted since the last `emit` is remembered by its DXIL, so the form of
the one `emit` returns is known whatever forms were tried before it.

On integration (9376fd6 merged), the title's wave64 compute programs:
69 paired, 30 local (all the allocation idiom, exact), 160 exchange,
141 halves, none refused.
In the paired form every per-lane branch is the wave's, so EXEC stays a
guard on each vector instruction and a guarded write is
select(guard, new, old): about a sixth of the paired programs' host code
(360,668 of 2,303,768 instructions in the title's 69 paired programs,
against 29,850 selects of that kind in all the other forms of the same
programs), each keeping the register's old value alive.

A lane that reads the register under a guard that implies the writer's
ran the write, so it now reads the value as computed: its own registers
only (not a DPP source, a lane read or write, a swizzle or permute, which
read other lanes), never the old value a write keeps for the lanes
outside its guard. The reader reads the writer's SSA value, so the
writer dominates it and no atom of the writer's guard is defined again in
between: both guards are evaluated on the same lane-mask atoms, and the
implication of the two functions (Bools::meet) holds lane by lane. The
selects nothing reads any more go with the clean-up's dead code.

Offline (CPU census, every program of the title): only the 69 paired
programs change; their host instructions 2,303,768 -> 1,617,871 (-30%),
guard selects 360,668 -> 124,509, joins 151,991 -> 122,297.
VICTORY_WAVE_RAW=0 turns it off. Test: values written and read under the
same guard, a narrower one in the block and in a nested branch, a wider
one after it and by every lane past the branch, floats and an
accumulator, against the console's 64 lanes.
A console wave64 compute program whose wave-wide values are used only as
the allocation idiom uses them (idiom::wave_local: each wave's first lane
reserves its count on a shared counter, every lane takes the base plus
its rank) is exact with each host wave on its own: the same records,
reserved by each half in another order. That form was only tried for
programs no form in two host waves took, so a program the exchange form
also translated took that one: two host waves meeting at two group
barriers for each first-lane read, mask and sum.
CS_Primary_RegisterAllocationRequests (33 group barriers in 681 host
instructions) took 3.7 ms of the card per dispatch in the opening
cutscene, 2.8 ms a frame, the most of any wave64 program; its
irradiance-cache twin 0.5 ms a frame. Where the exchange form translates
a program, the local form is now tried and kept if it translates
(split::local_if_exact).

The idiom check also took every guarded write as mixing the register's
old value (a wave count, say) into the lanes outside its EXEC, read or
not: the light-probe allocations reuse the register that held the count
for the first lane's lane number. Such a write now keeps its kind where
no reader can see those lanes (split::read_inside_only): followed through
the guarded writes that keep it and the joins that take it, every reader
of its own lane reads under a guard that lies, where it stands, inside
the guards written since the old value; a reader of other lanes and a
loop's join count as seeing them, a whole-wave section's select by its
mask, a first-lane read by its own guard (the idiom's shortcut for
first-lane reads).

Offline (CPU census of every program, the same build with the switch
off): 40 of the 160 exchange-form programs take the local form (both
allocation requests, the depth-of-field and trail-map tile
classifications, the depth pyramids, shadow-mask denoises, ray-bin
offsets, the screen-space ray pre-passes, water patch culling, among
them), and 5 of the 70 paired programs (the four temporal resolves that
count frame statistics, and lens_flares CS_ScanMip0, the idiom with a
multiply-add as its three siblings); no other program changes. Their host
instructions: the 5 paired ones 48,501 -> 19,039. VICTORY_WAVE_SPLIT=0 turns both
off. Diagnostics builds: VICTORY_WAVE_PAIRED_OVER_EXCHANGE=1 gives the
remaining exchange-form programs the paired form, to time the two in a
run. Test: an allocation that reuses its count register as the light-probe
requests do takes the local form; on the card its counter and records
against the console's (the paired form's also in the console's order).
The 71 mesh programs whose outputs pass D3D12's 32 KiB as translated
alone (128 vertices of 65 to 71 components) were linked with the pixel
program of their pipeline (link_mesh), but a pipeline without one, as
the title makes for depth (14,576 binds of 143 mesh programs alone in
the runs so far), got the invalid translation as it is. link_mesh_alone
translates such a program again without its outputs of arbitrary
semantics, which only a pixel program reads: position, clip and cull
distances stay, and it fits. The runtime makes those pipelines with it;
the offline census, whose stub pixel program reads nothing, checks that
form of the 71 (all 71 validate and get a pipeline, RTX 5090) and counts
them on its mesh line. None of the 71 was drawn alone in the runs so far:
the two drawn (72da0ba1efaec1e0, 8a621a22094767f3) came with pixel
programs and linked.
The census's 195 geometry programs (all GS_VoxelizeGeneric variants) stopped
at resource tracking: their first load reads the console driver's table that
user data 0 and 1 point at. The console runs such a program in one hardware
stage after the ES half of its vertex program: it reads its triangle's
vertices from LDS at the offsets v0 and v1 hold (16 bits each), writes the
vertices it emits to its lane's slot of the GS-VS ring, also in LDS, and
sends a GS message for each emit and cut. The stage data gives the ring's
layout (vertex count and dwords per vertex, four per register of the output
signature; StageIo::Gs).

The host runs the ES half as the vertex program it is (the container's VS
program, the other compilation of the same HLSL) and the program as a
geometry shader of one invocation per primitive (crate::geometry,
emit/rings.rs): the address of each LDS access is followed to the input
vertex and dword it reads, or the emitted vertex and dword it writes; a
ring read is that input's loadInput, a ring write is kept as that vertex's
output, and the n-th emit stores vertex n's outputs and emits it. The load
from the driver's table only places the ring (resource::DRIVER: its value
is never needed). The prologue that narrows EXEC to the wave's GS threads
keeps every lane (NativeProgram::patched_code). The primitive id (v2) is
the host's; an invocation id (v3, instancing), vertices 4 and 5
(adjacency), another stream or emits in branches are refused.

Offline (32-lane host) all 195 translate and validate (the census's new
geometry line), the DXIL of every other program unchanged; their pipelines
between a stub vertex and pixel shader build on the WARP device (the
card's are left to the general test session). Tests: the rings of a program
of the console's form written for them, the refusals, the prologue, the
primitive id, and that program drawn between a pass-through vertex and
pixel shader (every texel as it writes it; passed on WARP). No run so far
drew with a geometry stage.
A pipeline whose stream has a geometry shader was refused ("only vertex,
mesh, pixel and compute stages are translated") and its draws dropped. Its
geometry program now translates (the commit before): the host pipeline is
the vertex program, the pixel program and the geometry program between
them, its user data and views bound per stage as the others' (stage last,
so the pixel stage keeps its place; no rectangle stage beside it, and none
in a mesh pipeline). Its library entry has a name of its own. The translated
geometry stage brings its used-resource entries like the other stages.

shortcut: not run in the title yet: none of the runs so far (opening
cutscene, gameplay from the user's save) drew with a geometry stage.
Four lines in the summary: the 195 geometry programs run as host geometry
shaders (no run has drawn with one), oversized mesh programs drawn without
a pixel program keep their system values, and the CPU census (25,948 of
25,953 translate and validate; the rest: five ray-trace programs); the
loop fixes; the two wave64 forms; the split of dispatches past 65,535
groups in x. VICTORY_WAVE_SPLIT and VICTORY_WAVE_RAW in the table of
switches, VICTORY_MESH_LINK's alone form, and geometry stages out of what
the shaders lack.
Five of the title's sun-shadow trace programs (shadowmask:CS_TraceShadowRays
at full, half, quarter and eighth resolution) take the address of their
ray-tracing structure out of a buffer descriptor they pick from the view
heap at an index they compute, and walk the structure from it: they
stopped at "a descriptor read only as data". The host now keeps, per view
heap, a table of each slot's view address (buffer views, and ray-tracing
structure views) beside the table of strides, and such a load reads it
(root SRV t252 in space 1).

Offline (`victory translate`, VICTORY_HOST_MAX_WAVE=32, the game's shader
archive): compute programs 2677 -> 2681 of 2682 emitted, nothing else
changed; the four validate and get pipelines. The fifth (FullAdaptive) now
stops further on, at a lane mask read as data. In the user-save scenario
the title uses the checkerboard variant, which translated before.
With VICTORY_TEST_BVH_DLL=<the user's XboxBvhBuilder.dll> (skipped when
unset: nothing of the title's is in the repository), every wave64 program
of the builder whose picked form on a 32-lane host differs from the paired
form (one host wave per console wave) runs both on synthetic inputs and the
bytes are compared: the box and leaf rehydrations over control words with
payload counts, the radix sort's count and scatter over one block of 2,048
keys. VICTORY_TEST_BVH_FORM=picked|paired runs one form alone (repeatedly,
VICTORY_TEST_BVH_REPEAT) and checks the scatter against a CPU stable sort.
The root UAVs are bound as tables of one view, as the layer binds them
(the test host's Root::Uav and Root::UavAlias).

6 programs x 4 seeds agree; the scatter matches the CPU sort in both forms.
VICTORY_CRASH_MEMORY=1 (diagnostics builds): the crash report adds, per
exception, the 256 bytes around each register that holds a readable title
address, the kind of memory there (private, mapped view, image; region and
allocation), and 128 bytes at each title pointer among their first 32
qwords. The structure builder's crashes read a pointer of all ones loaded
from title objects; this shows what those objects held.
VICTORY_BVH_TRACE=<file> (diagnostics builds) writes one line per event,
unbuffered so a run that ends in the title's crash keeps it: each dispatch
of the builder or of another program that reaches title memory by address
(hash, groups, root constants, root views with the title bytes there), the
list upload memory a builder stage reads as it stands at submission, and,
from the builder's first dispatch on, every range put back into title
memory with its first bytes, the title's buffer copies and memory copies
done on the CPU, and the texture read-backs.

VICTORY_BVH_DRY=1 binds the builder's dispatches (copies made ready, writes
declared) and does not run them, to tell the builder's own writes from what
the rest of the machinery does. VICTORY_BVH_CHECK=<hash of the header stage>
walks the structures that stage names a frame later, in title memory:
boxes finite, not inverted and inside their parent's box, triangles inside
their box, nodes inside the structure and reached once.
CopyPageMappingsBatchX maps pool pages into the title's tiled heap at once,
while the console does it behind the work sent before it. With flights in
the air (results landed by the relay after their submission returned),
what their shaders wrote to a range being remapped was put back after the
remap, into the pages mapped there now, which the title also shows at
other addresses. Now such a remap first waits for the flights whose
declared writes touch the range (VICTORY_REMAP_LAND=0: as before).

Measured with the builder bound: 36 remaps in a run met flights that may
write them (rt-dry1), 9 and 15 in the runs with the builder on (rt-trace7,
rt-trace8). The trace's P lines give each batch's ranges (kind, pool page,
count).
A program that reaches title memory by address had every numbered host
copy declared written for its list as soon as it could store anywhere,
through a root view as well. Now only a program that can store through a
raw address (a flat or global store or atomic, not to scratch, or code not
all known) declares them. Of the structure builder's 52 programs 23 have
flat or global accesses and 11 store that way. Declaring for all had the
builder's first frame compare and put back 378 MB of title memory in 7,001
ranges (rt-trace1), against 67-85 MB a frame of gameplay without the
builder (rt-off1).
The structure builder hands its stages the addresses of what it writes
into list upload memory (`allocate_upload`), and its header stage
(InitHeaders) reads its records through such an address. The layer gave
out blocks of the process heap, at 1.5-1.8 TiB (rt-trace5, rt-dry1):
beyond the console's 40 bits and the directory of title memory by address
(below 128 GiB), so the records read as zeros and the stage stored its
headers at address 0, which drops them.

Upload memory now comes from 4 MiB chunks of one 512 MiB reservation from
4 GiB and below 128 GiB, write-watched as XMem makes the title's memory:
each chunk is one window of memory outside buffers, copied when a list
that names it is submitted. A list holds its chunks until it is reset or
its submission has run; requests over a chunk, or past the reservation,
still come from the heap. In rt-trace7 the header records were at 66 GiB.
Each list that ran a program reaching title memory by address brought
every numbered host copy up to date and, if the program could store,
declared every one written, so the copy-back compared them all: with the
builder's dispatches bound and not run (VICTORY_BVH_DRY), the 1,023
numbered windows (4 GiB) after each list made a median of 975 ms a frame
(rt-dry1), against 353 for the scene without the builder (rt-off1). Its
steady frames run 360 dispatches that name about 100 windows. Now a list
brings up to date the copies just numbered, those its dispatches name and
the list upload memory's, each once, and declares the first two written.
VICTORY_MEMORY_ALL=1 restores the old way.
shortcut: memory a stage reaches only through pointers, in a copy no
dispatch names, is brought up to date once, when numbered, and the stage's
writes there are not put back into title memory.

- List upload memory (`crate::list::upload`) is named before each
  dispatch: the builder's tables there are read through pointers.
- The low dword of a constant pair is no longer also taken as an address
  in 256-byte units: 717 of the 802 windows named that way in the
  builder's first frame were such low dwords (rt-trace8, which ran out of
  numbers in that frame), 2,144 of 2,256 over a run (rt-dry1).
- 2,047 numbers instead of 1,023: the builder's dispatches named 1,125
  windows in their first frame and about 1,450 in six minutes, those low
  dwords left out (rt-dry1).
- The trace notes each copy numbered (N, with why) and the pages shaders
  touched without a copy (F).
The title copies each structure's compacted size out of the builder's
buffer with CopyBufferRegion, in the list that computed it, and reads it on
the CPU. The layer does a title's buffer copy on the CPU at submission,
before the list's shaders run: it took what the source held before them
(the previous build's size, or zeros). Now, in a list whose shaders store
through addresses (the structure builder's), a copy whose source those
shaders declared written runs on the card between the two host copies,
behind them, and its destination is declared written so the size reaches
title memory once the list has run. Other title copies stay on the CPU:
moving all of them to the card cost 205 -> 232 ms a frame earlier
(README). VICTORY_CARD_TITLE_COPIES=0 turns this off.

In the builder's first frame 337-341 sizes went this way (rt-trace5,
rt-trace7), e.g. 0x400, 0x2780, 0x559780 bytes.
DispatchX passes the console's dispatch initiator bits as its flags, and
the ray-tracing structure builder sets USE_THREAD_DIMENSIONS (0x20) for its
box rehydration, header copies and triangle reloads: x, y and z count
threads, the last group is cut short, and no thread past the count is
launched. The layer took them for group counts. Box32 and Box16
rehydration rebuild a pre-built tree one level a dispatch, in place, one
node a thread, group g writing its 64 nodes at g times 8 or 4 KiB; given a
level's node count as groups, each ran 64 times its work and wrote empty
nodes far past the structure: 2.2 GiB past their levels over the 6,260 box
dispatches of rt-int1's first frame (272,948 groups for 5,983). Where that
was put back, it lay over the title's own objects, at their CPU view
24 GiB lower: every crash site of rt-int1 (title +0x2bd385b, +0x27c195d,
+0x4f38ba5, +0x4e51965) lies inside such an overrun.

dispatch_x now makes groups of the program's console size out of thread
counts. Where a last group is cut short, the pipeline runs in a form of
its program translated for that (translate_thread_limited, made on first
need and cached under a key of its own): the host passes the counts
(USER_THREAD_LIMIT), and the threads past them leave in the entry block,
so that a wave operation, a ballot of EXEC on entry (the box stages'
WaveAllBitCount, which places their payloads) and the title's barriers
count the launched threads only, as the console's partial wave does. The
two host waves of a console wave64 program that exchange first tell each
other whether they have a launched thread; one with none leaves whole, its
exchange dword holding 0, and a reduction's join takes the other half
alone. The paired and approximate forms are refused (a host thread holding
two console lanes cannot leave for one of them): such a dispatch runs whole
groups, and a builder stage turns the builder off.

Tests: a program that numbers its threads, dispatched by thread counts in
groups of 32 and of 64 (wave64), stores for every thread inside the counts
and for none past them (the plain form runs the whole last group); on WARP
here, the card being reserved. With VICTORY_TEST_BVH_DLL, 49 of the
builder's 52 programs translate for thread counts and validate, the three
paired prefix sums are refused.
The builder's leaf rehydration reads its geometry descriptions (48-byte
D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC records) through a root SRV in
list upload memory, and loads indices and vertices through the addresses
in them, which no root argument names. In rt-int1, 638 of the 2,139 such
addresses (from the records its trace shows) lay in no copy when the stage
ran: those leaves read zeros, and the fault note only helps the next frame,
after a structure rebuilt once.

Before a dispatch whose shader reads title memory by address, the block of
upload memory each of its root SRVs points into is looked through, 16 KiB
at most and up to what the list has handed out of that chunk, for 8-byte
title addresses (bits 32 to 39 set and nothing above, a low dword of 64 KiB
or more, as for an address in two constants); each is named as the
dispatch's own root views are. The builder fills the records before it
records the dispatch. Each chunk of upload memory keeps how far its list
has handed it out (one atomic a chunk, no lock), and the dispatch passes
its root SRVs' views apart from its other root views: the views the title
left bound for earlier pipelines are not looked through.
A console wave64 program of 64 threads a group reads its EXEC as a number
(s_bcnt1) and each lane's rank in it (v_mbcnt), which on a host of 32-lane
waves the two host waves of a console wave exchange. Translated for
dispatches by thread counts, a group cut short at 6, 32, 45 or 97 threads
has each launched lane store its rank and the launched count, and no other
lane store: in a group cut at 32 lanes or fewer the upper host wave has no
launched thread and gives no lanes to the exchanges. Lowered and validated
offline; run on a host GPU of 32-lane waves.
The structure builder's programs have a spilled user-data table and root
signatures close to the host's limit (USER_GROUP_BASE is not asked of them
for that reason). Translated for dispatches by thread counts they ask for a
count only along a dimension whose groups are more than one thread wide
(one dword for all of the builder's); the test sums the root signature the
layer makes of each (user data, root descriptors, one-view tables) and
fails past 64 dwords, and says the largest for group counts and for thread
counts.
VICTORY_BVH_CHECK=<hash>[,<hash>]: the second, if given, names the stage
that starts rebuilding a pre-built structure in place, its header at the
stage's root view 1 (DecompressHeader). Those structures are walked a frame
later as the ones InitHeaders starts, in a line of their own (V rebuilt):
the structures the crash of rt-int1 lay past, which the walk did not cover.
cargo clippy --all-targets -D warnings on wave2: manual_is_multiple_of in
the dispatch by thread counts and in its test, and items after the test
module of memory.rs.
VICTORY_BVH_CHECK=<hash>+<hash> as well as with a comma, for test scripts
that split their switches at commas.
The walk (VICTORY_BVH_CHECK) read title memory at the first trace line of
the frame after a structure was named, which comes before that frame's
shader writes are put back: in run integ-general-2-rt2-builder a structure
rebuilt in frame 3255 was walked at the start of 3256 still in its
streamed form (flag byte 0x81) and put back a few lines later (0x80). A
structure is now walked from the frame after a put-back over its header
landed (bvhtrace::put_back, called by host::write_mapped), or 16 frames
after it was named with none seen (counted as "late" in its V line).

The nodes of a structure rebuilt in place are in a space of their own: the
leaf rehydration writes each vertex as (M v - o) s with o and s from its
root constants (s powers of two, 2^18 2^18 2^17 or 2^14 2^21 2^15), while
the header keeps the bounds in the structure's space. Every root child the
walk found "outside" the header's bounds in that run was exactly that
scale, axis by axis; a rebuilt structure's root is no longer held to them.
The title's ray-traced passes run whether or not anything built their
structures (the irradiance cache's shadow trace from the first world frame
on). With the builder off they walked whatever bytes lay where the
structures would be: in wave 2's builder-off runs, screen-aligned dark
tiles on sunlit hair in the yard walk, lit squares in shadow in the
parking lot, and at the window the hair dark in two runs and lit in the
third.

A program with a node test now reads a host word (USER_STRUCTURES,
0x106). The host gives 1 while the builder runs whole
(pipeline::structures_walked), 0 before its first dispatch, with
VICTORY_BVH_BUILDER=0, or once it is turned off. While 0, every node test
answers no hit without reading the node or looking for its copy (a box
node enters no child, any other node is a triangle missed, so no page of
garbage addresses is fetched either): rays escape, shadow rays find no
occluder, the same picture every run. VICTORY_BVH_NO_HIT=0 lets them walk
those bytes, as before.

Tests (WARP): with the word 0, the node tests over title memory and in a
host buffer give no hit for every node and leave masked threads alone;
with 1, the node tests give the reference's results as before; a program
over title memory asks for the word.
The card test sessions of waves 1 and 3 (victory-shader on the RTX 5090,
driver 32.0.16.1742) died with an access violation in nvwgf2umx.dll, both
at +0x719ea6 (Windows' reports of 12:59 and 14:34). The dump of the second
shows the fault on a thread of the driver's own, reading freed memory,
while the test thread was building its scene on the CPU with no D3D12 call
in flight: the 64-bit host-buffer node test it died in lowers to the same
DXIL, byte for byte, as the 32-bit one that had just passed, over the same
data. Each run of a test made a device and dropped it at its end, the test
before twice; the driver's threads outlive that release.

Host::new now makes each device (the default adapter's, WARP's) once and
keeps it until the process ends. The game makes one device and never
drops it.
docs/fork-ray-tracing.md: what running the builder in the game took
(list upload memory below 128 GiB, the structures' sizes copied on the
card, copies of title memory by address kept current where named, remaps
after the flights, dispatches by thread counts, the addresses in upload
memory's records), the cause of the crash (its box rehydration dispatched
by thread counts, taken for group counts, wrote 2.2 GiB of empty nodes
past its levels), the runs since (420 s of save gameplay with the builder
on, no fault), node tests answering no hit while it does not run, the
sun-shadow trace programs that read view addresses by slot, the
diagnostics, and the cost that keeps it off by default (88 ms more card
time a frame; the opening cutscene's frame 385 -> 752 ms in our tree).
README: the ray-tracing line, the census (25,952 of 25,953), the no-hit
fallback beside VICTORY_BVH_HOLD, and the trace's switches. The trace's
D lines name the thread counts of a cut-short dispatch.
The comments of the builder's rule and of the no-hit fallback still spoke
of the default before the builder ran in the game. It now runs whole on a
card (420 s of save gameplay, no fault), and stays opt-in for its cost:
with it on, the opening cutscene's frame went from 385 to 752 ms (median,
two successive builds of our tree) and the card took some 88 ms more a
frame in gameplay. Node tests answer no hit while it does not run.
Conflicts, each a place where both sides added lines; both sides are
kept:
- crates/victory-gpu/src/draw.rs: a method each after
  State::list_dropped_roots (trace_dispatch here, may_store upstream).
- crates/victory-gpu/src/host.rs, twice: a diagnostics statement each
  under one attribute line, in run_deferred's title copy and at the top
  of write_mapped (the builder's trace line here; upstream's count of
  who reads what the copy-back stored, backreads). Each has the
  attribute now; upstream's statement stays next to the copy or the
  write it marks.
- crates/victory-gpu/src/lib.rs: a diagnostics module each under one
  attribute line (bvhtrace here, backreads upstream).

Merged without a conflict, and read through where both sides changed the
same code:
- indirect.rs: the clamp's source now has upstream's gathered records
  (bit 2 of has_count: a record's place read from a table) and this
  branch's split dispatch (kind 3). Only a windowed draw's record is
  gathered, never a dispatch's, so the two do not meet.
- draw.rs: execute_indirect ends the list's gathering for a dispatch
  before the split clamp, and a dispatch by thread counts goes through
  dispatch, which ends it too. A title copy run on the card
  (HostList::copy_on_card) follows a draw or dispatch of its list that
  stores by address, so the list no longer gathers by then.
- emit/lower.rs, emit/mod.rs, emit/bitcode/opt.rs: upstream's loads of
  four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default)
  beside this branch's forms; lower.rs is 519,626 bytes of the policy's
  524,288.
- queue.rs, shadow.rs, resource.rs, README.md: additions side by side.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
No conflict. Upstream's loads of four dwords a call (VICTORY_SHADER_OPT
bit 64, not in the default) merge into emit/lower.rs, emit/mod.rs and
emit/bitcode/opt.rs beside this branch's forms; lower.rs is 504,469
bytes of the policy's 524,288. The rest of upstream's commits is in
files this branch does not change, but for README.md (additions side by
side) and three lint lines in draw.rs, indirect.rs and resource.rs.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
No conflict. Read through where both sides changed the same code:
- indirect.rs: the clamp's source now has upstream's gathered records
  (bit 2 of has_count: a record's place read from a table) and this
  branch's split dispatch (kind 3). Only a windowed draw's record is
  gathered, never a dispatch's, so the two do not meet.
- draw.rs: execute_indirect ends the list's gathering for a dispatch
  before the split clamp, and a direct dispatch split past 65,535 groups
  ends it on entry.
- emit/lower.rs, emit/mod.rs, emit/bitcode/opt.rs: upstream's loads of
  four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default)
  beside this branch's forms; lower.rs is 511,375 bytes of the policy's
  524,288.
- host.rs, shadow.rs, lib.rs, README.md: additions side by side.
`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c4 with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
The test lowered the program for 64-lane waves only and returned when the
device refused the pipeline, so on a GPU of 32-lane waves it passed with
nothing run on the card (review of #854). It now asks the device how wide its
waves are (D3D12_OPTIONS1) before choosing the form: the console's own 64
lanes where they fit, the paired form on waves of 32, nothing on narrower
waves (the software adapter's 4). The pipeline and the dispatch are then made
on that same device, and a refusal fails the test.

On an RTX 5090 (32-lane waves) the paired form gives the console's tree bit
for bit with 64, 63, 40, 33, 32, 17, 5 and 1 lanes left.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:24 +00:00
Author
Owner

@⁠rafaconvaitis on GitHub · 2026-11-25 15:55 UTC · original

I tested c9ca6b2 with a lean native build and a test-only keyboard input shim on another RTX 4070 12 GB (driver 616.64, Windows 11 build 26300). The run used Series X, a cold pipeline cache, and VICTORY_BVH_BUILDER=1 with the remaining branch defaults.

  • All 53 builder pipelines were ready 421.4 s after account selection.
  • 35.72 s later the device was removed with DXGI_ERROR_INVALID_CALL (0x887A0001) while the host was mirroring heap buffer views.
  • The sampled views at removal included Constant(…, 1267456), compared with the D3D12 CBV limit of 65,536 bytes. The check sampled a batch of views, so the exact failing call remains unconfirmed.

This matches the symptom addressed by #911. I am testing its size cap in isolation on this head, using the same checkpoint and console profile.

**@⁠rafaconvaitis** on GitHub · 2026-11-25 15:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7167438479) I tested `c9ca6b2` with a lean native build and a test-only keyboard input shim on another RTX 4070 12 GB (driver 616.64, Windows 11 build 26300). The run used Series X, a cold pipeline cache, and `VICTORY_BVH_BUILDER=1` with the remaining branch defaults. - All 53 builder pipelines were ready 421.4 s after account selection. - 35.72 s later the device was removed with `DXGI_ERROR_INVALID_CALL` (`0x887A0001`) while the host was mirroring heap buffer views. - The sampled views at removal included `Constant(…, 1267456)`, compared with the D3D12 CBV limit of 65,536 bytes. The check sampled a batch of views, so the exact failing call remains unconfirmed. This matches the symptom addressed by #911. I am testing its size cap in isolation on this head, using the same checkpoint and console profile.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 15:55 UTC · original

Thanks for running it in the title — that was the check we could not make.

It matches what we saw: with dispatches by thread counts run as thread counts, the builder runs and nothing crashes. The 3–12 s crashes you had on #935 fit the overrun: in the first frame of a crashing run, the box stages wrote about 2.2 GiB of empty nodes past their levels, over pages the title's own objects share at another CPU view.

On the cost: the 1.2–4 s frames on entering the world look like the usual arrival (texture uploads and the heap pass), which is slow with or without the builder, and the trace's writes come on top. Without the trace, in our runs on an RTX 5090, the builder cost about 88 ms of card time a frame in the window scene (160 ms against 72), which is why this PR keeps it opt-in. If you have the time, a run with VICTORY_BVH_BUILDER=1 and no VICTORY_BVH_TRACE, against the same save without the builder, would give its price on a 4070.

And yes, please keep the quarantine (HostList::quarantine) as a small PR of its own: it is independent of the overrun. If #935 drops bvhtrace.rs and the crash-memory dump in favour of this one, the two will not conflict there, and we will look at the quarantine for our tree too.

**@⁠PiloteCode** on GitHub · 2026-11-25 15:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7167439593) Thanks for running it in the title — that was the check we could not make. It matches what we saw: with dispatches by thread counts run as thread counts, the builder runs and nothing crashes. The 3–12 s crashes you had on #935 fit the overrun: in the first frame of a crashing run, the box stages wrote about 2.2 GiB of empty nodes past their levels, over pages the title's own objects share at another CPU view. On the cost: the 1.2–4 s frames on entering the world look like the usual arrival (texture uploads and the heap pass), which is slow with or without the builder, and the trace's writes come on top. Without the trace, in our runs on an RTX 5090, the builder cost about 88 ms of card time a frame in the window scene (160 ms against 72), which is why this PR keeps it opt-in. If you have the time, a run with `VICTORY_BVH_BUILDER=1` and no `VICTORY_BVH_TRACE`, against the same save without the builder, would give its price on a 4070. And yes, please keep the quarantine (`HostList::quarantine`) as a small PR of its own: it is independent of the overrun. If #935 drops `bvhtrace.rs` and the crash-memory dump in favour of this one, the two will not conflict there, and we will look at the quarantine for our tree too.
Author
Owner

@⁠TheoGegout on GitHub · 2026-11-25 15:47 UTC · original · edited 2026-11-25 15:56 UTC

Ran this exact branch in the title, since you could not: no crash with the builder on.

Setup. Head c9ca6b2, cargo build --profile diag -p victory --features diagnostics, AMD Radeon RX 6800 XT (host wave lanes 32 to 64), Windows 11. That is the case your "Not tested" lists: a GPU with 64-lane waves, where the builder's wave64 programs run without the paired form, and the thread-count form ran there. VICTORY_BVH_BUILDER=1, VICTORY_BVH_TRACE=<file>, VICTORY_CRASH_MEMORY=1, VICTORY_RELAY=2. Save gameplay.

Result.

  • The builder ran from its first frame: "all of its programs have host pipelines" (53 pipelines).
  • More than 5 minutes in the world with it on (frames 2,371 to 2,959 in the trace, still running when I stopped looking): no exception, no device loss, no crash. On #935 (main plus the quarantine fix) the same save crashed 3 to 12 s after the builder's first frame, so the thread-count overrun fits what I saw there.
  • 265,628 builder dispatches in the trace. The rehydrate call's four programs all ran, none dropped: caa78b8ca62bc3d6 16,153, 28918b7150a7aad5 8,128, 5e68767498c57eb6 2,744, 4ddd6f9702fab2a7 2,744.
  • No ERROR line. 50 warnings of "shaders touched pages that had no copy", each followed by the copies being made.

Cost, with the trace on (it wrote 115 MB in the first 90 s):

  • On entering the world, frames of 1.2 to 4 s, all on the CPU (texture uploads at 2.5 s a frame with 21,887 waiting, the heap pass up to 1.4 s). The card was idle 80 to 90 % of the time.
  • Once textures settled, a median of 343 ms a frame (303 to 379), the card mostly idle. I have no run of this branch without the builder to compare against yet.

So my #935 diagnosis (the rehydrate stages' lost reads through pointers) was describing the overrun's effects, not its cause. Happy to drop the overlapping parts of #935 (bvhtrace.rs, crash.rs) in favour of yours. The quarantine fix (HostList::quarantine) still stands on its own if you want it.

**@⁠TheoGegout** on GitHub · 2026-11-25 15:47 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7167316005) · edited 2026-11-25 15:56 UTC Ran this exact branch in the title, since you could not: no crash with the builder on. **Setup.** Head `c9ca6b2`, `cargo build --profile diag -p victory --features diagnostics`, AMD Radeon RX 6800 XT (host wave lanes 32 to 64), Windows 11. That is the case your "Not tested" lists: a GPU with 64-lane waves, where the builder's wave64 programs run without the paired form, and the thread-count form ran there. `VICTORY_BVH_BUILDER=1`, `VICTORY_BVH_TRACE=<file>`, `VICTORY_CRASH_MEMORY=1`, `VICTORY_RELAY=2`. Save gameplay. **Result.** - The builder ran from its first frame: "all of its programs have host pipelines" (53 pipelines). - More than 5 minutes in the world with it on (frames 2,371 to 2,959 in the trace, still running when I stopped looking): no exception, no device loss, no crash. On #935 (`main` plus the quarantine fix) the same save crashed 3 to 12 s after the builder's first frame, so the thread-count overrun fits what I saw there. - 265,628 builder dispatches in the trace. The rehydrate call's four programs all ran, none dropped: `caa78b8ca62bc3d6` 16,153, `28918b7150a7aad5` 8,128, `5e68767498c57eb6` 2,744, `4ddd6f9702fab2a7` 2,744. - No ERROR line. 50 warnings of "shaders touched pages that had no copy", each followed by the copies being made. **Cost**, with the trace on (it wrote 115 MB in the first 90 s): - On entering the world, frames of 1.2 to 4 s, all on the CPU (texture uploads at 2.5 s a frame with 21,887 waiting, the heap pass up to 1.4 s). The card was idle 80 to 90 % of the time. - Once textures settled, a median of 343 ms a frame (303 to 379), the card mostly idle. I have no run of this branch without the builder to compare against yet. So my #935 diagnosis (the rehydrate stages' lost reads through pointers) was describing the overrun's effects, not its cause. Happy to drop the overlapping parts of #935 (`bvhtrace.rs`, `crash.rs`) in favour of yours. The quarantine fix (`HostList::quarantine`) still stands on its own if you want it.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 16:02 UTC · original

@⁠rafaconvaitis thanks — that fits a gap between this branch and the tree it came from, not the builder itself.

main (and so this branch) makes a constant buffer view of whatever size the title gives, and D3D12 allows at most 65,536 bytes (4,096 × 16). In our tree the size is clamped first: constant_bytes in descriptor/host.rs takes size.min(64 KiB) rounded up to 256, the same cap as #911. With it, the builder ran 420 s of save gameplay without a removal on our RTX 5090. This PR does not carry that cap, because it is #911's change.

So with #911 on top (or merged first), the Constant(…, 1267456) view should no longer remove the device. Your isolated test of #911 on this head will tell; if anything else shows up after it, please post it here.

**@⁠PiloteCode** on GitHub · 2026-11-25 16:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7167535073) @⁠rafaconvaitis thanks — that fits a gap between this branch and the tree it came from, not the builder itself. `main` (and so this branch) makes a constant buffer view of whatever size the title gives, and D3D12 allows at most 65,536 bytes (4,096 × 16). In our tree the size is clamped first: `constant_bytes` in `descriptor/host.rs` takes `size.min(64 KiB)` rounded up to 256, the same cap as #911. With it, the builder ran 420 s of save gameplay without a removal on our RTX 5090. This PR does not carry that cap, because it is #911's change. So with #911 on top (or merged first), the `Constant(…, 1267456)` view should no longer remove the device. Your isolated test of #911 on this head will tell; if anything else shows up after it, please post it here.
Author
Owner

@⁠HLVM04 on GitHub · 2026-11-25 16:28 UTC · original

An NVIDIA 32-lane data point (RTX 5070 Ti, driver 616.64, Windows 11, Series S profile). This PR was merged into our local tree: main 0b0074e + #798 #783 #799 #770 #827 #845 #896 #807 #987, plus local changes. That tree carries #799's CBV size clamp.

  • With VICTORY_BVH_BUILDER=1, it ran 240 s with no crash and no device loss.
  • Before, with only our own local fix for the 0x20 thread-count flag, the builder crashed about 70 s in on an earlier version of that tree, with or without VICTORY_BVH_QUARANTINE=1.
  • Cost: about 589 ms a frame with the builder on. The same stack without it has a median of 78 ms in the first gameplay scene. That is one run each, not a matched A/B, so take it only as an order of magnitude. Pictures were not compared.

Not having the 0x887A0001 removal reported above fits PiloteCode's reading that a CBV size cap (#911, or #799's clamp here) is what that run was missing. We did not test that directly.

**@⁠HLVM04** on GitHub · 2026-11-25 16:28 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7168040914) An NVIDIA 32-lane data point (RTX 5070 Ti, driver 616.64, Windows 11, Series S profile). This PR was merged into our local tree: main 0b0074e + #798 #783 #799 #770 #827 #845 #896 #807 #987, plus local changes. That tree carries #799's CBV size clamp. - With `VICTORY_BVH_BUILDER=1`, it ran 240 s with no crash and no device loss. - Before, with only our own local fix for the 0x20 thread-count flag, the builder crashed about 70 s in on an earlier version of that tree, with or without `VICTORY_BVH_QUARANTINE=1`. - Cost: about 589 ms a frame with the builder on. The same stack without it has a median of 78 ms in the first gameplay scene. That is one run each, not a matched A/B, so take it only as an order of magnitude. Pictures were not compared. Not having the 0x887A0001 removal reported above fits PiloteCode's reading that a CBV size cap (#911, or #799's clamp here) is what that run was missing. We did not test that directly.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 16:36 UTC · original

@⁠HLVM04 Thanks for the run. It confirms on a 32-lane NVIDIA card that the builder runs with this PR in your tree: 240 s with no crash and no device loss. It also fits the reading above: in a tree with a constant buffer size cap (#799's clamp here, #911 otherwise), the 0x887A0001 removal did not come, though as you say that is not a direct test.

On the cost, our runs point the same way. On our RTX 5090 the builder added 88 ms of card time a frame in the window scene (160 ms against 72). The opening cutscene's frame median went from 385 ms to 752 ms between two successive builds of our tree, the second with the builder on by default (it had other changes too). That is why this PR keeps the builder opt-in (VICTORY_BVH_BUILDER=1).

**@⁠PiloteCode** on GitHub · 2026-11-25 16:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7168247364) @⁠HLVM04 Thanks for the run. It confirms on a 32-lane NVIDIA card that the builder runs with this PR in your tree: 240 s with no crash and no device loss. It also fits the reading above: in a tree with a constant buffer size cap (#799's clamp here, #911 otherwise), the `0x887A0001` removal did not come, though as you say that is not a direct test. On the cost, our runs point the same way. On our RTX 5090 the builder added 88 ms of card time a frame in the window scene (160 ms against 72). The opening cutscene's frame median went from 385 ms to 752 ms between two successive builds of our tree, the second with the builder on by default (it had other changes too). That is why this PR keeps the builder opt-in (`VICTORY_BVH_BUILDER=1`).
Author
Owner

@⁠TheoGegout on GitHub · 2026-11-25 16:56 UTC · original

The two runs you asked for, without the trace, on the same Radeon RX 6800 XT (same head c9ca6b2, diag build, VICTORY_RELAY=2, same save, standing still at the same spot):

Frame median once settled Builder
VICTORY_BVH_BUILDER unset 230 to 241 ms (12 windows of 5 s) off
VICTORY_BVH_BUILDER=1 246 to 284 ms, still falling (last 7 windows) on

So about 30 ms a frame on this card (233 against 266 on average), less than the 88 ms you measured, though the second run had not quite settled.

But the second run lost the device 3 min 8 s after "the ray-tracing structure builder runs":

ERROR victory_gpu::host: host GPU device removed after 21 submissions sent ahead (VICTORY_RELAY=1) of 87 lists; no breadcrumbs (0x887A0004); device removed: 0x887A0006

0x887A0006 is DXGI_ERROR_DEVICE_HUNG, not the 0x887A0001 invalid call reported above on the RTX 4070. No exception before it. The run with the trace on (my first report) went more than 5 minutes with the builder and did not hang, so it may depend on timing. One run each so far; I can repeat it, or run with VICTORY_D3D12_DEBUG=1 if that would help.

(A first attempt at the run without the builder crashed inside the AMD driver's shader compiler when the system ran out of commit, unrelated to this PR; the runs above are after enlarging the page file.)

**@⁠TheoGegout** on GitHub · 2026-11-25 16:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7168766029) The two runs you asked for, without the trace, on the same Radeon RX 6800 XT (same head `c9ca6b2`, diag build, `VICTORY_RELAY=2`, same save, standing still at the same spot): | | Frame median once settled | Builder | |---|---|---| | `VICTORY_BVH_BUILDER` unset | 230 to 241 ms (12 windows of 5 s) | off | | `VICTORY_BVH_BUILDER=1` | 246 to 284 ms, still falling (last 7 windows) | on | So about 30 ms a frame on this card (233 against 266 on average), less than the 88 ms you measured, though the second run had not quite settled. **But the second run lost the device** 3 min 8 s after "the ray-tracing structure builder runs": ``` ERROR victory_gpu::host: host GPU device removed after 21 submissions sent ahead (VICTORY_RELAY=1) of 87 lists; no breadcrumbs (0x887A0004); device removed: 0x887A0006 ``` `0x887A0006` is `DXGI_ERROR_DEVICE_HUNG`, not the `0x887A0001` invalid call reported above on the RTX 4070. No exception before it. The run with the trace on (my first report) went more than 5 minutes with the builder and did not hang, so it may depend on timing. One run each so far; I can repeat it, or run with `VICTORY_D3D12_DEBUG=1` if that would help. (A first attempt at the run without the builder crashed inside the AMD driver's shader compiler when the system ran out of commit, unrelated to this PR; the runs above are after enlarging the page file.)
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 17:01 UTC · original

@⁠rafaconvaitis thanks, that settles it: the same head and checkpoint, with only #911's cap added, went from a removal 35.72 s after the builder's pipelines were ready to 240 s without one, and the log shows the 1,320,192-byte view cut to 65,536. So running the builder on main needs #911 (or an equivalent cap); I have added that to this PR's description.

**@⁠PiloteCode** on GitHub · 2026-11-25 17:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7168881984) @⁠rafaconvaitis thanks, that settles it: the same head and checkpoint, with only #911's cap added, went from a removal 35.72 s after the builder's pipelines were ready to 240 s without one, and the log shows the 1,320,192-byte view cut to 65,536. So running the builder on `main` needs #911 (or an equivalent cap); I have added that to this PR's description.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 17:01 UTC · original

@⁠TheoGegout thanks, both numbers are useful. About 30 ms a frame on an RX 6800 XT, against our 88 ms of card time on an RTX 5090, fits the builder's programs running in their own wave64 form on AMD rather than in the paired form a 32-lane GPU needs.

The hang matters more. As the description says under "Not tested", the thread-count form (threads past the counts leave at entry, USER_THREAD_LIMIT) has not been run by us on a 64-lane GPU: on AMD the builder's wave64 programs take that form natively, so this is the first run of it there. 0x887A0006 with nothing before it fits a dispatch that never finishes.

If you can repeat it, a diagnostics build with VICTORY_D3D12_DRED=1 would say which command the card was on when it hung (breadcrumbs and page-fault data in the removal report), at much less cost than the debug layer, which may hide a timing-dependent hang. Running the same save once more with the trace on would also tell whether the trace's extra time is what kept your first run alive.

**@⁠PiloteCode** on GitHub · 2026-11-25 17:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7168882444) @⁠TheoGegout thanks, both numbers are useful. About 30 ms a frame on an RX 6800 XT, against our 88 ms of card time on an RTX 5090, fits the builder's programs running in their own wave64 form on AMD rather than in the paired form a 32-lane GPU needs. The hang matters more. As the description says under "Not tested", the thread-count form (threads past the counts leave at entry, `USER_THREAD_LIMIT`) has not been run by us on a 64-lane GPU: on AMD the builder's wave64 programs take that form natively, so this is the first run of it there. `0x887A0006` with nothing before it fits a dispatch that never finishes. If you can repeat it, a diagnostics build with `VICTORY_D3D12_DRED=1` would say which command the card was on when it hung (breadcrumbs and page-fault data in the removal report), at much less cost than the debug layer, which may hide a timing-dependent hang. Running the same save once more with the trace on would also tell whether the trace's extra time is what kept your first run alive.
Author
Owner

@⁠rafaconvaitis on GitHub · 2026-11-25 16:45 UTC · original · edited 2026-11-25 17:07 UTC

I ran the direct #911 comparison on the same RTX 4070 12 GB (616.64). Both runs used the same Series X checkpoint, c9ca6b2 with the same input-only shim, cold pipeline caches, and VICTORY_BVH_BUILDER=1. The second run added only the 1087538 CBV cap.

  • Reference lost the host device with 0x887A0001 35.72 s after the 53 builder pipelines were ready.
  • With the cap, the log recorded a request for 1,320,192 bytes reduced to 65,536. Rendering continued for 240.81 s after that message and the window closed normally, 254.75 s after the builder pipelines were ready. The log contained no device removal or title exception in that interval.

A separate warm-cache run reached the cell, responded to camera and movement, and reached the prompt to talk to the companion. It closed at 735.78 s after builder readiness with no device removal. Median was 2.0 fps across 67 samples with at least 4,500 draws and no pending pipelines. Strong window glare and dark room surfaces were still visible.

For anyone using Codex to test the renderer, its UI showed the “This content can’t be shown” Daybreak safety banner during this graphics session. I left a report in openai/codex#63232. If you have seen the same banner during graphics work, adding the client version and context there may help the Codex team investigate.

**@⁠rafaconvaitis** on GitHub · 2026-11-25 16:45 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7168491594) · edited 2026-11-25 17:07 UTC I ran the direct #911 comparison on the same RTX 4070 12 GB (616.64). Both runs used the same Series X checkpoint, `c9ca6b2` with the same input-only shim, cold pipeline caches, and `VICTORY_BVH_BUILDER=1`. The second run added only the `1087538` CBV cap. - Reference lost the host device with `0x887A0001` 35.72 s after the 53 builder pipelines were ready. - With the cap, the log recorded a request for 1,320,192 bytes reduced to 65,536. Rendering continued for 240.81 s after that message and the window closed normally, 254.75 s after the builder pipelines were ready. The log contained no device removal or title exception in that interval. A separate warm-cache run reached the cell, responded to camera and movement, and reached the prompt to talk to the companion. It closed at 735.78 s after builder readiness with no device removal. Median was 2.0 fps across 67 samples with at least 4,500 draws and no pending pipelines. Strong window glare and dark room surfaces were still visible. For anyone using Codex to test the renderer, its UI showed the “This content can’t be shown” Daybreak safety banner during this graphics session. I left a report in openai/codex#63232. If you have seen the same banner during graphics work, adding the client version and context there may help the Codex team investigate.
Author
Owner

@⁠oz-stanislav-zhukov on GitHub · 2026-11-25 17:20 UTC · original

Another 32-lane NVIDIA data point, this time on Windows 10 (Agility SDK): RTX 5060 Ti 16 GB, i7-14700KF, Series X profile. This PR was merged into our tree: a253706 + 0b0074e + #854 #959 + Belobug's ambient pass. That tree has no CBV size cap (#911 / #799).

  • With VICTORY_BVH_BUILDER=1: "the ray-tracing structure builder runs ... pipelines=53", ~11 min including world entry and the cell, no crash and no device removal. Before this PR the same tree crashed at world entry, reading 0xffffffffffffffff in the title. I don't know why the missing CBV cap didn't bite here. It may just not have hit a large view in that stretch.
  • Cost, builder on vs off (the off run adds only Zettrox/ztrx#148 and a log counter): 3.3-3.7 fps → 2.4-3.0 fps. On the GPU ~172 → ~272 ms a frame, copying back ~174 → ~281 ms.
  • The picture got much darker with the builder on: the cell and the bunks are mostly in shade, where with it off they are lit. Our ambient constant (written after CS_ScreenProbes_TemporalResolve, as in #917) still ran (shaded=true in the log), so the traced passes seem to darken what it adds. Is that expected while the structures are only partly right, or does it point at something the traced passes read?

We keep the builder off for now. The PR is still worth taking for the crash fix alone.

AI-assisted (Claude Code, Claude Opus 5.5); no game data.

**@⁠oz-stanislav-zhukov** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7169362576) Another 32-lane NVIDIA data point, this time on Windows 10 (Agility SDK): RTX 5060 Ti 16 GB, i7-14700KF, Series X profile. This PR was merged into our tree: `a253706` + `0b0074e` + #854 #959 + Belobug's ambient pass. That tree has no CBV size cap (#911 / #799). - With `VICTORY_BVH_BUILDER=1`: "the ray-tracing structure builder runs ... pipelines=53", ~11 min including world entry and the cell, no crash and no device removal. Before this PR the same tree crashed at world entry, reading `0xffffffffffffffff` in the title. I don't know why the missing CBV cap didn't bite here. It may just not have hit a large view in that stretch. - Cost, builder on vs off (the off run adds only Zettrox/ztrx#148 and a log counter): 3.3-3.7 fps → 2.4-3.0 fps. On the GPU ~172 → ~272 ms a frame, copying back ~174 → ~281 ms. - The picture got much darker with the builder on: the cell and the bunks are mostly in shade, where with it off they are lit. Our ambient constant (written after `CS_ScreenProbes_TemporalResolve`, as in #917) still ran (`shaded=true` in the log), so the traced passes seem to darken what it adds. Is that expected while the structures are only partly right, or does it point at something the traced passes read? We keep the builder off for now. The PR is still worth taking for the crash fix alone. AI-assisted (Claude Code, Claude Opus 5.5); no game data.
Author
Owner

@⁠Zayfway on GitHub · 2026-11-25 17:25 UTC · original

Ran this branch as published (c9ca6b2) on a mid-range card with little RAM. AI-assisted (Claude Code); every number below is from these runs.

Machine: RTX 3060 12 GB (driver 610.88, 32-lane), Ryzen 7 5700X, 16 GB RAM with a 32 GB pagefile, Windows 11 26300, Series X profile, diag build.

Translation. translate --warm all over the shader pack: 25,950 of 25,985 translate (35 do not). On main (0b0074e) and on #980 it is 25,707 (278 do not).

In the game. Opening cutscene, two runs back to back with the same switches (ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT COPY_PLAIN LEVELS_ON_DEMAND), measured from world +60 s:

VICTORY_BVH_BUILDER=1 (and VICTORY_BVH_TRACE) builder off
builder runs ... pipelines=53 off
frame 1,972 ms median, p90 3,995 (0.59 fps) 669 ms median, p90 1,603 (1.84 fps)
GPU / preparing / copy-back per frame 444 / 816 / 446 ms 119 / 283 / 80 ms
private memory, max 24.0 GB 25.9 GB
how the run ended after ~7 min in the world: no device loss, no access violation; the title stopped on a breakpoint (0x80000003) ran the full 10 min, killed by the harness

For comparison, on the same machine #980 with the builder on died at world +95–146 s: shaders touched pages from 0x10000, then E_OUTOFMEMORY. Here the builder ran about 4 times longer and none of those messages appeared. That matches your diagnosis of the thread-count dispatches.

Not tested:

  • The picture. The cutscene at 0.6 fps skips most of its 3D shots (the captures are title cards), so I cannot compare lighting with and without the builder yet. I am getting a gameplay save for that.
  • The cause of the breakpoint. Only one run with the builder on; VICTORY_BVH_TRACE was on (a 250 MB file), which also costs time.
  • The ms per frame with the trace off.
**@⁠Zayfway** on GitHub · 2026-11-25 17:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7169475983) Ran this branch as published (`c9ca6b2`) on a mid-range card with little RAM. *AI-assisted (Claude Code); every number below is from these runs.* **Machine:** RTX 3060 12 GB (driver 610.88, 32-lane), Ryzen 7 5700X, 16 GB RAM with a 32 GB pagefile, Windows 11 26300, Series X profile, diag build. **Translation.** `translate --warm all` over the shader pack: **25,950 of 25,985** translate (35 do not). On `main` (`0b0074e`) and on #980 it is 25,707 (278 do not). **In the game.** Opening cutscene, two runs back to back with the same switches (`ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT COPY_PLAIN LEVELS_ON_DEMAND`), measured from world +60 s: | | `VICTORY_BVH_BUILDER=1` (and `VICTORY_BVH_TRACE`) | builder off | |---|---|---| | builder | `runs ... pipelines=53` | off | | frame | 1,972 ms median, p90 3,995 (**0.59 fps**) | 669 ms median, p90 1,603 (**1.84 fps**) | | GPU / preparing / copy-back per frame | 444 / 816 / 446 ms | 119 / 283 / 80 ms | | private memory, max | 24.0 GB | 25.9 GB | | how the run ended | after **~7 min in the world**: no device loss, no access violation; the title stopped on a breakpoint (`0x80000003`) | ran the full 10 min, killed by the harness | For comparison, on the same machine #980 with the builder on died at world +95–146 s: shaders touched pages from 0x10000, then `E_OUTOFMEMORY`. Here the builder ran about 4 times longer and none of those messages appeared. That matches your diagnosis of the thread-count dispatches. **Not tested:** - The picture. The cutscene at 0.6 fps skips most of its 3D shots (the captures are title cards), so I cannot compare lighting with and without the builder yet. I am getting a gameplay save for that. - The cause of the breakpoint. Only one run with the builder on; `VICTORY_BVH_TRACE` was on (a 250 MB file), which also costs time. - The ms per frame with the trace off.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 17:29 UTC · original

@⁠oz-stanislav-zhukov thanks — a third 32-lane card where the crash at world entry is gone, and an 11-minute run.

On the darker picture: we have not compared the lit passes against the console's yet (the description says so), so we cannot say which of your two pictures is right. Two things to keep apart:

  • With the builder off, this PR makes every node test answer no hit, so traced shadow and occlusion rays find nothing and the cell is lit as if open. With it on, they find the walls and bunks. Some darkening is what a working builder should give.
  • An ambient constant added after the screen-probe resolve is a stand-in for the light the traced passes are missing when the builder is off. With the builder on it may no longer be needed, or may count twice. A run with the builder on and the ambient pass off would show what the traced passes give on their own.

If parts look wrong rather than just darker (whole surfaces black, tiles, light leaking through walls), VICTORY_BVH_CHECK=<hash> in a diagnostics build walks the structures the header stage starts and reports bad nodes; that would tell a structure fault from a lighting difference.

**@⁠PiloteCode** on GitHub · 2026-11-25 17:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7169587156) @⁠oz-stanislav-zhukov thanks — a third 32-lane card where the crash at world entry is gone, and an 11-minute run. On the darker picture: we have not compared the lit passes against the console's yet (the description says so), so we cannot say which of your two pictures is right. Two things to keep apart: - With the builder off, this PR makes every node test answer no hit, so traced shadow and occlusion rays find nothing and the cell is lit as if open. With it on, they find the walls and bunks. Some darkening is what a working builder should give. - An ambient constant added after the screen-probe resolve is a stand-in for the light the traced passes are missing when the builder is off. With the builder on it may no longer be needed, or may count twice. A run with the builder on and the ambient pass off would show what the traced passes give on their own. If parts look wrong rather than just darker (whole surfaces black, tiles, light leaking through walls), `VICTORY_BVH_CHECK=<hash>` in a diagnostics build walks the structures the header stage starts and reports bad nodes; that would tell a structure fault from a lighting difference.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 17:29 UTC · original

@⁠Zayfway thanks — useful on a 12 GB card with 16 GB of RAM. The translation count is in line with our CPU census of this head (all but one shadow-mask trace program in the shader pack), and the builder outliving #980's run by a long way fits the thread-count overrun being the cause there.

The frame cost here is mostly the trace and the card: with VICTORY_BVH_TRACE on, every builder dispatch and every range put back is written out (your 250 MB file), and at 0.6 fps the cutscene skips its shots, so a run without the trace is the one to compare.

0x80000003 is a breakpoint instruction in the title, not a fault of ours; the title reaches one when one of its own checks fails. The lines just before it in the log (and the crash report's title address, if one was written) would say where. If it shows up again without the trace, please post those lines.

**@⁠PiloteCode** on GitHub · 2026-11-25 17:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7169587521) @⁠Zayfway thanks — useful on a 12 GB card with 16 GB of RAM. The translation count is in line with our CPU census of this head (all but one shadow-mask trace program in the shader pack), and the builder outliving #980's run by a long way fits the thread-count overrun being the cause there. The frame cost here is mostly the trace and the card: with `VICTORY_BVH_TRACE` on, every builder dispatch and every range put back is written out (your 250 MB file), and at 0.6 fps the cutscene skips its shots, so a run without the trace is the one to compare. `0x80000003` is a breakpoint instruction in the title, not a fault of ours; the title reaches one when one of its own checks fails. The lines just before it in the log (and the crash report's title address, if one was written) would say where. If it shows up again without the trace, please post those lines.
Author
Owner

@⁠Zayfway on GitHub · 2026-11-25 18:25 UTC · original

Follow-up: what ends builder-on runs on a 16 GB machine is the card's shared (system) memory budget, not commit and not VRAM. AI-assisted (Claude Code); numbers from these runs.

Same machine as above (RTX 3060 12 GB, 16 GB RAM, 32 GB pagefile), this branch (c9ca6b2), loading the prison save.

builder off builder on builder on, VICTORY_WINDOW_KB=256 VICTORY_WINDOW_TAILS=1
gameplay frame (world +120 s to +360 s) 371 ms median (2.67 fps) – –
how the run ended ran 8 min, killed by the harness a host state prelude did not record (0x8007000E) before the gameplay window access violation in nvwgf2umx.dll before the gameplay window
"the PC's shared with the card" – 7,178 of 7,488 MB 7,361 of 7,488 MB
commit left / card in use – 7.8 GB / 9.4 of 11.3 GB 9.4 GB / –

DXGI gives the card a non-local budget of about half the RAM. On a 16 GB machine that is 7.5 GB, and a larger pagefile does not move it.

What fills it, from the last memory lines of the 256 KiB run:

  • Windows outside buffers: 5,267 copies, 5,103 MB, lying over only 3,008 MB of title memory. That is 2.1 GB of overlap, each copied once per window. 1,275 of them (3,775 MB) were asked for without a length, so they run to the end of their 4 MiB cell even on the 256 KiB grid. With the builder off, windows are about 2.6 GB.
  • About 3 GB in 32 MB write-combined allocations (114 of them in the memory map), with 907 host lists alive. My guess is command allocators grown by builder-sized lists. I did not trace them.

So on 16 GB the builder needs its by-address reads to cost less shared memory. One option is windows sized to what the shaders read rather than to the cell's end. Another is copies for builder-only memory kept on the card (it is written by shaders, not the CPU). I have not tried either. This is also what ended my #980 runs: no shared buffer ... 0x8007000E.

**@⁠Zayfway** on GitHub · 2026-11-25 18:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7170893850) **Follow-up: what ends builder-on runs on a 16 GB machine is the card's *shared* (system) memory budget,** not commit and not VRAM. *AI-assisted (Claude Code); numbers from these runs.* Same machine as above (RTX 3060 12 GB, 16 GB RAM, 32 GB pagefile), this branch (`c9ca6b2`), loading the prison save. | | builder off | builder on | builder on, `VICTORY_WINDOW_KB=256 VICTORY_WINDOW_TAILS=1` | |---|---|---|---| | gameplay frame (world +120 s to +360 s) | **371 ms** median (2.67 fps) | – | – | | how the run ended | ran 8 min, killed by the harness | `a host state prelude did not record (0x8007000E)` before the gameplay window | access violation in `nvwgf2umx.dll` before the gameplay window | | "the PC's shared with the card" | – | **7,178 of 7,488 MB** | **7,361 of 7,488 MB** | | commit left / card in use | – | 7.8 GB / 9.4 of 11.3 GB | 9.4 GB / – | DXGI gives the card a non-local budget of about half the RAM. On a 16 GB machine that is 7.5 GB, and a larger pagefile does not move it. What fills it, from the last memory lines of the 256 KiB run: - **Windows outside buffers: 5,267 copies, 5,103 MB, lying over only 3,008 MB of title memory.** That is 2.1 GB of overlap, each copied once per window. **1,275 of them (3,775 MB) were asked for without a length**, so they run to the end of their 4 MiB cell even on the 256 KiB grid. With the builder off, windows are about 2.6 GB. - **About 3 GB in 32 MB write-combined allocations** (114 of them in the memory map), with 907 host lists alive. My guess is command allocators grown by builder-sized lists. I did not trace them. So on 16 GB the builder needs its by-address reads to cost less shared memory. One option is windows sized to what the shaders read rather than to the cell's end. Another is copies for builder-only memory kept on the card (it is written by shaders, not the CPU). I have not tried either. This is also what ended my #980 runs: `no shared buffer ... 0x8007000E`.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 18:29 UTC · original

@⁠Zayfway thanks, that is a clear account, and it is a real limit of this PR on 16 GB: we only ran the builder on a machine with 64 GB, where the shared budget is 32 GB, so we never met it.

Your reading matches the code. A window asked for without a length runs to the end of its 4 MiB cell, and windows over the same title memory are separate copies in the PC's memory shared with the card; the builder names far more windows than the passes without it. Both of your options are sound; the second (copies of memory only shaders write kept in the card's own memory) removes the most, and the first (windows sized to what the shaders read) is the smaller change. Neither is in this PR, which only makes the builder run without the overrun; it stays opt-in.

Until then, on 16 GB the builder is likely to stay out of reach; with it off this PR should cost no shared memory beyond main's (your 8-minute run fits that).

**@⁠PiloteCode** on GitHub · 2026-11-25 18:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7170984643) @⁠Zayfway thanks, that is a clear account, and it is a real limit of this PR on 16 GB: we only ran the builder on a machine with 64 GB, where the shared budget is 32 GB, so we never met it. Your reading matches the code. A window asked for without a length runs to the end of its 4 MiB cell, and windows over the same title memory are separate copies in the PC's memory shared with the card; the builder names far more windows than the passes without it. Both of your options are sound; the second (copies of memory only shaders write kept in the card's own memory) removes the most, and the first (windows sized to what the shaders read) is the smaller change. Neither is in this PR, which only makes the builder run without the overrun; it stays opt-in. Until then, on 16 GB the builder is likely to stay out of reach; with it off this PR should cost no shared memory beyond `main`'s (your 8-minute run fits that).
Author
Owner

@⁠Zayfway on GitHub · 2026-11-25 19:14 UTC · original

Correction to my last comment: the 32 MB write-combined blocks are not command allocators. Builder-off runs on the same machine show it.

run (same save) 32 MB write-combined blocks shared with the card, in use
main 465b94f 279 blocks, 5,751 MB 5,753 MB
this branch, builder off 277 blocks, 5,949 MB 5,807 MB
this branch, builder on, 256 KiB windows 114 blocks, 3,053 MB, plus 5.1 GB of windows 7,361 of 7,488 MB

So the shared memory is the host copies of title memory themselves, and the builder's by-address windows come on top of a base of about 5.7 GB. The 2.1 GB of overlap between windows (5,103 MB of windows over 3,008 MB of title memory) is what an address-keyed layout would remove: windows as views into one reserved buffer per title range, mapped a tile at a time, as XCL's sparse windows do. I have not tried that here.

On a 16 GB machine that is the difference between staying under the ~7.5 GB budget and not.

**@⁠Zayfway** on GitHub · 2026-11-25 19:14 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7172012106) Correction to my last comment: the 32 MB write-combined blocks are **not** command allocators. Builder-off runs on the same machine show it. | run (same save) | 32 MB write-combined blocks | shared with the card, in use | |---|---|---| | `main` `465b94f` | 279 blocks, 5,751 MB | 5,753 MB | | this branch, builder off | 277 blocks, 5,949 MB | 5,807 MB | | this branch, builder on, 256 KiB windows | 114 blocks, 3,053 MB, plus 5.1 GB of windows | 7,361 of 7,488 MB | So the shared memory is the host copies of title memory themselves, and the builder's by-address windows come on top of a base of about 5.7 GB. The 2.1 GB of overlap between windows (5,103 MB of windows over 3,008 MB of title memory) is what an address-keyed layout would remove: windows as views into one reserved buffer per title range, mapped a tile at a time, as XCL's sparse windows do. I have not tried that here. On a 16 GB machine that is the difference between staying under the ~7.5 GB budget and not.
Author
Owner

@⁠deadkid14 on GitHub · 2026-11-25 19:22 UTC · original

Linux/Proton report: with this stack, the game crashes in vkd3d-proton during pipeline creation at world entry, 3 runs out of 3. #854 on its own is fine on the same machine.

Setup: RTX 5070 Ti, driver 620.73.04, GE-Proton11-14 (its own vkd3d-proton), main d510ee4 plus our two Linux patches (DXC fallback from #20, the watchdog switch from upstream #454). Merged on top of that: #854, then this PR including #993. There was one conflict, in draw.rs (may_store from main next to trace_dispatch from here), resolved by keeping both. The structure builder was off (default) in every run.

Crash: 0xc0000005 at d3d12core.dll+0x28c726 (read 0x130: nothing mapped there) on a pipeline worker. It happens about a minute into the world (frames 1092 to 1784), while the first gameplay pipelines are being made:

#10 d3d12core.dll+0x43e3a8
#11 d3d12core.dll+0x42a8f2
#12 victory_gpu::pipeline::library::pipeline::<HostPipeline::new::{closure#5}, ...>
#13 victory_gpu::pipeline::host::HostPipeline::new
#16 victory_gpu::pipeline::make::workers::{closure#0}::{closure#1}

Xid 0, no device loss. The title's crash handler then runs (its upload is blocked by the layer).

Ruled out:

  • VICTORY_LIBRARY_LOCK=1: same crash, same address, so it is not two library calls at once.
  • Reverting 26cc0a3 (host pipelines for geometry stages): same crash.

Control: the same tree with #854 only (no #993/#994) ran twice without a crash. All five programs that were dropped before now bind (f133e35efed2a48a, 02384a60fda6f2d0, 2cc4c197ee29e291, 2da4beb386509b77, 369cbe906ea72764), at about 5 fps, the same as without it. The skin-coloured blocks on characters are unchanged there, which is why I wanted to try the no-hit node tests from this PR.

So the crash comes from something in #993/#994 other than 26cc0a3. Candidates by commit title: d70b069 (UAVs declared at every stage) and 82a0374 (mesh programs without a pixel program). I haven't bisected further.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

**@⁠deadkid14** on GitHub · 2026-11-25 19:22 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7172212498) Linux/Proton report: with this stack, the game crashes in vkd3d-proton during pipeline creation at world entry, 3 runs out of 3. #854 on its own is fine on the same machine. **Setup:** RTX 5070 Ti, driver 620.73.04, GE-Proton11-14 (its own vkd3d-proton), main `d510ee4` plus our two Linux patches (DXC fallback from #20, the watchdog switch from upstream #454). Merged on top of that: #854, then this PR including #993. There was one conflict, in `draw.rs` (`may_store` from main next to `trace_dispatch` from here), resolved by keeping both. The structure builder was off (default) in every run. **Crash:** `0xc0000005 at d3d12core.dll+0x28c726 (read 0x130: nothing mapped there)` on a pipeline worker. It happens about a minute into the world (frames 1092 to 1784), while the first gameplay pipelines are being made: ``` #10 d3d12core.dll+0x43e3a8 #11 d3d12core.dll+0x42a8f2 #12 victory_gpu::pipeline::library::pipeline::<HostPipeline::new::{closure#5}, ...> #13 victory_gpu::pipeline::host::HostPipeline::new #16 victory_gpu::pipeline::make::workers::{closure#0}::{closure#1} ``` Xid 0, no device loss. The title's crash handler then runs (its upload is blocked by the layer). **Ruled out:** - `VICTORY_LIBRARY_LOCK=1`: same crash, same address, so it is not two library calls at once. - Reverting `26cc0a3` (host pipelines for geometry stages): same crash. **Control:** the same tree with #854 only (no #993/#994) ran twice without a crash. All five programs that were dropped before now bind (`f133e35efed2a48a`, `02384a60fda6f2d0`, `2cc4c197ee29e291`, `2da4beb386509b77`, `369cbe906ea72764`), at about 5 fps, the same as without it. The skin-coloured blocks on characters are unchanged there, which is why I wanted to try the no-hit node tests from this PR. So the crash comes from something in #993/#994 other than `26cc0a3`. Candidates by commit title: `d70b069` (UAVs declared at every stage) and `82a0374` (mesh programs without a pixel program). I haven't bisected further. *AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.*
Author
Owner

@⁠Exopus-0x65f7ad0 on GitHub · 2026-11-25 19:43 UTC · original

Data point on 16 GB of RAM (RTX 5060 Ti 8 GB, Windows 11), PR head c9ca6b2 as is, with VICTORY_BVH_BUILDER=1. The builder starts (53/53 programs) and the game runs at 0.2-0.6 fps. Run 1 (cold cache): access violation in nvwgf2umx.dll before the cutscene. Run 2 (warm): ends without a message 67 s after the builder starts. Run 3: E_OUTOFMEMORY ("host copies in the card's memory could not be brought up to date") 2 min 20 after the builder starts, then device removed. That matches Zayfway's analysis of the shared-memory budget (about half the RAM). On 16 GB the builder is out of reach for now, as you said.

🤖 Generated with Claude Code

**@⁠Exopus-0x65f7ad0** on GitHub · 2026-11-25 19:43 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7172684116) Data point on 16 GB of RAM (RTX 5060 Ti 8 GB, Windows 11), PR head c9ca6b2 as is, with `VICTORY_BVH_BUILDER=1`. The builder starts (53/53 programs) and the game runs at 0.2-0.6 fps. Run 1 (cold cache): access violation in `nvwgf2umx.dll` before the cutscene. Run 2 (warm): ends without a message 67 s after the builder starts. Run 3: `E_OUTOFMEMORY` ("host copies in the card's memory could not be brought up to date") 2 min 20 after the builder starts, then device removed. That matches Zayfway's analysis of the shared-memory budget (about half the RAM). On 16 GB the builder is out of reach for now, as you said. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Zayfway on GitHub · 2026-11-25 19:52 UTC · original

Picture check on the same 32-lane card, builder off. This branch merged onto main 465b94f with #1002 (tree: Zayfway/victory-fork@integ/rtx3060, conflicts described in #1002) gives the following in the prison scene:

  • The 16 px steps of sunlight along the characters' silhouettes are gone. They remain on main, and on main + #1002 alone.
  • The window's dirty-glass and haze effect is drawn.
  • No compute program is refused by the driver; only the builder's stages are dropped, since it is off.

The cost on this card is 264–274 → 338 ms a frame (GPU 150–167 → 210 ms), as the four formerly refused programs now run in their exact 64-lane forms. Details and numbers: #1002. AI-assisted (Claude Code).

**@⁠Zayfway** on GitHub · 2026-11-25 19:52 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7172869137) Picture check on the same 32-lane card, builder **off**. This branch merged onto `main` `465b94f` with #1002 (tree: [`Zayfway/victory-fork@integ/rtx3060`](https://github.com/Zayfway/victory-fork/tree/integ/rtx3060), conflicts described in #1002) gives the following in the prison scene: - The 16 px steps of sunlight along the characters' silhouettes are gone. They remain on `main`, and on `main` + #1002 alone. - The window's dirty-glass and haze effect is drawn. - No compute program is refused by the driver; only the builder's stages are dropped, since it is off. The cost on this card is 264–274 → 338 ms a frame (GPU 150–167 → 210 ms), as the four formerly refused programs now run in their exact 64-lane forms. Details and numbers: https://git.gtahub.st/github/fxceless--victory-fork/pulls/1002. *AI-assisted (Claude Code).*
Author
Owner

@⁠Yorivel on GitHub · 2026-11-25 21:53 UTC · original

AI-assisted (Claude Code). Numbers and log lines only, no game data.

RTX 4090 with this stack and the builder on: no crash, no device loss, 4.5 fps in the barracks, and the picture is clean.

Setup. RTX 4090 (32-lane waves), driver 621.40, i9-14900K, 64 GB, Windows 11, Series X profile, diagnostics build. Tree: fork main 085ee7c + this PR (c9ca6b2) + #500 + #501. Merging this PR into 085ee7c had one conflict, in draw.rs: may_store from main and trace_dispatch from here sit at the same spot, and both were kept. Switches: VICTORY_BVH_BUILDER=1, RELAY=2, SHADER_OPT=0, LDS_EXACT=1, SHADER_LOOP_LIMIT=256, plus the README's speed set (ASYNC_SUBMIT, QUEUE2, INDIRECT_WINDOW, INDIRECT_GATHER, CARD_REHASH_RUNS, TEXTURE_NO_WAIT).

Stability. Six launches today on this tree, 3 to 10 minutes each (four of them cold-cache starts). Every one had 0 first-chance exceptions and no device removal. Each launch logged the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53.

Frame time in the barracks, once loading settled:

tree, builder on fps ms/frame on the GPU
085ee7c + #646 + #346 + #156 + #36 (no #854/#993) 4.1-4.4 227-245 50-60 ms
this stack 4.5-4.6 216-221 91 ms

Windows outside buffers compared on the CPU came to 544-600 MB a frame, in 136-150 ranges. Before #346 or this PR's raw-store rule it was 16.1 GB in 4,028 ranges, at 0.3 fps.

What changed in the picture against the tree without #854/#993. Same save, same spots:

  • The stair-stepped block edges on sunlit hair and shoulders are gone. The tree without #854 dropped f133e35efed2a48a every frame and had 02384a60fda6f2d0, 2cc4c197ee29e291 and 2da4beb386509b77 refused. This stack builds all four.
  • The band of blocks along the bottom edge is gone, as #993's split of the >65,535-group final gather predicts.
  • The window glass refracts the yard behind it.
  • VICTORY_WAVE_PAIRS=0 on this tree brings the edges back. It also turns the builder off: dropped 332.0/frame without a host pipeline: a stage of the ray-tracing structure builder, which is off. So the three builder programs that need the paired form are needed on this card too.

The indirect diffuse chain runs whole. The run bound 81 programs of indirect_diffuse_lighting and indirect_light_probes: screen probes, ray binning, CS_ScreenProbes_TraceRays_RayBinning_BVH_Mixed_ShaderBinning_WithFar, the irradiance cache and both CS_FinalGather variants. None was dropped. Their forms with VICTORY_WAVE_WHY=1:

  • 75 are plain;
  • 3 are paired: CS_IrradianceCache_Shade, _ShadeSecondary, _IntegrateIrradianceSH;
  • 3 use the allocation idiom: the two RegisterAllocationRequests and CS_GenerateRayBinOffsets;
  • none is approximate.

In two VICTORY_SHOT frames, the final image (R10G10B10A2, 2560x1440) has smooth shading on hair and skin, and bounce light on the walls and floor away from the window. No console reference has been compared yet.

A pitfall for anyone judging pictures by screenshot. A plain desktop capture (GDI CopyFromScreen) of this window showed heavy posterization: flat colour bands on faces and clothes. Neither the screen nor the VICTORY_SHOT final image showed it. Use the frame shot for pictures, not a desktop grab.

**@⁠Yorivel** on GitHub · 2026-11-25 21:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7175665767) *AI-assisted (Claude Code). Numbers and log lines only, no game data.* **RTX 4090 with this stack and the builder on: no crash, no device loss, 4.5 fps in the barracks, and the picture is clean.** **Setup.** RTX 4090 (32-lane waves), driver 621.40, i9-14900K, 64 GB, Windows 11, Series X profile, diagnostics build. Tree: fork `main` `085ee7c` + this PR (`c9ca6b2`) + #500 + #501. Merging this PR into `085ee7c` had one conflict, in `draw.rs`: `may_store` from main and `trace_dispatch` from here sit at the same spot, and both were kept. Switches: `VICTORY_BVH_BUILDER=1`, `RELAY=2`, `SHADER_OPT=0`, `LDS_EXACT=1`, `SHADER_LOOP_LIMIT=256`, plus the README's speed set (`ASYNC_SUBMIT`, `QUEUE2`, `INDIRECT_WINDOW`, `INDIRECT_GATHER`, `CARD_REHASH_RUNS`, `TEXTURE_NO_WAIT`). **Stability.** Six launches today on this tree, 3 to 10 minutes each (four of them cold-cache starts). Every one had 0 first-chance exceptions and no device removal. Each launch logged `the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53`. **Frame time in the barracks, once loading settled:** | tree, builder on | fps | ms/frame | on the GPU | |---|---|---|---| | `085ee7c` + #646 + #346 + #156 + #36 (no #854/#993) | 4.1-4.4 | 227-245 | 50-60 ms | | this stack | 4.5-4.6 | 216-221 | 91 ms | Windows outside buffers compared on the CPU came to 544-600 MB a frame, in 136-150 ranges. Before #346 or this PR's raw-store rule it was 16.1 GB in 4,028 ranges, at 0.3 fps. **What changed in the picture against the tree without #854/#993.** Same save, same spots: - The stair-stepped block edges on sunlit hair and shoulders are gone. The tree without #854 dropped `f133e35efed2a48a` every frame and had `02384a60fda6f2d0`, `2cc4c197ee29e291` and `2da4beb386509b77` refused. This stack builds all four. - The band of blocks along the bottom edge is gone, as #993's split of the >65,535-group final gather predicts. - The window glass refracts the yard behind it. - `VICTORY_WAVE_PAIRS=0` on this tree brings the edges back. It also turns the builder off: `dropped 332.0/frame without a host pipeline: a stage of the ray-tracing structure builder, which is off`. So the three builder programs that need the paired form are needed on this card too. **The indirect diffuse chain runs whole.** The run bound 81 programs of `indirect_diffuse_lighting` and `indirect_light_probes`: screen probes, ray binning, `CS_ScreenProbes_TraceRays_RayBinning_BVH_Mixed_ShaderBinning_WithFar`, the irradiance cache and both `CS_FinalGather` variants. None was dropped. Their forms with `VICTORY_WAVE_WHY=1`: - 75 are plain; - 3 are paired: `CS_IrradianceCache_Shade`, `_ShadeSecondary`, `_IntegrateIrradianceSH`; - 3 use the allocation idiom: the two `RegisterAllocationRequests` and `CS_GenerateRayBinOffsets`; - none is approximate. In two `VICTORY_SHOT` frames, the final image (R10G10B10A2, 2560x1440) has smooth shading on hair and skin, and bounce light on the walls and floor away from the window. No console reference has been compared yet. **A pitfall for anyone judging pictures by screenshot.** A plain desktop capture (GDI `CopyFromScreen`) of this window showed heavy posterization: flat colour bands on faces and clothes. Neither the screen nor the `VICTORY_SHOT` final image showed it. Use the frame shot for pictures, not a desktop grab.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:11 UTC · original

Merged main (c36971b) into the branch: a merge commit on top of the commits already here (6248570), then one lint commit. The branch merges into main without a conflict again. It still holds #993's and #854's heads as they were.

Conflicts. Four places in three files, each one where both sides had added lines. Both sides are kept in all of them:

  • draw.rs: a method each after State::list_dropped_roots (trace_dispatch here, may_store on main).
  • host.rs, twice: a diagnostics statement each under one attribute line, in run_deferred's title copy and at the top of write_mapped (the builder's trace line here, main's backreads calls). Each has its own attribute now, and main's statement stays next to the copy or the write it marks.
  • lib.rs: a diagnostics module each under one attribute line (bvhtrace here, backreads on main).

Merged without a conflict, and read through where both sides changed the same code:

  • indirect.rs: the clamp's shader now has main's gathered records (a record's place read from a table) and #993's split dispatch (kind 3). Only a windowed draw's record is gathered, never a dispatch's, so the two do not meet. The tests of both pass.
  • draw.rs: execute_indirect ends the list's gathering for a dispatch before the split clamp, and a dispatch by thread counts goes through dispatch, which ends it too. A title copy run on the card (copy_on_card) follows a draw or dispatch of its list that stores by address, so the list no longer gathers by then.
  • The translator: main's loads of four dwords a call (VICTORY_SHADER_OPT bit 64, not in the default) sit beside this stack's forms. main's test of them passes here both ways, and the shader tests give the same result with VICTORY_SHADER_OPT=127. emit/lower.rs is 519,626 bytes of the policy's 524,288.

Not run together: this branch with main's newer switches on (VICTORY_INDIRECT_GATHER, VICTORY_JOIN_PARTS, VICTORY_WINDOW_UPLOAD, VICTORY_COPY_CHANGED, VICTORY_CARD_BUFFERS_MIN_KB, VICTORY_TEXTURE_BACK). Two things from reading the code:

  • VICTORY_WINDOW_UPLOAD=1 rests on no shader writing a window outside buffers. With VICTORY_BVH_BUILDER=1 the builder's programs store by address into such windows.
  • A remap waits for the flights that may write its range (VICTORY_REMAP_LAND, on by default). main's notes now count some 850 remaps in a frame that streams; the wait has not been timed there.

Added after the merge: one lint commit for main's newer code, the same as on our other open branches: map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs, manual_is_multiple_of in queue.rs, shadow.rs, draw.rs and watch.rs. Without it cargo clippy --workspace --all-targets --locked -- -D warnings fails on c36971b, with or without --all-features.

Checked, the branch as it is (1ffff57), every test on the software adapter:

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy, cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics: pass.
  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 265 passed, 5 failed, 2 ignored. The five are the ones the description names; four of them fail on main alone on the software adapter (212 passed, 4 failed, 3 ignored), the fifth is #854's LDS subtraction test. The one test more than before is main's new one.
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 203 passed, 1 failed, 6 ignored. The failure is depth_bounds_pipeline_loads_and_filters_draws, as on main (200 passed, 1 failed, 6 ignored).
  • cargo test -p victory-hle -- --test-threads=1: 100 + 1 passed, as on main.
  • cargo test -p victory -p victory-loader: passed.
  • The offline census of the description, on the merged release build (victory translate --validate --list, VICTORY_HOST_MAX_WAVE=32, CPU only, no pipelines): 25,952 of 25,953 programs translate and validate. Its list is the same, line for line, as the one taken before the merge.
**@⁠PiloteCode** on GitHub · 2026-11-25 22:11 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7176055758) Merged `main` (`c36971b`) into the branch: a merge commit on top of the commits already here (`6248570`), then one lint commit. The branch merges into `main` without a conflict again. It still holds #993's and #854's heads as they were. **Conflicts.** Four places in three files, each one where both sides had added lines. Both sides are kept in all of them: - `draw.rs`: a method each after `State::list_dropped_roots` (`trace_dispatch` here, `may_store` on `main`). - `host.rs`, twice: a diagnostics statement each under one attribute line, in `run_deferred`'s title copy and at the top of `write_mapped` (the builder's trace line here, `main`'s `backreads` calls). Each has its own attribute now, and `main`'s statement stays next to the copy or the write it marks. - `lib.rs`: a diagnostics module each under one attribute line (`bvhtrace` here, `backreads` on `main`). **Merged without a conflict, and read through** where both sides changed the same code: - `indirect.rs`: the clamp's shader now has `main`'s gathered records (a record's place read from a table) and #993's split dispatch (kind 3). Only a windowed draw's record is gathered, never a dispatch's, so the two do not meet. The tests of both pass. - `draw.rs`: `execute_indirect` ends the list's gathering for a dispatch before the split clamp, and a dispatch by thread counts goes through `dispatch`, which ends it too. A title copy run on the card (`copy_on_card`) follows a draw or dispatch of its list that stores by address, so the list no longer gathers by then. - The translator: `main`'s loads of four dwords a call (`VICTORY_SHADER_OPT` bit 64, not in the default) sit beside this stack's forms. `main`'s test of them passes here both ways, and the shader tests give the same result with `VICTORY_SHADER_OPT=127`. `emit/lower.rs` is 519,626 bytes of the policy's 524,288. **Not run together:** this branch with `main`'s newer switches on (`VICTORY_INDIRECT_GATHER`, `VICTORY_JOIN_PARTS`, `VICTORY_WINDOW_UPLOAD`, `VICTORY_COPY_CHANGED`, `VICTORY_CARD_BUFFERS_MIN_KB`, `VICTORY_TEXTURE_BACK`). Two things from reading the code: - `VICTORY_WINDOW_UPLOAD=1` rests on no shader writing a window outside buffers. With `VICTORY_BVH_BUILDER=1` the builder's programs store by address into such windows. - A remap waits for the flights that may write its range (`VICTORY_REMAP_LAND`, on by default). `main`'s notes now count some 850 remaps in a frame that streams; the wait has not been timed there. **Added after the merge:** one lint commit for `main`'s newer code, the same as on our other open branches: `map_entry` in `fpsbox.rs`, `collapsible_if` in `pipeline/library.rs`, `manual_is_multiple_of` in `queue.rs`, `shadow.rs`, `draw.rs` and `watch.rs`. Without it `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on `c36971b`, with or without `--all-features`. **Checked**, the branch as it is (`1ffff57`), every test on the software adapter: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo xtask policy`, `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics`: pass. - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 265 passed, 5 failed, 2 ignored. The five are the ones the description names; four of them fail on `main` alone on the software adapter (212 passed, 4 failed, 3 ignored), the fifth is #854's LDS subtraction test. The one test more than before is `main`'s new one. - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 203 passed, 1 failed, 6 ignored. The failure is `depth_bounds_pipeline_loads_and_filters_draws`, as on `main` (200 passed, 1 failed, 6 ignored). - `cargo test -p victory-hle -- --test-threads=1`: 100 + 1 passed, as on `main`. - `cargo test -p victory -p victory-loader`: passed. - The offline census of the description, on the merged release build (`victory translate --validate --list`, `VICTORY_HOST_MAX_WAVE=32`, CPU only, no pipelines): 25,952 of 25,953 programs translate and validate. Its list is the same, line for line, as the one taken before the merge.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:55 UTC · original

@⁠BradRoland thanks, that is a real defect and your fix is the right one. With the structures off, the first look in the directory was still emitted, with a false predicate, before the branch on built; its fault-buffer store then went to the sink word. Inside the block that tests nodes the lane's guard and built both hold by control flow, so the look needs no predicate there, and it still comes once, before the branches on the node's kind.

Your commit 55f0043 is on the branch as you wrote it. Checked here at that commit:

  • cargo test -p victory-shader intersect: 8 passed on the software adapter and 8 passed on an RTX 5090, your disabled_structures_leave_the_page_fault_buffer_untouched among them;
  • cargo clippy --workspace --all-targets --locked -- -D warnings, the same with --all-features, and cargo xtask policy: clean;
  • the CPU census (victory translate --validate --list, 32-lane host): 25,952 of 25,953 programs translate and validate, as before.

The missing-page fix you adapted from #1165 is not taken here: it belongs with #1165, and this PR stays what it was plus your correction.

**@⁠PiloteCode** on GitHub · 2026-11-25 22:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7176942020) @⁠BradRoland thanks, that is a real defect and your fix is the right one. With the structures off, the first look in the directory was still emitted, with a false predicate, before the branch on `built`; its fault-buffer store then went to the sink word. Inside the block that tests nodes the lane's guard and `built` both hold by control flow, so the look needs no predicate there, and it still comes once, before the branches on the node's kind. Your commit `55f0043` is on the branch as you wrote it. Checked here at that commit: - `cargo test -p victory-shader intersect`: 8 passed on the software adapter and 8 passed on an RTX 5090, your `disabled_structures_leave_the_page_fault_buffer_untouched` among them; - `cargo clippy --workspace --all-targets --locked -- -D warnings`, the same with `--all-features`, and `cargo xtask policy`: clean; - the CPU census (`victory translate --validate --list`, 32-lane host): 25,952 of 25,953 programs translate and validate, as before. The missing-page fix you adapted from #1165 is not taken here: it belongs with #1165, and this PR stays what it was plus your correction.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:55 UTC · original

@⁠deadkid14 thanks for the report and for what you ruled out. A read of 0x130 with nothing mapped looks like a field read through a null object inside vkd3d-proton, while one pipeline is made. Of the two commits you name, the likelier one is 82a0374: it makes pipelines of a mesh program with no pixel program (the title's depth passes; before it those pipelines were refused, so nothing reached the driver). On Windows such a pipeline is valid and is made; a null pixel stage is the kind of thing a translation layer may not expect.

Two runs would tell:

  • VICTORY_MESH_LINK=0: turns that form off (those pipelines are refused again, as with #854 alone). If the crash goes, it is the mesh pipeline without a pixel shader.
  • d70b069 only changes vertex and mesh programs that have a root UAV, which without VICTORY_LOOP_NOTES=1 are few; if the first run still crashes, the log's last "first bind"/pipeline lines before the fault would name the program.

If it is the first, a stub pixel shader for those pipelines under Proton would be the way round it (the offline census already builds them that way); say so and we will add it behind a switch.

**@⁠PiloteCode** on GitHub · 2026-11-25 22:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7176942488) @⁠deadkid14 thanks for the report and for what you ruled out. A read of `0x130` with nothing mapped looks like a field read through a null object inside vkd3d-proton, while one pipeline is made. Of the two commits you name, the likelier one is `82a0374`: it makes pipelines of a mesh program **with no pixel program** (the title's depth passes; before it those pipelines were refused, so nothing reached the driver). On Windows such a pipeline is valid and is made; a null pixel stage is the kind of thing a translation layer may not expect. Two runs would tell: - `VICTORY_MESH_LINK=0`: turns that form off (those pipelines are refused again, as with #854 alone). If the crash goes, it is the mesh pipeline without a pixel shader. - `d70b069` only changes vertex and mesh programs that have a root UAV, which without `VICTORY_LOOP_NOTES=1` are few; if the first run still crashes, the log's last "first bind"/pipeline lines before the fault would name the program. If it is the first, a stub pixel shader for those pipelines under Proton would be the way round it (the offline census already builds them that way); say so and we will add it behind a switch.
Author
Owner

@⁠PiloteCode on GitHub · 2026-11-25 22:55 UTC · original

@⁠Zayfway @⁠Exopus-0x65f7ad0 @⁠Yorivel thanks for the three reports.

  • 16 GB machines (Zayfway, Exopus): agreed. The shared memory is the host copies of title memory themselves, and with the builder on its by-address windows come on top (5.1 GB over 3.0 GB of title memory in your run). This PR does not change that; the builder stays opt-in, and on 16 GB it is out of reach until the windows become views of one buffer per title range, as you describe. That is a change of the layer's copies, not of this PR.
  • Picture with the builder off (Zayfway): the 16 px steps of sunlight gone from the silhouettes and the window's haze drawn is what the no-hit node tests and the four formerly refused programs were meant to give. The cost you measured (264–274 → 338 ms a frame on that card) is theirs.
  • RTX 4090 with the builder on (Yorivel): six launches of 3 to 10 minutes with no exception and no device removal, 53 of 53 builder pipelines, and windows compared on the CPU down to 544–600 MB a frame from 16.1 GB: that is the first card other than ours where the builder ran this long.
**@⁠PiloteCode** on GitHub · 2026-11-25 22:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7176942821) @⁠Zayfway @⁠Exopus-0x65f7ad0 @⁠Yorivel thanks for the three reports. - **16 GB machines** (Zayfway, Exopus): agreed. The shared memory is the host copies of title memory themselves, and with the builder on its by-address windows come on top (5.1 GB over 3.0 GB of title memory in your run). This PR does not change that; the builder stays opt-in, and on 16 GB it is out of reach until the windows become views of one buffer per title range, as you describe. That is a change of the layer's copies, not of this PR. - **Picture with the builder off** (Zayfway): the 16 px steps of sunlight gone from the silhouettes and the window's haze drawn is what the no-hit node tests and the four formerly refused programs were meant to give. The cost you measured (264–274 → 338 ms a frame on that card) is theirs. - **RTX 4090 with the builder on** (Yorivel): six launches of 3 to 10 minutes with no exception and no device removal, 53 of 53 builder pipelines, and windows compared on the CPU down to 544–600 MB a frame from 16.1 GB: that is the first card other than ours where the builder ran this long.
Author
Owner

@⁠deadkid14 on GitHub · 2026-11-26 02:14 UTC · original

@⁠PiloteCode thanks. Results of the two checks you asked for, same tree as my report (main d510ee4 + Linux patches + #854 + this PR):

VICTORY_MESH_LINK=0 does not help. Same crash, same address (d3d12core.dll+0x28c726, read 0x130). With pipelines remembered from the earlier runs it now comes during loading (frame 32 to 43), or about a minute into the world.

The program: I added a log line before each library load and make, with the thread, and compared what was in flight at three crashes. Each time, the crash follows the start of the make of [compute e4a9f58e3acfcf7b]:

Run e4a9f58e3acfcf7b make starts Last log line before the fault
1 02:05:58.336 02:05:58.336 (that line)
2 02:11:50.149 02:11:50.149 (that line)
3 02:13:40.498 02:13:40.607

The same program builds fine in the same tree without #993/#994 (host pipeline shaders=[compute e4a9f58e3acfcf7b], first bind at frame 1187). So the crash comes from what this stack changes in its translation, not from mesh pipelines without a pixel program.

Something else turned up while looking, in both builds: four compute pipelines start and never finish on this stack (fdd56d97a806bcca, a1b20bc47e3c9597, e8c962358d862e3f, 559d9f0184e15fe3). One was still being made 95 s after it started. They are likely the ~5 draws a frame we see dropped as "being made" for a whole run. It is a separate issue, but worth knowing for anyone tuning VICTORY_PIPELINE_WAIT_MS on Linux.

I can run a build that leaves e4a9f58e3acfcf7b on its old translation, if there is a switch for the forms #993 adds.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

**@⁠deadkid14** on GitHub · 2026-11-26 02:14 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7180600810) @⁠PiloteCode thanks. Results of the two checks you asked for, same tree as my report (main `d510ee4` + Linux patches + #854 + this PR): **`VICTORY_MESH_LINK=0` does not help.** Same crash, same address (`d3d12core.dll+0x28c726`, read `0x130`). With pipelines remembered from the earlier runs it now comes during loading (frame 32 to 43), or about a minute into the world. **The program:** I added a log line before each library load and make, with the thread, and compared what was in flight at three crashes. Each time, the crash follows the **start of the make of `[compute e4a9f58e3acfcf7b]`**: | Run | `e4a9f58e3acfcf7b` make starts | Last log line before the fault | |---|---|---| | 1 | 02:05:58.336 | 02:05:58.336 (that line) | | 2 | 02:11:50.149 | 02:11:50.149 (that line) | | 3 | 02:13:40.498 | 02:13:40.607 | The same program builds fine in the same tree without #993/#994 (`host pipeline shaders=[compute e4a9f58e3acfcf7b]`, first bind at frame 1187). So the crash comes from what this stack changes in its translation, not from mesh pipelines without a pixel program. Something else turned up while looking, in both builds: four compute pipelines start and never finish on this stack (`fdd56d97a806bcca`, `a1b20bc47e3c9597`, `e8c962358d862e3f`, `559d9f0184e15fe3`). One was still being made 95 s after it started. They are likely the ~5 draws a frame we see dropped as "being made" for a whole run. It is a separate issue, but worth knowing for anyone tuning `VICTORY_PIPELINE_WAIT_MS` on Linux. I can run a build that leaves `e4a9f58e3acfcf7b` on its old translation, if there is a switch for the forms #993 adds. *AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.*
Author
Owner

@⁠drchef420 on GitHub · 2026-11-26 05:06 UTC · original

AI-assisted (Claude Code). Numbers and log lines only, no game data.

RTX 5070 12 GB, 32 GB RAM, builder on, no quarantine: no crash, no device loss, 6 min 17 s with the builder, and the picture looked right to the player. On main without this PR the same start crashed 8 s after the builder came up.

Setup. RTX 5070 12 GB (32-lane waves, driver 610.88; an RTX 3060 in the same PC, the game on the 5070 by Windows' per-app GPU preference), Core Ultra 7 270K Plus, 32 GB with a 32 GB paging file, Windows 11 26300, Series X profile, release build (no diagnostics). Tree: fork main 988aa41 + this PR at 7af465b. Switches: VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1, nothing else. A new start with no save, through the opening cutscene into the first room.

Merging. Since the last merge of main (c36971b) there are ten conflicting hunks in nine files. Two are more than both-sides-added:

  • emit/intersect.rs: main now has 96ff135 ("node tests can answer no hit", VICTORY_BVH_NO_HIT=1, credited to this PR's idea, as a translation-time switch). I kept its early return before this PR's built word test.
  • emit/mod.rs: main's VICTORY_WAVE_WIDE=last block returns again.map(|(shader, _)| shader); with this PR's return type it is return again;.
    The rest I kept both sides of (draw.rs, host.rs, pipeline.rs), or took this PR's side where only formatting differed (fpsbox.rs, pipeline/library.rs) and main's comment and cfg (indirect.rs, resource.rs). With that: cargo test -p victory-shader --locked 272 passed, 2 ignored; cargo test -p victory-gpu --locked -- --test-threads=1 207 passed, 6 ignored.

The run. 10 min 51 s; the builder came up at 3 min 30 s ("all of its programs have host pipelines", 53). From then on:

  • 0 unhandled exceptions, 0 device removals, 0 ERROR lines; the title ended normally when the window was closed (crashes.log untouched).
  • no number left for another copy never logged, with main's 1023 numbers.
  • Video memory: before the builder card 2.1 GB / shared 0.6 GB; 20 s after it, card 9.0 / shared 5.4; at the end card 9.4 GB of an 11.0 GB budget, shared 10.2 GB, still creeping (9.1 to 10.2 GB over the last 3 minutes).
  • Frames: about 1,080 in those 6 min 17 s; the last minute 560-770 ms a frame at 4,300-6,900 draws. We have no builder-off run of this tree; on main a183ea2 the same room ran at 3-4 fps with the builder off.

For comparison, without this PR. main a183ea2, same machine, same start, VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1 VICTORY_BVH_QUARANTINE=1: the title crashed about 8 s after the builder started, in the opening cutscene (a read reported at 0xffffffffffffffff at +0x52eca06, rdx all ones). From a save, on earlier trees of this fork, it crashed within seconds in five more runs, with and without the quarantine.

On 32 GB the builder fits for these six minutes; with shared memory still growing at the end, a longer run would tell whether it stops.

**@⁠drchef420** on GitHub · 2026-11-26 05:06 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7183179753) *AI-assisted (Claude Code). Numbers and log lines only, no game data.* **RTX 5070 12 GB, 32 GB RAM, builder on, no quarantine: no crash, no device loss, 6 min 17 s with the builder, and the picture looked right to the player. On `main` without this PR the same start crashed 8 s after the builder came up.** **Setup.** RTX 5070 12 GB (32-lane waves, driver 610.88; an RTX 3060 in the same PC, the game on the 5070 by Windows' per-app GPU preference), Core Ultra 7 270K Plus, 32 GB with a 32 GB paging file, Windows 11 26300, Series X profile, release build (no diagnostics). Tree: fork `main` `988aa41` + this PR at `7af465b`. Switches: `VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1`, nothing else. A new start with no save, through the opening cutscene into the first room. **Merging.** Since the last merge of `main` (`c36971b`) there are ten conflicting hunks in nine files. Two are more than both-sides-added: - `emit/intersect.rs`: `main` now has `96ff135` ("node tests can answer no hit", `VICTORY_BVH_NO_HIT=1`, credited to this PR's idea, as a translation-time switch). I kept its early return before this PR's `built` word test. - `emit/mod.rs`: `main`'s `VICTORY_WAVE_WIDE=last` block returns `again.map(|(shader, _)| shader)`; with this PR's return type it is `return again;`. The rest I kept both sides of (`draw.rs`, `host.rs`, `pipeline.rs`), or took this PR's side where only formatting differed (`fpsbox.rs`, `pipeline/library.rs`) and `main`'s comment and `cfg` (`indirect.rs`, `resource.rs`). With that: `cargo test -p victory-shader --locked` 272 passed, 2 ignored; `cargo test -p victory-gpu --locked -- --test-threads=1` 207 passed, 6 ignored. **The run.** 10 min 51 s; the builder came up at 3 min 30 s ("all of its programs have host pipelines", 53). From then on: - 0 unhandled exceptions, 0 device removals, 0 `ERROR` lines; the title ended normally when the window was closed (`crashes.log` untouched). - `no number left for another copy` never logged, with `main`'s 1023 numbers. - Video memory: before the builder card 2.1 GB / shared 0.6 GB; 20 s after it, card 9.0 / shared 5.4; at the end card 9.4 GB of an 11.0 GB budget, shared 10.2 GB, still creeping (9.1 to 10.2 GB over the last 3 minutes). - Frames: about 1,080 in those 6 min 17 s; the last minute 560-770 ms a frame at 4,300-6,900 draws. We have no builder-off run of this tree; on `main` `a183ea2` the same room ran at 3-4 fps with the builder off. **For comparison, without this PR.** `main` `a183ea2`, same machine, same start, `VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1 VICTORY_BVH_QUARANTINE=1`: the title crashed about 8 s after the builder started, in the opening cutscene (a read reported at `0xffffffffffffffff` at `+0x52eca06`, `rdx` all ones). From a save, on earlier trees of this fork, it crashed within seconds in five more runs, with and without the quarantine. On 32 GB the builder fits for these six minutes; with shared memory still growing at the end, a longer run would tell whether it stops.
Author
Owner

@⁠deadkid14 on GitHub · 2026-11-26 05:26 UTC · original

Follow-up on Linux with this PR's current head (7af465b, which includes main c36971b), using the switches from the RTX 5070 report above: VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1. On top: the watchdog switch from upstream #454, and the layer's own HLSL compiled with DXC (Wine's d3dcompiler refuses some of it).

The result is the same crash as before, so VICTORY_FIRSTLANE_OWN=1 does not avoid it under vkd3d-proton (GE-Proton11-14's build, RTX 5070 Ti, driver 620.73.04):

shader translated stage="compute" hash=e4a9f58e3acfcf7b user_data=3 samplers=1
... 35 log lines later:
0xc0000005 at d3d12core.dll+0x28c726 (read 0x130: nothing mapped there)
#12 victory_gpu::pipeline::library::pipeline::<HostPipeline::new::{closure}>
#13 victory_gpu::pipeline::host::HostPipeline::new

This was at frame 1268. A cached form of the same program had bound earlier at that frame, and the crash comes right after this new translation of it. No Xid and no device loss.

So on Windows the driver takes this pipeline, and under Wine vkd3d-proton fails on it with a null read. I haven't tried a newer vkd3d-proton than GE-Proton11-14's. If someone on Linux has one built from master, this program would be the one to check.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

**@⁠deadkid14** on GitHub · 2026-11-26 05:26 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7183485174) Follow-up on Linux with this PR's current head (`7af465b`, which includes main `c36971b`), using the switches from the RTX 5070 report above: `VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1`. On top: the watchdog switch from upstream #454, and the layer's own HLSL compiled with DXC (Wine's d3dcompiler refuses some of it). The result is the same crash as before, so `VICTORY_FIRSTLANE_OWN=1` does not avoid it under vkd3d-proton (GE-Proton11-14's build, RTX 5070 Ti, driver 620.73.04): ``` shader translated stage="compute" hash=e4a9f58e3acfcf7b user_data=3 samplers=1 ... 35 log lines later: 0xc0000005 at d3d12core.dll+0x28c726 (read 0x130: nothing mapped there) #12 victory_gpu::pipeline::library::pipeline::<HostPipeline::new::{closure}> #13 victory_gpu::pipeline::host::HostPipeline::new ``` This was at frame 1268. A cached form of the same program had bound earlier at that frame, and the crash comes right after this new translation of it. No Xid and no device loss. So on Windows the driver takes this pipeline, and under Wine vkd3d-proton fails on it with a null read. I haven't tried a newer vkd3d-proton than GE-Proton11-14's. If someone on Linux has one built from master, this program would be the one to check. *AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.*
Author
Owner

@⁠drchef420 on GitHub · 2026-11-26 06:10 UTC · original

AI-assisted (Claude Code). Numbers and log lines only, no game data.

Correction to my comment above: the tree I tested had this PR's COPIES = 2047, not main's 1023. I misread the merge; the numbers there are right, the limit was not.

A longer run of the same build (988aa41 + 7af465b, same machine and switches, from a save): 58 min 30 s, the builder up at 3 min 40 s. No exceptions, no device removal, no ERROR, no 0x8007000E; the title ended normally when the window was closed (host pipeline library saved).

  • Shared memory levels off. Card / shared: 9.3 / 8.9 GB at 8 min, 9.9 / 12.0 GB at 30 min, then 9.4-9.9 / 11.3-12.4 GB for the remaining half hour (11.9 GB at the end, budget 15.5 GB).
  • The copy numbers run out. no number left for another copy; its pages read zeros COPIES=2047 at 26 min 27 s (22 min 47 s after the builder came up), after the player had moved through several areas. Shortly before, at 20 min 32 s: no free dynamic descriptor slots: a table is not made n=182 and a draw whose descriptor table found no free slots is dropped (each logged once, so we can't tell how often).
  • What the player saw later: lit surfaces went black in a later area, and a boat's engine was destroyed right away. We can't tell from the log whether either comes from pages that read zeros. A game-logic result is a guess, but the timing (after the run-out, not in the 10-minute run) fits.
  • Frame cost doesn't grow. 400-650 ms a frame throughout, at 2,000-8,000 draws. About half of each frame is copying back: 220-440 ms and 50-140 MB a frame. The other half is 200-500 ms on the GPU. That matches the shortcut in memory.rs, where every such dispatch declares all numbered copies written and they are compared on the CPU.

So with this PR the builder runs for an hour on 32 GB without crashing, and memory holds. The limit we hit is the copy numbers, which #1082 addresses. It conflicts with this PR only in memory.rs; we'll report back if we run the two together.

**@⁠drchef420** on GitHub · 2026-11-26 06:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7184168094) *AI-assisted (Claude Code). Numbers and log lines only, no game data.* **Correction to my comment above:** the tree I tested had this PR's `COPIES = 2047`, not `main`'s 1023. I misread the merge; the numbers there are right, the limit was not. **A longer run of the same build** (`988aa41` + `7af465b`, same machine and switches, from a save): 58 min 30 s, the builder up at 3 min 40 s. No exceptions, no device removal, no `ERROR`, no `0x8007000E`; the title ended normally when the window was closed (`host pipeline library saved`). - **Shared memory levels off.** Card / shared: 9.3 / 8.9 GB at 8 min, 9.9 / 12.0 GB at 30 min, then 9.4-9.9 / 11.3-12.4 GB for the remaining half hour (11.9 GB at the end, budget 15.5 GB). - **The copy numbers run out.** `no number left for another copy; its pages read zeros COPIES=2047` at 26 min 27 s (22 min 47 s after the builder came up), after the player had moved through several areas. Shortly before, at 20 min 32 s: `no free dynamic descriptor slots: a table is not made n=182` and `a draw whose descriptor table found no free slots is dropped` (each logged once, so we can't tell how often). - **What the player saw later:** lit surfaces went black in a later area, and a boat's engine was destroyed right away. We can't tell from the log whether either comes from pages that read zeros. A game-logic result is a guess, but the timing (after the run-out, not in the 10-minute run) fits. - **Frame cost doesn't grow.** 400-650 ms a frame throughout, at 2,000-8,000 draws. About half of each frame is `copying back`: 220-440 ms and 50-140 MB a frame. The other half is 200-500 ms `on the GPU`. That matches the shortcut in `memory.rs`, where every such dispatch declares all numbered copies written and they are compared on the CPU. So with this PR the builder runs for an hour on 32 GB without crashing, and memory holds. The limit we hit is the copy numbers, which #1082 addresses. It conflicts with this PR only in `memory.rs`; we'll report back if we run the two together.
Author
Owner

@⁠deadkid14 on GitHub · 2026-11-26 06:44 UTC · original

Linux follow-up: with a newer vkd3d-proton the structure builder now starts here. The game then hangs about 50 s into the world.

Tree: this PR at 7af465b, plus the watchdog switch from upstream #454, the layer's HLSL compiled with DXC, and one local change: pipelines whose shaders are on VICTORY_SKIP_PIPELINES are refused when they would be made (a draw-time skip alone still makes them). VICTORY_SKIP_PIPELINES=e4a9f58e3acfcf7b (the program from my earlier reports). Switches: VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1. RTX 5070 Ti, driver 620.73.04, GE-Proton11-14's Wine with a rebuilt wineserver (CachyOS/wine-cachyos#50).

vkd3d-proton Result
GE-Proton11-14's (cae8353ed) Still crashed in d3d12core.dll (+0x28c726, read 0x130) at frame 1464, making mesh and pixel pipelines (36a9c81f635373e5, 47848d52f85892d8, 257fb752e6b64ce4 were the last translated). No "structure builder runs" line before that.
master 71cae091b (the project's CI package) No crash. The log says the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53.

The hang with master: the last log line is long frame 1315 at 51.7 s: 1834 ms, then nothing for 3+ minutes. Meanwhile the process uses exactly one core at 100%, the GPU is at about 6%, and there is no Xid and no device loss. So one thread spins waiting for something while the card idles. I can't tell from outside what it waits on. It looks like the builder's first results never arrive, but that is a guess. A run with VICTORY_HELPER_OWN=0 on GE's vkd3d-proton hung the same way (silent log, around frame 925), before any crash.

So with vkd3d-proton master the builder's own pipelines all get made, which GE-Proton11-14's build never got to. I can't say the mesh/pixel crash is gone: this run hung at frame 1315, before the frame (1464) where the earlier run crashed. The next blocker is this spin after the builder starts. If there's a trace switch that would show what the spinning thread waits for, I can run it.

AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.

**@⁠deadkid14** on GitHub · 2026-11-26 06:44 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7184740861) Linux follow-up: with a newer vkd3d-proton the structure builder now starts here. The game then hangs about 50 s into the world. **Tree:** this PR at `7af465b`, plus the watchdog switch from upstream #454, the layer's HLSL compiled with DXC, and one local change: pipelines whose shaders are on `VICTORY_SKIP_PIPELINES` are refused when they would be made (a draw-time skip alone still makes them). `VICTORY_SKIP_PIPELINES=e4a9f58e3acfcf7b` (the program from my earlier reports). Switches: `VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1`. RTX 5070 Ti, driver 620.73.04, GE-Proton11-14's Wine with a rebuilt wineserver (CachyOS/wine-cachyos#50). | vkd3d-proton | Result | |---|---| | GE-Proton11-14's (`cae8353ed`) | Still crashed in `d3d12core.dll` (+0x28c726, read 0x130) at frame 1464, making mesh and pixel pipelines (`36a9c81f635373e5`, `47848d52f85892d8`, `257fb752e6b64ce4` were the last translated). No "structure builder runs" line before that. | | master `71cae091b` (the project's CI package) | No crash. The log says `the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53`. | **The hang with master:** the last log line is `long frame 1315 at 51.7 s: 1834 ms`, then nothing for 3+ minutes. Meanwhile the process uses exactly one core at 100%, the GPU is at about 6%, and there is no Xid and no device loss. So one thread spins waiting for something while the card idles. I can't tell from outside what it waits on. It looks like the builder's first results never arrive, but that is a guess. A run with `VICTORY_HELPER_OWN=0` on GE's vkd3d-proton hung the same way (silent log, around frame 925), before any crash. So with vkd3d-proton master the builder's own pipelines all get made, which GE-Proton11-14's build never got to. I can't say the mesh/pixel crash is gone: this run hung at frame 1315, before the frame (1464) where the earlier run crashed. The next blocker is this spin after the builder starts. If there's a trace switch that would show what the spinning thread waits for, I can run it. *AI-assisted: Claude Code ran the builds and tests on my machine, read the logs and wrote this comment; posted at my request.*
Author
Owner

@⁠BradRoland on GitHub · 2026-11-25 22:21 UTC · original
On crates/victory-shader/src/emit/intersect.rs line 179 (outdated):

@@ -163,7 +176,7 @@ impl<'a> Lower<'a> {
                 // One look for the node's copy, before the branches: a
                 // node is 64 bytes on 64, so its first half lies in one
                 // 64 KiB page whatever its kind.
-                let (handle, byte) = self.bvh_memory(low, high, guard);
+                let (handle, byte) = self.bvh_memory(low, high, reads);

The first directory lookup is emitted before branching on built. Passing a false reads predicate sends the fault-buffer store to the sink at word 0. With USER_STRUCTURES=0 on 1ffff57, a synthetic WARP dispatch of 32 lanes targeting missing page 11 changed that word from 0xabcdef01 to 11. The page-request slot stayed zero and the box returned four misses. The extra UAV write is measurable independently of any effect on frame time.

I moved the directory lookup into the existing enabled block. The test keeps the entire fault buffer intact with traversal disabled, then enables traversal and checks that page 11 is requested. It passed on WARP and the RTX 4080. Correction and regression based on this head

For testing this alongside #1165, I also adapted the missing-page fix to this branch. All nine intersection tests passed on the combined tree, including disabled traversal, fully missing boxes and boxes split across pages. Gameplay remains unverified here. Combined branch

**@⁠BradRoland** on GitHub · 2026-11-25 22:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#discussion_r4701557365) On `crates/victory-shader/src/emit/intersect.rs` line 179 (outdated): ```diff @@ -163,7 +176,7 @@ impl<'a> Lower<'a> { // One look for the node's copy, before the branches: a // node is 64 bytes on 64, so its first half lies in one // 64 KiB page whatever its kind. - let (handle, byte) = self.bvh_memory(low, high, guard); + let (handle, byte) = self.bvh_memory(low, high, reads); ``` The first directory lookup is emitted before branching on `built`. Passing a false `reads` predicate sends the fault-buffer store to the sink at word 0. With `USER_STRUCTURES=0` on `1ffff57`, a synthetic WARP dispatch of 32 lanes targeting missing page 11 changed that word from `0xabcdef01` to `11`. The page-request slot stayed zero and the box returned four misses. The extra UAV write is measurable independently of any effect on frame time. I moved the directory lookup into the existing enabled block. The test keeps the entire fault buffer intact with traversal disabled, then enables traversal and checks that page 11 is requested. It passed on WARP and the RTX 4080. [Correction and regression based on this head](https://github.com/BradRoland/victory-fork/commit/55f00433ac5c4b8fbac19b0fdde12bc900865a8e) For testing this alongside #1165, I also adapted the missing-page fix to this branch. All nine intersection tests passed on the combined tree, including disabled traversal, fully missing boxes and boxes split across pages. Gameplay remains unverified here. [Combined branch](https://github.com/BradRoland/victory-fork/tree/codex/bvh-994-integration)
Author
Owner

@⁠BradRoland on GitHub · 2026-11-25 22:21 UTC · original · reviewed

I checked the builder-off path on the updated head and found one title-memory access that still runs on a disabled traversal. The returned no-hit values themselves were correct.

**@⁠BradRoland** on GitHub · 2026-11-25 22:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#pullrequestreview-6065797203) · **reviewed** I checked the builder-off path on the updated head and found one title-memory access that still runs on a disabled traversal. The returned no-hit values themselves were correct.
Author
Owner

@⁠drchef420 on GitHub · 2026-11-26 08:04 UTC · original

AI-assisted (Claude Code). Numbers and log lines only, no game data.

@⁠deadkid14 for the spin there's a switch already in this tree: VICTORY_STACKS=<seconds>[,<seconds>...] (crates/victory-loader/src/stacks.rs, started from apps/victory/src/run.rs). At each time listed, counted from the start, it suspends every thread in turn and prints its unwound stack as module+rva to stderr (not the tracing log), under VIctory: stacks of N threads. With your hang at about 52 s, VICTORY_STACKS=70,100,130 should catch the spinning thread three times; the frames that stay the same across the three dumps are what it waits in. It uses GetThreadContext and the same unwinder as the crash report, so I'd expect it to work under Wine, but we've only run it on Windows.

The log may already narrow it. The console CPU instructions, exceptions a second: ... line is printed only from the handler of an emulated console instruction (monitorx, mwaitx, clzero; console_insn.rs, line()), at most every 5 s. On Windows with the builder on, our 58-minute run shows a median of about 74,500 monitorx a second (631 such lines after the builder came up), so that line keeps coming even when frames take seconds. If it stops in your log along with everything else, no thread is in the title's monitorx/mwaitx wait during the hang. Then the core at 100% is a plain loop, the title's or ours, and the stacks will say which. If those lines do keep coming while frame lines stop, it is the title waiting on a value in memory that never arrives.

For comparison, on Windows (RTX 5070, this PR + main 988aa41) the builder's first frames were slow but they came: 0.7 fps, 1427.6 ms/frame at its start, frames of 950 to 1,450 ms for the next minute, then 450 to 650 ms. The longest gap between any two log lines in that run was 5.3 s.

**@⁠drchef420** on GitHub · 2026-11-26 08:04 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7186148254) *AI-assisted (Claude Code). Numbers and log lines only, no game data.* @⁠deadkid14 for the spin there's a switch already in this tree: `VICTORY_STACKS=<seconds>[,<seconds>...]` (`crates/victory-loader/src/stacks.rs`, started from `apps/victory/src/run.rs`). At each time listed, counted from the start, it suspends every thread in turn and prints its unwound stack as `module+rva` to **stderr** (not the tracing log), under `VIctory: stacks of N threads`. With your hang at about 52 s, `VICTORY_STACKS=70,100,130` should catch the spinning thread three times; the frames that stay the same across the three dumps are what it waits in. It uses `GetThreadContext` and the same unwinder as the crash report, so I'd expect it to work under Wine, but we've only run it on Windows. The log may already narrow it. The `console CPU instructions, exceptions a second: ...` line is printed only from the handler of an emulated console instruction (`monitorx`, `mwaitx`, `clzero`; `console_insn.rs`, `line()`), at most every 5 s. On Windows with the builder on, our 58-minute run shows a median of about 74,500 `monitorx` a second (631 such lines after the builder came up), so that line keeps coming even when frames take seconds. If it stops in your log along with everything else, no thread is in the title's `monitorx`/`mwaitx` wait during the hang. Then the core at 100% is a plain loop, the title's or ours, and the stacks will say which. If those lines do keep coming while frame lines stop, it is the title waiting on a value in memory that never arrives. For comparison, on Windows (RTX 5070, this PR + `main` `988aa41`) the builder's first frames were slow but they came: `0.7 fps, 1427.6 ms/frame` at its start, frames of 950 to 1,450 ms for the next minute, then 450 to 650 ms. The longest gap between any two log lines in that run was 5.3 s.
Author
Owner

@⁠HLVM04 on GitHub · 2026-11-26 08:06 UTC · original · edited 2026-11-26 08:25 UTC

An update to my 589 ms figure above, on the same RTX 5070 Ti (Series S profile, Windows 11). Our main stack now carries #993 and this PR at c9ca6b2, plus 55f0043 and 51700c6.

  • VICTORY_BVH_BUILDER=1: a steady 70–77 ms a frame in the window scene (about 13–14 fps), against the 589 ms I reported on the older base. There was no crash or device loss in 2 runs of 380 s, and interiors are much better lit. Free RAM went down to 0.5–0.8 GB of 31 GB during those runs.
  • One possible regression: with the builder on, the main character's skin draw (pixel shader b36c288fccc767b0) was missing from the G-buffer in 2 of 2 runs. It is also missing with the builder off while VICTORY_REMAP_LAND, VICTORY_HELPER_OWN and VICTORY_CARD_TITLE_COPIES are on (their defaults), and it is present with those three set to 0. That is one run per setting, and we haven't yet narrowed it to one switch or found the cause.
  • VICTORY_DISPATCH_THREADS=0 together with the builder crashed at 60 s.

Correction (2026-11-26): with the builder on, the skin draw was missing in both builder-on runs, including the one with VICTORY_REMAP_LAND, VICTORY_HELPER_OWN and VICTORY_CARD_TITLE_COPIES set to 0. The "present with those three set to 0" result above was with the builder off only.

AI-assisted (Claude Code).

**@⁠HLVM04** on GitHub · 2026-11-26 08:06 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7186195096) · edited 2026-11-26 08:25 UTC An update to my 589 ms figure above, on the same RTX 5070 Ti (Series S profile, Windows 11). Our main stack now carries #993 and this PR at `c9ca6b2`, plus `55f0043` and `51700c6`. - `VICTORY_BVH_BUILDER=1`: a steady 70–77 ms a frame in the window scene (about 13–14 fps), against the 589 ms I reported on the older base. There was no crash or device loss in 2 runs of 380 s, and interiors are much better lit. Free RAM went down to 0.5–0.8 GB of 31 GB during those runs. - One possible regression: with the builder on, the main character's skin draw (pixel shader `b36c288fccc767b0`) was missing from the G-buffer in 2 of 2 runs. It is also missing with the builder off while `VICTORY_REMAP_LAND`, `VICTORY_HELPER_OWN` and `VICTORY_CARD_TITLE_COPIES` are on (their defaults), and it is present with those three set to 0. That is one run per setting, and we haven't yet narrowed it to one switch or found the cause. - `VICTORY_DISPATCH_THREADS=0` together with the builder crashed at 60 s. **Correction (2026-11-26):** with the builder on, the skin draw was missing in both builder-on runs, including the one with `VICTORY_REMAP_LAND`, `VICTORY_HELPER_OWN` and `VICTORY_CARD_TITLE_COPIES` set to 0. The "present with those three set to 0" result above was with the builder off only. *AI-assisted (Claude Code).*
Author
Owner

@⁠drchef420 on GitHub · 2026-11-26 10:41 UTC · original

AI-assisted (Claude Code). Numbers and log lines only, no game data.

Follow-up to the boat and the black surfaces in my earlier comments here and on #1082. Neither one comes from this PR.

The boat was the water copy-back being off. I suggested the boat's engine might break because pages read zeros after the copy numbers ran out. That was wrong. I ran the same part of the game four ways on main + #994 + #1082 (da19199):

builder VICTORY_TEXTURE_BACK boat
on unset sinks at once, engine destroyed
off unset sinks at once, Cal falls off
off 1 floats, chase plays through to the camp (64 min run)
on (VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1) 1 floats, chase plays through to the camp (57 min run)

This is the known water bug (#863, #1034): the boat floats on wave heights the GPU writes, and without the copy-back the CPU reads nothing there. With the copy-back on, the builder doesn't change anything at the boat. The four water textures were copied back 646 times in the builder run. There was one a texture copied back could not be tiled e=Unsupported warning in each run; we saw no effect from it.

The black surfaces aren't from the builder either. Surfaces in shade (house walls, a wheelbarrow, parts of the dock, the building at the camp) come out flat black. They look the same with the builder on or off, so it's something else.

Still open: one indoor scene at the camp (the "Press X to fight" prompt) came out washed white with smeared streaks. That was with the builder on; I don't have the same moment with it off yet, so I can't say whether the builder is involved.

Cost of the builder in the same place: with it, frames took about 340–770 ms; without it, about 290–450 ms (RTX 5070, 32 GB PC). #1082's reclaim kept the run going after the copy numbers ran out at +28 min (7 give-backs, no crash).

**@⁠drchef420** on GitHub · 2026-11-26 10:41 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7189697859) *AI-assisted (Claude Code). Numbers and log lines only, no game data.* Follow-up to the boat and the black surfaces in my earlier comments here and on #1082. Neither one comes from this PR. **The boat was the water copy-back being off.** I suggested the boat's engine might break because pages read zeros after the copy numbers ran out. That was wrong. I ran the same part of the game four ways on main + #994 + #1082 (da19199): | builder | `VICTORY_TEXTURE_BACK` | boat | |---|---|---| | on | unset | sinks at once, engine destroyed | | off | unset | sinks at once, Cal falls off | | off | `1` | floats, chase plays through to the camp (64 min run) | | on (`VICTORY_BVH_BUILDER=1 VICTORY_FIRSTLANE_OWN=1`) | `1` | floats, chase plays through to the camp (57 min run) | This is the known water bug (#863, #1034): the boat floats on wave heights the GPU writes, and without the copy-back the CPU reads nothing there. With the copy-back on, the builder doesn't change anything at the boat. The four water textures were copied back 646 times in the builder run. There was one `a texture copied back could not be tiled e=Unsupported` warning in each run; we saw no effect from it. **The black surfaces aren't from the builder either.** Surfaces in shade (house walls, a wheelbarrow, parts of the dock, the building at the camp) come out flat black. They look the same with the builder on or off, so it's something else. **Still open:** one indoor scene at the camp (the "Press X to fight" prompt) came out washed white with smeared streaks. That was with the builder on; I don't have the same moment with it off yet, so I can't say whether the builder is involved. **Cost of the builder in the same place:** with it, frames took about 340–770 ms; without it, about 290–450 ms (RTX 5070, 32 GB PC). #1082's reclaim kept the run going after the copy numbers ran out at +28 min (7 give-backs, no crash).
Author
Owner

@⁠HyperEndgame on GitHub · 2026-11-26 17:18 UTC · original

With the builder on (VICTORY_BVH_BUILDER=1), no trace program ever reaches a node test on our card. The cause is the user-data view-address path. The 3-line fix below makes the walk run.

Setup

  • GPU: RTX 4070 SUPER 12 GB (32-lane waves). CPU: Ryzen 7 7700X. RAM: 32 GB. OS: Windows 11.
  • Base: main 085ee7c + #854 + #993 + this PR + #213 + #1147 + #1084. Diag build.
  • Switches: README run-253 set, plus VICTORY_BVH_BUILDER=1 VICTORY_RAY_PROBE=1. Scripted input, 7–9 min runs.

What we saw

  • #1084's probe stayed at 0 in every run. We added diag counters to it:
    • wave entries at program start: 9k–32k waves a frame across the 13 walkers, all Memory nodes;
    • lanes arriving at a walk site: 0;
    • lanes on this PR's "not built" path: 0.
  • So the walkers run, but every lane leaves before image_bvh.
  • The static read of the largest walker: the only gate before the walk is the root dword at structure base + 0x30. Root <= 0 pops an empty stack, exec goes empty, and the walk is never issued.
  • The base comes from a structure SRV in a descriptor table (slot 1, dword 8). Every run logs, once: a shader takes the address of a buffer view that is not there: it reads 0 slot=1 dword=8.
  • BVH_CHECK shows the builder does produce structures: hundreds a frame, tens of thousands of box nodes, about 3–6% bad nodes. So the walkers were reading base 0, not an unbuilt structure.

Cause
host_word, USER_VIEW_ADDRESS path (draw.rs), decodes the table entry with buffer_range only. A View::Shader with dimension RAYTRACING_ACCELERATION_STRUCTURE gives None, so the result is 0. The heap-index path (SLOT_VIEW_ADDRESSES) already goes through view_address, which handles structure views.

Fix

-            Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4)
-                .and_then(|view| crate::descriptor::host::buffer_range(&view))
-                .map_or(0, |range| range.0),
+            Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4)
+                .map_or(0, |view| crate::descriptor::host::view_address(&view)),

After the fix (same switches)

  • The warning is gone.
  • Probe: up to 14.3M node tests a frame; about 50% box hits; 5k–170k triangle hits; missing 0–9k.
  • Visual, opening cutscene: room walls lit and sun shadows on the character. With the builder off, the room is black and the character is flat-lit. Not the exact same moment.
  • No crash in two runs (7 and 9 min).
  • Cost: 0.1–0.6 fps (1.6–7 s a frame, about 95% GPU), against 2.5–3.4 fps with the builder on before the fix. The walk is now the frame cost.

Not tested

  • This PR alone, without the other PRs above.
  • Correctness of individual shadows against the console.
  • 64-lane GPUs.
**@⁠HyperEndgame** on GitHub · 2026-11-26 17:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7198811035) With the builder on (`VICTORY_BVH_BUILDER=1`), no trace program ever reaches a node test on our card. The cause is the user-data view-address path. The 3-line fix below makes the walk run. **Setup** - GPU: RTX 4070 SUPER 12 GB (32-lane waves). CPU: Ryzen 7 7700X. RAM: 32 GB. OS: Windows 11. - Base: main `085ee7c` + #854 + #993 + this PR + #213 + #1147 + #1084. Diag build. - Switches: README run-253 set, plus `VICTORY_BVH_BUILDER=1 VICTORY_RAY_PROBE=1`. Scripted input, 7–9 min runs. **What we saw** - #1084's probe stayed at 0 in every run. We added diag counters to it: - wave entries at program start: 9k–32k waves a frame across the 13 walkers, all `Memory` nodes; - lanes arriving at a walk site: 0; - lanes on this PR's "not built" path: 0. - So the walkers run, but every lane leaves before `image_bvh`. - The static read of the largest walker: the only gate before the walk is the root dword at structure base + 0x30. Root <= 0 pops an empty stack, exec goes empty, and the walk is never issued. - The base comes from a structure SRV in a descriptor table (slot 1, dword 8). Every run logs, once: `a shader takes the address of a buffer view that is not there: it reads 0 slot=1 dword=8`. - `BVH_CHECK` shows the builder does produce structures: hundreds a frame, tens of thousands of box nodes, about 3–6% bad nodes. So the walkers were reading base 0, not an unbuilt structure. **Cause** `host_word`, `USER_VIEW_ADDRESS` path (draw.rs), decodes the table entry with `buffer_range` only. A `View::Shader` with dimension `RAYTRACING_ACCELERATION_STRUCTURE` gives `None`, so the result is 0. The heap-index path (`SLOT_VIEW_ADDRESSES`) already goes through `view_address`, which handles structure views. **Fix** ```diff - Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4) - .and_then(|view| crate::descriptor::host::buffer_range(&view)) - .map_or(0, |range| range.0), + Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4) + .map_or(0, |view| crate::descriptor::host::view_address(&view)), ``` **After the fix (same switches)** - The warning is gone. - Probe: up to 14.3M node tests a frame; about 50% box hits; 5k–170k triangle hits; `missing` 0–9k. - Visual, opening cutscene: room walls lit and sun shadows on the character. With the builder off, the room is black and the character is flat-lit. Not the exact same moment. - No crash in two runs (7 and 9 min). - Cost: 0.1–0.6 fps (1.6–7 s a frame, about 95% GPU), against 2.5–3.4 fps with the builder on before the fix. The walk is now the frame cost. **Not tested** - This PR alone, without the other PRs above. - Correctness of individual shadows against the console. - 64-lane GPUs.
Author
Owner

@⁠HyperEndgame on GitHub · 2026-11-26 17:55 UTC · original

Correction to the cost numbers above: the 0.1–0.6 fps was measured with VICTORY_RAY_PROBE=1. The probe's per-node atomics, all to the same few dwords, were nearly all of it.

With the probe off, same build and switches (VICTORY_CARD_METER_PIPELINES=1, one 8-min run):

  • 2.4–3.0 fps (333–425 ms a frame), with the walk running and the room lit.
  • Card time per binding of the largest walkers: 11.4 ms, 4.9 ms, 3.2 ms, 1.9 ms, 1.3 ms (it was 181 ms for the largest with the probe on).
  • With VICTORY_SHADER_LOOP_LIMIT=trace:128 the frame rate stays the same, and VICTORY_LOOP_NOTES=1 shows only 3–13 lanes reaching the limit. So there is no long tail of runaway walks.
**@⁠HyperEndgame** on GitHub · 2026-11-26 17:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7199842506) Correction to the cost numbers above: the 0.1–0.6 fps was measured with `VICTORY_RAY_PROBE=1`. The probe's per-node atomics, all to the same few dwords, were nearly all of it. With the probe off, same build and switches (`VICTORY_CARD_METER_PIPELINES=1`, one 8-min run): - 2.4–3.0 fps (333–425 ms a frame), with the walk running and the room lit. - Card time per binding of the largest walkers: 11.4 ms, 4.9 ms, 3.2 ms, 1.9 ms, 1.3 ms (it was 181 ms for the largest with the probe on). - With `VICTORY_SHADER_LOOP_LIMIT=trace:128` the frame rate stays the same, and `VICTORY_LOOP_NOTES=1` shows only 3–13 lanes reaching the limit. So there is no long tail of runaway walks.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 18:09 UTC · original

An RTX 3090 Ti data point (32-lane, 24 GB; 62 GB RAM, Windows 11), this PR at 7af465b with only #911's cap (1087538) on top. Diagnostics build, release profile, a new start through the opening into the prologue cell, 6-minute runs, one per row.

As published, Series X profile (VICTORY_FIRSTLANE_OWN=1, otherwise defaults):

builder off VICTORY_BVH_BUILDER=1
frame once settled in the cell about 285 ms about 345 ms
process working set, peak / settled 39.0 / 31.6 GB 40.8 / 35-36 GB
title exceptions, device removals 0, 0 0, 0

The builder came up with all 53 pipelines and ran 4 min 38 s to the run's limit. On main before the thread-count fix, every builder run of mine ended within seconds.

With the README's speed switches (INDIRECT_WINDOW JOIN_PARTS BACK_OWN_VIEW INDIRECT_GATHER CARD_REHASH_RUNS LEVELS_ON_DEMAND ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT COPY_PLAIN, MERGE_GAP=64 MERGE_RUNS=4096 STAGING_POOL=0, CARD_BUFFERS_MIN_KB=64 CARD_BUFFERS_MB=1280), Series X: about 152 ms with the builder off and about 280 ms with it on, again with no exception and no removal. So here the builder costs about 60 ms a frame at the defaults and about 130 ms with the speed set.

Picture with the builder off (the no-hit node tests), same shot of the cell from behind, against main e4245f3 with #798 (Series S profile) on the same card; the Series S tree below shows the same three things as Series X:

  • the character's hair has its dark colour; on main it comes out pale blond;
  • the window's dirty glass and haze are drawn; on main the pane is clear;
  • the wall beside the bunk is dark and even; on main it is lit in bands.

With the builder on, the top of the head and the shoulders are darker, with a rim of light from the window. I have not compared either against the console.

Series S needs #798 on this base to show the world, so those runs are of a tree of mine (this PR + #911 + #798 + #1081 + our speed commits): about 81 ms a frame in the same shot, hair and window as above. One difference from Series X on the same build: the print on the back of the character's shirt is missing on Series S in 4 of 4 runs and there in 2 of 2 on Series X. VICTORY_REMAP_LAND=0 VICTORY_HELPER_OWN=0 VICTORY_CARD_TITLE_COPIES=0 (HLVM04's three, above) did not bring it back in one run. I do not know yet whether that comes from this PR.

Memory, for others with background apps open: the working set's peak comes at world entry with or without the builder (39 GB against 40.8 GB); the builder adds about 4 GB once settled.

AI-assisted (Claude Code, Claude Fable 5.2). Numbers and descriptions only, no game data.

**@⁠KyleS98** on GitHub · 2026-11-26 18:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7200128717) An RTX 3090 Ti data point (32-lane, 24 GB; 62 GB RAM, Windows 11), this PR at `7af465b` with only #911's cap (`1087538`) on top. Diagnostics build, release profile, a new start through the opening into the prologue cell, 6-minute runs, one per row. **As published, Series X profile** (`VICTORY_FIRSTLANE_OWN=1`, otherwise defaults): | | builder off | `VICTORY_BVH_BUILDER=1` | |---|---|---| | frame once settled in the cell | about 285 ms | about 345 ms | | process working set, peak / settled | 39.0 / 31.6 GB | 40.8 / 35-36 GB | | title exceptions, device removals | 0, 0 | 0, 0 | The builder came up with all 53 pipelines and ran 4 min 38 s to the run's limit. On `main` before the thread-count fix, every builder run of mine ended within seconds. **With the README's speed switches** (`INDIRECT_WINDOW JOIN_PARTS BACK_OWN_VIEW INDIRECT_GATHER CARD_REHASH_RUNS LEVELS_ON_DEMAND ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT COPY_PLAIN`, `MERGE_GAP=64 MERGE_RUNS=4096 STAGING_POOL=0`, `CARD_BUFFERS_MIN_KB=64 CARD_BUFFERS_MB=1280`), Series X: about 152 ms with the builder off and about 280 ms with it on, again with no exception and no removal. So here the builder costs about 60 ms a frame at the defaults and about 130 ms with the speed set. **Picture with the builder off** (the no-hit node tests), same shot of the cell from behind, against `main` `e4245f3` with #798 (Series S profile) on the same card; the Series S tree below shows the same three things as Series X: - the character's hair has its dark colour; on `main` it comes out pale blond; - the window's dirty glass and haze are drawn; on `main` the pane is clear; - the wall beside the bunk is dark and even; on `main` it is lit in bands. With the builder on, the top of the head and the shoulders are darker, with a rim of light from the window. I have not compared either against the console. **Series S** needs #798 on this base to show the world, so those runs are of a tree of mine (this PR + #911 + #798 + #1081 + our speed commits): about 81 ms a frame in the same shot, hair and window as above. One difference from Series X on the same build: the print on the back of the character's shirt is missing on Series S in 4 of 4 runs and there in 2 of 2 on Series X. `VICTORY_REMAP_LAND=0 VICTORY_HELPER_OWN=0 VICTORY_CARD_TITLE_COPIES=0` (HLVM04's three, above) did not bring it back in one run. I do not know yet whether that comes from this PR. Memory, for others with background apps open: the working set's peak comes at world entry with or without the builder (39 GB against 40.8 GB); the builder adds about 4 GB once settled. AI-assisted (Claude Code, Claude Fable 5.2). Numbers and descriptions only, no game data.
Author
Owner

@⁠Swagi-REDACTED on GitHub · 2026-11-26 20:09 UTC · original

Local integration test of #994 at 72e50a10aaa32adfa4e8d8f948c1ecdd037f6f59 in my fork (includes #1002, the small #1112 translator fixes, #1205 and live input). This is an integration result, not an isolated comparison of this PR.

Hardware: Ryzen 7 9800X3D, 16 GB system RAM, RTX 3060 12 GB, NVIDIA 621.14, Windows 11. A newer retail game remained on an HDD; cache/profile were on SSD. Series X profile, builder enabled, D3D12 debug layer and input/BVH tracing enabled; no ambient substitute, shader skips, quarantine or dry builder mode.

Runtime, 2026-11-26 19:40–20:05 UTC:

  • All 53 builder host pipelines became ready. The private trace recorded actual builder dispatches over hundreds of frames and GPU writebacks; this went beyond pipeline creation.
  • The opening rendered, but lighting, geometry and texture defects remained substantial. Observed frame rates varied approximately 0.5–7 FPS during world rendering/loading; scenes and diagnostics differed, so this is not a controlled performance comparison.
  • Peak sampled process private commit was 27,022 MB; minimum free system commit 359 MB, minimum available physical RAM 136 MB. This 16 GB host was heavily memory constrained.
  • Debug-layer warnings included id 538: a buffer in COPY_DEST was bound as a compute root SRV. No device-removal failure was observed in this run. I ended it intentionally with a normal window close, process exit 0.
  • Live menu input advanced into loading, and the corrected pause input was actually read, but interactive movement, a checkpoint and completion of the prologue were not verified.

Validation of the tested integration: cargo test --locked --workspace -- --test-threads=4 --nocapture: 690 passed, 0 failed, 12 ignored, with 10 explicit skipped/not-run cases (two queue2 adapter checks, two unset local builder DLL tests, four compiler checks and two WARP limitations). Separate local builder-DLL tests: 4 passed, 0 failed, 0 ignored. Diagnostics build passed. Offline builder validation/pipeline creation: 52/52 on NVIDIA; runtime then reported 53 ready pipelines. A previous parallel GPU test attempt crashed in d3d10warp.dll; serial and repeated parallel GPU tests and the final workspace run passed, but that crash has no proven root cause.

AI use: Codex, GPT-6 (exact serving variant not exposed), integrated the existing changes, ran the tests and local runtime checks, and wrote this report. No game data or raw traces are attached.

**@⁠Swagi-REDACTED** on GitHub · 2026-11-26 20:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/994#issuecomment-7202369216) Local integration test of #994 at `72e50a10aaa32adfa4e8d8f948c1ecdd037f6f59` in my fork (includes #1002, the small #1112 translator fixes, #1205 and live input). This is an integration result, not an isolated comparison of this PR. Hardware: Ryzen 7 9800X3D, 16 GB system RAM, RTX 3060 12 GB, NVIDIA 621.14, Windows 11. **A newer retail game** remained on an HDD; cache/profile were on SSD. Series X profile, builder enabled, D3D12 debug layer and input/BVH tracing enabled; no ambient substitute, shader skips, quarantine or dry builder mode. Runtime, 2026-11-26 19:40–20:05 UTC: - All 53 builder host pipelines became ready. The private trace recorded actual builder dispatches over hundreds of frames and GPU writebacks; this went beyond pipeline creation. - The opening rendered, but lighting, geometry and texture defects remained substantial. Observed frame rates varied approximately 0.5–7 FPS during world rendering/loading; scenes and diagnostics differed, so this is not a controlled performance comparison. - Peak sampled process private commit was 27,022 MB; minimum free system commit 359 MB, minimum available physical RAM 136 MB. This 16 GB host was heavily memory constrained. - Debug-layer warnings included id 538: a buffer in COPY_DEST was bound as a compute root SRV. No device-removal failure was observed in this run. I ended it intentionally with a normal window close, process exit 0. - Live menu input advanced into loading, and the corrected pause input was actually read, but interactive movement, a checkpoint and completion of the prologue were not verified. Validation of the tested integration: `cargo test --locked --workspace -- --test-threads=4 --nocapture`: 690 passed, 0 failed, 12 ignored, with 10 explicit skipped/not-run cases (two queue2 adapter checks, two unset local builder DLL tests, four compiler checks and two WARP limitations). Separate local builder-DLL tests: 4 passed, 0 failed, 0 ignored. Diagnostics build passed. Offline builder validation/pipeline creation: 52/52 on NVIDIA; runtime then reported 53 ready pipelines. A previous parallel GPU test attempt crashed in d3d10warp.dll; serial and repeated parallel GPU tests and the final workspace run passed, but that crash has no proven root cause. AI use: Codex, GPT-6 (exact serving variant not exposed), integrated the existing changes, ran the tests and local runtime checks, and wrote this report. No game data or raw traces are attached.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/fpsbox.rs
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.rs
  • crates/victory-gpu/src/list.rs
  • crates/victory-gpu/src/memory.rs
  • crates/victory-gpu/src/pipeline.rs
  • crates/victory-gpu/src/pipeline/library.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-shader/src/emit/intersect.rs
  • crates/victory-shader/src/emit/lower.rs
  • crates/victory-shader/src/emit/mod.rs
  • crates/victory-shader/src/emit/shader.rs
  • crates/victory-shader/src/emit/wave64_tests.rs
  • crates/victory-shader/src/ir.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/994/head:github-bot/gh-994'
git switch 'github-bot/gh-994'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-994'
git switch 'github-bot/gh-994'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-994'
git switch 'github-bot/gh-994'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-994'
git switch 'main'
git merge --squash 'github-bot/gh-994'
git switch 'main'
git merge --ff-only 'github-bot/gh-994'
git switch 'main'
git merge 'github-bot/gh-994'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.