Skip to content

Commit def47f8

Browse files
committed
Use normal objc2 naming scheme
1 parent cf8bd5d commit def47f8

File tree

7 files changed

+309
-317
lines changed

7 files changed

+309
-317
lines changed

Cargo.lock

Lines changed: 14 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,6 @@ termcolor = "1.4.1"
192192
#web-sys = { path = "../wasm-bindgen/crates/web-sys" }
193193
#js-sys = { path = "../wasm-bindgen/crates/js-sys" }
194194
#wasm-bindgen = { path = "../wasm-bindgen" }
195-
block2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
196-
objc2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
197-
objc2-encode = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
198-
objc-sys = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
199-
objc2-foundation = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
200-
objc2-quartz-core = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
201-
objc2-metal = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
202195

203196
[profile.release]
204197
lto = "thin"

wgpu-hal/src/metal/adapter.rs

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl crate::Adapter for super::Adapter {
3434
.shared
3535
.device
3636
.lock()
37-
.new_command_queue_with_max_command_buffer_count(MAX_COMMAND_BUFFERS)
37+
.newCommandQueueWithMaxCommandBufferCount(MAX_COMMAND_BUFFERS)
3838
.unwrap();
3939

4040
// Acquiring the meaning of timestamp ticks is hard with Metal!
@@ -489,7 +489,7 @@ impl super::PrivateCapabilities {
489489
features_sets
490490
.iter()
491491
.cloned()
492-
.any(|x| raw.supports_feature_set(x))
492+
.any(|x| raw.supportsFeatureSet(x))
493493
}
494494

495495
pub fn new(device: &ProtocolObject<dyn MTLDevice>) -> Self {
@@ -523,27 +523,27 @@ impl super::PrivateCapabilities {
523523

524524
let version = NSProcessInfo::processInfo().operatingSystemVersion();
525525

526-
let os_is_mac = device.supports_feature_set(MTLFeatureSet::_macOS_GPUFamily1_v1);
526+
let os_is_mac = device.supportsFeatureSet(MTLFeatureSet::_macOS_GPUFamily1_v1);
527527
// Metal was first introduced in OS X 10.11 and iOS 8. The current version number of visionOS is 1.0.0. Additionally,
528528
// on the Simulator, Apple only provides the Apple2 GPU capability, and the Apple2+ GPU capability covers the capabilities of Apple2.
529529
// Therefore, the following conditions can be used to determine if it is visionOS.
530530
// https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator
531-
let os_is_xr = version.majorVersion < 8 && device.supports_family(MTLGPUFamily::Apple2);
531+
let os_is_xr = version.majorVersion < 8 && device.supportsFamily(MTLGPUFamily::Apple2);
532532
let family_check = os_is_xr || version.at_least((10, 15), (13, 0), os_is_mac);
533533

534534
let mut sample_count_mask = crate::TextureFormatCapabilities::MULTISAMPLE_X4; // 1 and 4 samples are supported on all devices
535-
if device.supports_texture_sample_count(2) {
535+
if device.supportsTextureSampleCount(2) {
536536
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X2;
537537
}
538-
if device.supports_texture_sample_count(8) {
538+
if device.supportsTextureSampleCount(8) {
539539
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X8;
540540
}
541-
if device.supports_texture_sample_count(16) {
541+
if device.supportsTextureSampleCount(16) {
542542
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X16;
543543
}
544544

545545
let rw_texture_tier = if version.at_least((10, 13), (11, 0), os_is_mac) {
546-
device.read_write_texture_support()
546+
device.readWriteTextureSupport()
547547
} else if version.at_least((10, 12), OS_NOT_SUPPORT, os_is_mac) {
548548
if Self::supports_any(device, &[MTLFeatureSet::_macOS_ReadWriteTextureTier2]) {
549549
MTLReadWriteTextureTier::MTLReadWriteTextureTier2
@@ -556,18 +556,18 @@ impl super::PrivateCapabilities {
556556

557557
let mut timestamp_query_support = TimestampQuerySupport::empty();
558558
if version.at_least((11, 0), (14, 0), os_is_mac)
559-
&& device.supports_counter_sampling(MTLCounterSamplingPoint::AtStageBoundary)
559+
&& device.supportsCounterSampling(MTLCounterSamplingPoint::AtStageBoundary)
560560
{
561561
// If we don't support at stage boundary, don't support anything else.
562562
timestamp_query_support.insert(TimestampQuerySupport::STAGE_BOUNDARIES);
563563

564-
if device.supports_counter_sampling(MTLCounterSamplingPoint::AtDrawBoundary) {
564+
if device.supportsCounterSampling(MTLCounterSamplingPoint::AtDrawBoundary) {
565565
timestamp_query_support.insert(TimestampQuerySupport::ON_RENDER_ENCODER);
566566
}
567-
if device.supports_counter_sampling(MTLCounterSamplingPoint::AtDispatchBoundary) {
567+
if device.supportsCounterSampling(MTLCounterSamplingPoint::AtDispatchBoundary) {
568568
timestamp_query_support.insert(TimestampQuerySupport::ON_COMPUTE_ENCODER);
569569
}
570-
if device.supports_counter_sampling(MTLCounterSamplingPoint::AtBlitBoundary) {
570+
if device.supportsCounterSampling(MTLCounterSamplingPoint::AtBlitBoundary) {
571571
timestamp_query_support.insert(TimestampQuerySupport::ON_BLIT_ENCODER);
572572
}
573573
// `TimestampQuerySupport::INSIDE_WGPU_PASSES` emerges from the other flags.
@@ -601,11 +601,11 @@ impl super::PrivateCapabilities {
601601
read_write_texture_tier: rw_texture_tier,
602602
msaa_desktop: os_is_mac,
603603
msaa_apple3: if family_check {
604-
device.supports_family(MTLGPUFamily::Apple3)
604+
device.supportsFamily(MTLGPUFamily::Apple3)
605605
} else {
606-
device.supports_feature_set(MTLFeatureSet::_iOS_GPUFamily3_v4)
606+
device.supportsFeatureSet(MTLFeatureSet::_iOS_GPUFamily3_v4)
607607
},
608-
msaa_apple7: family_check && device.supports_family(MTLGPUFamily::Apple7),
608+
msaa_apple7: family_check && device.supportsFamily(MTLGPUFamily::Apple7),
609609
resource_heaps: Self::supports_any(device, RESOURCE_HEAP_SUPPORT),
610610
argument_buffers: Self::supports_any(device, ARGUMENT_BUFFER_SUPPORT),
611611
shared_textures: !os_is_mac,
@@ -620,30 +620,29 @@ impl super::PrivateCapabilities {
620620
BASE_VERTEX_FIRST_INSTANCE_SUPPORT,
621621
),
622622
dual_source_blending: Self::supports_any(device, DUAL_SOURCE_BLEND_SUPPORT),
623-
low_power: !os_is_mac || device.is_low_power(),
624-
headless: os_is_mac && device.is_headless(),
623+
low_power: !os_is_mac || device.isLowPower(),
624+
headless: os_is_mac && device.isHeadless(),
625625
layered_rendering: Self::supports_any(device, LAYERED_RENDERING_SUPPORT),
626626
function_specialization: Self::supports_any(device, FUNCTION_SPECIALIZATION_SUPPORT),
627627
depth_clip_mode: Self::supports_any(device, DEPTH_CLIP_MODE),
628628
texture_cube_array: Self::supports_any(device, TEXTURE_CUBE_ARRAY_SUPPORT),
629629
supports_float_filtering: os_is_mac
630630
|| (version.at_least((11, 0), (14, 0), os_is_mac)
631-
&& device.supports32_bit_float_filtering()),
632-
format_depth24_stencil8: os_is_mac
633-
&& device.is_depth24_stencil8_pixel_format_supported(),
631+
&& device.supports32BitFloatFiltering()),
632+
format_depth24_stencil8: os_is_mac && device.isDepth24Stencil8PixelFormatSupported(),
634633
format_depth32_stencil8_filter: os_is_mac,
635634
format_depth32_stencil8_none: !os_is_mac,
636635
format_min_srgb_channels: if os_is_mac { 4 } else { 1 },
637636
format_b5: !os_is_mac,
638637
format_bc: os_is_mac,
639638
format_eac_etc: !os_is_mac
640639
// M1 in macOS supports EAC/ETC2
641-
|| (family_check && device.supports_family(MTLGPUFamily::Apple7)),
640+
|| (family_check && device.supportsFamily(MTLGPUFamily::Apple7)),
642641
// A8(Apple2) and later always support ASTC pixel formats
643-
format_astc: (family_check && device.supports_family(MTLGPUFamily::Apple2))
642+
format_astc: (family_check && device.supportsFamily(MTLGPUFamily::Apple2))
644643
|| Self::supports_any(device, ASTC_PIXEL_FORMAT_FEATURES),
645644
// A13(Apple6) M1(Apple7) and later always support HDR ASTC pixel formats
646-
format_astc_hdr: family_check && device.supports_family(MTLGPUFamily::Apple6),
645+
format_astc_hdr: family_check && device.supportsFamily(MTLGPUFamily::Apple6),
647646
format_any8_unorm_srgb_all: Self::supports_any(device, ANY8_UNORM_SRGB_ALL),
648647
format_any8_unorm_srgb_no_write: !Self::supports_any(device, ANY8_UNORM_SRGB_ALL)
649648
&& !os_is_mac,
@@ -698,10 +697,10 @@ impl super::PrivateCapabilities {
698697
max_buffers_per_stage: 31,
699698
max_vertex_buffers: 31.min(crate::MAX_VERTEX_BUFFERS as u32),
700699
max_textures_per_stage: if os_is_mac
701-
|| (family_check && device.supports_family(MTLGPUFamily::Apple6))
700+
|| (family_check && device.supportsFamily(MTLGPUFamily::Apple6))
702701
{
703702
128
704-
} else if family_check && device.supports_family(MTLGPUFamily::Apple4) {
703+
} else if family_check && device.supportsFamily(MTLGPUFamily::Apple4) {
705704
96
706705
} else {
707706
31
@@ -710,7 +709,7 @@ impl super::PrivateCapabilities {
710709
buffer_alignment: if os_is_mac || os_is_xr { 256 } else { 64 },
711710
max_buffer_size: if version.at_least((10, 14), (12, 0), os_is_mac) {
712711
// maxBufferLength available on macOS 10.14+ and iOS 12.0+
713-
device.max_buffer_length() as u64
712+
device.maxBufferLength() as u64
714713
} else if os_is_mac {
715714
1 << 30 // 1GB on macOS 10.11 and up
716715
} else {
@@ -731,7 +730,7 @@ impl super::PrivateCapabilities {
731730
max_texture_3d_size: 2048,
732731
max_texture_layers: 2048,
733732
max_fragment_input_components: if os_is_mac
734-
|| device.supports_feature_set(MTLFeatureSet::_iOS_GPUFamily4_v1)
733+
|| device.supportsFeatureSet(MTLFeatureSet::_iOS_GPUFamily4_v1)
735734
{
736735
124
737736
} else {
@@ -751,14 +750,14 @@ impl super::PrivateCapabilities {
751750
},
752751
// Per https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
753752
max_color_attachment_bytes_per_sample: if family_check
754-
&& device.supports_family(MTLGPUFamily::Apple4)
753+
&& device.supportsFamily(MTLGPUFamily::Apple4)
755754
{
756755
64
757756
} else {
758757
32
759758
},
760759
max_varying_components: if device
761-
.supports_feature_set(MTLFeatureSet::_macOS_GPUFamily1_v1)
760+
.supportsFeatureSet(MTLFeatureSet::_macOS_GPUFamily1_v1)
762761
{
763762
124
764763
} else {
@@ -796,8 +795,8 @@ impl super::PrivateCapabilities {
796795
],
797796
),
798797
supports_binary_archives: family_check
799-
&& (device.supports_family(MTLGPUFamily::Apple3)
800-
|| device.supports_family(MTLGPUFamily::Mac1)),
798+
&& (device.supportsFamily(MTLGPUFamily::Apple3)
799+
|| device.supportsFamily(MTLGPUFamily::Mac1)),
801800
supports_capture_manager: version.at_least((10, 13), (11, 0), os_is_mac),
802801
can_set_maximum_drawables_count: version.at_least((10, 14), (11, 2), os_is_mac),
803802
can_set_display_sync: version.at_least((10, 13), OS_NOT_SUPPORT, os_is_mac),
@@ -811,30 +810,30 @@ impl super::PrivateCapabilities {
811810
],
812811
),
813812
supports_arrays_of_textures_write: family_check
814-
&& (device.supports_family(MTLGPUFamily::Apple6)
815-
|| device.supports_family(MTLGPUFamily::Mac1)
816-
|| device.supports_family(MTLGPUFamily::MacCatalyst1)),
813+
&& (device.supportsFamily(MTLGPUFamily::Apple6)
814+
|| device.supportsFamily(MTLGPUFamily::Mac1)
815+
|| device.supportsFamily(MTLGPUFamily::MacCatalyst1)),
817816
supports_mutability: version.at_least((10, 13), (11, 0), os_is_mac),
818817
//Depth clipping is supported on all macOS GPU families and iOS family 4 and later
819818
supports_depth_clip_control: os_is_mac
820-
|| device.supports_feature_set(MTLFeatureSet::_iOS_GPUFamily4_v1),
819+
|| device.supportsFeatureSet(MTLFeatureSet::_iOS_GPUFamily4_v1),
821820
supports_preserve_invariance: version.at_least((11, 0), (13, 0), os_is_mac),
822821
// Metal 2.2 on mac, 2.3 on iOS.
823822
supports_shader_primitive_index: version.at_least((10, 15), (14, 0), os_is_mac),
824823
has_unified_memory: if version.at_least((10, 15), (13, 0), os_is_mac) {
825-
Some(device.has_unified_memory())
824+
Some(device.hasUnifiedMemory())
826825
} else {
827826
None
828827
},
829828
timestamp_query_support,
830829
supports_simd_scoped_operations: family_check
831-
&& (device.supports_family(MTLGPUFamily::Metal3)
832-
|| device.supports_family(MTLGPUFamily::Mac2)
833-
|| device.supports_family(MTLGPUFamily::Apple7)),
830+
&& (device.supportsFamily(MTLGPUFamily::Metal3)
831+
|| device.supportsFamily(MTLGPUFamily::Mac2)
832+
|| device.supportsFamily(MTLGPUFamily::Apple7)),
834833
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=5
835834
int64: family_check
836-
&& (device.supports_family(MTLGPUFamily::Apple3)
837-
|| device.supports_family(MTLGPUFamily::Metal3)),
835+
&& (device.supportsFamily(MTLGPUFamily::Apple3)
836+
|| device.supportsFamily(MTLGPUFamily::Metal3)),
838837
}
839838
}
840839

@@ -1179,7 +1178,7 @@ impl super::PrivateDisabilities {
11791178
let is_intel = device.name().to_string().starts_with("Intel");
11801179
Self {
11811180
broken_viewport_near_depth: is_intel
1182-
&& !device.supports_feature_set(MTLFeatureSet::_macOS_GPUFamily1_v4),
1181+
&& !device.supportsFeatureSet(MTLFeatureSet::_macOS_GPUFamily1_v4),
11831182
broken_layered_clear_image: is_intel,
11841183
}
11851184
}

0 commit comments

Comments
 (0)