Looking for the light passes by the places their tables bind is now opt-in (VICTORY_AMBIENT_SHAPE=1). Checked against a title profile's names, the rule gave the radiance and air parts to programs the profile does not name in every one of 48 checks and found none of the named ones, so without a profile the stand-in stays off rather than run on the wrong passes. The reflections' 10 s line now says how many miss dispatches read the depth kept and why the others did not: kept at another size (with the two sizes), kept too long ago, or the kept depth switched off. A run at full scene size showed it read by all but the first, which rules it out as the cause of the faults seen there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 KiB
Ray tracing in this fork: how console titles trace rays and what has been built
Status, 2026-11-25, midday: with VICTORY_BVH_BUILDER=1 rooms get their
indirect light (three runs), for some 40 ms more of the
card's time a frame (an interior scene: 75 of 90 ms busy against 34 of 64). Off by
default. VICTORY_AMBIENT=1 puts an estimate of that light in its place
for next to nothing (below).
How a console title can trace rays
A title can ray trace its indirect light (probes, bounce, reflections) and the shadows of its lights. Without them, anything a light does not hit directly is black.
Such a title need not use a ray-tracing API:
- Traversal can be ordinary compute-shader code: a per-thread stack in shared memory, and loads through raw 40-bit addresses of title memory.
- Acceleration structures can come pre-built in the program's data, in the console GPU's native node format (64-byte nodes: box nodes with four children and 16-bit float bounds, 128-byte box nodes with 32-bit float bounds, triangle nodes, instance nodes), unpacked on the GPU.
- Builder programs (the console's structure-builder library, shipped with a title as compute programs) build and refit dynamic structures on the GPU every frame.
- Only the per-node test is hardware: the instructions
image_bvh64_intersect_rayandimage_bvh_intersect_ray. One call tests a ray against a box node's four children (returning the hit children, nearest first) or against a triangle node (returning the intersection's numerator, denominator and barycentric numerators).
So mapping this onto the host's own ray tracing (DXR) is not practical: the layer would have to know the geometry behind structures the program never describes to it, and the traversal loops live in the program's own programs. This fork runs the builder and traversal as translated shaders and emulates the one instruction.
What this fork adds
- The builder programs translate (all 52, with host pipelines on the RX 7900 XTX; the program creates 53 such pipelines). They pass buffer addresses in a spilled parameter table rather than in descriptors. Added: the spilled user-data table, root unordered-access views (translator and host binding), byte and 16-bit buffer accesses, and several control-flow shapes.
- Title memory by raw address from shaders. A directory with one entry per 64 KiB of title address space leads a shader to the layer's host copy of that memory; loads, stores, atomic add/sub and float min/max go through it. Before a dispatch the host makes ready the memory its root views and root constants name.
- The ray test, emulated in DXIL. Four slab tests and a sorting network
for box nodes; a watertight ray/triangle test for triangle nodes; both forms
of the instruction. A plain Rust reference lives in
crates/victory-shader/src/bvh.rs; tests run the emitted DXIL on the GPU over 311 ray/node cases and compare with the reference bit for bit. - The trace and shading programs translate (59 of 64 trace programs then, the other five since, see "Known gaps", and the irradiance-cache shading program). This needed lane masks treated as plain numbers on some paths, and exact forms for programs written for 64-lane waves running on a GPU with 32-lane waves.
- A safety rule on the host side. The builder's stages run only while
every builder pipeline the program has created has a host pipeline; otherwise
none run (
VICTORY_BVH_BUILDER=1asks for it;VICTORY_BVH_QUARANTINE=1also keeps the builder's stores out of title memory, for a first test). A partly working builder wrote garbage bounds into title memory and crashed the program.
The structures (from saved copies of the arenas, VICTORY_MEMORY_DUMP)
- Header, 64 bytes: dword 0 the version 6 in the low half and marks in the high (0x8000 bottom level, 0x4 compacted, 0x2 rehydrated, 0x100 still packed), dword 1 the size in 64-byte nodes, 3 the number of elements, 4-9 the bounds, 10 the offset of the box nodes, 12 the root's node pointer, 13 the offset of the elements, 14 the offset of the parent table (from the header; the static ones' index counts the leaves too, so it is negative).
- An instance is 128 bytes at the top level's offset 13: a 3x4 matrix in dwords 0-11, id and mask, flags, the root pointer (bit 30 set for static ones), the bottom level's address in 256-byte units.
- The static world's structures are shipped packed ("dehydrated") and unpacked in place, once, by the builder's unpacking programs (header, box nodes of both widths, leaves) when they have been streamed in (3,000 in the first scene).
- Dynamic ones are built, their compacted size read back by the program from a small buffer, and copied to a place of that size.
How title memory by address is held (memory.rs)
Pages of 64 KiB in arenas on the card, whole title buffers in their own copies, pages with small title buffers as windows of title memory. The module's comment has the rules. In short: what the builder stores stays on the card (only small title buffers it was given to write come back); a packed structure goes up whole when the builder comes to it; title buffers take its stores only after it was given them as an unordered access view.
| variable | does |
|---|---|
VICTORY_BVH_BUILDER=1 |
the builder's stages run |
VICTORY_BVH_FENCES=0 |
no fences around the builder's buffer atomics (beloooo's 72e748ea has them too) |
VICTORY_BVH_SIZES_WAIT=1 |
submissions that ask for structures' sizes are waited for (off: no help, slow) |
VICTORY_BVH_BOUNDS=0 |
the builder's accesses are not bounded |
VICTORY_BVH_TRACE=1 |
logs what sizes are asked, when they came, and the copies (diagnostics) |
VICTORY_BVH_QUARANTINE=1 |
nothing it stores comes back to title memory |
VICTORY_MEMORY_CARD_MB |
the most of it on the card (4096) |
VICTORY_MEMORY_DUMP=<folder> |
a file go there writes the arenas out (diagnostics) |
VICTORY_UPLOAD_LOW=0, VICTORY_LENT_HEAP=0 |
lists' upload memory above 2^40, no view heap for lists without one, as before |
Every ten seconds the log has a line "title memory by address: ..." with pages, dispatches, faults and what came.
Known gaps
- Dynamic structures overlap each other (8 of 65 good in one run, 48 of
275 in another). Part of the cause, one run's trace (
VICTORY_BVH_TRACE=1): the program asks for a new structure's compacted size, reads it one or two frames later without looking whether it is there, takes memory of that size and has the structure copied into it. Our submissions land up to two frames late; the program read what the slot held before, another structure's size, and the copy wrote over the neighbours. Waiting for a submission that asks (VICTORY_BVH_SIZES_WAIT=1) did not mend it and costs some 20 ms a frame: the program asks in every frame, and what it read was as old as before. Open. - What a structure that was written over says of its size sent the builder's
copy of it through gigabytes of other structures; bounded now
(
VICTORY_BVH_BOUNDS). Pages touched that are not there: 2,500 a frame before, 90 after (an interior scene). - The card's time in that scene with the builder (one timing run, the program's commands 84 ms): the builder's copy for updates 13.3 ms in 63 dispatches (before the bound), traces 24 ms (the visibility-buffer trace 7.9, screen probes 6.4, irradiance cache 3.5, primary probes 2.3, shadows 1.6).
- Captures made on 2026-11-25 (builder on or off) hang the card in a replay (cause unknown; do not try).
- Five shadow-mask trace programs take a structure's address out of a
descriptor picked from the heap by a computed index. They translate while the
structure builder is on: the host gives a table of view addresses by slot,
16 MiB more of the PC's memory shared with the card per view heap
(
VICTORY_HEAP_VIEW_ADDRESSES=0: no table, those programs refused).- While the builder is off they are refused, as before: dispatched, they would walk structures nothing built or unpacked.
- The table is written when the host sees a slot written. A view the title copies into its heap as bytes reaches it up to 4 frames later, as it reaches the stride table and the host's descriptor.
- Bytes that put a slot back to what the heap sync last saw in it (a view made by a call and zeroed before a round saw it) go unseen by the sync. The buffer pass finds the slot: at its next run, or within 16 runs if it has looked at the slot since the view came (from the code, not tested).
- Nothing readies memory named only by an address picked from the heap. A page without a copy reads zero and is there from the next frame (pages come that way at most 2,048 times a run); a page outside title buffers that no dispatch names is taken from title memory again only by the sweep, up to 128 frames later.
- An access to a page that is not there is lost (a read gives zero, a store is dropped).
- Not publicly documented, and assumed: the instruction's rounding, the order of two boxes entered at the same distance, and the result for a ray exactly through an edge.
While no structures are built
- Hit resolves left out. The programs that resolve ray hits find nothing to resolve, so they are left out of
play: the title profile's
rt_resolveprograms, or, without a profile, the compute programs whose code tests structure nodes (one line counts them;VICTORY_RT_WALKS=1runs them). - Shadow rays. The title profile's
shadow_raysprograms answer "occluded" while no structures are built.VICTORY_SHADOW_RAYS_LIT=1tests them as other rays are (a translation change); one line a run names the programs. - Hardware ray tracing (
VICTORY_HW_RT=1, off) builds the card's own structures; it needs DXR tier 1.1 and shader model 6.5.VICTORY_HW_RT_LIFT=shadowslifts the walks of the profile'sshadow_raysprograms to ray queries. It follows the host's decision: on a card without the tier, or with the route off, those programs keep the software walk. Without a title profile there is nothing to lift.VICTORY_HW_RT_LIFT=reportandVICTORY_HW_RT_CENSUS=1only count.
Without rays: the stand-in (crates/victory-gpu/src/ambient.rs)
Without structures every ray misses. The program's program that resolves the
diffuse light of its screen probes (its temporal resolve, list
184 of a frame) then leaves the sky's light outdoors, nothing indoors, and in
blocks of tiles what the probes' memory held. VICTORY_AMBIENT=<share> raises
it to an estimate right after that program: the program keeps, for its own screen
traces, the light visible surfaces send out (its radiance cache,
1280x720, the frame before); its mean in 64x36 cells is gathered at 160x90
points, each cell weighted by the share of the surroundings it covers, as a
directional value; each pixel takes it between the points by depth, with its
normal and a shade in creases. So level and tint follow the hour, the room and
its lamps. What the program left counts up to four times the estimate.
Where it can be put, and the crease shade, are beloooo's (VIctory-Belobug-AMD
06031237, 4f45ab88, cd9f78ce); VICTORY_AMBIENT=constant:<level> is that
fork's constant.
| variable | does |
|---|---|
VICTORY_AMBIENT=<share> |
the estimate, 1 all of it (unset: the program's own) |
VICTORY_AMBIENT=constant:<level> |
the same light everywhere |
VICTORY_AMBIENT_SHADE=<strength>,<metres> |
the creases (1,0.6) |
VICTORY_AMBIENT_AIR=<multiple> |
what the air scatters is bounded by a multiple of the light around (off: a brown veil can stay in lit interiors) |
VICTORY_AMBIENT_FLOOR=<level> |
a floor under the estimate in close views; the view's distance is measured from the scene's depth in the resolve pass (off) |
VICTORY_AMBIENT_FILTER=1|2 |
probe light of the colours the program's leftovers have is dropped: 1 (the default) magenta and deep blue, 2 also neon green |
VICTORY_AMBIENT_SHAPE=1 |
without a title profile, the passes are looked for by shape (off by default: the rule found other programs than the profile names) |
It is off while the builder runs.
Which programs are the resolve, the radiance cache and the air pass: the title profile's names. Without a profile they are found by the places their tables bind; the radiance and air passes are followed only while one program alone has their shape. With a profile, the first matches are compared with its names in the log, so the rule can be checked. A warning says when "Dark areas" is on and nothing was found after about 1,800 frames.
Where to look
crates/victory-shader/src/bvh.rs: the reference for the node test.crates/victory-shader/src/emit/lower.rs: the lowering of the two instructions and of memory by address (Lower::memory).crates/victory-shader/src/resource.rs: address tracking for descriptors and raw addresses.crates/victory-gpu/src/pipeline.rs,draw.rs: the builder rule and the host side of root views and title memory.