Skip to content

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
PiloteCode wants to merge 61 commits into
fxceless:mainfrom
PiloteCode:pr/ray-tracing

Conversation

@PiloteCode

@PiloteCode PiloteCode commented Nov 25, 2026 •

Copy link
Copy Markdown

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 Shaders, second round: geometry programs as geometry shaders, loops as the console runs them, lighter wave64 forms, dispatches past 65,535 groups in x (stacked on #854) #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:

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

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.

…s-only count

`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.
…rams over 32 KiB linked with their pixel program, and more: 230 more programs pass

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.
…, mesh programs linked with their pixel program (VICTORY_MESH_LINK)

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.
…them

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.
…024,...)

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).
…s limit (VICTORY_LOOP_NOTES=1)

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.
…limit

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.
…t by ending the lane

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.
…ery stage

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).
…remote-desktop reset

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).
…5,535 groups in x is named

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.
…s count their groups from a base the host gives

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).
…a 32-lane host

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.
…re only lanes inside the guard read it

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.
…n as two host waves of their own, not meeting at group barriers

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).
…ps only its system values

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.
… that allocate, dispatches past 65,535 groups

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.
… indirect records, frame capture, card-memory windows, texture copy-back and wide loads; conflicts in draw.rs, host.rs and lib.rs

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.
…rt, an if joined to its let, counts tested with is_multiple_of)

`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c 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.
…ate sessions, frame capture, texture copy-back and wide loads; no conflict

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.
…rt, an if joined to its let, counts tested with is_multiple_of)

`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c 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.
…thered indirect records, frame capture, card-memory windows, texture copy-back and wide loads; no conflict

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.
…rt, an if joined to its let, counts tested with is_multiple_of)

`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c 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.
@Yorivel

Yorivel commented Nov 25, 2026

Copy link
Copy Markdown

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 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.

@PiloteCode

Copy link
Copy Markdown
Author

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 Shaders, second round: geometry programs as geometry shaders, loops as the console runs them, lighter wave64 forms, dispatches past 65,535 groups in x (stacked on #854) #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 Shaders: wave64 programs in a paired form on 32-lane GPUs, mesh programs over 32 KiB linked with their pixel program, and more (230 more programs pass) #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.

@BradRoland BradRoland left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

// 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

triippywhale pushed a commit to triippywhale/victory-fork that referenced this pull request Nov 25, 2026
…records are named (builder only)

From fxceless's ray-tracing branch (fxceless#994: 2d95091, 273fc65), by hand onto
the fork's marks design. With VICTORY_BVH_BUILDER set, list upload memory
comes from chunks shaders reach by address (9afd8c2, the commit before),
each chunk is given its copy, and the 8-byte title addresses in the block a
dispatch's root SRVs point into (16 KiB at most, up to what the list handed
out) are named before the dispatch: the builder's leaf rehydration takes
index and vertex buffers out of 48-byte records there, and the ones in no
copy read zeros (leaves without triangles; the builder-on run at 75a4fe7
had no walls). Without the builder asked for nothing is carved or scanned.

The low dword of a constant pair is no longer also named in 256-byte
units: most windows named that way were such low dwords.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017V7WBCi8h4eymnRhdth77t
…e card takes

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 fxceless#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.
@PiloteCode

Copy link
Copy Markdown
Author

@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

Copy link
Copy Markdown
Author

@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:

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

Copy link
Copy Markdown
Author

@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.

fxceless added a commit that referenced this pull request Nov 26, 2026
…=1, off by default); VICTORY_WAVE_WIDE=last (fork PR #1141)

The structure builder does not run unless asked for, and the title's ray-traced passes run all the same: every node test then reads whatever bytes lie where a structure would be, in a walk bounded at 65,535 steps a wave. With VICTORY_BVH_NO_HIT=1 (and not VICTORY_BVH_BUILDER=1) a box node enters no child and any other node is missed: every ray leaves at its first test, the answer is the same in every run, and the program asks the host for neither the directory of title memory nor the list of missing pages (unit test). The idea is fork PR #994's, done here at translation instead of by a host word. Also fork PR #1141 as it is (VICTORY_WAVE_WIDE=last: the barrier form only for programs every other form leaves at 64 lanes; opt-in), and the comment on the wide loads corrected (not the same result on the card: run 277). A TRANSLATOR EDIT: an exe from here on has a new shader fingerprint; wipe the DXIL cache and the pipeline library before its first launch. Not run in a game.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@deadkid14

Copy link
Copy Markdown

@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.

@drchef420

Copy link
Copy Markdown

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.

@deadkid14

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.