Skip to content

GPU: a root constant's dword 4 is a value, not a view offset (#2699) - #2703

Open
Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/gpu-root-view-offset
Open

Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/gpu-root-view-offset

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

Fixes #2699.

In the user-data loop, a dword numbered ROOT_VIEW_OFFSET (4) was taken for a root view's offset without asking whether the parameter was a root descriptor at all. Root constants with five or more dwords have a real dword 4; it was looked up as a root view, none was found, and the draw or dispatch was refused (a root view's offset: no root view, or outside title buffers) with no log line. The ray-tracing builder's dispatches were among the casualties.

Ask u.root == RootType::Descriptor too, through a helper beside is_root_view, so a root constant's dword 4 goes to the title's user data as the value it is.

The test pins the predicate: a descriptor's dword 4 is an offset; constants' and tables' dword 4 are not.

Tests: cargo test -p victory-gpu --lib --locked only_a_root_descriptors_dword_four (pass), cargo clippy -p victory-gpu --all-targets clean.

…k#2699)

In the user-data loop, a dword numbered `ROOT_VIEW_OFFSET` (4) was taken
for a root view's offset without asking whether the parameter was a root
descriptor at all. Root constants with five or more dwords have a real
dword 4; it was looked up as a root view, none was found, and the draw or
dispatch was refused ("a root view's offset: no root view, or outside
title buffers") with no log line. The ray-tracing builder's dispatches
were among the casualties.

Ask `u.root == RootType::Descriptor` too, through a helper beside
`is_root_view`, so a root constant's dword 4 goes to the title's user data
as the value it is.

The test pins the predicate: descriptor dword 4 is an offset, constants
and table dword 4 are not.
@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

The same WARP shader goes through VIctory's dispatch and reads a user-data word into a buffer. A root constant at dword 4 leaves the output at 0 on main 13f91ca and writes 1.25 on 7bb3eba. The control puts a real root view 16 bytes into its buffer and reads the offset 16 on both revisions. Six paired runs across both debug settings reproduced this.

The serial GPU suite had 200 passes and one ignored in each setting. Strict GPU Clippy in both configurations and asset policy passed.

Test-only commit c4e53db is directly on your current head and checks the dispatch and readback in addition to the predicate. Please keep the Git author if you cherry-pick it, or add this trailer if folding it into another commit:

Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com

@kotekompotek

Copy link
Copy Markdown

Real bug, minimal fix - dword 4 is ROOT_VIEW_OFFSET only in the root-descriptor encoding; a constants param has a genuine value there. Gating on root == Descriptor matches how is_root_view already treats the namespace. The predicate test pins all three root types.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP verification and full-repo audit of 7bb3ebaf (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • RTX 5090: cargo test --locked -p victory-gpu --features diagnostics --lib draw: 14 passed, 0 failed (including only_a_root_descriptors_dword_four_is_a_view_offset).
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1: 199 passed, 0 failed, 1 ignored.

Code Review & Repo Audit

  • Audited all remaining references to ROOT_VIEW_OFFSET, ROOT_SRV_VIEW, ROOT_UAV_VIEW, RootType, and user_data across victory-gpu and victory-shader: no other call site conflates RootType::Constants / RootType::Table dword 4 with a root view offset (user_value, is_root_view, and lower.rs all gate on RootType::Descriptor).
  • Looks clean and ready to merge (cherry-picking @andrewpozdnakov7-jpg's c4e53db end-to-end dispatch test would be a nice bonus, though not blocking; also supersedes older GPU: the fifth dword of a root constants parameter is read as a constant #2295 on current main).

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Independent WARP/CPU verification (claim: #1633)

  • PR head: 7bb3ebaf46081958a6546cd74bd8290cd3a3b715 / origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • State: OPEN, non-draft; git merge-tree --write-tree origin/main <head> merges cleanly; no prior oni-swr comment on this head.
  • Environment: Windows 11 Pro 10.0.26200, VICTORY_WARP=1 + VICTORY_D3D12_WARP=1 (WARP only, no physical GPU, no game files/dumps/retail hashes), dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0, via VICTORY_DXIL), rustc 1.98.1 (48a229cea 2026-09-01), debug profile, --locked.

Commands / results (baseline = origin/main, same environment)

cargo test -p victory-shader --locked
cargo test -p victory-gpu --locked
cargo clippy -p victory-gpu --locked --all-targets
  • victory-gpu: 196 passed / 0 failed / 1 ignored (+1 vs baseline 195). New draw::tests::only_a_root_descriptors_dword_four_is_a_view_offset ok.
  • victory-shader: 267 / 3 / 3, identical to baseline (the same 3 pre-existing WARP failures; unaffected by this PR).
  • clippy -p victory-gpu: 0 warnings, 0 errors (baseline 0).

Negative control: with the predicate loosened back to the old condition (u.dword == ROOT_VIEW_OFFSET, root type ignored), the new test FAILS; reverted afterwards.

Code review: No bugs found. Minimal fix: the offset substitution now requires RootType::Descriptor, so a root constant's dword 4 stays a value. The test is a unit test of the predicate (Descriptor/Constants/Table); it does not exercise the surrounding fill loop end to end.

Not tested: physical GPU hardware (RX 7800 XT or any), retail game run, release build, other crates.

AI use: Claude Code (Claude Sonnet 5.5) ran the commands and reviewed the diff; the results above are from the actual runs.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate (recommend a look). This is a real bug fix. In the user-data loop of State (crates/victory-gpu/src/draw.rs), any UserData with dword == ROOT_VIEW_OFFSET (4) was treated as a root view's offset. The translator (Lower::user_dword in emit/lower.rs) also emits dword: 4 for the fifth dword of a root constants parameter, so such draws and dispatches were refused. The new is_root_view_offset also requires RootType::Descriptor, the only root type for which Lower::root_view_offset emits that dword. The test pins the predicate. A contributor's comment adds an end-to-end WARP readback (main 0, this branch 1.25). It fixes the same thing as the older #2295 (needs work) and merges cleanly, so this is the one to take.

CI: check passing on this head.


Generated by Claude Code

@Anzymanz

Copy link
Copy Markdown

From a tester working with Claude (AI-assisted, Claude Code): a second machine where this is the biggest drop class in the world.

Setup: RX 9070 XT, RADV (Mesa 26.3.1) through vkd3d-proton (GE-Proton 11-14), CachyOS; diagnostics build of main 13f91ca + #1997 + #454, Series X, 1.0.2.1; Microsoft's d3dcompiler_47 in the prefix so the indirect clamp builds.

Drops (a root view's offset: no root view, or outside title buffers, highest per-frame rate of each program over one world run): 3b90165a77d95cdf 1,014, f6e47efa50226beb 768, 6f6a359d1166bb27 314, 5e68767498c57eb6 298, and ffd93c8a029ff016, c42a31951201f9a0, 5062bc7a48e842f8, 190fbf0ebe040169, c85822de2e41cfaa 10-58 each. That is more than the being made drops (839) in the same run.

Why, checked offline: all of these are compute programs from XboxBvhBuilder.dll, and translating them (emit::translate_with) gives each a user-data entry with root: Constants, dword: 4 (3b90165a77d95cdf slot 2, f6e47efa50226beb slot 8, 6f6a359d1166bb27 and 5e68767498c57eb6 slot 0), which the ROOT_VIEW_OFFSET arm takes for a root view. So the RDNA4/Linux drops are this bug too. I haven't run the title with this PR yet; I'll post the A/B when I have it.

No game data here: hashes and counts only.

@Anzymanz

Copy link
Copy Markdown

The A/B I promised above, same machine (RX 9070 XT, RADV/Mesa 26.3.1 via vkd3d-proton, GE-Proton 11-14), same base (13f91ca + #1997 + #454 + #2644), diagnostics builds, warm shader cache, one run per arm, 30 s in the world each (the opening cutscene), VICTORY_GPU_TIMING=1:

base base + this PR
a root view's offset summary lines 56 0
draws and dispatches dropped per frame, world intervals 192 / 619 / 346 / 473 54 / 808 / 16 / 4 / 4
per-dispatch GPU time of the two costliest builder kernels (caa78b8ca62bc3d6, 28918b7150a7aad5) 0.37 / 0.77 ms 0.35 / 0.81 ms

So on RDNA4 under Linux this PR removes that drop class completely, and the ray-tracing builder's other programs now run; no new fault in the 30 s. Frame times aren't comparable between the two runs (different cutscene moments, and the timing mode serialises lists), so I'm not quoting them. The one 808 interval is right after the world loaded (pipelines still being made).

AI-assisted (Claude Code, Claude Opus 5.5); no game data, hashes and counts only.

crashbashash added a commit to crashbashash/VIctory-proton that referenced this pull request Nov 25, 2026
In the prison cutscene the Xbox BVH builder's dispatches (about 250-400 a
frame) were dropped because a root constant's dword 4 was taken for a
root view's offset. With Marvisak#2703 2-3 draws and dispatches a frame are
dropped in all, in three runs, at no measurable cost.
pragyaangaur pushed a commit to pragyaangaur/VIctory-macOS that referenced this pull request Nov 26, 2026
Backport Marvisak/VIctory#2703 (7bb3ebaf46081958a6546cd74bd8290cd3a3b715) to the macOS branch.
@davesousa

Copy link
Copy Markdown

NVIDIA in-game A/B: RTX 3070 Ti 8 GB (Ampere), driver 621.40, Windows 11 26200, TDR delay 8 s. diag build, warm caches. Base: main 63bcca4 + #2319 + #2178 + #2634 (what this card needs to reach the world). Then the same with this PR (7bb3eba, merges cleanly; only_a_root_descriptors_dword_four_is_a_view_offset passes here). Scripted input walks in the prologue from 150 s.

base base + this PR
runs 1 2
end stopped by me at 6 min, no removal 0x887A0006 at 133 s and at 81 s
a root view's offset drops per frame 259 0
world frame, median (frames with no pipelines being made) 815 ms (GPU 421 ms) 2.5-4 s (GPU 2.0-3.1 s), 2 samples before the removal
longest host submission 6 slow ones, all short 14.9 s and 15.5 s, each 2 lists

So the fix does what it says on NVIDIA too: the drop class is gone, and the builder programs the thread names (3b90165a77d95cdf, f6e47efa50226beb, 6f6a359d1166bb27, 5e68767498c57eb6 and the rest) run. But on this card what they then submit does not fit the timeout. In the second run, with VICTORY_D3D12_DRED=1, the removal follows a 2-list submission of 17,406 commands (the first list alone 11,969). DRED's stop is at an ordinary texture upload in that first list, so I read it as where the GPU was at 8 s, not as the cause. Three nvlddmkm resets at the moment of removal; no event 13.

That matches the 5080/Linux report in #1968's thread of the builder list running past the timeout until #2167. So on NVIDIA this PR seems to need the builder's work cut into smaller submissions (or made cheaper) to land without turning a running world into a hang. I haven't tried #2167 or #2214 with it yet.

AI-assisted (Claude Code); the runs are on my machine.

@crashbashash

Copy link
Copy Markdown

AMD data point for comparison with the RTX 3070 Ti above: RX 6800 XT (RDNA2), Linux, Mesa RADV 26.2.6,
vkd3d-proton 71cae091b (GE-Proton11-14 with a newer vkd3d-proton), diag build of main 219878a plus our Linux
commits, the same prison scene from a save, 120 s in the world, idle machine.

without this PR with it
runs 2 2
draws and dispatches dropped per frame (median) 254, 355 2, 4
world frame, median 700, 779 ms 794, 746 ms
GPU time per frame, median 205, 214 ms 221, 210 ms
device removals or hangs none none

So on RDNA2 the builder's work lands at most at a small GPU cost (a few ms a frame, within run-to-run noise here),
unlike on Ampere. In the same runs nothing in the picture changed that I could attribute to it.

AI-assisted (Claude Code). No game data attached.

@davesousa

Copy link
Copy Markdown

Follow-up: the same card and base, with this PR and #2167 (3cb308d, rebased on 63bcca4, merges cleanly; its mark and memory tests pass here), shader cache and pipelines rebuilt.

this PR this PR + #2167
end 0x887A0006 at 133 s and 81 s 0x887A0006 at 101 s (1 run)
the long 2-list submission 14.9 s, 15.5 s 11.1 s
commands in it 17,406 19,268

So #2167 takes about a quarter off, but not enough for an 8 s TDR here.

With VICTORY_GPU_TIMING=1 (each list run on its own; its times are inflated, FIND-29), a single list of 10,730 commands is what removes the device: slow host list ms=21168. DRED's stop is inside a barrier-free run of about 400 commands (1,267..1,668) that starts at dispatch 4x1x1 [compute f6e47efa50226beb], one of the builder programs this PR lets through. The per-command times in that list came back 0 because the device was gone, so I can't single out one dispatch. On this card the builder's work needs to reach the GPU in more than one submission (or with barriers that let the timeout breathe) before this PR can land without a hang on NVIDIA.

AI-assisted (Claude Code); the runs are on my machine.

crashbashash added a commit to crashbashash/VIctory-proton that referenced this pull request Nov 26, 2026
proton-ge -> eaf1aaa7: CachyOS's wineserver patch for Wine bug 60868
(memory views in an rb tree instead of a list). With the same VIctory build,
two interleaved runs each: wineserver 33-39 % -> 5 % of a core in the
world, load into the world 74-80 s -> 59-60 s, frame median 809/972 ms ->
776/550 ms.

Docs: pipeline pre-build times with a cold and a warm driver cache; known
limits: the NVIDIA device removals reported with Marvisak#2703 and the skip list
that leaves the BVH builder out, where the bottom strip first goes wrong,
the teeth through the lip, late detailed models.
@davesousa

Copy link
Copy Markdown

Follow-up 2: the same card and base (63bcca4 + #2319 + #2178 + #2634), this PR with #2118 and, separately, with #2841. Scripted walking from 150 s, 10-minute runs, warm caches (the #2841 build got its own shader cache and pipelines first). Both merge cleanly on this stack; #2118's three tests pass here.

this PR + #2118 (af8b9ad) + #2841 (274cdad)
runs 2 2 (one with DRED) 2 (one with DRED and VICTORY_GPU_TIMING=1)
end 0x887A0006 at 133 s and 81 s no removal, both stopped by me at 10 min GPU lost at 97 s (0x887A0006) and at about 90 s
longest host submission 14.9 s, 15.5 s 1.3 s, 0.64 s 13.1 s; in the timing run one list of 10,747 commands, 14.0 s
a root view's offset drops 0 0 0
world frame, median (2 samples, 2.5-4 s) 809 ms (GPU 430), 702 ms (GPU 352) (did not get that far)

For comparison, the base without this PR, summarised the same way: 835 ms median (GPU 431), longest submission 0.78 s. My first comment's 815 ms picked its frames slightly differently.

With #2118 the builder never starts on this card: BVH builder held back: not all its pipelines are made pipelines=53 made=44 refused=9 at the first world frame, and it stays held back for the whole run. The 9 are programs this card cannot make (its wave64 ones; the driver returns 0x80070057). So the resets need the builder dispatches this PR lets through, and on a 32-lane NVIDIA card those run without the 9, which is the case #2118 is for. With #2118, this PR lands here without a reset and keeps its drop count at 0.

#2841 on its own does not change that. Its thread-count path does run here (4ddd6f9702fab2a7 and 5062bc7a48e842f8 get their cut-short pipelines), but the long submission and the reset stay. The timing run has no DRED stop: VIctory crashed while writing its device-removed report.

Not tested here: the builder running whole on NVIDIA, which needs the wave64 work in #439/#2214. So whether its whole work fits the timeout on this card is still open.

AI-assisted (Claude Code); the runs are on my machine.

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

Tested merged onto origin/main (63bcca4) on Windows 11 x64:

  • cargo test -p victory-gpu --lib draw::tests::only_a_root_descriptors_dword_four_is_a_view_offset: 1 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified 7bb3ebaf locally on Windows 11 (RTX 5090 and WARP, with VICTORY_D3D12_DEBUG=1):

  • cargo xtask policy and cargo clippy -p victory-gpu --tests -- -D warnings (default and --all-features): clean.
  • draw::tests (12/12, including only_a_root_descriptors_dword_four_is_a_view_offset): passed on RTX 5090, RTX 5090 + VICTORY_D3D12_DEBUG=1, and WARP + VICTORY_D3D12_DEBUG=1.

Checked every other ROOT_VIEW_OFFSET / ROOT_SRV_VIEW / ROOT_UAV_VIEW / is_root_view site across the workspace; this branch in State::bind was the only place missing the RootType::Descriptor guard (matching is_root_view). Clean, minimal fix — ready to merge.

@lhnizdo

lhnizdo commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Follow-up to my comment above, now measured with a raised TdrDelay: on this 32-lane card the change needs #2118 alongside it, and with both there is no reset.

without this PR this PR + #2118 (af8b9ad)
device removal none none
longest host submission 2.4 s 2.5 s
dropped a root view's offset: no root view, or outside title buffers ~248 a frame (7 compute programs) 0
all dropped draws and dispatches ~526 a frame ~285 a frame
BVH builder — held back the whole run: pipelines=53 made=45 refused=8

So @davesousa's reading holds here too. My earlier resets with this PR (submissions of 2.9–12 s) look like the builder running without the 8 wave64 programs this card refuses. With #2118 holding the builder back, the submissions stay where they were without this PR. The rest of the drops in the right column are local diagnostics skipping programs on purpose, plus ~20 a frame for programs that don't translate here. None of it comes from this PR.

One unrelated note in case it saves someone time: with TdrDelay at 10 s, the programs I had blamed for hangs earlier ran fine. They had just been over 2 s. Raising it is worth doing before reading a device removal on a slower card as a stuck program.

AI-assisted (Claude Code); the runs were on my machine. No game data.

crashbashash added a commit to crashbashash/VIctory-proton that referenced this pull request Nov 26, 2026
In the prison cutscene the Xbox BVH builder's dispatches (about 250-400 a
frame) were dropped because a root constant's dword 4 was taken for a
root view's offset. With Marvisak#2703 2-3 draws and dispatches a frame are
dropped in all, in three runs, at no measurable cost.
crashbashash added a commit to crashbashash/VIctory-proton that referenced this pull request Nov 26, 2026
proton-ge -> eaf1aaa7: CachyOS's wineserver patch for Wine bug 60868
(memory views in an rb tree instead of a list). With the same VIctory build,
two interleaved runs each: wineserver 33-39 % -> 5 % of a core in the
world, load into the world 74-80 s -> 59-60 s, frame median 809/972 ms ->
776/550 ms.

Docs: pipeline pre-build times with a cold and a warm driver cache; known
limits: the NVIDIA device removals reported with Marvisak#2703 and the skip list
that leaves the BVH builder out, where the bottom strip first goes wrong,
the teeth through the lip, late detailed models.
crashbashash added a commit to crashbashash/VIctory-proton that referenced this pull request Nov 26, 2026
A new game went through the intro into the prison scene (about 2,100 frames, 15 minutes) without VICTORY_NO_POOL_TRAP and without the +0x5149aec assert, as Anzymanz saw on an RX 9070 XT. One run; the hook stays for when it does stop.
@JurajSimicevic

Copy link
Copy Markdown

Blackwell data point: this PR with #2118, on top of #2461

Setup:

without this PR + #2118
a root view's offset: no root view, or outside title buffers report lines in the world 509 0
a dispatch of the BVH builder held back — logged at the world's first frames
longest slow host submission 4.8 s 4.6 s
most draws in a frame 10,190 11,690
device removed no no

This matches lhnizdo's RTX 2080 and davesousa's RTX 3070 Ti results above. The root-view drops are gone, and with the builder held back, no submission gets longer than before. I didn't run this PR without #2118 on this card.

Local diagnostics only. No game data: log counts only.

AI-assisted.

@Jackster

Copy link
Copy Markdown

A named program this restores, and the scale of the effect on the title

On the retail build (RX 7900 XTX, driver 32.0.32029.2010, Windows 10 26300.10075, 300 s world runs, diagnostics build at 63bcca4 plus a stack of open PRs), the difference this makes on one program and on the frame:

  • On unpatched main, compute c85822de2e41cfaa translates and makes its pipeline, then is dropped at dispatch with: a root view's offset: no root view, or outside title buffers [compute c85822de2e41cfaa], about 5 draws/frame. With this PR in the tree the same program binds and the drop disappears.
  • Across the frame, the "a root view's offset" refusals went from 336 logged lines over 11 programs (up to 402 draws dropped in a frame) to 0, and dropped/frame from 431 (1,216 still being made) to 64 and then 0 as the queue drained. Shaders translated in the run rose from 500 to 1,711 because those programs now reach the device.

Those numbers are from a 300 s A/B on the same save with this PR as the only difference in the second step; the per-program line above is from a VICTORY_LOG=victory=info run and is reproducible by grepping for the hash.

The per-program name is the part this PR's description does not have, and it is the same class as #3094's report — a root constant's dword 4 read as a view offset.

Written with an AI assistant.

@zed6000

zed6000 commented Nov 26, 2026

Copy link
Copy Markdown

Tried in the game: this removes every a root view's offset drop in the intro, on AMD.

Setup: RX 7900 XTX (RDNA3), driver 32.0.32029.2010, Windows 11 26200, Ryzen 9 7900X3D; diag builds (--profile diag --features diagnostics), Series X profile, played by hand from boot into the intro cutscene. Warm caches (the counts below exclude the AMD driver's first-run compile).

build report windows dispatch: a root view's offset: no root view, or outside title buffers other drops, once warm fps, warm
main 63bcca4 21 in 9 windows: 60 to 1,060 dispatches/frame (median about 560), 11 compute pipelines indirect "no host pipeline", 8 shaders that do not translate 1–2
the #1247 shader stack + this PR (7bb3ebaf cherry-picked cleanly) 104 none 0 dropped draws/frame and 0 dropped indirect in every warm window 1.4–2.4

The release build of the stack without this PR still dropped 200–370 draws/frame in the same scene (posted on #400), and its shaders all translate, so this reason accounted for most of what remained there. No new warnings and no hang. The intro draws far more of the scene; some surfaces (skin) still look too dark, which this PR would not be expected to change.

#2295 makes the same change, so it should behave the same; I only ran this one.

@lhnizdo

lhnizdo commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@zed6000, thanks, that matches what I saw on NVIDIA. On an RTX 2080 in the world, root-view drops went from about 248 dispatches a frame to 0.

One note for anyone trying this on a 32-lane NVIDIA card: there it needs #2118 alongside. Without it, the BVH builder's dispatches run while the card refuses some of its wave64 programs. On the RTX 2080 that gave single submissions of 12–15 s and a device reset in the world, and @davesousa saw the same on an RTX 3070 Ti. With #2118 holding the builder back, the longest submission stayed at about 2.5 s, the same as without this PR. JurajSimicevic's RTX 5080 run with both agrees. On your RX 7900 XTX the builder's programs all run, so the PR stands on its own there.

AI-assisted (Claude Code). No game data.

@AIcelos

AIcelos commented Nov 26, 2026

Copy link
Copy Markdown

Tested on Linux + NVIDIA (Wine) — this stack now boots GTA VI v1.0.2.1 to a running game window.

Setup that works today (merged all open PRs in branch nvidia-wine):

  • Cross-build from Linux: cargo xwin build --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvc
  • Wine 10 prefix + vkd3d-proton d3d12.dll/d3d12core.dll and DXVK dxgi.dll from GE-Proton 11-14 copied to system32/, WINEDLLOVERRIDES="d3d12,d3d12core,dxgi=n,builtin"
  • Do NOT copy dxil.dll: Wine's built-in (Wine-mono) DXBC builder works; NVIDIA's Windows dxil.dll cannot load under Wine and blocks vkd3d-proton. (The team gist "remove all D3D12/DXGI/DXIL + builtin override" fails on stock wine — wine 10 ships no d3d12.dll of its own.)
  • Fixes in this branch that made it work: versioned dxcompiler_NN.dll fallback (Wine's is unversioned), IDxcContainerBuilder v1→v2→v3 retry, root-signature fallback, VICTORY_CACHE_DIR.

Result on RTX 5090: window appears, swapchain presents (frame 2048+ in 90 s ≈ 20 fps diag build), all 49 ttpf + packs open via dstorage, XUserAddAsync offline user, 52 shaders translated through Wine's dxil→DXBC path. No crash.

The "XCL requires Windows" premise is wrong: the whole layer runs under Wine with vkd3d-proton; only the host tooling assumed Windows.

@latentdev

Copy link
Copy Markdown

RTX 4090, the case after the gate: every builder pipeline made, with this PR

As on the 2080 above, #2118 holds the builder on a 32-lane card as long as any stage is refused. This is the next case, which #2118's author suggested raising here: every stage exists, so the builder runs whole.

Tree:

Without a loop cap (with #2118's previous head af8b9ad; the gate is open either way when nothing is dropped). BVH builder runs ... made=53 refused=0 dropped=0. Seven frames into the world the device hangs (0x887A0006, nvlddmkm event 153). The list stops in dispatch 1075x1x1 [compute 5552dac6a2b7a1fd]. That program (wave32, [32,1,1]) is a bottom-up refit:

  • each thread buffer_atomic_add ... glc on its node's arrival counter;
  • the first arrival stops;
  • the second reads the node with glc dlc loads and climbs to the parent.

That loop can only fail to end if the parent links form a cycle.

With VICTORY_SHADER_LOOP_LIMIT=4096.

  • The builder runs whole, never held back, with no hang in 9 + 7 minute runs.
  • The ray-traced lighting that reads the structures comes on (screen-probe ray tracing ~33 ms/frame, a light-probe gather ~47 ms, ped skinning for the structures ~55 ms), about +100 ms/frame in all.
  • In the cell window shot, though, the character and the whole room go pure black, where the same shot with the builder held shows them dimly lit. The cap applies to every shader, so it may play a part in that too.

My reading. The hang isn't this PR. A builder stage writes a wrong structure (parent links with a cycle), and the refit is where that shows. The suspects are the stages this PR un-drops (f6e47efa, 3b90165a and the rest of the 11) and the 7 that e2d3cfd keeps out (LDS and sections in console-flow halves). I haven't separated the two groups yet. A per-stage dump of the node buffers would be the next step.

Until then, on a 32-lane card the safe combination stays as above: #439 with e2d3cfd's limit, so #2118 holds the builder.

@lhnizdo

lhnizdo commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@latentdev, this matches what I see on an RTX 2080 (32-lane), and I have part of the per-stage answer, from running the builder's own wave64 programs against CPU references.

Setup. I dumped the builder's 53 containers at run time and lowered each wave64 one the way our stack does on 32-lane hosts (the split into two host waves, close to #3147). I ran the real container on the 2080 through title memory, over random input, and compared with a CPU reference of what the program computes. It's synthetic input only, and no game data leaves the machine.

Found and fixed: two split bugs. Together they made lanes 32–63 of every console wave read 0 in the builder's block-wide prefix sums (39321a95, 77360df2, 9fc111d3, 256/512 threads; and f6eb6498, 5e19e7c7, 64 threads):

  • A ds_swizzle checked whether its source lane was active by its console lane in the host wave's 32-lane ballot, so every upper-half source looked inactive.
  • A lane mask written as two s_mov_b32 (s0 = 0, s1 = -1, the scan's "add lane 31" step) was tested by its low dword in both halves.

After the fix all five match their references exactly. 39321a95, 77360df2 and 9fc111d3 are three of the 7 stages e2d3cfd keeps out, so they may be worth checking on your translation too.

Checked and correct on ours: the radix sort pass e63d22c4 (a local 8-bit sort of 2,048 pairs, then the scatter) and the radix histogram 14394a32 (64-lane compare masks used as data).

Not changed by a split at all (no cross-lane operations; LDS only behind barriers): the bitonic steps 198f6dfd/9205d265, and cb9647e7, 894c9165, 4b5aedc0, a63e2dfc, 5e687674. The tree build itself (a197f50c, f28a33a8, count-leading-zeros on the codes) and the refits are native wave32.

But the hang stays. With all of that fixed, the whole builder still hangs in its first frame here, in a 14.9 s submission. Two wave64 stages are still unverified on my side: 28918b71 and caa78b8c (64 threads; a full-wave scan with dpp8/row_shr/v_permlanex16 and direct exec_lo/exec_hi writes, then node encoding). Those run in our console mode. I'm looking at them next, and at reading the parent buffer back before the refit, to see whether the cycle is already there.

The harness is three local tests in wave64_console_tests.rs on my stack (one_container_block_scan_…, one_container_radix_pass_…, one_container_radix_histogram_…, each taking a container path by env var). I can push them to a branch if they'd help with your translation.

AI-assisted (Claude Code). No game data.

@JurajSimicevic

Copy link
Copy Markdown

@latentdev @lhnizdo one data point from the other side of the gate, in case it helps you read the picture once the builder works. On a 32-lane card, the combination that is safe from hangs is not safe for the picture.

RTX 5080 tree: main 63bcca4 + #2098, #2626, #2628, #2464, #2118 and #439 at e2d3cfd with its limit; this PR is not in it. That is the combination recommended above: the builder is held back every frame (53 pipelines, 46 made, 7 refused).

What it does in the cell:

My reading (not proven): those 18 are the ray-traced lighting stages that come on in latentdev's run once that limit is lifted.

  • With the limit: the chain runs without them, and the stages that do run read data nobody wrote that frame. Result: green.
  • Without the limit: they run on a wrong structure. Result: black.

If that's right, the cell should come out right only when both are in place:

  • wave64 groups of more than 64 threads translate correctly;
  • the builder builds a correct structure.

Until then, an all-or-none rule for that lighting work, like #2118's for the builder, would give a dark but clean cell instead of a green one.

If you push the split fixes or the builder work to a branch, I can run the same cell measurement on the RTX 5080: the lighting buffer's green share at a fixed world frame, plus a screenshot that stays local.

Local diagnostics only. No game data: counts and roles.

AI-assisted.

@latentdev

Copy link
Copy Markdown

@lhnizdo thanks, that's a big step. I checked both patterns on our translation (#439's console flow plus #2214's multi-wave groups) with two hardware tests. Each runs one group of 64 on the RTX 4090 (split into 32-lane halves) and on the 7950X3D's Radeon iGPU (native wave64), and compares every lane.

  • A mask written as two dwords (s_mov_b32 s10, 0, s_mov_b32 s11, -1), used as a v_cndmask_b32 mask and as exec: exact on both; lanes 32-63 see the high dword.
  • ds_swizzle_b32 xor 16 (BITMASK_PERM) in the console flow, with all lanes active and with lanes 48-63 inactive: identical on both. Lanes 32-47 read 0 when their source lane is inactive.

So neither bug is what breaks the structure in our tree; it has to come from somewhere else. Your harness would help a lot. Running 39321a95, 77360df2, 9fc111d3, 28918b71 and caa78b8c against your CPU references with our lowering would show whether one of them is it. If you push the tests to a branch, I'll run them here on both adapters and report back.

@latentdev

Copy link
Copy Markdown

Follow-up, going further on the stages you named. I ran the builder's own code for their cross-lane parts. For each stage I took its instruction words and replaced only the memory loads and stores with a known input and the test output. I then compared every lane between the RTX 4090 (split) and the Radeon iGPU (native wave64).

  • 39321a95 / 77360df2 (the same scan core): the five masked ds_swizzle steps, the lane-31 carry, the per-wave totals in LDS and the loop over earlier waves, at 64, 128, 256 and 512 threads. I also ran the tail that picks the group's last thread to store the total (s_cselect_b64 exec, 0 and vcc, then s_and_saveexec_b64), with the flag set and clear. Exact on both.
  • 28918b71 (caa78b8c is the same block with other registers): the wave sum of the counts (dpp8, row_mirror, permlanex16, a read of lane 32), and the exclusive prefix sums of the counts and of the popcounts (row_shr, permlanex16 under exec 0xffff0000:0xffff0000, the lane-31 carry). Exact on both.

9fc111d3, f6eb6498 and 5e19e7c7 repeat the same swizzle scan with other registers; I haven't run them separately.

So on our tree the wave-level arithmetic of these stages is right, and the wrong structure comes from somewhere else. Our whole-builder run only finished with VICTORY_SHADER_LOOP_LIMIT=4096, so some loop doesn't end on its own, and a loop cut short would leave a wrong structure by itself. I'll look for which stage's loop that is, and why it doesn't end (bad input from an earlier stage, or a stage's writes not reaching the next).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU: any user-data dword numbered 4 is taken for a root view offset, and the dispatch is dropped