gfx-rs/wgpu · error

Ray tracing pipelines are unsupported on Metal

Error message

Ray tracing pipelines are unsupported on Metal

What it means

`create_ray_tracing_pipeline` on the Metal backend is a stub that panics with `unimplemented!("Ray tracing pipelines are unsupported on Metal")`. The Metal backend simply does not implement hardware ray tracing pipelines, so calling this API always panics instead of returning a Result error.

Source

Thrown at wgpu-hal/src/metal/device.rs:1964

            self.counters.compute_pipelines.add(1);

            Ok(super::ComputePipeline { raw, cs_info })
        })
    }

    unsafe fn destroy_compute_pipeline(&self, _pipeline: super::ComputePipeline) {
        self.counters.compute_pipelines.sub(1);
    }

    unsafe fn create_ray_tracing_pipeline(
        &self,
        _desc: &crate::RayTracingPipelineDescriptor<
            super::PipelineLayout,
            super::ShaderModule,
            super::PipelineCache,
        >,
    ) -> Result<super::RayTracingPipeline, crate::PipelineError> {
        unimplemented!("Ray tracing pipelines are unsupported on Metal")
    }

    unsafe fn destroy_ray_tracing_pipeline(&self, _pipeline: super::RayTracingPipeline) {
        unimplemented!("Ray tracing pipelines are unsupported on Metal")
    }

    unsafe fn get_raytracing_pipeline_group_data(
        &self,
        _pipeline: &super::RayTracingPipeline,
        _groups: core::ops::Range<u32>,
    ) -> Result<Vec<u8>, crate::DeviceError> {
        unimplemented!("Ray tracing pipelines are unsupported on Metal")
    }

    unsafe fn create_pipeline_cache(
        &self,
        _desc: &crate::PipelineCacheDescriptor<'_>,
    ) -> Result<super::PipelineCache, crate::PipelineCacheError> {

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Do not create ray tracing pipelines on Metal; gate creation behind a backend check (AdapterInfo::backend != Metal)
  2. Use compute-shader ray tracing on Metal instead
  3. If RT is required, choose a backend that supports it (Vulkan with rayTracingPipeline, DX12 with DXR)

Example fix

// before
let rt_pipeline = unsafe { device.create_ray_tracing_pipeline(&rt_desc) }?;
// after
if adapter.get_info().backend == Backend::Metal {
    return Err(anyhow!("ray tracing not supported on Metal"));
}
Defensive patterns

Strategy: fallback

Validate before calling

fn rt_supported(info: &AdapterInfo) -> bool { !matches!(info.backend, Backend::Metal) }

Try / catch

// panic, not Err — must be prevented, not caught:
if rt_supported(&adapter.get_info()) { pipeline = Some(create_rt_pipeline(..)) } else { pipeline = None; /* compute fallback */ }

Prevention

When it happens

Trigger: Calling `Device::create_ray_tracing_pipeline` (wgpu-hal `create_ray_tracing_pipeline`) on the Metal backend with any descriptor.

Common situations: Cross-backend code that constructs RT pipelines unconditionally (Vulkan/DX12 primary targets) and is then run on macOS/Metal; RT feature detection not performed before pipeline creation.

Related errors


AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03). Data as JSON: /api/errors/f10eb461a3865483. Report an issue: GitHub.