@@ -452,12 +452,16 @@ impl super::PrivateCapabilities {
452
452
major : usize ,
453
453
minor : usize ,
454
454
patch : usize ,
455
- is_mac : bool ,
456
455
}
457
456
458
457
impl NSOperatingSystemVersion {
459
- fn at_least ( & self , mac_version : ( usize , usize ) , ios_version : ( usize , usize ) ) -> bool {
460
- if self . is_mac {
458
+ fn at_least (
459
+ & self ,
460
+ mac_version : ( usize , usize ) ,
461
+ ios_version : ( usize , usize ) ,
462
+ is_mac : bool ,
463
+ ) -> bool {
464
+ if is_mac {
461
465
self . major > mac_version. 0
462
466
|| ( self . major == mac_version. 0 && self . minor >= mac_version. 1 )
463
467
} else {
@@ -467,15 +471,14 @@ impl super::PrivateCapabilities {
467
471
}
468
472
}
469
473
470
- let mut version: NSOperatingSystemVersion = unsafe {
474
+ let version: NSOperatingSystemVersion = unsafe {
471
475
let process_info: * mut objc:: runtime:: Object =
472
476
msg_send ! [ class!( NSProcessInfo ) , processInfo] ;
473
477
msg_send ! [ process_info, operatingSystemVersion]
474
478
} ;
475
479
476
480
let os_is_mac = device. supports_feature_set ( MTLFeatureSet :: macOS_GPUFamily1_v1) ;
477
- version. is_mac = os_is_mac;
478
- let family_check = version. at_least ( ( 10 , 15 ) , ( 13 , 0 ) ) ;
481
+ let family_check = version. at_least ( ( 10 , 15 ) , ( 13 , 0 ) , os_is_mac) ;
479
482
480
483
let mut sample_count_mask = crate :: TextureFormatCapabilities :: MULTISAMPLE_X4 ; // 1 and 4 samples are supported on all devices
481
484
if device. supports_texture_sample_count ( 2 ) {
@@ -488,9 +491,9 @@ impl super::PrivateCapabilities {
488
491
sample_count_mask |= crate :: TextureFormatCapabilities :: MULTISAMPLE_X16 ;
489
492
}
490
493
491
- let rw_texture_tier = if version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) ) {
494
+ let rw_texture_tier = if version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) , os_is_mac ) {
492
495
device. read_write_texture_support ( )
493
- } else if version. at_least ( ( 10 , 12 ) , OS_NOT_SUPPORT ) {
496
+ } else if version. at_least ( ( 10 , 12 ) , OS_NOT_SUPPORT , os_is_mac ) {
494
497
if Self :: supports_any ( device, & [ MTLFeatureSet :: macOS_ReadWriteTextureTier2] ) {
495
498
MTLReadWriteTextureTier :: Tier2
496
499
} else {
@@ -502,25 +505,25 @@ impl super::PrivateCapabilities {
502
505
503
506
Self {
504
507
family_check,
505
- msl_version : if version. at_least ( ( 12 , 0 ) , ( 15 , 0 ) ) {
508
+ msl_version : if version. at_least ( ( 12 , 0 ) , ( 15 , 0 ) , os_is_mac ) {
506
509
MTLLanguageVersion :: V2_4
507
- } else if version. at_least ( ( 11 , 0 ) , ( 14 , 0 ) ) {
510
+ } else if version. at_least ( ( 11 , 0 ) , ( 14 , 0 ) , os_is_mac ) {
508
511
MTLLanguageVersion :: V2_3
509
- } else if version. at_least ( ( 10 , 15 ) , ( 13 , 0 ) ) {
512
+ } else if version. at_least ( ( 10 , 15 ) , ( 13 , 0 ) , os_is_mac ) {
510
513
MTLLanguageVersion :: V2_2
511
- } else if version. at_least ( ( 10 , 14 ) , ( 12 , 0 ) ) {
514
+ } else if version. at_least ( ( 10 , 14 ) , ( 12 , 0 ) , os_is_mac ) {
512
515
MTLLanguageVersion :: V2_1
513
- } else if version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) ) {
516
+ } else if version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) , os_is_mac ) {
514
517
MTLLanguageVersion :: V2_0
515
- } else if version. at_least ( ( 10 , 12 ) , ( 10 , 0 ) ) {
518
+ } else if version. at_least ( ( 10 , 12 ) , ( 10 , 0 ) , os_is_mac ) {
516
519
MTLLanguageVersion :: V1_2
517
- } else if version. at_least ( ( 10 , 11 ) , ( 9 , 0 ) ) {
520
+ } else if version. at_least ( ( 10 , 11 ) , ( 9 , 0 ) , os_is_mac ) {
518
521
MTLLanguageVersion :: V1_1
519
522
} else {
520
523
MTLLanguageVersion :: V1_0
521
524
} ,
522
525
// macOS 10.11 doesn't support read-write resources
523
- fragment_rw_storage : version. at_least ( ( 10 , 12 ) , ( 8 , 0 ) ) ,
526
+ fragment_rw_storage : version. at_least ( ( 10 , 12 ) , ( 8 , 0 ) , os_is_mac ) ,
524
527
read_write_texture_tier : rw_texture_tier,
525
528
msaa_desktop : os_is_mac,
526
529
msaa_apple3 : if family_check {
@@ -537,7 +540,7 @@ impl super::PrivateCapabilities {
537
540
MUTABLE_COMPARISON_SAMPLER_SUPPORT ,
538
541
) ,
539
542
sampler_clamp_to_border : Self :: supports_any ( device, SAMPLER_CLAMP_TO_BORDER_SUPPORT ) ,
540
- sampler_lod_average : { version. at_least ( ( 11 , 0 ) , ( 9 , 0 ) ) } ,
543
+ sampler_lod_average : { version. at_least ( ( 11 , 0 ) , ( 9 , 0 ) , os_is_mac ) } ,
541
544
base_instance : Self :: supports_any ( device, BASE_INSTANCE_SUPPORT ) ,
542
545
base_vertex_instance_drawing : Self :: supports_any ( device, BASE_VERTEX_INSTANCE_SUPPORT ) ,
543
546
dual_source_blending : Self :: supports_any ( device, DUAL_SOURCE_BLEND_SUPPORT ) ,
@@ -626,7 +629,7 @@ impl super::PrivateCapabilities {
626
629
} ,
627
630
max_samplers_per_stage : 16 ,
628
631
buffer_alignment : if os_is_mac { 256 } else { 64 } ,
629
- max_buffer_size : if version. at_least ( ( 10 , 14 ) , ( 12 , 0 ) ) {
632
+ max_buffer_size : if version. at_least ( ( 10 , 14 ) , ( 12 , 0 ) , os_is_mac ) {
630
633
// maxBufferLength available on macOS 10.14+ and iOS 12.0+
631
634
let buffer_size: mtl:: NSInteger =
632
635
unsafe { msg_send ! [ device. as_ref( ) , maxBufferLength] } ;
@@ -710,10 +713,10 @@ impl super::PrivateCapabilities {
710
713
supports_binary_archives : family_check
711
714
&& ( device. supports_family ( MTLGPUFamily :: Apple3 )
712
715
|| device. supports_family ( MTLGPUFamily :: Mac1 ) ) ,
713
- supports_capture_manager : version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) ) ,
714
- can_set_maximum_drawables_count : version. at_least ( ( 10 , 14 ) , ( 11 , 2 ) ) ,
715
- can_set_display_sync : version. at_least ( ( 10 , 13 ) , OS_NOT_SUPPORT ) ,
716
- can_set_next_drawable_timeout : version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) ) ,
716
+ supports_capture_manager : version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) , os_is_mac ) ,
717
+ can_set_maximum_drawables_count : version. at_least ( ( 10 , 14 ) , ( 11 , 2 ) , os_is_mac ) ,
718
+ can_set_display_sync : version. at_least ( ( 10 , 13 ) , OS_NOT_SUPPORT , os_is_mac ) ,
719
+ can_set_next_drawable_timeout : version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) , os_is_mac ) ,
717
720
supports_arrays_of_textures : Self :: supports_any (
718
721
device,
719
722
& [
@@ -726,14 +729,14 @@ impl super::PrivateCapabilities {
726
729
&& ( device. supports_family ( MTLGPUFamily :: Apple6 )
727
730
|| device. supports_family ( MTLGPUFamily :: Mac1 )
728
731
|| device. supports_family ( MTLGPUFamily :: MacCatalyst1 ) ) ,
729
- supports_mutability : version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) ) ,
732
+ supports_mutability : version. at_least ( ( 10 , 13 ) , ( 11 , 0 ) , os_is_mac ) ,
730
733
//Depth clipping is supported on all macOS GPU families and iOS family 4 and later
731
734
supports_depth_clip_control : os_is_mac
732
735
|| device. supports_feature_set ( MTLFeatureSet :: iOS_GPUFamily4_v1) ,
733
- supports_preserve_invariance : version. at_least ( ( 11 , 0 ) , ( 13 , 0 ) ) ,
736
+ supports_preserve_invariance : version. at_least ( ( 11 , 0 ) , ( 13 , 0 ) , os_is_mac ) ,
734
737
// Metal 2.2 on mac, 2.3 on iOS.
735
- supports_shader_primitive_index : version. at_least ( ( 10 , 15 ) , ( 14 , 0 ) ) ,
736
- has_unified_memory : if version. at_least ( ( 10 , 15 ) , ( 13 , 0 ) ) {
738
+ supports_shader_primitive_index : version. at_least ( ( 10 , 15 ) , ( 14 , 0 ) , os_is_mac ) ,
739
+ has_unified_memory : if version. at_least ( ( 10 , 15 ) , ( 13 , 0 ) , os_is_mac ) {
737
740
Some ( device. has_unified_memory ( ) )
738
741
} else {
739
742
None
0 commit comments