Skip to content

Commit 934a03f

Browse files
committed
Implements Device::get_acceleration_structure_build_sizes().
1 parent 6a7b903 commit 934a03f

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

wgpu-hal/src/metal/device.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,9 +1574,34 @@ impl crate::Device for super::Device {
15741574

15751575
unsafe fn get_acceleration_structure_build_sizes(
15761576
&self,
1577-
_desc: &crate::GetAccelerationStructureBuildSizesDescriptor<super::Buffer>,
1577+
descriptor: &crate::GetAccelerationStructureBuildSizesDescriptor<super::Buffer>,
15781578
) -> crate::AccelerationStructureBuildSizes {
1579-
unimplemented!()
1579+
let acceleration_structure_descriptor =
1580+
conv::map_acceleration_structure_descriptor(descriptor.entries);
1581+
/* The Rust metal crate does not expose metal::MTLAccelerationStructureUsage yet
1582+
usage.set_extended_limits(false);
1583+
if descriptor.flags.contains(wgt::AccelerationStructureFlags::ALLOW_COMPACTION) {
1584+
}
1585+
if descriptor.flags.contains(wgt::AccelerationStructureFlags::ALLOW_UPDATE) {
1586+
usage.set_refit(true);
1587+
}
1588+
if descriptor.flags.contains(wgt::AccelerationStructureFlags::LOW_MEMORY) {
1589+
}
1590+
if descriptor.flags.contains(wgt::AccelerationStructureFlags::PREFER_FAST_BUILD) {
1591+
usage.set_prefer_fast_build(true);
1592+
}
1593+
if descriptor.flags.contains(wgt::AccelerationStructureFlags::PREFER_FAST_TRACE) {
1594+
}
1595+
descriptor.set_usage(usage);
1596+
*/
1597+
let device = self.shared.device.lock();
1598+
let info =
1599+
device.acceleration_structure_sizes_with_descriptor(&acceleration_structure_descriptor);
1600+
crate::AccelerationStructureBuildSizes {
1601+
acceleration_structure_size: info.acceleration_structure_size,
1602+
update_scratch_size: info.refit_scratch_buffer_size,
1603+
build_scratch_size: info.build_scratch_buffer_size,
1604+
}
15801605
}
15811606

15821607
unsafe fn get_acceleration_structure_device_address(

0 commit comments

Comments
 (0)