Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metal: support (simulated) visionOS #3883

Merged
merged 3 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
cwfitzgerald marked this conversation as resolved.
Show resolved Hide resolved
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