Skip to content

GPU path tracer: run on Metal on macOS (#7183) - #7185

Merged
bherbruck merged 5 commits into
tangency-labs:mainfrom
ablasik:gpu/metal-path-tracer
Oct 29, 2026
Merged

bherbruck merged 5 commits into
tangency-labs:mainfrom
ablasik:gpu/metal-path-tracer

Conversation

@ablasik

@ablasik ablasik commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Change

The GPU path tracer ran on Vulkan only (#3217, #3306), and macOS has no Vulkan driver, so every Render-workspace image on a Mac fell back to the CPU. This lets it run on Metal on macOS. The WGSL, the software BVH and the executor are unchanged; only the adapter selection changes.

  • select::path_backends() is the native backends that may run the path tracer: Vulkan, plus Metal on macOS. D3D12 stays excluded (GPU path tracer: DX12 with FXC takes ~2 h to compile the path shader #3217: FXC compile times).
  • pick_vulkan is now pick_path and enumerates those backends. Windows and Linux still resolve to Vulkan only.
  • path::host_on_adapter takes a viewport adapter already on Vulkan or Metal as it is; any other backend is reopened on the same GPU through pick_path.
  • The device tests that skipped "unless Vulkan" now skip unless path_backends() is non-empty, so SOLIDCRAFT_REQUIRE_GPU=1 makes them mandatory on a Mac. path_devices_are_vulkan_only became path_devices_are_vulkan_or_metal_only.
  • docs/render-path.md says so.

Follow-up to #3306 and #3217, which left macOS on the CPU. It does not change Windows or Linux.

Changes a default: yes — on macOS the Render workspace now prepares a Metal path-tracer device and offers "GPU path tracing" (it was unavailable there; the default image method is still Raster and no saved setup changes), old behaviour kept behind preference SOLIDCRAFT_GPU

(Set the environment variable SOLIDCRAFT_GPU=cpu to keep the path executor unavailable and render images on the CPU, as before.)

Validation

Apple M3 Max, macOS 27, wgpu 30.0.1, release build, SOLIDCRAFT_REQUIRE_GPU=1:

  • cargo test --release -p solidcraft-gpu --lib path::: 108 passed, 0 failed, 2 ignored (the two manual ones: path_performance passes when run explicitly; glass_transport_evidence needs SOLIDCRAFT_GLASS_EVIDENCE). 67 device tests logged "Apple M3 Max (IntegratedGpu, Metal)", none skipped. That includes the f64-oracle BRDF, furnace, glass, MIS, shadow and denoiser tests at their existing tolerances.
  • No naga WGSL→MSL error, no Metal limit problem (six storage buffers, 1 GiB bindings), no portability fix needed in the shader or the executor.
  • cargo test --release -p solidcraft-ui-egui --lib render_workspace: 100 passed, including progressive_image_controls_route_to_the_registered_host, which now drives the real Metal host.

Render time, examples/studio/coffee-exploded through studio_evidence (render_and_encode_seconds), 3 runs each:

Case Run 1 Run 2 Run 3
Metal, 1920x1080, 8 spp 4.31 s 4.47 s 3.73 s
Metal, 1920x1080, 64 spp 20.18 s 19.01 s 21.77 s
Metal, 1280x720, 8 spp 1.24 s 1.42 s 1.58 s
Metal, 640x360, 8 spp 0.372 s 0.376 s 0.376 s
CPU raytrace, 640x360, 8 spp 5.86 s 5.48 s 5.26 s

The CPU row is a different integrator (direct light, no GPU-path glass or MIS), so it shows the order of magnitude, not a like-for-like speed-up. At 1280x720 the CPU run hit "ray tracing work budget exhausted" after 40 s at 72% of the work; the Metal run took about 1.4 s.

Setup (adapter, device, shader and pipeline creation, gpu_host_setup_seconds): 0.72 s, 0.31 s, 0.06 s on three consecutive runs. Metal's shader cache is warm after the first one. I did not measure a cold machine, because the tests had already compiled the shader.

Screenshots of the behavior (when observable)

Metal renders of the coffee scene at 1280x720 (8 spp and 64 spp), produced by the production render.start path. Attach: metal-coffee-1280x720-8spp.png, metal-coffee-1280x720-64spp.png.

Integration status

Rebased on origin/main cfb3f52. Fixes #7183. Not touched: Windows and Linux backend selection.

@ablasik
ablasik marked this pull request as ready for review October 26, 2026 16:42
@ablasik

ablasik commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author
metal-coffee-1280x720-8spp metal-coffee-1280x720-64spp

@ablasik

ablasik commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@jyviko ready for review: Metal path tracer (#7183), merged with current main, mergeable.

@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) and removed approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Oct 29, 2026
@bherbruck
bherbruck enabled auto-merge October 29, 2026 13:18
@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 29, 2026
@ablasik

ablasik commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@bherbruck the last CI run was cancelled, so auto-merge was stuck on a non-green ci. I merged current main (clean; fmt and clippy pass) to restart it; the new run needs a workflow approval (fork PR).

@bherbruck
bherbruck added this pull request to the merge queue Oct 29, 2026
@ablasik

ablasik commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@bherbruck CI is green now, but auto-merge looks off after my push (GitHub shows no auto-merge request). Could you re-enable it or merge?

Merged via the queue into tangency-labs:main with commit cb05e1e Oct 29, 2026
21 checks passed
@ablasik
ablasik deleted the gpu/metal-path-tracer branch October 29, 2026 14:52
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) 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: run on Metal on macOS, where every render falls back to the CPU

2 participants