Skip to content

Respect D3D12 limits, Preload and Play, POPS diagnostics, and RTX 5060 shader/pipeline fixes - #61

Draft
Castyan wants to merge 20 commits into
DexNom:mainfrom
Castyan:combined-preload-pops
Draft

Castyan wants to merge 20 commits into
DexNom:mainfrom
Castyan:combined-preload-pops

Conversation

@Castyan

@Castyan Castyan commented Nov 26, 2026

Copy link
Copy Markdown

Summary

Combines #47 (Respect Direct3D 12 limits and add Preload and Play) and #50 (Diagnose primitive-ordered pixel shaders in the DXIL translator) into one pull request on current main. Both are closed in favour of this one.

Conflicts with main from #47 were resolved:

  • play_launcher.rs: --play added to the new LaunchOptions parser (only accepted by victory-warm). The child process setup is now a closure so preload and play each get a configured runtime process.
  • Setup-DexNomRuntime.ps1: keeps the RayTime shortcuts and the FSR Quality 4K profile, and adds the Preload and Play shortcut.
  • host.rs, descriptor/host.rs, translate.rs, pipeline/make.rs, d3d12x.rs: both sides kept.

Status

Not compiled locally. Six CI pipelines are still failing and need fixing before merge.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Castyan

Castyan commented Nov 26, 2026

Copy link
Copy Markdown
Author

CI results for the combined branch

The CI and Screen runs here wait for maintainer approval (action_required) because the branch is on a fork. I ran the same ci.yml on the fork against current main instead: https://github.com/Castyan/VIctory/actions/runs/45733280634

