@@ -2,6 +2,7 @@ use alloc::{borrow::ToOwned as _, sync::Arc, vec::Vec};
22use core:: { ptr:: NonNull , sync:: atomic} ;
33use std:: { thread, time} ;
44
5+ use bytemuck:: TransparentWrapper ;
56use parking_lot:: Mutex ;
67
78use super :: { conv, PassthroughShader } ;
@@ -1613,8 +1614,39 @@ impl crate::Device for super::Device {
16131614 // self.counters.acceleration_structures.sub(1);
16141615 }
16151616
1616- fn tlas_instance_to_bytes ( & self , _instance : TlasInstance ) -> Vec < u8 > {
1617- unimplemented ! ( )
1617+ fn tlas_instance_to_bytes ( & self , instance : TlasInstance ) -> Vec < u8 > {
1618+ let temp = metal:: MTLAccelerationStructureInstanceDescriptor {
1619+ transformation_matrix : [
1620+ [
1621+ instance. transform [ 0 ] ,
1622+ instance. transform [ 4 ] ,
1623+ instance. transform [ 8 ] ,
1624+ ] ,
1625+ [
1626+ instance. transform [ 1 ] ,
1627+ instance. transform [ 5 ] ,
1628+ instance. transform [ 9 ] ,
1629+ ] ,
1630+ [
1631+ instance. transform [ 2 ] ,
1632+ instance. transform [ 6 ] ,
1633+ instance. transform [ 10 ] ,
1634+ ] ,
1635+ [
1636+ instance. transform [ 3 ] ,
1637+ instance. transform [ 7 ] ,
1638+ instance. transform [ 11 ] ,
1639+ ] ,
1640+ ] ,
1641+ options : metal:: MTLAccelerationStructureInstanceOptions :: None ,
1642+ mask : ( instance. custom_data << 8 ) | instance. mask as u32 ,
1643+ intersection_function_table_offset : 0 ,
1644+ acceleration_structure_index : instance. blas_address as u32 ,
1645+ } ;
1646+
1647+ wgt:: bytemuck_wrapper!( unsafe struct Desc ( metal:: MTLAccelerationStructureInstanceDescriptor ) ) ;
1648+
1649+ bytemuck:: bytes_of ( & Desc :: wrap ( temp) ) . to_vec ( )
16181650 }
16191651
16201652 fn get_internal_counters ( & self ) -> wgt:: HalCounters {
0 commit comments