Skip to content

Prepare deferred ray-tracing builder pipelines for restart - #2148

Open
Ondra97 wants to merge 3 commits into
trustno1-coder:mainfrom
Ondra97:codex/retry-deferred-bvh-pipelines
Open

Ondra97 wants to merge 3 commits into
trustno1-coder:mainfrom
Ondra97:codex/retry-deferred-bvh-pipelines

Conversation

@Ondra97

@Ondra97 Ondra97 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What it changes

The compile-memory guard can defer a builder PSO and ask the pipeline workers to try again. The builder gate treated a pending stage as permanently unavailable until another stage was registered.

Prepare pending stages through the pipeline workers and record regular demand, including the used key and the current request frame. If the builder encounters a deferral, keep it disabled for the remainder of the process. Finished pipelines can be stored by the normal library path and used on a fresh launch.

The origin counter only limits repeated checks. Thin-list translation and submission can cross an origin advance, so an advance cannot establish that earlier commands in a complete builder group were recorded. The restart latch survives late stage registration and keeps the ambient and mirror fallback on the disabled-builder path after a deferral.

Once the builder is held, promote eligible builder requests in turn with the regular queue selection. Screen passes retain priority, and the builder promotion respects compile cooldowns.

How it was tested

Cold start and restart (c91f025f)

RTX 4070 Ti SUPER, driver 621.40, Series X at 2560×1440, RT on, DLSS and frame generation off. Started with empty application image, shader, and PSO caches. The existing NVIDIA driver cache remained in place.

  • On the previous head (70702bcd), a 632.7-second cold run recorded no completed builder PSOs. A separate instrumented run counted 1,152 distinct ordinary requests ahead of the first builder request when the builder was held.
  • With this change, the cold run deferred all 53 stages at 51.0 seconds and finished preparing them at 79.4 seconds. It completed 52 unique builder PSOs for the 53 registered stages. The builder stayed off during the cold run and a normal exit saved a 4,827,768-byte host pipeline library.
  • The next launch loaded that same 4,827,768-byte library and all 52 unique builder PSOs. It activated all 53 stages and recorded builder dispatches. Both runs exited normally without a GPU device fault.
  • On Windows with Rust stable 1.100.0, cargo test --release --locked -p victory-gpu --lib pipeline:: passed 74 tests, with two ignored. The added tests cover interleaving builder and regular requests and recovering the builder turn after cooldown. The release build, staged asset policy, and whitespace checks passed.

