{"record":{"id":"b9827a105d323b2b","repo":"gfx-rs/wgpu","slug":"buffers-are-required-to-build-acceleration-structu","errorCode":null,"errorMessage":"Buffers are required to build acceleration structures","messagePattern":"Buffers are required to build acceleration structures","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"wgpu-hal/src/vulkan/command.rs","lineNumber":587,"sourceCode":"        const CAPACITY_OUTER: usize = 8;\n        const CAPACITY_INNER: usize = 1;\n        let descriptor_count = descriptor_count as usize;\n\n        let ray_tracing_functions = self\n            .device\n            .extension_fns\n            .ray_tracing\n            .as_ref()\n            .expect(\"Feature `RAY_TRACING` not enabled\");\n\n        let get_device_address = |buffer: Option<&super::Buffer>| unsafe {\n            match buffer {\n                Some(buffer) => ray_tracing_functions\n                    .buffer_device_address\n                    .get_buffer_device_address(\n                        &vk::BufferDeviceAddressInfo::default().buffer(buffer.raw),\n                    ),\n                None => panic!(\"Buffers are required to build acceleration structures\"),\n            }\n        };\n\n        // storage to all the data required for cmd_build_acceleration_structures\n        let mut ranges_storage = smallvec::SmallVec::<\n            [smallvec::SmallVec<[vk::AccelerationStructureBuildRangeInfoKHR; CAPACITY_INNER]>;\n                CAPACITY_OUTER],\n        >::with_capacity(descriptor_count);\n        let mut geometries_storage = smallvec::SmallVec::<\n            [smallvec::SmallVec<[vk::AccelerationStructureGeometryKHR; CAPACITY_INNER]>;\n                CAPACITY_OUTER],\n        >::with_capacity(descriptor_count);\n\n        // pointers to all the data required for cmd_build_acceleration_structures\n        let mut geometry_infos = smallvec::SmallVec::<\n            [vk::AccelerationStructureBuildGeometryInfoKHR; CAPACITY_OUTER],\n        >::with_capacity(descriptor_count);\n        let mut ranges_ptrs = smallvec::SmallVec::<","sourceCodeStart":569,"sourceCodeEnd":605,"githubUrl":"https://github.com/gfx-rs/wgpu/blob/3e11ff59bf3f9795d285ecc045014089640d7248/wgpu-hal/src/vulkan/command.rs#L569-L605","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nencoder.build_acceleration_structures(&[BuildAccelerationStructureDescriptor { buffer: None, .. }]);\n// after\nlet blas_buffer = device.create_buffer(&BufferDescriptor { usage: BufferUses::ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY, .. });\nencoder.build_acceleration_structures(&[BuildAccelerationStructureDescriptor { buffer: Some(&blas_buffer), .. }]);","handlingStrategy":"validation","validationCode":"assert!(blas_buffer.is_some(), \"acceleration structure build requires a buffer\");","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| encoder.build_acceleration_structures(&descs))","preventionTips":["Keep buffers alive until build submission completes","Always attach a buffer to every BuildAccelerationStructureDescriptor","Validate ray-tracing descriptors before encoding"],"tags":["panic","vulkan","ray-tracing","acceleration-structure","buffer"],"backgroundTag":"missing-required-buffer","analyzedSha":"3e11ff59bf3f9795d285ecc045014089640d7248","analyzedAt":"2026-09-03T01:43:21.459Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}