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: refactor PrivateCapabilities creation #2509

Merged
merged 3 commits into from Mar 2, 2022
Merged

metal: refactor PrivateCapabilities creation #2509

merged 3 commits into from Mar 2, 2022

Conversation

jinleili
Copy link
Contributor

@jinleili jinleili commented Feb 25, 2022

Description

  • refactor version_at_least, make use like objc @available(macOS xx.x, iOS xx.x, *) to simplify version check logic.

  • Follow Apple's API doc:

If your app is running on an operating system that supports the supportsFamily: method, use that method instead.

Some original family_check && supports_family conditons,if MTLGPUFamily lower than Apple6, replaced to:

if family_check { supports_family(xx) } else { supports_feature_set(xx) }

Some original supports_feature_set || (family_check && supports_family) conditons,changed family_check && supports_family to front.

More recent GPUs have higher version numbers and support larger feature sets. A higher GPU version is always a superset of an earlier version in the same GPU family.
...
If a GPU supports a feature set, it supports all features provided by earlier members of the same family, and all features in earlier software revisions. For example, MTLFeatureSet_iOS_GPUFamily4_v2 is version 2 of family 4, so it supports the same features as version 1, as well as all features supported by families 1, 2, and 3.

supports_any does not need to enumerate all feature sets in the same family,It is enough to keep only the first one。

The OS is updated every year, Maybe some day, we can remove all supports_feature_set code.

  • format_r32_xx detecting is wrong, all GPU Families supports write, r32_float support filer only on macOS, and M1 Mac also support iOS_GPUFamily_xx feature:

截屏2022-02-23 15 38 10

Similarly, format_rg32_xx , format_rgba32_xx, format_depth16unorm_xx, format_bgr10a2_xx need to be fixed too.

  • supports_feature_set(iOS_GPUFamily1_v1) is equal to !os_is_mac
  • supports_feature_set(macOS_GPUFamily1_v1) is equal to os_is_mac
  • supports_any(&[iOS_GPUFamily1_v1, macOS_GPUFamily1_v1]) is equal to true
  • !supports_any(&[iOS_GPUFamily1_v1, macOS_GPUFamily1_v1]) is equal to false

Testing
Tested wgpu examples on M1 Mac, Intel Mac.
Tested wgpu-on-app demos on M1 Mac, Intel Mac, iPhone 6 Plus, iPad Mini4, iPhone 12 Pro.
Tested my private app 字习 Pro on M1 Mac, iPhone 6 Plus, iPad Mini4, iPhone 12 Pro,iPad Pro 2018

wgpu-hal/src/metal/adapter.rs Show resolved Hide resolved
wgpu-hal/src/metal/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/metal/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/metal/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/metal/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/metal/adapter.rs Show resolved Hide resolved
@jinleili jinleili requested a review from kvark February 25, 2022 12:29
@jinleili jinleili requested a review from kvark March 2, 2022 02:34
@kvark kvark merged commit 810dc5a into gfx-rs:master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants