diff --git a/.deny.toml b/.deny.toml index af5635c22f..35e9c6d0c7 100644 --- a/.deny.toml +++ b/.deny.toml @@ -64,6 +64,7 @@ private = { ignore = true } [sources] allow-git = [ # Waiting on releases; used in examples/tests only + "https://github.com/gfx-rs/metal-rs.git" ] unknown-registry = "deny" unknown-git = "deny" diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dda0fbc3b..37bc096cde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,9 @@ SamplerDescriptor { - Fixed a validation error regarding atomic memory semantics. By @atlv24 in [#8391](https://github.com/gfx-rs/wgpu/pull/8391). +#### Metal +- Fixed a variety of feature detection related bugs. By @inner-daemons in [#8439](https://github.com/gfx-rs/wgpu/pull/8439). + #### hal - `DropCallback`s are now called after dropping all other fields of their parent structs. By @jerzywilczek in [#8353](https://github.com/gfx-rs/wgpu/pull/8353) diff --git a/Cargo.lock b/Cargo.lock index 826c140a70..3167543ce5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2396,8 +2396,7 @@ dependencies = [ [[package]] name = "metal" version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00c15a6f673ff72ddcc22394663290f870fb224c1bfce55734a75c414150e605" +source = "git+https://github.com/gfx-rs/metal-rs.git?rev=65eff6e77ebec23e4c8c171c6a252234f48a0c82#65eff6e77ebec23e4c8c171c6a252234f48a0c82" dependencies = [ "bitflags 2.10.0", "block", diff --git a/Cargo.toml b/Cargo.toml index 12f94bfed0..eee9fffef5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -199,7 +199,7 @@ which = "8" xshell = "0.2.2" # Metal dependencies -metal = "0.32" +metal = { git = "https://github.com/gfx-rs/metal-rs.git", rev = "65eff6e77ebec23e4c8c171c6a252234f48a0c82" } block = "0.1.6" core-graphics-types = "0.2" objc = "0.2.5" diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 20af4fdd0e..4ce580637c 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -537,15 +537,17 @@ impl super::PrivateCapabilities { &self, mac_version: (usize, usize), ios_version: (usize, usize), - is_mac: bool, + tvos_version: (usize, usize), + visionos_version: (usize, usize), + os_type: super::OsType, ) -> bool { - if is_mac { - self.major > mac_version.0 - || (self.major == mac_version.0 && self.minor >= mac_version.1) - } else { - self.major > ios_version.0 - || (self.major == ios_version.0 && self.minor >= ios_version.1) - } + let required = match os_type { + super::OsType::Macos => mac_version, + super::OsType::Ios => ios_version, + super::OsType::Tvos => tvos_version, + super::OsType::VisionOs => visionos_version, + }; + self.major > required.0 || (self.major == required.0 && self.minor >= required.1) } } @@ -555,13 +557,27 @@ impl super::PrivateCapabilities { msg_send![process_info, operatingSystemVersion] }; - let os_is_mac = device.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v1); - // Metal was first introduced in OS X 10.11 and iOS 8. The current version number of visionOS is 1.0.0. Additionally, - // on the Simulator, Apple only provides the Apple2 GPU capability, and the Apple2+ GPU capability covers the capabilities of Apple2. - // Therefore, the following conditions can be used to determine if it is visionOS. - // https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator - let os_is_xr = version.major < 8 && device.supports_family(MTLGPUFamily::Apple2); - let family_check = os_is_xr || version.at_least((10, 15), (13, 0), os_is_mac); + let os_type = { + // Metal was first introduced in OS X 10.11 and iOS 8. The current version number of visionOS is 1.0.0. Additionally, + // on the Simulator, Apple only provides the Apple2 GPU capability, and the Apple2+ GPU capability covers the capabilities of Apple2. + // Therefore, the following conditions can be used to determine if it is visionOS. + // https://developer.apple.com/documentation/metal/developing_metal_apps_that_run_in_simulator + let os_is_xr = version.major < 8 && device.supports_family(MTLGPUFamily::Apple2); + let os_is_mac = device.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v1); + let os_is_tvos = device.supports_feature_set(MTLFeatureSet::tvOS_GPUFamily1_v1); + if os_is_xr { + super::OsType::VisionOs + } else if os_is_mac { + super::OsType::Macos + } else if os_is_tvos { + super::OsType::Tvos + } else { + super::OsType::Ios + } + }; + let family_check = version.at_least((10, 15), (13, 0), (13, 0), (1, 0), os_type); + let metal3 = family_check && device.supports_family(MTLGPUFamily::Metal3); + let metal4 = family_check && device.supports_family(MTLGPUFamily::Metal4); let mut sample_count_mask = crate::TextureFormatCapabilities::MULTISAMPLE_X4; // 1 and 4 samples are supported on all devices if device.supports_texture_sample_count(2) { @@ -574,9 +590,15 @@ impl super::PrivateCapabilities { sample_count_mask |= crate::TextureFormatCapabilities::MULTISAMPLE_X16; } - let rw_texture_tier = if version.at_least((10, 13), (11, 0), os_is_mac) { + let rw_texture_tier = if version.at_least((10, 13), (11, 0), (11, 0), (1, 0), os_type) { device.read_write_texture_support() - } else if version.at_least((10, 12), OS_NOT_SUPPORT, os_is_mac) { + } else if version.at_least( + (10, 12), + OS_NOT_SUPPORT, + OS_NOT_SUPPORT, + OS_NOT_SUPPORT, + os_type, + ) { if Self::supports_any(device, &[MTLFeatureSet::macOS_ReadWriteTextureTier2]) { MTLReadWriteTextureTier::Tier2 } else { @@ -587,7 +609,7 @@ impl super::PrivateCapabilities { }; let mut timestamp_query_support = TimestampQuerySupport::empty(); - if version.at_least((11, 0), (14, 0), os_is_mac) + if version.at_least((11, 0), (14, 0), (14, 0), (1, 0), os_type) && device.supports_counter_sampling(MTLCounterSamplingPoint::AtStageBoundary) { // If we don't support at stage boundary, don't support anything else. @@ -605,44 +627,42 @@ impl super::PrivateCapabilities { // `TimestampQuerySupport::INSIDE_WGPU_PASSES` emerges from the other flags. } + // TODO: is this check something we can comfortably run? let argument_buffers = device.argument_buffers_support(); Self { family_check, - msl_version: if os_is_xr || version.at_least((14, 0), (17, 0), os_is_mac) { + msl_version: if version.at_least((14, 0), (17, 0), (17, 0), (1, 0), os_type) { MTLLanguageVersion::V3_1 - } else if version.at_least((13, 0), (16, 0), os_is_mac) { + } else if version.at_least((13, 0), (16, 0), (16, 0), (1, 0), os_type) { MTLLanguageVersion::V3_0 - } else if version.at_least((12, 0), (15, 0), os_is_mac) { + } else if version.at_least((12, 0), (15, 0), (15, 0), (1, 0), os_type) { MTLLanguageVersion::V2_4 - } else if version.at_least((11, 0), (14, 0), os_is_mac) { + } else if version.at_least((11, 0), (14, 0), (14, 0), (1, 0), os_type) { MTLLanguageVersion::V2_3 - } else if version.at_least((10, 15), (13, 0), os_is_mac) { + } else if version.at_least((10, 15), (13, 0), (13, 0), (1, 0), os_type) { MTLLanguageVersion::V2_2 - } else if version.at_least((10, 14), (12, 0), os_is_mac) { + } else if version.at_least((10, 14), (12, 0), (12, 0), (1, 0), os_type) { MTLLanguageVersion::V2_1 - } else if version.at_least((10, 13), (11, 0), os_is_mac) { + } else if version.at_least((10, 13), (11, 0), (11, 0), (1, 0), os_type) { MTLLanguageVersion::V2_0 - } else if version.at_least((10, 12), (10, 0), os_is_mac) { + } else if version.at_least((10, 12), (10, 0), (10, 0), (1, 0), os_type) { MTLLanguageVersion::V1_2 - } else if version.at_least((10, 11), (9, 0), os_is_mac) { + } else if version.at_least((10, 11), (9, 0), (9, 0), (1, 0), os_type) { MTLLanguageVersion::V1_1 } else { MTLLanguageVersion::V1_0 }, // macOS 10.11 doesn't support read-write resources - fragment_rw_storage: version.at_least((10, 12), (8, 0), os_is_mac), + fragment_rw_storage: version.at_least((10, 12), (8, 0), (8, 0), (1, 0), os_type), read_write_texture_tier: rw_texture_tier, - msaa_desktop: os_is_mac, - msaa_apple3: if family_check { - device.supports_family(MTLGPUFamily::Apple3) - } else { - device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily3_v4) - }, + msaa_desktop: os_type == super::OsType::Macos, + msaa_apple3: (family_check && device.supports_family(MTLGPUFamily::Apple3)) + || device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily3_v4), msaa_apple7: family_check && device.supports_family(MTLGPUFamily::Apple7), resource_heaps: Self::supports_any(device, RESOURCE_HEAP_SUPPORT), argument_buffers, - shared_textures: !os_is_mac, + shared_textures: os_type != super::OsType::Macos, mutable_comparison_samplers: Self::supports_any( device, MUTABLE_COMPARISON_SAMPLER_SUPPORT, @@ -654,22 +674,26 @@ impl super::PrivateCapabilities { BASE_VERTEX_FIRST_INSTANCE_SUPPORT, ), dual_source_blending: Self::supports_any(device, DUAL_SOURCE_BLEND_SUPPORT), - low_power: !os_is_mac || device.is_low_power(), - headless: os_is_mac && device.is_headless(), + low_power: os_type != super::OsType::Macos || device.is_low_power(), + headless: os_type == super::OsType::Macos && device.is_headless(), layered_rendering: Self::supports_any(device, LAYERED_RENDERING_SUPPORT), function_specialization: Self::supports_any(device, FUNCTION_SPECIALIZATION_SUPPORT), depth_clip_mode: Self::supports_any(device, DEPTH_CLIP_MODE), texture_cube_array: Self::supports_any(device, TEXTURE_CUBE_ARRAY_SUPPORT), - supports_float_filtering: os_is_mac - || (version.at_least((11, 0), (14, 0), os_is_mac) + supports_float_filtering: os_type == super::OsType::Macos + || (version.at_least((11, 0), (14, 0), (16, 0), (1, 0), os_type) && device.supports_32bit_float_filtering()), - format_depth24_stencil8: os_is_mac && device.d24_s8_supported(), - format_depth32_stencil8_filter: os_is_mac, - format_depth32_stencil8_none: !os_is_mac, - format_min_srgb_channels: if os_is_mac { 4 } else { 1 }, - format_b5: !os_is_mac, - format_bc: os_is_mac, - format_eac_etc: !os_is_mac + format_depth24_stencil8: os_type == super::OsType::Macos && device.d24_s8_supported(), + format_depth32_stencil8_filter: os_type == super::OsType::Macos, + format_depth32_stencil8_none: os_type != super::OsType::Macos, + format_min_srgb_channels: if os_type == super::OsType::Macos { + 4 + } else { + 1 + }, + format_b5: os_type != super::OsType::Macos, + format_bc: os_type == super::OsType::Macos, + format_eac_etc: os_type != super::OsType::Macos // M1 in macOS supports EAC/ETC2 || (family_check && device.supports_family(MTLGPUFamily::Apple7)), // A8(Apple2) and later always support ASTC pixel formats @@ -681,9 +705,9 @@ impl super::PrivateCapabilities { format_astc_3d: family_check && device.supports_family(MTLGPUFamily::Apple3), format_any8_unorm_srgb_all: Self::supports_any(device, ANY8_UNORM_SRGB_ALL), format_any8_unorm_srgb_no_write: !Self::supports_any(device, ANY8_UNORM_SRGB_ALL) - && !os_is_mac, + && os_type != super::OsType::Macos, format_any8_snorm_all: Self::supports_any(device, ANY8_SNORM_RESOLVE), - format_r16_norm_all: os_is_mac, + format_r16_norm_all: os_type == super::OsType::Macos, // No devices support r32's all capabilities format_r32_all: false, // All devices support r32's write capability @@ -691,8 +715,8 @@ impl super::PrivateCapabilities { // iOS support r32float's write capability, macOS support r32float's all capabilities format_r32float_no_write_no_filter: false, // Only iOS doesn't support r32float's filter capability - format_r32float_no_filter: !os_is_mac, - format_r32float_all: os_is_mac, + format_r32float_no_filter: os_type != super::OsType::Macos, + format_r32float_all: os_type == super::OsType::Macos, format_rgba8_srgb_all: Self::supports_any(device, RGBA8_SRGB), format_rgba8_srgb_no_write: !Self::supports_any(device, RGBA8_SRGB), format_rgb10a2_unorm_all: Self::supports_any(device, RGB10A2UNORM_ALL), @@ -701,16 +725,17 @@ impl super::PrivateCapabilities { format_rg11b10_all: Self::supports_any(device, RG11B10FLOAT_ALL), format_rg11b10_no_write: !Self::supports_any(device, RG11B10FLOAT_ALL), format_rgb9e5_all: Self::supports_any(device, RGB9E5FLOAT_ALL), - format_rgb9e5_no_write: !Self::supports_any(device, RGB9E5FLOAT_ALL) && !os_is_mac, - format_rgb9e5_filter_only: os_is_mac, + format_rgb9e5_no_write: !Self::supports_any(device, RGB9E5FLOAT_ALL) + && os_type != super::OsType::Macos, + format_rgb9e5_filter_only: os_type == super::OsType::Macos, format_rg32_color: true, format_rg32_color_write: true, // Only macOS support rg32float's all capabilities - format_rg32float_all: os_is_mac, + format_rg32float_all: os_type == super::OsType::Macos, // All devices support rg32float's color + blend capabilities format_rg32float_color_blend: true, // Only iOS doesn't support rg32float's filter - format_rg32float_no_filter: !os_is_mac, + format_rg32float_no_filter: os_type != super::OsType::Macos, format_rgba32int_color: true, // All devices support rgba32uint and rgba32sint's color + write capabilities format_rgba32int_color_write: true, @@ -718,7 +743,7 @@ impl super::PrivateCapabilities { // All devices support rgba32float's color + write capabilities format_rgba32float_color_write: true, // Only macOS support rgba32float's all capabilities - format_rgba32float_all: os_is_mac, + format_rgba32float_all: os_type == super::OsType::Macos, format_depth16unorm: Self::supports_any( device, &[ @@ -726,13 +751,13 @@ impl super::PrivateCapabilities { MTLFeatureSet::macOS_GPUFamily1_v2, ], ), - format_depth32float_filter: os_is_mac, - format_depth32float_none: !os_is_mac, + format_depth32float_filter: os_type == super::OsType::Macos, + format_depth32float_none: os_type != super::OsType::Macos, format_bgr10a2_all: Self::supports_any(device, BGR10A2_ALL), format_bgr10a2_no_write: !Self::supports_any(device, BGR10A2_ALL), max_buffers_per_stage: 31, max_vertex_buffers: 31.min(crate::MAX_VERTEX_BUFFERS as u32), - max_textures_per_stage: if os_is_mac + max_textures_per_stage: if os_type == super::OsType::Macos || (family_check && device.supports_family(MTLGPUFamily::Apple6)) { 128 @@ -742,6 +767,7 @@ impl super::PrivateCapabilities { 31 }, max_samplers_per_stage: 16, + // TODO: check max_binding_array_elements: if argument_buffers == MTLArgumentBuffersTier::Tier2 { 1_000_000 } else if family_check && device.supports_family(MTLGPUFamily::Apple4) { @@ -749,6 +775,7 @@ impl super::PrivateCapabilities { } else { 31 }, + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=7 max_sampler_binding_array_elements: if family_check && device.supports_family(MTLGPUFamily::Apple9) { @@ -757,18 +784,22 @@ impl super::PrivateCapabilities { && (device.supports_family(MTLGPUFamily::Apple7) || device.supports_family(MTLGPUFamily::Mac2)) { - 1000 + 1024 } else if family_check && device.supports_family(MTLGPUFamily::Apple6) { 128 } else { 16 }, - buffer_alignment: if os_is_mac || os_is_xr { 256 } else { 64 }, - max_buffer_size: if version.at_least((10, 14), (12, 0), os_is_mac) { + buffer_alignment: if matches!(os_type, super::OsType::Macos | super::OsType::VisionOs) { + 256 + } else { + 64 + }, + max_buffer_size: if version.at_least((10, 14), (12, 0), (12, 0), (1, 0), os_type) { // maxBufferLength available on macOS 10.14+ and iOS 12.0+ let buffer_size: NSInteger = unsafe { msg_send![device.as_ref(), maxBufferLength] }; buffer_size as _ - } else if os_is_mac { + } else if os_type == super::OsType::Macos { 1 << 30 // 1GB on macOS 10.11 and up } else { 1 << 28 // 256MB on iOS 8.0+ @@ -787,7 +818,7 @@ impl super::PrivateCapabilities { }, max_texture_3d_size: 2048, max_texture_layers: 2048, - max_fragment_input_components: if os_is_mac + max_fragment_input_components: if os_type == super::OsType::Macos || device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1) { 124 @@ -806,10 +837,12 @@ impl super::PrivateCapabilities { } else { 4 }, - // Per https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=7 max_color_attachment_bytes_per_sample: if family_check - && device.supports_family(MTLGPUFamily::Apple4) + && device.supports_family(MTLGPUFamily::Apple7) { + 128 + } else if family_check && device.supports_family(MTLGPUFamily::Apple4) { 64 } else { 32 @@ -852,13 +885,32 @@ impl super::PrivateCapabilities { MTLFeatureSet::tvOS_GPUFamily1_v2, ], ), - supports_binary_archives: family_check - && (device.supports_family(MTLGPUFamily::Apple3) - || device.supports_family(MTLGPUFamily::Mac1)), - supports_capture_manager: version.at_least((10, 13), (11, 0), os_is_mac), - can_set_maximum_drawables_count: version.at_least((10, 14), (11, 2), os_is_mac), - can_set_display_sync: version.at_least((10, 13), OS_NOT_SUPPORT, os_is_mac), - can_set_next_drawable_timeout: version.at_least((10, 13), (11, 0), os_is_mac), + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4 + supports_binary_archives: metal3 + || device.supports_family(MTLGPUFamily::Apple3) + || device.supports_family(MTLGPUFamily::Mac2), + supports_capture_manager: version.at_least((10, 13), (11, 0), (11, 0), (1, 0), os_type), + can_set_maximum_drawables_count: version.at_least( + (10, 14), + (11, 2), + (11, 2), + (1, 0), + os_type, + ), + can_set_display_sync: version.at_least( + (10, 13), + OS_NOT_SUPPORT, + OS_NOT_SUPPORT, + OS_NOT_SUPPORT, + os_type, + ), + can_set_next_drawable_timeout: version.at_least( + (10, 13), + (11, 0), + (11, 0), + (1, 0), + os_type, + ), supports_arrays_of_textures: Self::supports_any( device, &[ @@ -867,48 +919,64 @@ impl super::PrivateCapabilities { MTLFeatureSet::macOS_GPUFamily1_v3, ], ), - supports_arrays_of_textures_write: family_check - && (device.supports_family(MTLGPUFamily::Apple6) - || device.supports_family(MTLGPUFamily::Mac1) - || device.supports_family(MTLGPUFamily::MacCatalyst1)), - supports_mutability: version.at_least((10, 13), (11, 0), os_is_mac), + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=3 + supports_arrays_of_textures_write: metal3 + || device.supports_family(MTLGPUFamily::Apple6) + || device.supports_family(MTLGPUFamily::Mac2), + // https://developer.apple.com/documentation/metal/mtlpipelinebufferdescriptor/mutability + supports_mutability: version.at_least((10, 13), (11, 0), (11, 0), (1, 0), os_type), + // TODO: how did they come to the following conclusion //Depth clipping is supported on all macOS GPU families and iOS family 4 and later - supports_depth_clip_control: os_is_mac + supports_depth_clip_control: os_type == super::OsType::Macos || device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1), - supports_preserve_invariance: version.at_least((11, 0), (13, 0), os_is_mac), - // Metal 2.2 on mac, 2.3 on iOS. - supports_shader_primitive_index: version.at_least((10, 15), (14, 0), os_is_mac), - has_unified_memory: if version.at_least((10, 15), (13, 0), os_is_mac) { + // https://developer.apple.com/documentation/metal/mtlcompileoptions/preserveinvariance + supports_preserve_invariance: version.at_least( + (11, 0), + (14, 0), + (14, 0), + (1, 0), + os_type, + ), + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4 + supports_shader_primitive_index: metal3 + || device.supports_family(MTLGPUFamily::Apple7) + || device.supports_family(MTLGPUFamily::Mac2), + // https://developer.apple.com/documentation/metal/mtldevice/hasunifiedmemory + has_unified_memory: if version.at_least((10, 15), (13, 0), (13, 0), (1, 0), os_type) { Some(device.has_unified_memory()) } else { None }, timestamp_query_support, - supports_simd_scoped_operations: family_check - && (device.supports_family(MTLGPUFamily::Metal3) - || device.supports_family(MTLGPUFamily::Mac2) - || device.supports_family(MTLGPUFamily::Apple7)), - // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=5 - int64: family_check - && (device.supports_family(MTLGPUFamily::Apple3) - || device.supports_family(MTLGPUFamily::Metal3)), - // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6 + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4 + supports_simd_scoped_operations: metal3 + || device.supports_family(MTLGPUFamily::Mac2) + || device.supports_family(MTLGPUFamily::Apple7), + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4 + int64: metal3 || device.supports_family(MTLGPUFamily::Apple3), + // TODO: my head hurts, does this only allow min/max? + // "Some GPU devices in the Apple8 family support 64-bit atomic minimum and maximum..." + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4 int64_atomics: family_check - && ((device.supports_family(MTLGPUFamily::Apple8) - && device.supports_family(MTLGPUFamily::Mac2)) - || device.supports_family(MTLGPUFamily::Apple9)), - // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=6 - float_atomics: family_check - && (device.supports_family(MTLGPUFamily::Apple7) - || device.supports_family(MTLGPUFamily::Mac2)), - supports_shared_event: version.at_least((10, 14), (12, 0), os_is_mac), - shader_barycentrics: device.supports_shader_barycentric_coordinates(), + && (device.supports_family(MTLGPUFamily::Apple9) + || (device.supports_family(MTLGPUFamily::Apple8) + && device.supports_family(MTLGPUFamily::Mac2))), + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=4 + float_atomics: metal3 + || device.supports_family(MTLGPUFamily::Apple7) + || device.supports_family(MTLGPUFamily::Mac2), + // https://developer.apple.com/documentation/metal/mtlsharedevent + supports_shared_event: version.at_least((10, 14), (12, 0), (12, 0), (1, 0), os_type), + // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=5 (footnote) + // Very difficult to piece together. The function docs claims to require macOS 10.15+, + // but the feature set tables say "some GPU devices in the Mac2 and Metal3 families... + // [check support by] by inspecting its MTLDevice.supportsShaderBarycentricCoordinates property" + // If we get a bug report for metal 3 on macOS 10.14 should be easy to fix. Otherwise it works. + shader_barycentrics: metal4 + || (version.at_least((10, 15), (14, 0), (16, 0), (1, 0), os_type) + && device.supports_shader_barycentric_coordinates()), // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf#page=3 - supports_memoryless_storage: if family_check { - device.supports_family(MTLGPUFamily::Apple2) - } else { - version.at_least((11, 0), (10, 0), os_is_mac) - }, + supports_memoryless_storage: metal4 || device.supports_family(MTLGPUFamily::Apple2), } } diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index f8f87d56b6..7b673830e7 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -1026,3 +1026,11 @@ impl crate::DynPipelineCache for PipelineCache {} pub struct AccelerationStructure; impl crate::DynAccelerationStructure for AccelerationStructure {} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum OsType { + Macos, + Ios, + Tvos, + VisionOs, +}