@@ -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
) ;
@@ -540,10 +544,10 @@ impl crate::CommandEncoder for super::CommandEncoder {
540
544
at_descriptor. set_resolve_texture ( Some ( & resolve. view . raw ) ) ;
541
545
}
542
546
let load_action = if at. ops . contains ( crate :: AttachmentOps :: LOAD ) {
543
- metal :: MTLLoadAction :: Load
547
+ MTLLoadAction :: Load
544
548
} else {
545
549
at_descriptor. set_clear_color ( conv:: map_clear_color ( & at. clear_value ) ) ;
546
- metal :: MTLLoadAction :: Clear
550
+ MTLLoadAction :: Clear
547
551
} ;
548
552
let store_action = conv:: map_store_action (
549
553
at. ops . contains ( crate :: AttachmentOps :: STORE ) ,
@@ -560,15 +564,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
560
564
at_descriptor. set_texture ( Some ( & at. target . view . raw ) ) ;
561
565
562
566
let load_action = if at. depth_ops . contains ( crate :: AttachmentOps :: LOAD ) {
563
- metal :: MTLLoadAction :: Load
567
+ MTLLoadAction :: Load
564
568
} else {
565
569
at_descriptor. set_clear_depth ( at. clear_value . 0 as f64 ) ;
566
- metal :: MTLLoadAction :: Clear
570
+ MTLLoadAction :: Clear
567
571
} ;
568
572
let store_action = if at. depth_ops . contains ( crate :: AttachmentOps :: STORE ) {
569
- metal :: MTLStoreAction :: Store
573
+ MTLStoreAction :: Store
570
574
} else {
571
- metal :: MTLStoreAction :: DontCare
575
+ MTLStoreAction :: DontCare
572
576
} ;
573
577
at_descriptor. set_load_action ( load_action) ;
574
578
at_descriptor. set_store_action ( store_action) ;
@@ -583,15 +587,15 @@ impl crate::CommandEncoder for super::CommandEncoder {
583
587
at_descriptor. set_texture ( Some ( & at. target . view . raw ) ) ;
584
588
585
589
let load_action = if at. stencil_ops . contains ( crate :: AttachmentOps :: LOAD ) {
586
- metal :: MTLLoadAction :: Load
590
+ MTLLoadAction :: Load
587
591
} else {
588
592
at_descriptor. set_clear_stencil ( at. clear_value . 1 ) ;
589
- metal :: MTLLoadAction :: Clear
593
+ MTLLoadAction :: Clear
590
594
} ;
591
595
let store_action = if at. stencil_ops . contains ( crate :: AttachmentOps :: STORE ) {
592
- metal :: MTLStoreAction :: Store
596
+ MTLStoreAction :: Store
593
597
} else {
594
- metal :: MTLStoreAction :: DontCare
598
+ MTLStoreAction :: DontCare
595
599
} ;
596
600
at_descriptor. set_load_action ( load_action) ;
597
601
at_descriptor. set_store_action ( store_action) ;
@@ -953,8 +957,8 @@ impl crate::CommandEncoder for super::CommandEncoder {
953
957
format : wgt:: IndexFormat ,
954
958
) {
955
959
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 ) ,
958
962
} ;
959
963
self . state . index = Some ( super :: IndexState {
960
964
buffer_ptr : AsNative :: from ( binding. buffer . raw . as_ref ( ) ) ,
@@ -1002,7 +1006,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
1002
1006
depth_range. end
1003
1007
} ;
1004
1008
let encoder = self . state . render . as_ref ( ) . unwrap ( ) ;
1005
- encoder. set_viewport ( metal :: MTLViewport {
1009
+ encoder. set_viewport ( MTLViewport {
1006
1010
originX : rect. x as _ ,
1007
1011
originY : rect. y as _ ,
1008
1012
width : rect. w as _ ,
@@ -1013,7 +1017,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
1013
1017
}
1014
1018
unsafe fn set_scissor_rect ( & mut self , rect : & crate :: Rect < u32 > ) {
1015
1019
//TODO: support empty scissors by modifying the viewport
1016
- let scissor = metal :: MTLScissorRect {
1020
+ let scissor = MTLScissorRect {
1017
1021
x : rect. x as _ ,
1018
1022
y : rect. y as _ ,
1019
1023
width : rect. w as _ ,
@@ -1301,7 +1305,7 @@ impl crate::CommandEncoder for super::CommandEncoder {
1301
1305
unsafe fn dispatch ( & mut self , count : [ u32 ; 3 ] ) {
1302
1306
if count[ 0 ] > 0 && count[ 1 ] > 0 && count[ 2 ] > 0 {
1303
1307
let encoder = self . state . compute . as_ref ( ) . unwrap ( ) ;
1304
- let raw_count = metal :: MTLSize {
1308
+ let raw_count = MTLSize {
1305
1309
width : count[ 0 ] as u64 ,
1306
1310
height : count[ 1 ] as u64 ,
1307
1311
depth : count[ 2 ] as u64 ,
0 commit comments