@@ -5,6 +5,10 @@ use alloc::{
55 vec:: Vec ,
66} ;
77use core:: ops:: Range ;
8+ use metal:: {
9+ MTLIndexType , MTLLoadAction , MTLPrimitiveType , MTLScissorRect , MTLSize , MTLStoreAction ,
10+ MTLViewport , MTLVisibilityResultMode , NSRange ,
11+ } ;
812
913// has to match `Temp::binding_sizes`
1014const WORD_SIZE : usize = 4 ;
@@ -15,9 +19,9 @@ impl Default for super::CommandState {
1519 blit : None ,
1620 render : None ,
1721 compute : None ,
18- raw_primitive_type : metal :: MTLPrimitiveType :: Point ,
22+ raw_primitive_type : MTLPrimitiveType :: Point ,
1923 index : None ,
20- raw_wg_size : metal :: MTLSize :: new ( 0 , 0 , 0 ) ,
24+ raw_wg_size : MTLSize :: new ( 0 , 0 , 0 ) ,
2125 stage_infos : Default :: default ( ) ,
2226 storage_buffer_length_map : Default :: default ( ) ,
2327 vertex_buffer_size_map : Default :: default ( ) ,
@@ -81,7 +85,7 @@ impl super::CommandEncoder {
8185 // As explained above, we need to do some write:
8286 // Conveniently, we have a buffer with every query set, that we can use for this for a dummy write,
8387 // since we know that it is going to be overwritten again on timer resolve and HAL doesn't define its state before that.
84- let raw_range = metal :: NSRange {
88+ let raw_range = NSRange {
8589 location : last_query. as_ref ( ) . unwrap ( ) . 1 as u64 * crate :: QUERY_SIZE ,
8690 length : 1 ,
8791 } ;
@@ -413,7 +417,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
413417 . as_ref ( )
414418 . unwrap ( )
415419 . set_visibility_result_mode (
416- metal :: MTLVisibilityResultMode :: Boolean ,
420+ MTLVisibilityResultMode :: Boolean ,
417421 index as u64 * crate :: QUERY_SIZE ,
418422 ) ;
419423 }
@@ -427,7 +431,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
427431 . render
428432 . as_ref ( )
429433 . unwrap ( )
430- . set_visibility_result_mode ( metal :: MTLVisibilityResultMode :: Disabled , 0 ) ;
434+ . set_visibility_result_mode ( MTLVisibilityResultMode :: Disabled , 0 ) ;
431435 }
432436 _ => { }
433437 }
@@ -473,7 +477,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
473477
474478 unsafe fn reset_queries ( & mut self , set : & super :: QuerySet , range : Range < u32 > ) {
475479 let encoder = self . enter_blit ( ) ;
476- let raw_range = metal :: NSRange {
480+ let raw_range = NSRange {
477481 location : range. start as u64 * crate :: QUERY_SIZE ,
478482 length : ( range. end - range. start ) as u64 * crate :: QUERY_SIZE ,
479483 } ;
@@ -503,7 +507,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
503507 wgt:: QueryType :: Timestamp => {
504508 encoder. resolve_counters (
505509 set. counter_sample_buffer . as_ref ( ) . unwrap ( ) ,
506- metal :: NSRange :: new ( range. start as u64 , ( range. end - range. start ) as u64 ) ,
510+ NSRange :: new ( range. start as u64 , ( range. end - range. start ) as u64 ) ,
507511 & buffer. raw ,
508512 offset,
509513 ) ;
@@ -540,10 +544,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
540544 at_descriptor. set_resolve_texture ( Some ( & resolve. view . raw ) ) ;
541545 }
542546 let load_action = if at. ops . contains ( crate :: AttachmentOps :: LOAD ) {
543- metal :: MTLLoadAction :: Load
547+ MTLLoadAction :: Load
544548 } else {
545549 at_descriptor. set_clear_color ( conv:: map_clear_color ( & at. clear_value ) ) ;
546- metal :: MTLLoadAction :: Clear
550+ MTLLoadAction :: Clear
547551 } ;
548552 let store_action = conv:: map_store_action (
549553 at. ops . contains ( crate :: AttachmentOps :: STORE ) ,
@@ -560,15 +564,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
560564 at_descriptor. set_texture ( Some ( & at. target . view . raw ) ) ;
561565
562566 let load_action = if at. depth_ops . contains ( crate :: AttachmentOps :: LOAD ) {
563- metal :: MTLLoadAction :: Load
567+ MTLLoadAction :: Load
564568 } else {
565569 at_descriptor. set_clear_depth ( at. clear_value . 0 as f64 ) ;
566- metal :: MTLLoadAction :: Clear
570+ MTLLoadAction :: Clear
567571 } ;
568572 let store_action = if at. depth_ops . contains ( crate :: AttachmentOps :: STORE ) {
569- metal :: MTLStoreAction :: Store
573+ MTLStoreAction :: Store
570574 } else {
571- metal :: MTLStoreAction :: DontCare
575+ MTLStoreAction :: DontCare
572576 } ;
573577 at_descriptor. set_load_action ( load_action) ;
574578 at_descriptor. set_store_action ( store_action) ;
@@ -583,15 +587,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
583587 at_descriptor. set_texture ( Some ( & at. target . view . raw ) ) ;
584588
585589 let load_action = if at. stencil_ops . contains ( crate :: AttachmentOps :: LOAD ) {
586- metal :: MTLLoadAction :: Load
590+ MTLLoadAction :: Load
587591 } else {
588592 at_descriptor. set_clear_stencil ( at. clear_value . 1 ) ;
589- metal :: MTLLoadAction :: Clear
593+ MTLLoadAction :: Clear
590594 } ;
591595 let store_action = if at. stencil_ops . contains ( crate :: AttachmentOps :: STORE ) {
592- metal :: MTLStoreAction :: Store
596+ MTLStoreAction :: Store
593597 } else {
594- metal :: MTLStoreAction :: DontCare
598+ MTLStoreAction :: DontCare
595599 } ;
596600 at_descriptor. set_load_action ( load_action) ;
597601 at_descriptor. set_store_action ( store_action) ;
@@ -953,8 +957,8 @@ impl crate::CommandEncoder for super::CommandEncoder {
953957 format : wgt:: IndexFormat ,
954958 ) {
955959 let ( stride, raw_type) = match format {
956- wgt:: IndexFormat :: Uint16 => ( 2 , metal :: MTLIndexType :: UInt16 ) ,
957- wgt:: IndexFormat :: Uint32 => ( 4 , metal :: MTLIndexType :: UInt32 ) ,
960+ wgt:: IndexFormat :: Uint16 => ( 2 , MTLIndexType :: UInt16 ) ,
961+ wgt:: IndexFormat :: Uint32 => ( 4 , MTLIndexType :: UInt32 ) ,
958962 } ;
959963 self . state . index = Some ( super :: IndexState {
960964 buffer_ptr : AsNative :: from ( binding. buffer . raw . as_ref ( ) ) ,
@@ -1002,7 +1006,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10021006 depth_range. end
10031007 } ;
10041008 let encoder = self . state . render . as_ref ( ) . unwrap ( ) ;
1005- encoder. set_viewport ( metal :: MTLViewport {
1009+ encoder. set_viewport ( MTLViewport {
10061010 originX : rect. x as _ ,
10071011 originY : rect. y as _ ,
10081012 width : rect. w as _ ,
@@ -1013,7 +1017,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
10131017 }
10141018 unsafe fn set_scissor_rect ( & mut self , rect : & crate :: Rect < u32 > ) {
10151019 //TODO: support empty scissors by modifying the viewport
1016- let scissor = metal :: MTLScissorRect {
1020+ let scissor = MTLScissorRect {
10171021 x : rect. x as _ ,
10181022 y : rect. y as _ ,
10191023 width : rect. w as _ ,
@@ -1301,7 +1305,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
13011305 unsafe fn dispatch ( & mut self , count : [ u32 ; 3 ] ) {
13021306 if count[ 0 ] > 0 && count[ 1 ] > 0 && count[ 2 ] > 0 {
13031307 let encoder = self . state . compute . as_ref ( ) . unwrap ( ) ;
1304- let raw_count = metal :: MTLSize {
1308+ let raw_count = MTLSize {
13051309 width : count[ 0 ] as u64 ,
13061310 height : count[ 1 ] as u64 ,
13071311 depth : count[ 2 ] as u64 ,
0 commit comments