Skip to content

[BUNDLE] Ray tracing on 32-lane GPUs + 46 shader programs: #156, #213, #203 on main, verified together - #487

Open
pepezin-ai wants to merge 6 commits into
fxceless:mainfrom
pepezin-ai:bundle/rt-shaders
Open

pepezin-ai wants to merge 6 commits into
fxceless:mainfrom
pepezin-ai:bundle/rt-shaders

Conversation

@pepezin-ai

@pepezin-ai pepezin-ai commented Nov 25, 2026 •

Copy link
Copy Markdown

What

The three open PRs below, merged onto main @ a803c87 and run together on a 32-lane NVIDIA card:

Each PR keeps its own commits and author; this branch only adds the merges.

Conflict resolved

#156 against current main conflicts in one place, the pub use shader::{...} list in crates/victory-shader/src/emit/mod.rs: main added view_heap_limit, #156 added SLOT_ADDRESSES and SLOT_STRIDES_DWORDS. The merge keeps all of them; nothing else in the file differs from main.

Verified

Windows 11, AMD Ryzen 7 5700X (8C/16T), 32 GB DDR4-3200, NVIDIA RTX 5070 12 GB, Series X profile, release build, VICTORY_HOST_WAVE=32, AnyXboxX tuned settings (LATE_WAIT=3, WIDE_BACK=1, CARD_BUFFERS_MB=1024, loop limit 256).

  • cargo build --release: ok. cargo test --workspace -- --test-threads=1: 506 passed, 0 failed. (With parallel test threads the victory-gpu lib tests once stopped with STATUS_ACCESS_VIOLATION; run one at a time, all 112 pass on this branch and on plain main, so it looks like a race between tests rather than these PRs.)
  • In the game: the first gameplay scene renders with characters (skin and hair coloured), textures, sunlight, cast shadows on walls and the area outside with people; HUD prompts and pad input work. 2.3 fps average in the world (max 3.8) over 56 frame lines, no device loss.
  • Also on this machine: with the Series S profile the picture stays black (as Series S: the second present plane, and a plain stretch for the upscale dispatch #188 describes); with Series X it renders. Without the R9G9B9E5 stand-in (GPU: 16-bit float RGBA stands in for R9G9B9E5 render targets #32) the GPU was lost on entering the world on this card; main @ a803c87 already carries a form of it.

No game files, logs with paths, or personal data in this PR.

sedzz and others added 6 commits November 24, 2026 22:55
…ate on 32-lane GPUs

Two gaps kept the ray-tracing programs off on a host whose waves are 32 lanes.

1. Buffer views picked from the view heap at a computed index. The shadow-ray
   trace programs read the address of their structure out of a heap descriptor
   they choose with a per-wave index, and walk the memory behind it. The
   translator could only take such an address from a fixed table position.
   The host now keeps, after the strides of `SLOT_STRIDES`, two more dwords
   per heap slot (low and high of the title address of the buffer view
   there), written where the strides are written, and the shader reads them
   by heap slot (`SLOT_ADDRESSES`). No new root parameter; the table grows
   from 8 MB to 24 MB per view heap.

2. `lane_uniform` proves three more things where no lane of a wave can part
   from the others: `tid >> 6` of the entry thread number (in a group whose x
   size is a multiple of 64) is the same in all lanes of a console wave; an
   `ds_read_b32` at such an address is; and a value joined by a phi, also at
   a loop header, is when its arguments are and every predecessor is entered
   by all the arriving lanes or none (a greatest fixed point over the loop's
   carried values and lane masks). The structure builder's block-scan
   programs fetch a wave-uniform running total with `v_readfirstlane` in
   such a loop; without the proof they asked for an exchange between the two
   host waves where not every lane runs.

Effect, with `VICTORY_HOST_WAVE=32` on a 32-lane card:
- 4 of the 5 shadow-ray trace programs (and their screen-space variants) now
  translate and validate; the adaptive one still stops at a lane mask read
  as data.
- 52 of the 52 structure-builder programs now translate, validate and
  create a host pipeline (3 did not).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…16-bit wave sums with lanes gone

Three translator gaps that dropped world shaders (46 programs of the
retail pack; 0 that translated before stop now, by a whole-pack
`translate --validate --list` against the previous commit):

- A descriptor nothing uses as one, whose dwords the code reads all the
  same ("a descriptor read only as data", 35, and one "a descriptor's
  address or format read as data"): an 8-dword image picked from the heap
  by an index in a constant buffer, its width/height/base level turned
  into a texel size (PS_PuddleDetect, 34 pixel programs), or a 4-dword
  buffer tested for being empty by its record count
  (ShallowWaterSim:CS_MinTimestepReduce). New `unused_descriptor_kind`
  gives such loads a kind (image: a 2D texture, documented as a shortcut;
  buffer: a raw view) and `descriptor_data` rebuilds their size dwords from
  the host view as it does for used descriptors; the buffer's address
  dwords come from the host as before. Lane-copied descriptors and
  samplers keep their own handling (checked first).
- The first half of an f16 interpolation pair whose register an f16 second
  half then writes the high half of ("the first half of an
  interpolation", 8, PS_DeferredTextured and mirror-reflection variants):
  the second half keeps the low half of the register, which the first
  half wrote and nothing reads. The first half of a pair now writes 0.
- A 16-bit float wave sum where some lanes have left the program ("a wave
  sum of 16-bit floats where not every lane runs", 2,
  compute_graph_ops:CS_TransposeVecMatMul*): on a host wave of 64 lanes,
  `half_sum_present` follows the console's balanced tree, each lane
  reading its partner run's partial sum from the first lane of that run
  that is here (every lane of an aligned run holds the run's sum on the
  console, the ones outside EXEC included), +0 where none is. Two host
  waves of 32 still refuse it.

Tests: a GPU test of the 16-bit sum with 64, 63, 40, 33, 32, 17, 5 and 1
lanes staying, bit for bit against the console's tree (RX 7900 XT).
cargo test --workspace and clippy -D warnings pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The node test's reference (bvh.rs) and its emitter (emit/intersect.rs)
took a child whose pointer is 0xffff_ffff for a hit whenever the ray
entered its box. Its result dword was "none" either way, but sorted it
came with a finite distance, so it could stand before a child that is
there; a traversal that stops at the first "none" would then miss that
child.

Both now test the pointer too: a child that is not there is a miss, as
the reference's description of the result already said. The box test's
emitted code grows by two integer instructions per child (a compare and
an and): the parity tests' program (the 64-bit form) goes from 519 to
527 instructions.

The reference's new test is the reproducer of fxceless#173: a child that is not
there whose box is entered first, one child behind it, and two that are
not there with their boxes at the ray's origin, in both node widths. The
card tests run the same node and ray. With the reference corrected and
the emitter not, the four parity tests fail on the card; corrected, they
pass on the card and on WARP.

Not known: what the console returns for such a child, and whether the
title's builder ever leaves a box under one. The cases of fxceless#173 are
synthetic. docs/fork-ray-tracing.md lists it with the other assumptions.

Reproducer and patch: @Bennet0k, fxceless#173.

Co-Authored-By: GLM <noreply@z.ai>
# Conflicts:
#	crates/victory-shader/src/emit/mod.rs
pug205gti6 pushed a commit to pug205gti6/victory-fork that referenced this pull request Nov 25, 2026
RecompLive pushed a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
…ents

HLE: read manifest fields past inline XML comments
@Curry-976

Copy link
Copy Markdown

Test report for this bundle's head f1475073e053413e66ceb44fa90abd7fc8632b50 on a 6 GB laptop GPU with 32-lane waves. I ran it three times with the same settings: with the structure builder on, with it on and quarantined, and with it off. The builder starts on this card, and then the title crashes. With quarantine it still crashes. Without the builder, the run holds.

Machine

  • NVIDIA GeForce RTX 4050 Laptop GPU, 6 GB (driver 32.0.16.1742), Intel Core i5-12450HX, 24 GB RAM, Windows 11 26300, Series X profile.
  • cargo build --release -p victory on this head; the test suite was not run.
  • Common settings: VICTORY_HOST_WAVE=32 VICTORY_RELAY=2.

Results

Run Builder settings Result
1 VICTORY_BVH_BUILDER=1 the ray-tracing structure builder runs: all of its programs have host pipelines pipelines=53; the title crashes (0xC0000005) 16 s later
2 VICTORY_BVH_BUILDER=1 VICTORY_BVH_QUARANTINE=1 builder runs (same line); the title crashes (0xC0000005) 39 s later
3 builder off no exception, no crash, over 5 min in the world (opening cutscene into the prologue)

Run 1: first-chance exceptions in the title's own code just before the crash:

  • title+0x4684e7 (repeated, several threads), reading 0xffffffffffffffff, 0x7c0601a093e4 (nothing mapped) and 0x7fd3b0000 (reserved, never committed)
  • title+0x4e9d800, title+0x52ecfd9 and title+0x8f92a, as well as VCRUNTIME140.dll+0x11297 and +0x10d7b
  • one faulting register holds 0x7c00f95afc0050ae

The title then ran its crash reporter; the layer blocked the upload. Four compute pipelines were refused by the driver with E_INVALIDARG earlier in the run. The title reported memory load at 99 % at the crash.

My guess: 0x7c00 is the half-float infinity, so this looks like #16. Box bounds written by the builder get read as pointers by the CPU side. I did not check this in the code.

Run 2 (quarantine): the exceptions move to title+0x47de5, again reading 0xffffffffffffffff, and the 0x7c00 pattern does not appear. In the last frame line before the crash, preparing rose to 8994 ms with copies of 1541 MB per frame; that frame took 10726 ms, with 4881 draws. So quarantine delays the crash, but it does not prevent it on this card.

Run 3 (control): 0.3 to 2.9 fps. The slow frames (1–3.3 s) come from texture preparation when new areas load. Once a scene settles, frames take 345–475 ms at about 5,200 draws, of which roughly 300 ms is copying back and 120–240 ms is GPU time. Lighting on faces and skin in the cutscenes is clearly better than on main 310c6eb on this machine. Since the builder is off, this comes from #203 and/or #156. Shadowed areas are still dark. Peak private memory was 19 GB, with about 1 GB of physical RAM left.

Not tested

  • The test suite on this head.
  • The builder with VICTORY_BVH_SKIP or other diagnostics.
  • Other GPUs.
  • Whether the crash depends on the scene: all three runs went through the same opening.

AI use

  • Claude Code (Claude Opus 5.5) ran the commands above on this machine, read the logs and wrote this report. No game files, logs with paths or personal data are attached.

@loftymocha

Copy link
Copy Markdown

Heads-up: as of fork main 9376fd6, this PR no longer merges cleanly. git merge stops on a conflict in crates/victory-shader/src/emit/lower.rs (emit/mod.rs auto-merges). Curry-976 also reported in #16 that it conflicts with #36 and #646.

I wanted to check it offline on an RTX 5070 (32-lane) against the title's shader pack. The interest is the five shadowmask:CS_TraceShadowRays_* programs, which still fail on 9376fd6 with a descriptor read only as data when translated as a 32-lane host. If you rebase it, I can post the before/after counts of the failing programs (hashes and reasons only, no game data).

AI-assisted (Claude Code, Claude Opus 5.5).

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.

6 participants