Skip to content

Commit edab1b3

Browse files
committed
Use normal objc2 naming scheme
1 parent 6918851 commit edab1b3

File tree

7 files changed

+331
-345
lines changed

7 files changed

+331
-345
lines changed

Cargo.lock

+14-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-7
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,6 @@ ndk-sys = "0.5.0"
242242
# These overrides allow our examples to explicitly depend on release crates
243243
[patch.crates-io]
244244
wgpu = { path = "./wgpu" }
245-
block2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
246-
objc2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
247-
objc2-encode = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
248-
objc2-foundation = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
249-
objc2-quartz-core = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
250-
objc2-metal = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
251-
objc2-core-foundation = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
252245

253246
[profile.release]
254247
lto = "thin"

wgpu-hal/src/metal/adapter.rs

+47-49
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl crate::Adapter for super::Adapter {
3535
.shared
3636
.device
3737
.lock()
38-
.new_command_queue_with_max_command_buffer_count(MAX_COMMAND_BUFFERS)
38+
.newCommandQueueWithMaxCommandBufferCount(MAX_COMMAND_BUFFERS)
3939
.unwrap();
4040

4141
// Acquiring the meaning of timestamp ticks is hard with Metal!
@@ -519,7 +519,7 @@ impl super::PrivateCapabilities {
519519
features_sets
520520
.iter()
521521
.cloned()
522-
.any(|x| raw.supports_feature_set(x))
522+
.any(|x| raw.supportsFeatureSet(x))
523523
}
524524

525525
pub fn new(device: &ProtocolObject<dyn MTLDevice>) -> Self {
@@ -553,27 +553,27 @@ impl super::PrivateCapabilities {
553553

554554
let version = NSProcessInfo::processInfo().operatingSystemVersion();
555555

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

564564
let mut sample_count_mask = crate::TextureFormatCapabilities::MULTISAMPLE_X4; // 1 and 4 samples are supported on all devices
565-
if device.supports_texture_sample_count(2) {
565+
if device.supportsTextureSampleCount(2) {
566566
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X2;
567567
}
568-
if device.supports_texture_sample_count(8) {
568+
if device.supportsTextureSampleCount(8) {
569569
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X8;
570570
}
571-
if device.supports_texture_sample_count(16) {
571+
if device.supportsTextureSampleCount(16) {
572572
sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X16;
573573
}
574574

575575
let rw_texture_tier = if version.at_least((10, 13), (11, 0), os_is_mac) {
576-
device.read_write_texture_support()
576+
device.readWriteTextureSupport()
577577
} else if version.at_least((10, 12), OS_NOT_SUPPORT, os_is_mac) {
578578
if Self::supports_any(device, &[MTLFeatureSet::macOS_ReadWriteTextureTier2]) {
579579
MTLReadWriteTextureTier::Tier2
@@ -586,18 +586,18 @@ impl super::PrivateCapabilities {
586586

587587
let mut timestamp_query_support = TimestampQuerySupport::empty();
588588
if version.at_least((11, 0), (14, 0), os_is_mac)
589-
&& device.supports_counter_sampling(MTLCounterSamplingPoint::AtStageBoundary)
589+
&& device.supportsCounterSampling(MTLCounterSamplingPoint::AtStageBoundary)
590590
{
591591
// If we don't support at stage boundary, don't support anything else.
592592
timestamp_query_support.insert(TimestampQuerySupport::STAGE_BOUNDARIES);
593593

594-
if device.supports_counter_sampling(MTLCounterSamplingPoint::AtDrawBoundary) {
594+
if device.supportsCounterSampling(MTLCounterSamplingPoint::AtDrawBoundary) {
595595
timestamp_query_support.insert(TimestampQuerySupport::ON_RENDER_ENCODER);
596596
}
597-
if device.supports_counter_sampling(MTLCounterSamplingPoint::AtDispatchBoundary) {
597+
if device.supportsCounterSampling(MTLCounterSamplingPoint::AtDispatchBoundary) {
598598
timestamp_query_support.insert(TimestampQuerySupport::ON_COMPUTE_ENCODER);
599599
}
600-
if device.supports_counter_sampling(MTLCounterSamplingPoint::AtBlitBoundary) {
600+
if device.supportsCounterSampling(MTLCounterSamplingPoint::AtBlitBoundary) {
601601
timestamp_query_support.insert(TimestampQuerySupport::ON_BLIT_ENCODER);
602602
}
603603
// `TimestampQuerySupport::INSIDE_WGPU_PASSES` emerges from the other flags.
@@ -631,13 +631,13 @@ impl super::PrivateCapabilities {
631631
read_write_texture_tier: rw_texture_tier,
632632
msaa_desktop: os_is_mac,
633633
msaa_apple3: if family_check {
634-
device.supports_family(MTLGPUFamily::Apple3)
634+
device.supportsFamily(MTLGPUFamily::Apple3)
635635
} else {
636-
device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily3_v4)
636+
device.supportsFeatureSet(MTLFeatureSet::iOS_GPUFamily3_v4)
637637
},
638-
msaa_apple7: family_check && device.supports_family(MTLGPUFamily::Apple7),
638+
msaa_apple7: family_check && device.supportsFamily(MTLGPUFamily::Apple7),
639639
resource_heaps: Self::supports_any(device, RESOURCE_HEAP_SUPPORT),
640-
argument_buffers: device.argument_buffers_support(),
640+
argument_buffers: device.argumentBuffersSupport(),
641641
shared_textures: !os_is_mac,
642642
mutable_comparison_samplers: Self::supports_any(
643643
device,
@@ -650,30 +650,29 @@ impl super::PrivateCapabilities {
650650
BASE_VERTEX_FIRST_INSTANCE_SUPPORT,
651651
),
652652
dual_source_blending: Self::supports_any(device, DUAL_SOURCE_BLEND_SUPPORT),
653-
low_power: !os_is_mac || device.is_low_power(),
654-
headless: os_is_mac && device.is_headless(),
653+
low_power: !os_is_mac || device.isLowPower(),
654+
headless: os_is_mac && device.isHeadless(),
655655
layered_rendering: Self::supports_any(device, LAYERED_RENDERING_SUPPORT),
656656
function_specialization: Self::supports_any(device, FUNCTION_SPECIALIZATION_SUPPORT),
657657
depth_clip_mode: Self::supports_any(device, DEPTH_CLIP_MODE),
658658
texture_cube_array: Self::supports_any(device, TEXTURE_CUBE_ARRAY_SUPPORT),
659659
supports_float_filtering: os_is_mac
660660
|| (version.at_least((11, 0), (14, 0), os_is_mac)
661-
&& device.supports32_bit_float_filtering()),
662-
format_depth24_stencil8: os_is_mac
663-
&& device.is_depth24_stencil8_pixel_format_supported(),
661+
&& device.supports32BitFloatFiltering()),
662+
format_depth24_stencil8: os_is_mac && device.isDepth24Stencil8PixelFormatSupported(),
664663
format_depth32_stencil8_filter: os_is_mac,
665664
format_depth32_stencil8_none: !os_is_mac,
666665
format_min_srgb_channels: if os_is_mac { 4 } else { 1 },
667666
format_b5: !os_is_mac,
668667
format_bc: os_is_mac,
669668
format_eac_etc: !os_is_mac
670669
// M1 in macOS supports EAC/ETC2
671-
|| (family_check && device.supports_family(MTLGPUFamily::Apple7)),
670+
|| (family_check && device.supportsFamily(MTLGPUFamily::Apple7)),
672671
// A8(Apple2) and later always support ASTC pixel formats
673-
format_astc: (family_check && device.supports_family(MTLGPUFamily::Apple2))
672+
format_astc: (family_check && device.supportsFamily(MTLGPUFamily::Apple2))
674673
|| Self::supports_any(device, ASTC_PIXEL_FORMAT_FEATURES),
675674
// A13(Apple6) M1(Apple7) and later always support HDR ASTC pixel formats
676-
format_astc_hdr: family_check && device.supports_family(MTLGPUFamily::Apple6),
675+
format_astc_hdr: family_check && device.supportsFamily(MTLGPUFamily::Apple6),
677676
format_any8_unorm_srgb_all: Self::supports_any(device, ANY8_UNORM_SRGB_ALL),
678677
format_any8_unorm_srgb_no_write: !Self::supports_any(device, ANY8_UNORM_SRGB_ALL)
679678
&& !os_is_mac,
@@ -728,10 +727,10 @@ impl super::PrivateCapabilities {
728727
max_buffers_per_stage: 31,
729728
max_vertex_buffers: 31.min(crate::MAX_VERTEX_BUFFERS as u32),
730729
max_textures_per_stage: if os_is_mac
731-
|| (family_check && device.supports_family(MTLGPUFamily::Apple6))
730+
|| (family_check && device.supportsFamily(MTLGPUFamily::Apple6))
732731
{
733732
128
734-
} else if family_check && device.supports_family(MTLGPUFamily::Apple4) {
733+
} else if family_check && device.supportsFamily(MTLGPUFamily::Apple4) {
735734
96
736735
} else {
737736
31
@@ -740,7 +739,7 @@ impl super::PrivateCapabilities {
740739
buffer_alignment: if os_is_mac || os_is_xr { 256 } else { 64 },
741740
max_buffer_size: if version.at_least((10, 14), (12, 0), os_is_mac) {
742741
// maxBufferLength available on macOS 10.14+ and iOS 12.0+
743-
device.max_buffer_length() as u64
742+
device.maxBufferLength() as u64
744743
} else if os_is_mac {
745744
1 << 30 // 1GB on macOS 10.11 and up
746745
} else {
@@ -761,7 +760,7 @@ impl super::PrivateCapabilities {
761760
max_texture_3d_size: 2048,
762761
max_texture_layers: 2048,
763762
max_fragment_input_components: if os_is_mac
764-
|| device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1)
763+
|| device.supportsFeatureSet(MTLFeatureSet::iOS_GPUFamily4_v1)
765764
{
766765
124
767766
} else {
@@ -781,14 +780,13 @@ impl super::PrivateCapabilities {
781780
},
782781
// Per https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
783782
max_color_attachment_bytes_per_sample: if family_check
784-
&& device.supports_family(MTLGPUFamily::Apple4)
783+
&& device.supportsFamily(MTLGPUFamily::Apple4)
785784
{
786785
64
787786
} else {
788787
32
789788
},
790-
max_varying_components: if device
791-
.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v1)
789+
max_varying_components: if device.supportsFeatureSet(MTLFeatureSet::macOS_GPUFamily1_v1)
792790
{
793791
124
794792
} else {
@@ -826,8 +824,8 @@ impl super::PrivateCapabilities {
826824
],
827825
),
828826
supports_binary_archives: family_check
829-
&& (device.supports_family(MTLGPUFamily::Apple3)
830-
|| device.supports_family(MTLGPUFamily::Mac1)),
827+
&& (device.supportsFamily(MTLGPUFamily::Apple3)
828+
|| device.supportsFamily(MTLGPUFamily::Mac1)),
831829
supports_capture_manager: version.at_least((10, 13), (11, 0), os_is_mac),
832830
can_set_maximum_drawables_count: version.at_least((10, 14), (11, 2), os_is_mac),
833831
can_set_display_sync: version.at_least((10, 13), OS_NOT_SUPPORT, os_is_mac),
@@ -841,39 +839,39 @@ impl super::PrivateCapabilities {
841839
],
842840
),
843841
supports_arrays_of_textures_write: family_check
844-
&& (device.supports_family(MTLGPUFamily::Apple6)
845-
|| device.supports_family(MTLGPUFamily::Mac1)
846-
|| device.supports_family(MTLGPUFamily::MacCatalyst1)),
842+
&& (device.supportsFamily(MTLGPUFamily::Apple6)
843+
|| device.supportsFamily(MTLGPUFamily::Mac1)
844+
|| device.supportsFamily(MTLGPUFamily::MacCatalyst1)),
847845
supports_mutability: version.at_least((10, 13), (11, 0), os_is_mac),
848846
//Depth clipping is supported on all macOS GPU families and iOS family 4 and later
849847
supports_depth_clip_control: os_is_mac
850-
|| device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1),
848+
|| device.supportsFeatureSet(MTLFeatureSet::iOS_GPUFamily4_v1),
851849
supports_preserve_invariance: version.at_least((11, 0), (13, 0), os_is_mac),
852850
// Metal 2.2 on mac, 2.3 on iOS.
853851
supports_shader_primitive_index: version.at_least((10, 15), (14, 0), os_is_mac),
854852
has_unified_memory: if version.at_least((10, 15), (13, 0), os_is_mac) {
855-
Some(device.has_unified_memory())
853+
Some(device.hasUnifiedMemory())
856854
} else {
857855
None
858856
},
859857
timestamp_query_support,
860858
supports_simd_scoped_operations: family_check
861-
&& (device.supports_family(MTLGPUFamily::Metal3)
862-
|| device.supports_family(MTLGPUFamily::Mac2)
863-
|| device.supports_family(MTLGPUFamily::Apple7)),
859+
&& (device.supportsFamily(MTLGPUFamily::Metal3)
860+
|| device.supportsFamily(MTLGPUFamily::Mac2)
861+
|| device.supportsFamily(MTLGPUFamily::Apple7)),
864862
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=5
865863
int64: family_check
866-
&& (device.supports_family(MTLGPUFamily::Apple3)
867-
|| device.supports_family(MTLGPUFamily::Metal3)),
864+
&& (device.supportsFamily(MTLGPUFamily::Apple3)
865+
|| device.supportsFamily(MTLGPUFamily::Metal3)),
868866
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6
869867
int64_atomics: family_check
870-
&& ((device.supports_family(MTLGPUFamily::Apple8)
871-
&& device.supports_family(MTLGPUFamily::Mac2))
872-
|| device.supports_family(MTLGPUFamily::Apple9)),
868+
&& ((device.supportsFamily(MTLGPUFamily::Apple8)
869+
&& device.supportsFamily(MTLGPUFamily::Mac2))
870+
|| device.supportsFamily(MTLGPUFamily::Apple9)),
873871
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6
874872
float_atomics: family_check
875-
&& (device.supports_family(MTLGPUFamily::Apple7)
876-
|| device.supports_family(MTLGPUFamily::Mac2)),
873+
&& (device.supportsFamily(MTLGPUFamily::Apple7)
874+
|| device.supportsFamily(MTLGPUFamily::Mac2)),
877875
supports_shared_event: version.at_least((10, 14), (12, 0), os_is_mac),
878876
}
879877
}
@@ -1235,7 +1233,7 @@ impl super::PrivateDisabilities {
12351233
let is_intel = device.name().to_string().starts_with("Intel");
12361234
Self {
12371235
broken_viewport_near_depth: is_intel
1238-
&& !device.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v4),
1236+
&& !device.supportsFeatureSet(MTLFeatureSet::macOS_GPUFamily1_v4),
12391237
broken_layered_clear_image: is_intel,
12401238
}
12411239
}

0 commit comments

Comments
 (0)