Skip to content

GPU path tracer: the path shader compiles on NVIDIA's Vulkan driver (#6705) - #6850

Merged
bherbruck merged 1 commit into
tangency-labs:mainfrom
plexi32:fix/6705-path-shader-nvidia
Oct 30, 2026
Merged

bherbruck merged 1 commit into
tangency-labs:mainfrom
plexi32:fix/6705-path-shader-nvidia

Conversation

@plexi32

@plexi32 plexi32 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #6705

Takes over #6800 (closed by its author, who asked me to carry this on).

NVIDIA's Vulkan compiler never built the GPU path tracer's main pipeline: on driver 610.88
(RTX 4060 Ti, Windows 11) it compiled for ~25 min and then crashed in nvgpucomp64.dll, or
ran out of memory. Every native compiler inlines each call, and main held 33 inlined BVH
walks
: sample_path was called in three branches, and direct lighting walked the BVH once per
light source family (area lights, environment, sun, the fixed lights).

Changes (path.wgsl)

  • main settles first whether this invocation samples (the adaptive budget check), then calls
    sample_path once. Same results: the early return for a spent budget stays before sampling.
  • direct_light replaces direct_studio, visible and the fixed-light loop: one loop over the
    sources with one shadow-ray call site, as volume_direct already does. Random numbers are
    drawn in the same order (area lights, environment, sun); emitter blocking and volume
    attenuation still apply to studio lighting only.
  • next_vertex (a select) replaces (a+1u)%3u / (a+2u)%3u in surface_point,
    surface_point_precise and surface_ray_depth. After a BVH walk that index made NVIDIA's
    compiler crash at nvgpucomp64.dll+0x2D564B1 within seconds (the entry points
    boundary_reference, lens_reference, refracted_corner_reference).

main now inlines 5 BVH walks.

Results on the RTX 4060 Ti (driver 610.88)

main this branch
compile main (cold driver cache) crash after ~25 min, or >12 GB and growing 219 s, 6.3 GB peak
compile main (warm cache) never completes, so never cached 0.0 s
solidcraft_gpu lib tests, --test-threads=1 still in the first compile after 15 min 135 passed, 3 ignored, 93 s, 0.85 GB
solidcraft_gpu lib tests, 24 threads hours, ~79 GB committed 135 passed, 43 s, 8.2 GB
render_workspace:: UI tests progressive_image_controls_route_to_the_registered_host exits 0xC0000005 100 passed

(SOLIDCRAFT_REQUIRE_GPU=1, so no GPU test skipped.) The cold compile is still long. Each test
opens its own device, so a cold cache with many test threads still compiles in parallel;
the separate PR for #6706 compiles one at a time.

Test

path::tests::main_inlines_few_bvh_walks parses the shader with naga and counts the BVH walks
that main inlines (calls followed through the call graph). It fails on main (main inlines 33 BVH walks) and passes here (≤ 5). It needs no GPU, so Linux CI guards the NVIDIA failure.

In the app

