Bring Metal APIs to a common .NET TFM #2788
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 of Change
Currently all Metal related APIs are hardcoded to .NET iOS and .NET macOS TFM.
It makes it a bit more difficult to use these APIs, when consuming library either doesn't use these targets or just wants to abstract these calls without an extra TFM.
In Avalonia, for macOS specifically, we don't use "net8.0-macos" target, as all necessary AppKit API we call from our native library. Thus, we don't have typical .NET IMtlDevice and friends, instead we only have pointers.
This caused a problem on our side, but there is no problem that can't be solved with some reflection:https://github.com/AvaloniaUI/Avalonia/blob/master/src/Skia/Avalonia.Skia/Gpu/Metal/SkiaMetalApi.cs
From the API perspective, I think changes in this PR do make sense:
API Changes
Metal APIs backported to common TFM, but with IntPtr members.
Note: SkiaSharp.Views package API wasn't changed, as it would be way more involving.
Behavioral Changes
None.
Required skia PR
None.
PR Checklist
Can be considered a backport candidate, but understandably 2.88 might have API freeze at this point.