Add Metal 4 API support and detection utilities#823
Closed
luengnat wants to merge 1 commit intomadsmtm:mainfrom
Closed
Add Metal 4 API support and detection utilities#823luengnat wants to merge 1 commit intomadsmtm:mainfrom
luengnat wants to merge 1 commit intomadsmtm:mainfrom
Conversation
This commit adds comprehensive Metal 4 API support to objc2-metal: - Add metal4_detection module with runtime and compile-time detection - Fix duplicate setLodBias method in MTLSampler - Fix unstable-darwin-objc feature flag requiring nightly Rust - Add comprehensive tests for Metal 4 types and MTLTensor - Add Metal 4 documentation to crate-level docs Metal 4 detection includes: - Version constants for OS requirements (macOS 26.0+, iOS 26.0+, etc.) - Platform detection for compile-time checks - Feature availability detection - Integration with objc2's available! macro Test coverage: - 22 tests covering detection utilities and type imports - All tests passing with zero warnings - MTLTensor support fully tested
madsmtm
requested changes
Mar 6, 2026
Owner
madsmtm
left a comment
There was a problem hiding this comment.
I feel like this is better left to other crates building on objc2-metal to handle. I'd be fine with improved documentation.
Also, for the future, if you use AI, it's good style to state so in your PR description.
Author
|
Ok. Thanks. I'm sure where I should put this to. I'm testing vllm on metal4 to see if it improves anything. |
Owner
|
I did include the Feel free to file a new PR (or re-open this one) with docs improvements. |
Author
|
Oh great. Thanks. I noticed the dup when I was working on it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds comprehensive Metal 4 API support to
objc2-metal, building on the existing Metal 4 type bindings that were already generated from Xcode 26.3 SDKs.Changes
Core Implementation
src/metal4_detection.rs)objc2::available!macroMetal4FeaturesstructBug Fixes
setLodBiasmethod inMTLSampler(removed fromprivate.rs)unstable-darwin-objcfeature flag that required nightly RustDocumentation
Testing
tests/metal4_detection.rs- 11 tests for detection utilitiestests/metal4_types.rs- 11 tests for type integration and MTLTensor support#[allow(unused_imports)]for import-only verification testsMetal 4 Features Supported
The existing
objc2-metalalready has comprehensive Metal 4 type bindings generated from Xcode 26.3 SDKs. This PR adds:available!macroUsage Example
Testing
All tests pass with zero warnings:
Backwards Compatibility
✅ No breaking changes
✅ All existing Metal 3 APIs remain functional
✅ Metal 4 features are opt-in via runtime detection
Related
objc2-metal-fxcrateChecklist
Fixes #[issue number if applicable]