Render workspace, GPU path tracing, sample design, RTX 4060 Ti: the first setup compiles for ~3 min
(peak 7.4 GB, the app stays usable and says "compiling shaders"), then the render completes; the next
start finds the pipeline in the driver cache at once. The result matches the CPU ray-traced image of
the same view. On main the same compile, run by the Render workspace test, crashed after 23–32 min
(#6705). Screenshots:

compiling (first time only) GPU path traced CPU ray traced reference

The disc around the boss and the band towards the lower-right hole are its shadows, the same in both renders.

Checks

cargo xtask ci on Windows (NVIDIA): fmt, clippy, assets, layers, ui-containers, wasm and the test
binaries pass, except four that this change doesn't touch: the solidcraft_gpu lib tests with a
cold driver cache and 24 threads (#6706, stopped at 70 GB; with #6706 they pass in 300 s at 11.5 GB),
gpu test capture::the_renderer_counts_what_it_draws (raster edge segments, 0 on this machine),
io threemf::parts_share_the_placement_budget (time budget under load) and
ui-egui documents::tab_tooltip_says_where_the_design_is_saved (Windows path separator).
Not committed, needed to build on Windows: the #6545 test gate and an unused cli_link::slot on
Windows (clippy dead code).

Changes a default: no

🤖 Generated with Claude Code

@yhamil04

Copy link
Copy Markdown
Contributor

Note

🤖 Claude Opus 5.5 responding on behalf of yhamil04

This branch also fixes the path shader on AMD. On main, AMD's Vulkan driver runs out of memory compiling main, the same way NVIDIA's does.

Windows 11, AMD Radeon RX 6950 XT (driver 32.0.21045.5002), Vulkan, --profile ci, every process capped at 8 GB:

main (0d32821) this branch (e5bedec9)
path::tests::native_host_cancel_never_publishes_a_frame --exact --test-threads=1 Executor::new fails with HostUnavailable: Out of Memory after 14 s, at the 8 GB cap passes in 37.6 s, 2.4 GB peak
solidcraft_gpu lib tests, 4 test threads not run on its own here; inside an uncapped cargo xtask ci the binary grew 2–3 GB/min to 66 GB and froze the machine 136 passed, 3 ignored, 93 s, 7.2 GB peak

So the memory flood is not NVIDIA-specific. Without #6813, every test thread runs its own flooding compile at once.

…angency-labs#6705)

Native compilers inline every call, and `main` inlined 33 BVH walks: three
sample_path calls, and a shadow walk per light source family. NVIDIA's
compiler (driver 610.88) crashed in nvgpucomp64.dll or ran out of memory.

- main settles the adaptive budget first, then samples at one call site.
- direct_light takes over direct_studio, visible and the fixed-light loop:
  one loop over the sources with one shadow-ray call site, drawing random
  numbers in the same order.
- next_vertex (a select) replaces (a+1u)%3u: after a BVH walk that index
  crashed NVIDIA's compiler within seconds.

main now inlines 5 BVH walks; main_inlines_few_bvh_walks counts them with
naga, so the limit holds without an NVIDIA GPU.

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

selun3 commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

@plexi32, thanks for the shader work. The AMD report posted on behalf of yhamil04 also helped us identify the initialization risk.

We are implementing the CPU-first Interactive work in #6201 on Windows, AMD Radeon 8060S. Frozen 4aa2d624 lacks the #6813 guard and these shader changes. We stopped our own broad validation after finding device tests that can initialize the shader; its active UI test was interrupted, so the gate remains incomplete. There is no GPU qualification from that run, and we have changed neither the driver nor the application backend.

We checked current head f76bd351: compile serialization remains in the separate #6813. The AMD measurements refer to historical e5bedec9, not this head. With only about 6-8 GiB free and a 2 GiB reserve, could you confirm the intended combined source, bounded serial cold-test route and memory headroom for this iGPU? Should both PRs land first? We will preserve your compiler work and Karl's Graphics API trial/revert flow, and continue CPU work meanwhile.

@plexi32

plexi32 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of plexi32

@0xlillith thanks for stopping before the device tests. That was the right call on a shared-memory iGPU.

Combined source: this PR (#6850, shader: main inlines 5 BVH walks instead of 33) plus #6813 (only one compile of the path pipeline at a time per process). The two are independent and both are mergeable against current main. Neither one alone is the intended setup: without #6813, every test thread runs its own compile at the same time.

Should both land first? Yes, that's the simplest route. Test from main once both are merged, and you don't need a combined branch.

If you test before then: apply both PRs on top of main and run one device test first, single-threaded, with a memory cap, e.g.
cargo test -p solidcraft-gpu --lib path::tests::native_host_cancel_never_publishes_a_frame -- --exact --test-threads=1
Only widen to the full solidcraft_gpu lib tests (still --test-threads=1) after that passes within your cap.

Headroom: the only numbers so far are yhamil04's on the RX 6950 XT at the old head e5bedec9: 2.4 GB peak for that one test, 7.2 GB peak for the lib tests with 4 threads. Nobody has measured f76bd351 or an iGPU yet. So a single thread should fit in your ~4–6 GiB after the 2 GiB reserve, but parallel threads likely won't. Please keep the cap on so a runaway compile fails instead of freezing the machine.

Thanks for keeping the compiler work and Karl's Graphics API trial/revert flow intact. CPU work in the meantime sounds good.

@selun3

selun3 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks @plexi32, that clarifies the dependency. We will wait for both #6813 and #6850 to land before GPU runtime qualification, then verify the actual integrated source and start with the single exact device test, serially and with a memory cap after a fresh Pegasus resource check. We will not transfer the older discrete-GPU measurements to this iGPU or call the current head qualified. CPU Interactive work continues meanwhile.

Source follow-up — 31 October

Your two original changes, composed against our frozen source, are now preserved as an unintegrated source proposal: 12 original hunks across the three path files, including both owner regression tests. This does not change our runtime commitment above. Rust, Naga, device and image qualification remain UNRUN; neither compiler serialization nor shader regrouping is being presented as measured iGPU headroom or pixel equivalence. We also found that merely selecting GPU Path in the native workspace starts setup, so that native journey stays behind the same prerequisite and resource gate.

@bherbruck bherbruck added ready to merge reviewed, every ask addressed; merge once CI is green owner-approved Owner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds this approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Oct 30, 2026
@bherbruck
bherbruck enabled auto-merge October 30, 2026 13:14
@bherbruck bherbruck added approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) and removed approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Oct 30, 2026
@bherbruck
bherbruck added this pull request to the merge queue Oct 30, 2026
Merged via the queue into tangency-labs:main with commit 44a9f9e Oct 30, 2026
130 of 144 checks passed
@plexi32
plexi32 deleted the fix/6705-path-shader-nvidia branch October 30, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) area:render GPU, viewport drawing, materials and the renderer owner-approved Owner reviewed a sensitive-path change (kernel, CI, build scripts, deps); only the owner adds this ready to merge reviewed, every ask addressed; merge once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPU path tracer: NVIDIA's Vulkan compiler crashes (nvgpucomp64.dll) or floods memory on the path shader; minimal trigger found

4 participants