@@ -5,6 +5,10 @@ use alloc::{
5
5
vec:: Vec ,
6
6
} ;
7
7
use core:: ops:: Range ;
8
+ use metal:: {
9
+ MTLIndexType , MTLLoadAction , MTLPrimitiveType , MTLScissorRect , MTLSize , MTLStoreAction ,
10
+ MTLViewport , MTLVisibilityResultMode , NSRange ,
11
+ } ;
8
12
9
13
// has to match `Temp::binding_sizes`
10
14
const WORD_SIZE : usize = 4 ;
@@ -15,9 +19,9 @@ impl Default for super::CommandState {
15
19
blit : None ,
16
20
render : None ,
17
21
compute : None ,
18
- raw_primitive_type : metal :: MTLPrimitiveType :: Point ,
22
+ raw_primitive_type : MTLPrimitiveType :: Point ,
19
23
index : None ,
20
- raw_wg_size : metal :: MTLSize :: new ( 0 , 0 , 0 ) ,
24
+ raw_wg_size : MTLSize :: new ( 0 , 0 , 0 ) ,
21
25
stage_infos : Default :: default ( ) ,
22
26
storage_buffer_length_map : Default :: default ( ) ,
23
27
vertex_buffer_size_map : Default :: default ( ) ,
@@ -81,7 +85,7 @@ impl super::CommandEncoder {
81
85
// As explained above, we need to do some write:
82
86
// Conveniently, we have a buffer with every query set, that we can use for this for a dummy write,
83
87
// 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 {
85
89
location : last_query. as_ref ( ) . unwrap ( ) . 1 as u64 * crate :: QUERY_SIZE ,
86
90
length : 1 ,
87
91
} ;
@@ -413,7 +417,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
413
417
. as_ref ( )
414
418
. unwrap ( )
415
419
. set_visibility_result_mode (
416
- metal :: MTLVisibilityResultMode :: Boolean ,
420
+ MTLVisibilityResultMode :: Boolean ,
417
421
index as u64 * crate :: QUERY_SIZE ,
418
422
) ;
419
423
}
@@ -427,7 +431,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
427
431
. render
428
432
. as_ref ( )
429
433
. unwrap ( )
430
- . set_visibility_result_mode ( metal :: MTLVisibilityResultMode :: Disabled , 0 ) ;
434
+ . set_visibility_result_mode ( MTLVisibilityResultMode :: Disabled , 0 ) ;
431
435
}
432
436
_ => { }
433
437
}
@@ -473,7 +477,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
473
477
474
478
unsafe fn reset_queries ( & mut self , set : & super :: QuerySet , range : Range < u32 > ) {
475
479
let encoder = self . enter_blit ( ) ;
476
- let raw_range = metal :: NSRange {
480
+ let raw_range = NSRange {
477
481
location : range. start as u64 * crate :: QUERY_SIZE ,
478
482
length : ( range. end - range. start ) as u64 * crate :: QUERY_SIZE ,
479
483
} ;
@@ -503,7 +507,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
503
507
wgt:: QueryType :: Timestamp => {
504
508
encoder. resolve_counters (
505
509
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 ) ,
507
511
& buffer. raw ,
508
512
offset,
509
513
) ;
@@ -537,10 +541,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
537
541
at_descriptor. set_resolve_texture ( Some ( & resolve. view . raw ) ) ;
538
542
}
539
543
let load_action = if at. ops . contains ( crate :: AttachmentOps :: LOAD ) {
540
- metal :: MTLLoadAction :: Load
544
+ MTLLoadAction :: Load
541
545
} else {
542
546
at_descriptor. set_clear_color ( conv:: map_clear_color ( & at. clear_value ) ) ;
543
- metal :: MTLLoadAction :: Clear
547
+ MTLLoadAction :: Clear
544
548
} ;
545
549
let store_action = conv:: map_store_action (
546
550
at. ops . contains ( crate :: AttachmentOps :: STORE ) ,
@@ -557,15 +561,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
557
561
at_descriptor. set_texture ( Some ( & at. target . view . raw ) ) ;
558
562
559
563
let load_action = if at. depth_ops . contains ( crate :: AttachmentOps :: LOAD ) {
560
- metal :: MTLLoadAction :: Load
564
+ MTLLoadAction :: Load
561
565
} else {
562
566
at_descriptor. set_clear_depth ( at. clear_value . 0 as f64 ) ;
563
- metal :: MTLLoadAction :: Clear
567
+ MTLLoadAction :: Clear
564
568
} ;
565
569
let store_action = if at. depth_ops . contains ( crate :: AttachmentOps :: STORE ) {
566
- metal :: MTLStoreAction :: Store
570
+ MTLStoreAction :: Store
567
571
} else {
568
- metal :: MTLStoreAction :: DontCare
572
+ MTLStoreAction :: DontCare
569
573
} ;
570
574
at_descriptor. set_load_action ( load_action) ;
571
575
at_descriptor. set_store_action ( store_action) ;
@@ -580,15 +584,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
580
584
at_descriptor. set_texture ( Some ( & at. target . view . raw ) ) ;
581
585
582
586
let load_action = if at. stencil_ops . contains ( crate :: AttachmentOps :: LOAD ) {
583
- metal :: MTLLoadAction :: Load
587
+ MTLLoadAction :: Load
584
588
} else {
585
589
at_descriptor. set_clear_stencil ( at. clear_value . 1 ) ;
586
- metal :: MTLLoadAction :: Clear
590
+ MTLLoadAction :: Clear
587
591
} ;
588
592
let store_action = if at. stencil_ops . contains ( crate :: AttachmentOps :: STORE ) {
589
- metal :: MTLStoreAction :: Store
593
+ MTLStoreAction :: Store
590
594
} else {
591
- metal :: MTLStoreAction :: DontCare
595
+ MTLStoreAction :: DontCare
592
596
} ;
593
597
at_descriptor. set_load_action ( load_action) ;
594
598
at_descriptor. set_store_action ( store_action) ;
@@ -948,8 +952,8 @@ impl crate::CommandEncoder for super::CommandEncoder {
948
952
format : wgt:: IndexFormat ,
949
953
) {
950
954
let ( stride, raw_type) = match format {
951
- wgt:: IndexFormat :: Uint16 => ( 2 , metal :: MTLIndexType :: UInt16 ) ,
952
- wgt:: IndexFormat :: Uint32 => ( 4 , metal :: MTLIndexType :: UInt32 ) ,
955
+ wgt:: IndexFormat :: Uint16 => ( 2 , MTLIndexType :: UInt16 ) ,
956
+ wgt:: IndexFormat :: Uint32 => ( 4 , MTLIndexType :: UInt32 ) ,
953
957
} ;
954
958
self . state . index = Some ( super :: IndexState {
955
959
buffer_ptr : AsNative :: from ( binding. buffer . raw . as_ref ( ) ) ,
@@ -997,7 +1001,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
997
1001
depth_range. end
998
1002
} ;
999
1003
let encoder = self . state . render . as_ref ( ) . unwrap ( ) ;
1000
- encoder. set_viewport ( metal :: MTLViewport {
1004
+ encoder. set_viewport ( MTLViewport {
1001
1005
originX : rect. x as _ ,
1002
1006
originY : rect. y as _ ,
1003
1007
width : rect. w as _ ,
@@ -1008,7 +1012,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
1008
1012
}
1009
1013
unsafe fn set_scissor_rect ( & mut self , rect : & crate :: Rect < u32 > ) {
1010
1014
//TODO: support empty scissors by modifying the viewport
1011
- let scissor = metal :: MTLScissorRect {
1015
+ let scissor = MTLScissorRect {
1012
1016
x : rect. x as _ ,
1013
1017
y : rect. y as _ ,
1014
1018
width : rect. w as _ ,
@@ -1296,7 +1300,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
1296
1300
unsafe fn dispatch ( & mut self , count : [ u32 ; 3 ] ) {
1297
1301
if count[ 0 ] > 0 && count[ 1 ] > 0 && count[ 2 ] > 0 {
1298
1302
let encoder = self . state . compute . as_ref ( ) . unwrap ( ) ;
1299
- let raw_count = metal :: MTLSize {
1303
+ let raw_count = MTLSize {
1300
1304
width : count[ 0 ] as u64 ,
1301
1305
height : count[ 1 ] as u64 ,
1302
1306
depth : count[ 2 ] as u64 ,
0 commit comments