Repository navigation
GPU path tracer: run on Metal on macOS (#7183) - #7185
Merged
Merged
Conversation
ablasik
marked this pull request as ready for review
October 26, 2026 16:42
Contributor
Author
# Conflicts: # crates/gpu/src/path/mod.rs
3 tasks
Contributor
Author
bherbruck
enabled auto-merge
October 29, 2026 13:18
Contributor
Author
|
@bherbruck the last CI run was cancelled, so auto-merge was stuck on a non-green |
bherbruck
added this pull request to the merge queue
Oct 29, 2026
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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_vulkanis nowpick_pathand enumerates those backends. Windows and Linux still resolve to Vulkan only.path::host_on_adaptertakes a viewport adapter already on Vulkan or Metal as it is; any other backend is reopened on the same GPU throughpick_path.path_backends()is non-empty, soSOLIDCRAFT_REQUIRE_GPU=1makes them mandatory on a Mac.path_devices_are_vulkan_onlybecamepath_devices_are_vulkan_or_metal_only.docs/render-path.mdsays 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=cputo 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_performancepasses when run explicitly;glass_transport_evidenceneedsSOLIDCRAFT_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.cargo test --release -p solidcraft-ui-egui --lib render_workspace: 100 passed, includingprogressive_image_controls_route_to_the_registered_host, which now drives the real Metal host.Render time,
examples/studio/coffee-explodedthroughstudio_evidence(render_and_encode_seconds), 3 runs each: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.startpath. 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.