gfx-rs/wgpu · error

Feature `EXPERIMENTAL_RAY_TRACING` not enabled

Error message

Feature `EXPERIMENTAL_RAY_TRACING` not enabled

What it means

`trace_rays` expects `device.extension_fns.ray_tracing` to be present, using `.expect("Feature `EXPERIMENTAL_RAY_TRACING` not enabled")`. Note the different feature name: this is gated on wgpu's `EXPERIMENTAL_RAY_TRACING` flag. Dispatching a ray tracing pipeline without that experimental feature enabled at device creation — or without the Vulkan ray tracing functions loaded — panics here.

Source

Thrown at wgpu-hal/src/vulkan/command.rs:1429

        if self.rpass_debug_marker_active {
            unsafe { self.end_debug_marker() };
            self.rpass_debug_marker_active = false
        }
    }

    unsafe fn trace_rays(
        &mut self,
        count: [u32; 3],
        ray_generation_group_data: crate::PipelineGroupData<super::Buffer>,
        miss_group_data: crate::PipelineGroupData<super::Buffer>,
        intersection_group_data: crate::PipelineGroupData<super::Buffer>,
    ) {
        let ray_tracing_functions = self
            .device
            .extension_fns
            .ray_tracing
            .as_ref()
            .expect("Feature `EXPERIMENTAL_RAY_TRACING` not enabled");

        let ray_tracing_pipeline_functions = self
            .device
            .extension_fns
            .ray_tracing_pipelines
            .as_ref()
            .expect("Feature `EXPERIMENTAL_RAY_TRACING_PIPELINES` not enabled");

        let get_device_address = |buffer: &super::Buffer| unsafe {
            ray_tracing_functions
                .buffer_device_address
                .get_buffer_device_address(
                    &vk::BufferDeviceAddressInfo::default().buffer(buffer.raw),
                )
        };

        unsafe {
            ray_tracing_pipeline_functions.cmd_trace_rays(

View on GitHub (pinned to 3e11ff59bf)

Solutions

  1. Add `Features::EXPERIMENTAL_RAY_TRACING` to required_features when creating the device
  2. Re-check which feature flag your wgpu version requires (RAY_TRACING vs EXPERIMENTAL_RAY_TRACING) and match it to the API you call
  3. Verify adapter support for VK_KHR_ray_tracing_pipeline and that the version of wgpu you use exposes the experimental feature
  4. Fall back to compute-based ray tracing if the adapter lacks RT support

Example fix

// before
let device = adapter.create_device(&DeviceDescriptor {
    required_features: wgpu::Features::RAY_TRACING,
    ..Default::default()
})?;
// after: experimental pipelines need the experimental flag
let device = adapter.create_device(&DeviceDescriptor {
    required_features: wgpu::Features::EXPERIMENTAL_RAY_TRACING,
    ..Default::default()
})?;
Defensive patterns

Strategy: validation

Validate before calling

if !adapter.features().contains(wgpu::Features::EXPERIMENTAL_RAY_TRACING) {
    return Err(Error::ExperimentalRayTracingUnsupported);
}
let device = adapter.create_device(&DeviceDescriptor {
    required_features: wgpu::Features::EXPERIMENTAL_RAY_TRACING,
    ..Default::default()
})?;

Type guard

fn supports_experimental_ray_tracing(features: wgpu::Features) -> bool {
    features.contains(wgpu::Features::EXPERIMENTAL_RAY_TRACING)
}

Try / catch

// check before dispatching rays; do not rely on catching the panic:
if !device.features().contains(wgpu::Features::EXPERIMENTAL_RAY_TRACING) {
    return Err(Error::ExperimentalRayTracingUnsupported);
}
encoder.trace_rays(...);

Prevention

When it happens

Trigger: Calling `trace_rays` (vkCmdTraceRays path) on a device created without `Features::EXPERIMENTAL_RAY_TRACING` in required_features, or where `extension_fns.ray_tracing` is None (extensions/functions not available).

Common situations: Using wgpu's experimental ray tracing pipeline API while forgetting the EXPERIMENTAL_RAY_TRACING feature bit (distinct from the stable RAY_TRACING one); adapters/driver combos where ray tracing extensions fail to load; code updated for the new feature name but devices still created with the old set.

Related errors


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