From cecc78a359dc8f807a2ae502c900733293046fd2 Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Thu, 22 Jun 2023 16:57:31 +0800 Subject: [PATCH 1/3] metal: support visionOS --- wgpu-hal/src/metal/adapter.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index e5c3de3417..c5e6316c19 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -478,7 +478,12 @@ impl super::PrivateCapabilities { }; let os_is_mac = device.supports_feature_set(MTLFeatureSet::macOS_GPUFamily1_v1); - let family_check = version.at_least((10, 15), (13, 0), os_is_mac); + // 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 mut sample_count_mask = crate::TextureFormatCapabilities::MULTISAMPLE_X4; // 1 and 4 samples are supported on all devices if device.supports_texture_sample_count(2) { @@ -505,7 +510,7 @@ impl super::PrivateCapabilities { Self { family_check, - msl_version: if version.at_least((12, 0), (15, 0), os_is_mac) { + msl_version: if os_is_xr || version.at_least((12, 0), (15, 0), os_is_mac) { MTLLanguageVersion::V2_4 } else if version.at_least((11, 0), (14, 0), os_is_mac) { MTLLanguageVersion::V2_3 @@ -627,7 +632,7 @@ impl super::PrivateCapabilities { 31 }, max_samplers_per_stage: 16, - buffer_alignment: if os_is_mac { 256 } else { 64 }, + 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) { // maxBufferLength available on macOS 10.14+ and iOS 12.0+ let buffer_size: metal::NSInteger = From 6dadc6752cb3bf59c8dcd6738e8beba348de2605 Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Thu, 22 Jun 2023 18:27:00 +0800 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd54727c8..4543937474 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,7 @@ Bottom level categories: #### Metal - Fix renderpasses being used inside of renderpasses. By @cwfitzgerald in [#3828](https://github.com/gfx-rs/wgpu/pull/3828) +- Add visionOS support. By @jinleili in [#3883](https://github.com/gfx-rs/wgpu/pull/3883) #### General From a11211f208e3667685f9568739580adc8c72e89f Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Fri, 23 Jun 2023 22:19:49 +0800 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4543937474..94acb283f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,7 +76,7 @@ Bottom level categories: #### Metal - Fix renderpasses being used inside of renderpasses. By @cwfitzgerald in [#3828](https://github.com/gfx-rs/wgpu/pull/3828) -- Add visionOS support. By @jinleili in [#3883](https://github.com/gfx-rs/wgpu/pull/3883) +- Support (simulated) visionOS. By @jinleili in [#3883](https://github.com/gfx-rs/wgpu/pull/3883) #### General