@@ -564,6 +564,9 @@ impl crate::Device for super::Device {
564564 if let Some ( label) = desc. label {
565565 descriptor. set_label ( label) ;
566566 }
567+ if self . features . contains ( wgt:: Features :: TEXTURE_BINDING_ARRAY ) {
568+ descriptor. set_support_argument_buffers ( true ) ;
569+ }
567570 let raw = self . shared . device . lock ( ) . new_sampler ( & descriptor) ;
568571
569572 self . counters . samplers . add ( 1 ) ;
@@ -810,8 +813,8 @@ impl crate::Device for super::Device {
810813 } ) ;
811814 for ( entry, layout) in layout_and_entry_iter {
812815 // Bindless path
813- if let Some ( count ) = layout. count {
814- let count = count . get ( ) ;
816+ if layout. count . is_some ( ) {
817+ let count = entry . count ;
815818
816819 let stages = conv:: map_render_stages ( layout. visibility ) ;
817820 let uses = conv:: map_resource_usage ( & layout. ty ) ;
@@ -823,7 +826,9 @@ impl crate::Device for super::Device {
823826 | metal:: MTLResourceOptions :: StorageModeShared ,
824827 ) ;
825828
826- let contents: * mut metal:: MTLResourceID = buffer. contents ( ) . cast ( ) ;
829+ let contents: & mut [ metal:: MTLResourceID ] = unsafe {
830+ std:: slice:: from_raw_parts_mut ( buffer. contents ( ) . cast ( ) , count as usize )
831+ } ;
827832
828833 match layout. ty {
829834 wgt:: BindingType :: Texture { .. }
@@ -833,9 +838,7 @@ impl crate::Device for super::Device {
833838 let textures = & desc. textures [ start..end] ;
834839
835840 for ( idx, tex) in textures. iter ( ) . enumerate ( ) {
836- unsafe {
837- contents. add ( idx) . write ( tex. view . raw . gpu_resource_id ( ) )
838- }
841+ contents[ idx] = tex. view . raw . gpu_resource_id ( ) ;
839842
840843 let use_info = bg
841844 . resources_to_use
@@ -852,13 +855,8 @@ impl crate::Device for super::Device {
852855 let end = start + count as usize ;
853856 let samplers = & desc. samplers [ start..end] ;
854857
855- dbg ! ( samplers) ;
856-
857858 for ( idx, & sampler) in samplers. iter ( ) . enumerate ( ) {
858- dbg ! ( sampler) ;
859- unsafe {
860- contents. add ( idx) . write ( dbg ! ( sampler. raw. gpu_resource_id( ) ) )
861- }
859+ contents[ idx] = sampler. raw . gpu_resource_id ( ) ;
862860 // Samplers aren't resources like buffers and textures, so don't
863861 // need to be passed to useResource
864862 }
0 commit comments