gfx-rs/wgpu · error
Buffers are required to build acceleration structures
Error message
Buffers are required to build acceleration structures
What it means
When building acceleration structures (Vulkan ray tracing), wgpu-hal needs the device address of the source buffer holding the build geometry data. If the buffer reference is `None` at this point, the backend panics, because a build command without an underlying buffer cannot produce the required `vk::AccelerationStructureBuildGeometryInfoKHR` device addresses. In normal operation wgpu-core always supplies a buffer; hitting this indicates the internal invariant was broken.
Source
Thrown at wgpu-hal/src/vulkan/command.rs:587
const CAPACITY_OUTER: usize = 8;
const CAPACITY_INNER: usize = 1;
let descriptor_count = descriptor_count as usize;
let ray_tracing_functions = self
.device
.extension_fns
.ray_tracing
.as_ref()
.expect("Feature `RAY_TRACING` not enabled");
let get_device_address = |buffer: Option<&super::Buffer>| unsafe {
match buffer {
Some(buffer) => ray_tracing_functions
.buffer_device_address
.get_buffer_device_address(
&vk::BufferDeviceAddressInfo::default().buffer(buffer.raw),
),
None => panic!("Buffers are required to build acceleration structures"),
}
};
// storage to all the data required for cmd_build_acceleration_structures
let mut ranges_storage = smallvec::SmallVec::<
[smallvec::SmallVec<[vk::AccelerationStructureBuildRangeInfoKHR; CAPACITY_INNER]>;
CAPACITY_OUTER],
>::with_capacity(descriptor_count);
let mut geometries_storage = smallvec::SmallVec::<
[smallvec::SmallVec<[vk::AccelerationStructureGeometryKHR; CAPACITY_INNER]>;
CAPACITY_OUTER],
>::with_capacity(descriptor_count);
// pointers to all the data required for cmd_build_acceleration_structures
let mut geometry_infos = smallvec::SmallVec::<
[vk::AccelerationStructureBuildGeometryInfoKHR; CAPACITY_OUTER],
>::with_capacity(descriptor_count);
let mut ranges_ptrs = smallvec::SmallVec::<View on GitHub (pinned to 3e11ff59bf)
Solutions
- Ensure every acceleration structure build descriptor has a valid, live buffer before calling build_acceleration_structures
- Hold the buffer (keep the wgpu::Buffer/Arc alive) until the build has been submitted and completed
- Update wgpu — this may be an internal lifetime bug; report with a backtrace if reproducible with standard wgpu APIs
- If using wgpu-hal directly, pass Some(buffer) with correct usage ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY
Example fix
// before
encoder.build_acceleration_structures(&[BuildAccelerationStructureDescriptor { buffer: None, .. }]);
// after
let blas_buffer = device.create_buffer(&BufferDescriptor { usage: BufferUses::ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY, .. });
encoder.build_acceleration_structures(&[BuildAccelerationStructureDescriptor { buffer: Some(&blas_buffer), .. }]); Defensive patterns
Strategy: validation
Validate before calling
assert!(blas_buffer.is_some(), "acceleration structure build requires a buffer");
Try / catch
std::panic::catch_unwind(|| encoder.build_acceleration_structures(&descs))
Prevention
- Keep buffers alive until build submission completes
- Always attach a buffer to every BuildAccelerationStructureDescriptor
- Validate ray-tracing descriptors before encoding
When it happens
Trigger: Invoking `command_encoder.build_acceleration_structures` on the Vulkan backend where an entry in the build descriptors has no acceleration structure buffer backing it — e.g. a descriptor whose buffer was dropped, never set, or built by an internal caller passing `None` as the buffer.
Common situations: Using experimental ray-tracing APIs or internal wgpu-hal APIs directly; a wgpu-core/HAL desynchronization bug where buffer lifetime management dropped the buffer before the build; custom engines integrating wgpu-hal Vulkan ray tracing by hand.
Related errors
- Feature `RAY_TRACING` not enabled
- Feature `EXPERIMENTAL_RAY_TRACING` not enabled
- 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/b9827a105d323b2b.
Report an issue: GitHub.