gfx-rs/wgpu · error
Feature `RAY_TRACING` not enabled
Error message
Feature `RAY_TRACING` not enabled
What it means
`read_acceleration_structure_compact_size` calls `.expect("Feature `RAY_TRACING` not enabled")` on `device.extension_fns.ray_tracing`. This Option is only `Some` when the Vulkan device was created with the ray tracing extensions (e.g. VK_KHR_acceleration_structure/KHR_ray_query) and their function pointers were loaded. Panicking here means a compact-size query was requested for an acceleration structure without ray tracing support being enabled on the device.
Source
Thrown at wgpu-hal/src/vulkan/command.rs:496
self.device.raw.cmd_write_timestamp(
self.active,
vk::PipelineStageFlags::BOTTOM_OF_PIPE,
set.raw,
index,
)
};
}
unsafe fn read_acceleration_structure_compact_size(
&mut self,
acceleration_structure: &super::AccelerationStructure,
buffer: &super::Buffer,
) {
let ray_tracing_functions = self
.device
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
let query_pool = acceleration_structure
.compacted_size_query
.as_ref()
.unwrap();
unsafe {
self.device
.raw
.cmd_reset_query_pool(self.active, *query_pool, 0, 1);
ray_tracing_functions
.acceleration_structure
.cmd_write_acceleration_structures_properties(
self.active,
&[acceleration_structure.raw],
vk::QueryType::ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,
*query_pool,
0,
);
self.device.raw.cmd_copy_query_pool_results(View on GitHub (pinned to 3e11ff59bf)
Solutions
- Request `Features::RAY_TRACING` in the DeviceDescriptor and confirm `Adapter::features()` advertises it before enabling
- Check `adapter.features().contains(Features::RAY_TRACING)` before creating a device or calling compact-size queries
- Ensure the Vulkan driver/GPU supports VK_KHR_acceleration_structure and VK_KHR_ray_query (RTX-class hardware, up-to-date driver)
- Gate ray-tracing code paths behind a capability check and provide a non-RT fallback
Example fix
// before: panics if RT not enabled
coder.read_acceleration_structure_compact_size(as_gpu, &query);
// after: guard on the feature
if device.features().contains(wgpu::Features::RAY_TRACING) {
encoder.read_acceleration_structure_compact_size(as_gpu, &query);
} Defensive patterns
Strategy: validation
Validate before calling
if !adapter.features().contains(wgpu::Features::RAY_TRACING) {
return Err(Error::RayTracingUnsupported);
} Type guard
fn supports_ray_tracing(features: wgpu::Features) -> bool {
features.contains(wgpu::Features::RAY_TRACING)
} Try / catch
// panic-based; avoid catching. Assert capability at device creation instead:
assert!(device.features().contains(wgpu::Features::RAY_TRACING),
"ray tracing required"); Prevention
- Always request Features::RAY_TRACING in required_features when using acceleration structures
- Check adapter.features() before device creation and pick a compatible adapter
- Gate RT code paths on a runtime capability flag
- Keep GPU drivers updated to get VK_KHR_acceleration_structure/ray_query
When it happens
Trigger: Calling `CommandEncoder::read_acceleration_structure_compact_size` (wgpu's ray-tracing API) on a device created without `Features::RAY_TRACING` (or where `extension_fns.ray_tracing` was None because extensions/functions were unavailable at device init).
Common situations: Using wgpu's experimental ray tracing API on a device/GPU/driver without VK_KHR_acceleration_structure or ray query support; forgetting to request `Features::RAY_TRACING` in `DeviceDescriptor`; running on adapters where the feature was filtered out by `adapter_features`.
Related errors
- Feature `EXPERIMENTAL_RAY_TRACING` not enabled
- Buffers are required to build acceleration structures
- This vulkan device is affected by [#8333](https://github.com
- vkFreeDescriptorSets error: {err}, please report this error
- {}
AI-assisted analysis of gfx-rs/wgpu@3e11ff59bf (2026-09-03).
Data as JSON: /api/errors/2d26be308a5c99c8.
Report an issue: GitHub.