Skip to content

Commit

Permalink
metal: support (simulated) visionOS (#3883)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili authored Jun 23, 2023
1 parent cc203a6 commit 757245c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- Support (simulated) visionOS. By @jinleili in [#3883](https://github.com/gfx-rs/wgpu/pull/3883)

#### General

Expand Down
11 changes: 8 additions & 3 deletions wgpu-hal/src/metal/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 757245c

Please sign in to comment.