metal: refactor PrivateCapabilities
creation
#2509
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Some original
family_check && supports_family
conditons,if MTLGPUFamily lower thanApple6
, replaced to:Some original
supports_feature_set || (family_check && supports_family)
conditons,changedfamily_check && supports_family
to front.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 supportiOS_GPUFamily_xx
feature: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 toos_is_mac
supports_any(&[iOS_GPUFamily1_v1, macOS_GPUFamily1_v1])
is equal totrue
!supports_any(&[iOS_GPUFamily1_v1, macOS_GPUFamily1_v1])
is equal tofalse
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