CI check: passes on 5075b04 (windows-latest):

  • cargo clippy --workspace --all-targets --locked -D warnings ✅
  • cargo clippy ... --all-features (diagnostics build) ✅
  • cargo test --workspace --locked ✅ (GPU tests skip themselves on the runner's software adapter, as configured)

What was fixed: the first run failed Clippy (clippy::err_expect) on two POPS tests from #50 in crates/victory-shader/src/emit/mod.rs. Commit 5075b04 replaces .err().expect(...) with let Err(error) = ... else { panic!(...) };.

Screen: this check fails on purpose because the PR changes Setup-DexNomRuntime.ps1 (the Preload and Play shortcut). By design it means a maintainer has to read that file. It is not a code error.

Not verified: no run on a real GPU / RTX 5060 with the game (preload, then --play).

A maintainer still has to approve the workflows on this PR for the checks to show up here.

🤖 Generated with Claude Code

@Castyan

Castyan commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

work in progress for 3 shaders and the last pipeline on NVIDIA

Castyan and others added 2 commits November 26, 2026 02:56
…wn lanes

Three wave64 compute shaders (a 512-thread prefix over per-wave totals) were
refused on 32-lane hosts: inside a loop only one console wave's lanes run,
v_readfirstlane copies a running sum built from scalars and LDS alone. Two
host waves cannot exchange there (no group barrier inside the loop), but every
lane holds the same sum, so each host wave's own first lane is exact.

scalar_built() finds such VGPR values (VALU results and LDS reads of them,
phis at loop headers or where every predecessor runs on all lanes; guards
allowed), and remembers which a guarded write made: those are only taken by a
read that is itself inside a branch.

Fixes 9fc111d3be79364f, 77360df21e12ea43 and 39321a95223001ed on the
RTX 5060; their pipelines are now created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…change loop

Compute 7f61193d2c0e5f22 was refused by CreateComputePipelineState with
E_OUTOFMEMORY on the RTX 5060 and on WARP alike, although its DXIL validates.
Bisecting the console code down to one instruction: ds_add_rtn_u32 of
(0 - x) on group-shared memory. Host compilers turn atomicrmw add of a
negation into atomicrmw sub, which DXIL has no group-shared form of, and
refuse the pipeline; ds_sub_u32 (atomicrmw sub) fails the same way.

Both are now a load and a cmpxchg loop on old - x (lds_subtract); other
atomics keep their atomicrmw. A test runs ds_add of 0 - 1 and ds_sub of
0 - 1 over 32 threads and checks LDS on the card (32 and 96).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Castyan

Castyan commented Nov 26, 2026

Copy link
Copy Markdown
Author

Fixes for the RTX 5060 preload refusals

Tested on an RTX 5060 (32-lane waves only) with the game's shader archives.

1. Three compute shaders that did not translate: 0118c86

9fc111d3be79364f, 77360df21e12ea43, 39321a95223001ed: "a first-lane read where not every lane runs".

All three run the same 512-thread prefix. Each console wave past the first adds up the totals of the waves before it from LDS, in a loop that only its own lanes run. v_readfirstlane then copies the running sum back to an SGPR. On a 32-lane host, the two halves of a console wave cannot exchange inside that loop (no group barrier). The sum is built from scalars and LDS only, though, so every active lane holds the same value and each host wave's own first lane is exact.

The new scalar_built() finds such values. It allows guards. A value made by a guarded write is only accepted when the read is itself inside a branch.

For reference, the 7900XTX fork has the same refusal. It does not hit it because that card runs native 64-lane waves.

2. Compute pipeline refused with E_OUTOFMEMORY: 44c1813

7f61193d2c0e5f22: the DXIL validates, but CreateComputePipelineState returns 0x8007000E on both NVIDIA and WARP, and keeps doing so when the pipeline is created alone. So it is not memory pressure.

I narrowed the console code down to a single instruction: ds_add_rtn_u32 of 0 - x. Host compilers turn atomicrmw add of a negation into atomicrmw sub, which DXIL has no group-shared form of, and the pipeline is refused. ds_sub_u32 (which we emitted as atomicrmw sub) fails the same way. Both are now a compare-exchange loop on old - x. Every other atomic keeps its atomicrmw.

Tests

  • New: a_first_lane_read_of_a_scalar_built_sum_inside_a_lane_loop_takes_the_host_waves_own (the game's real loop on a 32-lane host).
  • New: an_lds_addition_of_a_negated_value_is_a_compare_exchange_loop. It runs on the card: 32 threads take 1 from 64 → 32, and ds_sub of −1 → 96.
  • cargo clippy (both configurations, -D warnings) and cargo test --workspace: all green locally.

Full preload on the RTX 5060

before after
shaders translated 25 755 (3 refused) 25 758 (0 refused)
compute pipelines 2 699 (32 refused) 2 703 (31 refused)

The 31 pipelines still refused are a separate category that was already there before this PR and is not part of this fix (e.g. "shader requires wave64, host supports 32..=32 lanes").

Not verified: a gameplay session past the start screens with these shaders running. They now translate and their pipelines are created, but I have not looked at their output in the game.

🤖 Generated with Claude Code

@Castyan Castyan changed the title Respect D3D12 limits, add Preload and Play, and diagnose POPS pixel shaders Respect D3D12 limits, add Preload and Play, and diagnose POPS pixel shaders -> Resolving Pipelines and Shaders on NVIDIA [In Progress Status] Nov 26, 2026
@Castyan

Castyan commented Nov 26, 2026

Copy link
Copy Markdown
Author

Launch report: build 44c1813 on an RTX 5060

Setup: Windows 11, NVIDIA GeForce RTX 5060 (0x10de:0x2d05, waves of 32 lanes only), release build of this branch at 44c1813. Launched with victory-warm.exe --play (shader preload, then the game) and the log filter at debug (victory=trace). Session from 02:12:34 to 02:26:03 UTC, stopped by hand once gameplay was reached. The log is 6.8 MB.

1. Shader preload: 81 s

warm  25758 translated, 0 refused; 2703 compute pipelines, 31 refused; 0 omitted by ray-tracing mode; 81 s
Shader preload finished. Starting the game.
  • The 3 shaders that did not translate before (9fc111d3…, 77360df2…, 39321a95…) now translate, and their pipelines are created.
  • The pipeline refused with E_OUTOFMEMORY (7f61193d…) is now created.
  • The 31 pipelines still refused all require wave64 (required=64 min=32 max=32); see below.
  • 81 s with a warm cache. The first preload took 180 s.

2. Start screens: about 30 fps

3 to 13 draws per frame, 0 draws dropped, and the queue of pipelines being made went from 734 to 0 in about 15 s.

3. Gameplay: reached, but very slow

Gameplay starts at 02:15:10. Over 106 five-second samples with more than 100 draws per frame:

value
fps 1.3 on average (min 0.1, max 2.9)
draws per frame 3 728 on average, 9 626 max (about 7 000 in the indoor scene at the end)
draws dropped without a host pipeline about 350 per frame (81 725 over the session)
indirect draws dropped 70 in total
pipelines still being made 30 at most, then 0
errors, panics, device removed or hung 0

One late frame line, broken down:

1.7 fps, 597 ms/frame (339.7 preparing: copies 103.7 ms 159.6 MB, textures 7.8 ms 17.6 MB;
180.7 on the GPU; 406.2 copying back 70.7 MB), 7041 draws/frame, dropped 367 without a host pipeline
cpu 27.6% gpu 30% busy ram 3462 MB
textures picked by index: 42999 uploaded so far (2933 MB), 8569 waiting, 13429 passed over unmapped

The bottleneck is not the GPU. Copying back to the CPU (about 406 ms and 70 MB per frame) and preparing (about 340 ms, of which 104 ms copy 160 MB) take most of each frame. The GPU itself takes about 181 ms.

Picture: the scene is drawn: an indoor room with ceiling lights and a character with fine hair. There is strong colour banding (concentric rings around the lights, posterized fog and shadows), which looks like a render target or tone-mapping step with too little precision. The overall image is very dark.

4. Remaining warnings (70 in the whole session)

count warning
38 host compute pipeline requires a wave size outside the adapter range (31 distinct shaders, required=64)
29 a pipeline creation method that is not implemented: the title goes without this pipeline (2 vtable slots)
1 each constant buffer not 256-byte aligned on the host, host view heap capped, buffer view the host would refuse left null (1 659 such views per frame line), unordered buffer view the host would refuse left null, VRAM texture budget reached, dstorage: a request ran before its page array was filled, a host DLL outside the host policy: refused rpcrt4.dll

Next

  1. The 31 wave64-only compute pipelines (this PR, next).
  2. Copy-back and preparing cost per frame (the main cause of the 1–2 fps).
  3. Colour banding in the lit, foggy scene.
  4. The 2 pipeline creation methods that are not implemented.

🤖 Generated with Claude Code

Port of DexNom#40 (notquiteog), unchanged. A console wave64 compute
program that no other form takes off 64-lane waves is refused by a 32-lane
host and every dispatch of it is dropped; the exact wave-wide form is tried
last, only for those. VICTORY_WAVE_WIDE=0 keeps the old refusal.

On the RTX 5060 this creates 22 of the 31 compute pipelines the title's
preload left refused for requiring WaveSize(64). The 9 left: 7 run groups of
several console waves (128 to 1024 threads), which the wave-wide form does
not take, and 2 are ray-tracing BVH builder programs (28918b7150a7aad5,
caa78b8ca62bc3d6) whose waves exchange across halves.

Co-Authored-By: notquiteog <notquiteog@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Castyan

Castyan commented Nov 26, 2026

Copy link
Copy Markdown
Author

Wave64-only compute pipelines on 32-lane hosts: 31 → 9 (6684db0)

What is in this PR

6684db0 ports #40 (notquiteog) unchanged, with the author credited. When no other form takes a console wave64 compute program off 64-lane waves, the exact wave-wide form (widen) is tried last. VICTORY_WAVE_WIDE=0 keeps the old refusal. The programs that lost a card with the wave-wide form have another working form, so they never reach this code.

Full preload on the RTX 5060:

before after
compute pipelines created 2 703 2 725
refused (required=64 min=32 max=32) 31 9
shaders translated 25 758 (0 refused) 25 758 (0 refused)

cargo clippy (both configurations, -D warnings) and cargo test --workspace: green.

The 9 left, and who has worked on them

hash group why the wave-wide form does not take it
02384a60fda6f2d0 128 several console waves per group (widen takes groups of 64 only)
22338086ea4c5364 128 same
2da4beb386509b77 256 same
1d434307d981352a 512 same
3b02415f67c6b0d8 512 same
6832a9da15c2e584 1024 same
6b82bc7d22016cb5 1024 same
28918b7150a7aad5 64 ray-tracing BVH builder: a wave sum used as data, and it still needs 64 lanes when taken wave-wide
caa78b8ca62bc3d6 64 same shape as 28918b71

All 7 multi-wave programs read and write LDS inside a lane branch in groups larger than one console wave. Their two halves would have to meet at group barriers that not every wave reaches.

Prior work found while looking for an NVIDIA solution:

Not verified

Gameplay with the 22 newly created pipelines running: does the picture change, and is there any device loss over a long session? #40's author ran 7.5 minutes in the story world on an RTX 5060 Ti without device loss.

🤖 Generated with Claude Code

@Castyan Castyan changed the title Respect D3D12 limits, add Preload and Play, and diagnose POPS pixel shaders -> Resolving Pipelines and Shaders on NVIDIA [In Progress Status] Respect D3D12 limits, Preload and Play, POPS diagnostics, and RTX 5060 shader/pipeline fixes Nov 26, 2026
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.

1 participant