Skip to content

Fix NVIDIA path shader compilation (#6705) - #6800

Closed
bluecmd wants to merge 2 commits into
tangency-labs:mainfrom
bluecmd:fix/nvidia-path-compile-6705
Closed

bluecmd wants to merge 2 commits into
tangency-labs:mainfrom
bluecmd:fix/nvidia-path-compile-6705

Conversation

@bluecmd

@bluecmd bluecmd commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

On NVIDIA Vulkan, the complete path shader could remain in native compilation for more than 20 minutes while committing over 100 GB. This change reduces its expanded traversal/control-flow complexity while preserving exact integer binary32 arithmetic and the existing rendering features.

Fixes #6705.

The shared path/light traversal is based on plexi32's shader fix, linked from #6813. Its author is credited in the commit. The compile-serialization fix in #6813/#6706 complements this work.

  • Share one path sample across fixed, pilot and adaptive production accumulation, retaining the early rejection for exhausted budgets.
  • Share shadow traversal across fixed lights, area lights, environment and sun, retaining source/RNG order and MIS/volume handling.
  • Express the exact IEEE binary32 addition and shift-jam helpers as linear integer dataflow, with one software-subtraction fallback. RTE, signed zeros, subnormals, canonical NaNs and the reassociation barrier remain covered by bit-level GPU oracles.
  • Replace the problematic cyclic %3 vertex indexing with equivalent selects.
  • Add a Naga call-expansion budget (five BVH walks), expanded arithmetic sign/boundary coverage, and rotated-corner reconstruction coverage.

Measurements and native evidence

RTX 4090, NVIDIA 616.56, Windows, wgpu 30.0.1, Vulkan, full main entry in a separate bounded process: 6.224 s pipeline compilation, 709,828,608 bytes peak private commit (677 MiB). cache: None; the driver cache/settings were left intact, so this is not a proven empty-driver-cache measurement. The exact probe input and source hashes are in the evidence manifest.

For comparison on this same machine and probe, the arithmetic-only candidate compiled in 42.4 s at about 2.5 GiB. The linked e5bedec9 shader alone exceeded the 4 GiB probe budget after 33.1 s; that stopped run is an incomplete compile. Combining their shared traversal with the linear exact arithmetic gives the measurement above. These are measurements on driver 616.56, not new validation on the issue author's 610.88 driver.

The actual native app completed GPU-path renders of the built-in Sample Plate (1024x768, 64 samples) and an original thin-glass scene with a rectangular studio light and transmitted shadows (768x576, 128 samples). In-app recordings, inspected window stills, exported images and resolved job metadata were supplied to the publishing relay. GitHub media attachments remain pending; no media was committed to the source branch. The black rectangle in the glass image is the finite emitter's non-emitting back side. Evidence uses original public-safe scenes; historical private screenshots/document dumps are excluded.

Validation

These checks and hardware measurements were performed on Gaming at source commit 1925f53cea404e5f9707f1b6bb96c018b048d958. The publishing relay verified the handoff hashes, commit, two-file diff and unchanged baseline failure location; it did not rerun the GPU workloads.

  • cargo test --locked -p solidcraft-gpu -p solidcraft-render --profile ci -- --test-threads=1: 442 passed, 3 existing manual tests ignored. SOLIDCRAFT_REQUIRE_GPU=1, WGPU_BACKEND=vulkan. Includes 65,536-case integer arithmetic and 65,536-case relative-coordinate bit checks, glass/corner/distant-coordinate, studio/shadow/volume, adaptive/nonadaptive and material oracles.
  • Strict GPU all-target Clippy, all 12 WebAssembly crates, offline-web checks and native application build passed.
  • cargo xtask ci was run on the final source tree. Formatting, assets/icons, licences, sorted lists, layers and UI-container checks passed. The aggregate gate stops at unchanged Windows errors in crates/ui-egui/src/cli_link.rs: Unix-only symlink code in a test (line 174) and the unused slot function (line 48). These lines are identical to upstream main. The full workspace test phase was therefore not reached; the aggregate gate is not green.

Keep this PR draft pending the repository-wide gate and independent review/hardware verification. No application release is part of this change.

Changes a default: no

bluecmd and others added 2 commits October 25, 2026 20:22
Share path sampling and light-family shadow traversal, and keep exact IEEE
binary32 arithmetic in a linear integer dataflow so native compilation stays
manageable without removing precision, glass, shadows or volume transport.

Integrate the shared-light traversal and BVH expansion regression from
plexi32/solidcraft commit e5bedec940dde467e6d49e99655c80e6bf5db6e4.
Extend arithmetic sign/boundary and rotated-corner regression coverage.

Co-authored-by: Frank <58932224+plexi32@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@bluecmd
bluecmd force-pushed the fix/nvidia-path-compile-6705 branch from ad4d5c4 to 1925f53 Compare October 25, 2026 19:51
@plexi32

plexi32 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Hi! I had a working fix for #6705 ready when this claim appeared, so I'm leaving it here instead of opening a second PR. It takes a different route from your commit (fewer inlined call sites rather than branchless helpers), so the two may combine. Use as much of it as you like.

Branch: plexi32:fix/6705-path-shader-nvidia (one commit, path.wgsl + a test):

  • main settles the adaptive budget first, then calls sample_path once (it was inlined three times, once per branch).
  • direct_light replaces direct_studio, visible and the fixed-light loop: one loop over the light sources with one shadow-ray call site, like volume_direct. Random numbers are drawn in the same order; emitter blocking and volume attenuation still apply to studio lighting only.
  • next_vertex (a select) replaces (a+1u)%3u in surface_point* / surface_ray_depth; after a BVH walk that index alone crashes NVIDIA's compiler within seconds (see GPU path tracer: NVIDIA's Vulkan compiler crashes (nvgpucomp64.dll) or floods memory on the path shader; minimal trigger found #6705).
  • main now inlines 5 BVH walks instead of 33. main_inlines_few_bvh_walks counts them with naga (no GPU needed), so it fails on main and guards this on Linux CI.

On an RTX 4060 Ti (driver 610.88, Windows 11): cold compile 219 s at 6.3 GB peak, then 0 s from the driver cache. All 135 solidcraft_gpu lib tests pass with SOLIDCRAFT_REQUIRE_GPU=1, as do the 100 render_workspace UI tests. In the app, GPU path tracing compiles once (~3 min, 7.4 GB), then renders; the result matches CPU ray tracing of the same view:

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

The cold compile is still heavy, so reducing the remaining walks further is worth a look. For the tests, #6813 (#6706) compiles one at a time per process: NVIDIA keeps one cache per executable, so every new test binary starts cold.

@bluecmd

bluecmd commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@plexi32 Take this over, it's your fix and I am running low on tokens :)

@plexi32

plexi32 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Thanks @bluecmd, taken over: the fix for #6705 is now #6850 (same branch, with the screenshots and test results). Your draft is already closed, so nothing else to do here.

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.

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

3 participants