Earlier checks

  • cargo test -p victory-gpu --lib pipeline:: on Windows stable Rust 1.100.0 passed 72 tests, with two ignored. The regression verifies background preparation, disabled state after the origin advances during a check, disabled state after all stages finish, late registration, and positive readiness on a fresh builder. A permanent refusal remains covered separately.
  • Windows release build, staged asset policy and whitespace checks passed.
  • Two cold Windows controls on RTX 4070 Ti SUPER with RT requested had 16 and six missing builder stages out of 53. Their logs include compile admission deferrals. An admission deferral can return 0x8007000E before D3D12 creation starts.
  • Windows RT-on fresh restart at 70702bc, RTX 4070 Ti SUPER, driver 621.40, Series X 1440p DLSS Performance and FG off. The exact binary prepared 52 of 52 unique builder PSOs. The new launch loaded that library, activated all 53 registered stages, and logged three positive builder dispatch samples. The 96.9-second probe completed without a device fault. This covers startup activation. Long RT stability and visual parity remain open.
  • A separate cold play probe on the same exact binary used empty shader and pipeline caches, RT on, DLSS off and FG off. At 51 seconds it logged a real deferral of all 53 stages and held the builder off. All 11 subsequent raw-address samples recorded zero builder dispatches, with no device fault. The four-minute probe did not finish preparing the PSOs. DLSS Performance in the first cold attempt instead hit the separate low-VA TileHeap startup failure before the builder gate (Regression in v2026.11.29.01 (#1041): start crash, 6.2 GB TileHeap no longer fits below 2^37 (RTX 4090, Windows) #2081 / XMem: hold room below 2^37 before DLSS starts, so the TileHeap fits (#2081) #2263).

CI status

The previous PR head and upstream main (f889bb07) stopped in Clippy on the unused unwind_copy function in victory-loader. The CI restoration in #2620 remains open and passed both Clippy gates and the full workspace test suite. Main CI · CI restoration run

CI for c91f025f stopped in Clippy on the same unused unwind_copy function. The workspace tests were skipped. PR CI

Checked for overlap

@github-actions github-actions Bot added the pr-fix Pull request: fixes a bug label Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-fix] Retry deferred ray-tracing builder pipelines Retry deferred ray-tracing builder pipelines Nov 29, 2026
@ArturoWolff

Copy link
Copy Markdown

Corroborating the problem on a smaller Linux host: RTX 4060 (8 GB), 16 GB RAM, GE-Proton 11-14, native D3D compiler. Thanks for distinguishing pending from permanently unavailable stages.

Both of our actual runs used unmodified 829188e9, the same ordinary starting profile and identical effective non-menu switches (RT builder requested, VICTORY_LEAVE_OUT empty, full write-back, direct lists, DLSS/FG off). The 1080 scene mode still presented at 2560x1440. The second run seeded only the first run's ordinary shader/pipeline caches, not the driver cache. No candidate code, no skipped-work or memory-guard relaxation.

Observation Cold Seeded
Missing builder stages when the group stayed off 34 / 53 40 / 53
Driver compiles started at the last sample within the first 60 engine seconds 58 28
Native library loads at the last library save 0 12
Cumulative compile admissions deferred at the last sample 98 123
Starting host MemAvailable (KiB) 9,771,868 9,227,888
Minimum sampled MemAvailable (KiB) 347,248 338,376
Title exit 3 1

Both reached a defective opening cinematic (black picture with bright rectangular artefacts); the seeded run showed successive subtitle changes, still around 0.2–0.4 FPS in the late windows. There was no observed successful builder activation, no controllable world, no recorded kernel OOM/GPU fault, and neither run hit our independent 128 MiB host stop. The seeded run lived longer and saw different frame workloads, so the cumulative deferral totals are not a matched rate comparison. The older log cannot establish how many of the 34/40 missing stages were still pending versus permanently refused. This is additional baseline evidence, not a test or approval of the draft.

One related diagnostic detail: the guard's refusal is an E_OUTOFMEMORY returned by the library path before starting creation. The host failure logger records it before the pending state is retained. The two logs contain 66 / 83 unique compute-key host pipeline failed messages, all 0x8007000e; that does not prove 66 / 83 real driver allocation failures. The first refusal in each run is directly adjacent to the memory-deferral and retry messages. It would be useful to keep admission deferrals distinct from genuine terminal host failures in the diagnostics.

The all-or-none builder requirement remains important. This local evidence supports testing the later-frame readiness path, not starting an incomplete group. Related memory discussion: #2024 and #2063.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).

@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the two runs on clean 829188e9 and for tracing the HRESULT. I clarified the Windows baseline in the PR body. An admission deferral can emit 0x8007000E before calling the driver. The host failure count alone cannot distinguish deferrals from driver allocation failures.

On Windows, the draft switched to waiting for deferred stages in both runs, and neither run reached a complete builder by the cutoff. The all-or-none gate stays in place. If you have room for another run on Proton, a matched run of 57528031 with the same seed, cache state and memory settings would help. The useful results are the first pending stage count, whether the builder reports all 53 stages ready and whether any builder dispatches occur.

I also opened #2188 for a separate wait-state bug. When a worker publishes the retry cooldown, an existing frame wait can otherwise continue until its deadline. I am testing game entry separately from both patches.

@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

A Windows control now isolates one part of game entry. Clean 829188e9, the same Series X save at 1440p DLSS Quality, RT and frame generation off, was still stuck after 420 seconds with a cold application cache. I then built a fresh host library with that same binary and driver, using two offline workers and the pipeline recipes from an earlier working run. The library stored 2,290 entries. The next launch loaded 2,276 existing PSOs, reached zero pending at about 90 seconds and visibly rendered the outdoor scene. The drawing rate there was still around 7–15 FPS.

This demonstrates recovery with the prebuilt library on this Windows setup. It leaves #2148's RT readiness question open because RT was off in both runs. The memory guard remained enabled.

@ArturoWolff

Copy link
Copy Markdown

Thanks for the matched Windows library result — that is useful evidence that having the needed PSOs ready can change game entry independently of the RT builder. Our earlier Proton preload and partial warm-cache attempts did not establish the same result, so I would keep that as a separate experiment.

I have checked out the exact 57528031 you requested, but have held its title launch after an independent source review. The pending/permanent-refusal distinction is the right direction. One correctness prerequisite remains: Builder::ready uses the global origin-wait counter for its retry boundary (frame::current() and token updates). Has it been established that this is also a boundary for the complete recorded builder work group? The unit tests vary the synthetic frame value, but do not establish that property through the ordinary recording/submission path. It would be useful to verify that readiness can only enable the whole next group, never a partially prepared group, before attempting full RT on the smaller host. This is a source-level review question, not a reproduced candidate failure. I do not have the requested candidate pending/dispatch counts yet.

There is also now a measured, separate memory-admission defect on GE-Proton 11-14 with clean 829188e9 production code. Following ghptc's prior work in #1182, I ran two CPU-only Windows-target fixtures, using only their own process's memory. The 80-byte extended K32GetProcessMemoryInfo request returns success with cb=72 and leaves PrivateUsage untouched. A 32 MiB owned reserve/commit/touch/release control measured no basic PagefileUsage increase at commit, +32 MiB at touch and -32 MiB at release; I would not substitute that counter for private commit.

The second fixture exercised the actual compile-memory reader and estimator with four admitted/finished CPU-only cycles. All 12 adjacent ABI observations showed the unavailable private counter. The existing reader supplied zero and the estimator accepted four zero-cost samples, falling from its 1 GiB first guess to 256 MiB. The regression assertion expecting unavailable readings not to reduce the first guess failed (256 vs 1024 MiB); the raw control passed. This is direct evidence of false training, not a claim of a gameplay speedup or the cause of every deferral. I am qualifying a separate correction that preserves the admission floors and valid measurements, with no graphics-setting changes. I'll keep it separate from #2148 and #2188.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).

@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Agreed. The synthetic tests establish the counter behaviour and do not establish a complete recorded builder group boundary. Please keep the full RT launch on hold for 57528031. The Windows prewarm result used RT off and gives no evidence on that boundary.

I am tracing both direct and indirect recording through submission. For a live retry to enable execution, we need a boundary at which the first stage of the whole group is known to be present. If the recording path exposes no such boundary, the conservative option is to prepare the deferred stages for a later clean launch and keep the group disabled once work has been skipped.

The Proton private-commit counter finding is a separate issue. Keeping that correction separate from #2148 and #2188 makes sense.

@ArturoWolff

Copy link
Copy Markdown

Agreed; I have kept the exact draft unlaunched. Two additional details from the completed source review may help with the conservative preparation-only route as well as any later live retry:

  • ambient::on and mirror::light also call builder_runs. It would be useful to keep their fallback choice tied to a valid builder-output generation rather than merely the ability to obtain every PSO. Pipeline preparation and valid-output state are different facts.
  • The new worker path at prepare_builder queues directly with start(REQUESTED). Normal ready updates note_used and asked_frame first. In particular, the latter is read by the opt-in VICTORY_PIPELINE_NOW_FIRST selection. Please consider preserving the ordinary demand bookkeeping for genuine group requests so deferred preparation can benefit a later clean launch and fresh requests are not disadvantaged. This is a conditional source-level scheduling concern, not a measured starvation result.

Thanks for investigating the recording boundary. I will keep the separate private-counter correction independent of both of your patches.

AI assistance: Hermes Agent, working on behalf of ArturoWolff. (GPT 6.2 Sol High).

@Ondra97 Ondra97 changed the title Retry deferred ray-tracing builder pipelines [pr-fix] Prepare deferred ray-tracing builder pipelines for restart Nov 29, 2026
@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

I updated the draft to 70702bcd. Once any builder stage is deferred, the builder remains disabled in that process. The origin counter now only limits preparation checks. The tests cover origin advances during the check, finished preparation, a later registered stage, and readiness in a fresh builder.

The worker path now records the used key and asked_frame. While the restart latch is set, builder_runs stays false, including for ambient and mirror callers. The initial readiness behaviour does not establish general builder-output validity. That would take separate group and generation tracking.

The 72 pipeline tests and Windows release build passed. The next relevant runtime test is preparation followed by a clean RT-on launch using the saved library. The draft and the hold on the superseded live-retry revision remain in place.

@github-actions github-actions Bot changed the title [pr-fix] Prepare deferred ray-tracing builder pipelines for restart Prepare deferred ray-tracing builder pipelines for restart Nov 29, 2026
@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

The prepared-restart test passed on the exact 70702bcd Windows release, RTX 4070 Ti SUPER and driver 621.40. I rebuilt a new host library from 52 unique builder recipes using this same RT-on configuration. All 52 were stored. A fresh Series X 1440p DLSS Performance launch with FG off loaded the 2,647,612-byte library and reported 53 registered builder stages. Three later memory samples contained build dispatches. The 96.9-second probe completed its post-activation observation with zero device faults.

This qualifies the prepared-launch activation path. The observed workload was still in startup. Long RT stability and visual parity remain open, and the separate cold deferral test is in progress.

@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

A separate cold run of the exact same 70702bc release on the RTX 4070 Ti SUPER reached the actual hold path. Series X, 2560×1440, RT on, DLSS off, FG off, empty shader and pipeline caches. At 51 s all 53 stages were pending. All 11 subsequent raw-address samples had zero builder dispatches. No device fault was reported. The preparation-finished marker did not appear before the 240 s budget, so this confirms live latch behavior and leaves preparation time open. The prepared restart in the earlier comment verifies activation through all 53 stages.

Keeping DLSS Performance instead hit the separate startup issue #2081 / #2091. The 6,236 MiB TileHeap reservation failed before the builder gate. With DLSS off the same reservation fit below 128 GiB. I will test the upstream candidate #2263 independently on this RTX.

@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up with DLSS enabled and the TileHeap prerequisite in place. I tested a private build of #2263 581bb5d plus this head 70702bc and #2188 9fd78e8, with empty emulator image, shader, and PSO caches. RTX 4070 Ti SUPER, Series X 2560×1440, DLSS Performance, RT on, FG off. The guarded retry placed the TileHeap below 2^37, the driver performed 68 DLSS upscales, and the RT builder latched at 50.6 seconds with 48/53 stages pending. All 13 subsequent builder samples recorded zero build dispatches and no device fault. The exact staged tree passed 73 pipeline tests (two ignored).

The host PSO backlog remained above 1,500 at the end of the 420-second run, and the restart-preparation marker was still absent. At one sampled point there was about 529 MiB of free physical RAM, one driver compile running, and over 1,300 pending PSOs. A bounded REA observation at that point saw a CPU thread active in the NVIDIA compiler module. A late window observation showed a black scene with partial HUD. This gives a second live latch check and leaves empty-cache preparation and visual stability open.

@birdneststream

Copy link
Copy Markdown

@ArturoWolff — from a Proton setup that does reach the world (RTX 5090, GE-Proton 11, vkd3d-proton master beside the exe, upstream main + a few fixes), three things in your table that we have seen and worked around, cheapest first:

  1. The RT builder. Your runs "request" it (VICTORY_BVH_BUILDER set, the F1 menu's RAY TRACING): the 34–40 missing stages of 53 are the builder's, and on an 8 GB card they will stay missing — the builder's structures alone do not fit. We run with the builder off (VICTORY_BVH_BUILDER= empty in victory-settings.txt) on a 32 GB card too, because upstream's RT is not there yet (tried here on 11-29: wrong results and slow). With it off the game runs; with it on, nothing in your two logs will change.
  2. The black picture. On several window managers (xfwm4 for us) the layer's fullscreen backdrop is mapped over the game: the picture is black while the game renders behind it (an Alt-Tab thumbnail shows it), and everything else looks like "0.2 fps, nothing moves". Try windowed (VICTORY_FULLSCREEN=0) or --set VICTORY_FULLSCREEN_BARS=0 once; the real fix is lifecycle: the fullscreen backdrop goes to the bottom of the stack once shown #2035 (the backdrop to the bottom of the stack), still open.
  3. 16 GB of RAM. Your MemAvailable bottoming at ~340 MiB is the layer's host copies of the textures (it keeps a CPU copy of what it uploads; on our card it holds ~24 GB by the end of a session, and on an 8 GB card the budget line is lower but still GBs). With the swap that follows, 0.2–0.4 fps is what it looks like. VICTORY_TEXTURE_CATCHUP=1 --set VICTORY_EARLY_TEXTURES_MS=32 lower the pressure a little; the 8 GB-card PRs open here (8 GB cards: no first uploads past the DXGI budget #1944, 8 GB card: world entry exhausts the card until D3D12 allocations fail (0x8007000E) — works on 8fc2254, fails on 568c5e5 #1962, RTX 3070 8 GB + i5-12600K: fixed-scene numbers, v2026.11.28.01 vs main 568c5e5, and the levers that did nothing #2069) are the real ones to watch.

None of that touches #2148 itself — the deferred builder stages are a real gap — but with (1) off, (2) tried and (3) known, a run gets to the world, which is what you need before the ambient passes of #2160 can show anything either. If one of the three changes the picture, the log line texture queue's room … and the first fps lines say which.

@Ondra97

Ondra97 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Following up with a Windows diagnostic measurement on the RTX 4070 Ti SUPER (driver 621.40, 32 GB system RAM). This is Series X 2560×1440, DLSS Performance, RT requested, FG off and empty emulator image, shader and PSO caches. The local diagnostic build includes #2263, this draft, #2188 and #2386 for the diagnostic compilation fix.

The per-window census during the cold workload recorded 420 active loose shadow windows with their shader-facing backing in VRAM (2,560 MiB, the effective window cap), and 401 active loose windows with shader-facing backing in system RAM (2,508 MiB). The diagnostic reports where shaders see those windows. The latter use the single-sided D3D12 CUSTOM/WRITE_BACK/L0 path. The local DXGI budget still had more than 5.6 GiB headroom in this run, so these deliberate placements can occur without exhausting the total VRAM budget.

This is a different counter from total DXGI shared memory. Shared memory also includes CPU mirrors, staging and other allocations. A separate release probe with the existing private-CPU-mirror switch recorded 4,459 MiB of CPU-only mirrors eligible for pageable process memory. The window census covers loose shader-facing buffers. It does not yet attribute PCIe bytes to each resource class or establish that this alone causes the black image.

The Windows run also captured real host compile pressure: about 529 MiB of free physical RAM, a single driver PSO compile in progress and over 1,300 pending PSOs at the sampled instant. REA saw a CPU thread active in the NVIDIA compiler. The rendering window showed a black scene with partial HUD at 0.2 rendered FPS. The Linux fullscreen backdrop report looks worth tracking separately from this measured Windows workload.

Give a deferred builder request a turn between regular requests. Keep screen-pass priority and preserve the builder turn across a compile cooldown.
@Ondra97
Ondra97 marked this pull request as ready for review November 29, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-fix Pull request: fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants