Skip to content

Structure builder: queue its pipelines at creation and make them in parallel (VICTORY_BVH_BUILDER_EARLY) - #121

Open
notquiteog wants to merge 1 commit into
DexNom:mainfrom
notquiteog:pr/dexnom-bvh-fixes
Open

notquiteog wants to merge 1 commit into
DexNom:mainfrom
notquiteog:pr/dexnom-bvh-fixes

Conversation

@notquiteog

Copy link
Copy Markdown

This PR gives back one fix from notquiteog/victory-nvidia for the title's native ray tracing: the structure builder's pipelines are now made in parallel instead of one after another. It has its own switch, VICTORY_BVH_BUILDER_EARLY (on by default; =0 turns it off), and does nothing unless the builder is on (VICTORY_BVH_BUILDER=1). Your builder default does not change: it stays opt-in.

What it does and why

The builder's stages run all or none, so its first dispatch makes every builder pipeline the title has created (make::now), one after another on that dispatch's thread. With a cold driver cache each of the 53 took about a second. The title's main thread waited for the frame, and its 30 s watchdog ended the run with a store to address 0. When it hit, 40 of the 53 pipelines were made. A run with a warm cache took 8 s for them, and that one frame took 13 s.

With this change:

  • Each builder pipeline is queued for the pipeline workers when the title creates it. This happens only while the builder is allowed. The new make::soon(p, false) queues it at the early priority.
  • At the builder's first dispatch, all of the builder's pipelines are promoted to requested (make::soon(p, true)) before that thread makes or waits for each one in turn. The ones not made yet are made side by side.

VICTORY_BVH_BUILDER_EARLY=0 restores the old order. docs/fork-ray-tracing.md describes the switch.

Our other ray-tracing fixes, not in this PR

These need our memory-by-address layout (64 KiB pages in card arenas and one directory buffer), and your memory.rs is built differently (shadow copies, Writes ranges). I did not want to hand-port them without being able to run them on your tree:

  • Compacted-size bound (VICTORY_BVH_SIZES_BOUND): the title reads a structure's compacted size before the card has written it. The fix gives the slot the prebuild upper bound at once and the real size when it lands. Card time per frame went from 19 ms to 9 ms on ours.
  • Pushed directory and arenas (VICTORY_BVH_PUSH): about 7 ms a frame saved on the submit thread with rays on.

They are e8258c1 and df64c27 on notquiteog/victory-nvidia if you want to look. Our fork also now runs the builder by default (unless VICTORY_BVH_BUILDER=0). That is offered as an idea only and is not in this PR.

How it was tested

On this branch (off main 64bd58f), on Windows, after Initialize-FormatTables.ps1:

  • cargo build --locked: OK, no warnings.
  • cargo test --locked -p victory-gpu --lib: 219 passed, 0 failed, 4 ignored.
  • cargo test --locked -p victory-shader --lib: 239 passed, 0 failed, 4 ignored.

The watchdog and timing numbers come from runs of the original commit (3e423ed) on our fork. This port was not run in the title.

🤖 Generated with Claude Code

…on and all at once at its first dispatch (VICTORY_BVH_BUILDER_EARLY, on)

The builder's first dispatch made its 53 pipelines one after another on
its thread, about a second each with a cold driver cache; 40 were made
when the title's watchdog fired 30 s into the frame (a store to address 0).
A warm run took 8 s for them. Now each builder pipeline is queued for the
pipeline workers when the title creates it (only with VICTORY_BVH_BUILDER=1),
and all of them are promoted to requested at the builder's first dispatch,
so the ones not made yet are made side by side before that thread makes or
waits for each in turn. VICTORY_BVH_BUILDER_EARLY=0 restores the old order.

Hand-port of notquiteog/victory-nvidia 3e423ed.

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

Copy link
Copy Markdown

Independent native RTX 5070 routing check at e7eb99a: three separate processes passed 16 synthetic builder-tagged compute pipeline identities through hand_out and builder_runs, each producing a real D3D12 PSO. With early mode enabled, each identity compiled exactly once across all eight worker threads. With early mode disabled, all 16 remained unqueued at creation and built on the requesting test thread. With the builder disabled, all stayed unqueued and builder_runs returned false.

The fixture pre-tagged synthetic shaders as builder shaders and inserted a controlled 20 ms compilation delay to expose scheduling. It verifies routing, not elapsed-time benefit, title builder content, cold-cache watchdog recovery, or gameplay.

Verification was AI-assisted with GPT-6.2 Astra.

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.

2 participants