-
Notifications
You must be signed in to change notification settings - Fork 515
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] Add support for Xcode15. #19379
[Metal] Add support for Xcode15. #19379
Conversation
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also was trying to follow your PR description but I think the code examples for the 2 approaches may need to be updated, they seem to be the same 🙂
src/metal.cs
Outdated
#endif | ||
[Export ("accelerationStructureCommandEncoder")] | ||
IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder (); | ||
|
||
[Mac (13, 0), iOS (16, 0)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catalyst and tvOS?
src/metal.cs
Outdated
@@ -2091,6 +2443,13 @@ partial interface MTLTexture : MTLResource { | |||
[return: NullAllowed] | |||
[return: Release] | |||
IMTLTexture CreateRemoteTexture (IMTLDevice device); | |||
|
|||
[Mac (13, 0), iOS (16, 0)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catalyst and tvOS?
src/metal.cs
Outdated
@@ -2153,7 +2516,7 @@ partial interface MTLTextureDescriptor : NSCopying { | |||
[Export ("allowGPUOptimizedContents")] | |||
bool AllowGpuOptimizedContents { get; set; } | |||
|
|||
[NoMac, iOS (15, 0), NoMacCatalyst, NoTV, NoWatch] | |||
[Mac (12, 5), iOS (15, 0), NoMacCatalyst, TV (17, 0), NoWatch] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Export ("setVertexBuffer:offset:attributeStride:atIndex:")] | ||
void SetVertexBuffer ([NullAllowed] IMTLBuffer buffer, nuint offset, nuint stride, nuint index); | ||
|
||
[Mac (14, 0), iOS (17, 0), TV (17, 0), MacCatalyst (17, 0), NoWatch] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit doesn't make a functional diff but I don't think the no watch attr is necessary here bc the metal framework does not provide support for watchOS
src/metal.cs
Outdated
@@ -4907,6 +5904,13 @@ interface MTLIndirectCommandBuffer : MTLResource { | |||
[MacCatalyst (13, 1)] | |||
[Export ("indirectComputeCommandAtIndex:")] | |||
IMTLIndirectComputeCommand GetIndirectComputeCommand (nuint commandIndex); | |||
|
|||
[Mac (13, 0), iOS (16, 0)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catalyst and tv?
Look like git commit decide that the #if and #else were git comments.. yay! |
src/Metal/Defs.cs
Outdated
@@ -527,15 +531,13 @@ public struct MTLCoordinate2D { | |||
} | |||
#endif | |||
|
|||
#if !TVOS || !NET | |||
|
|||
#if !TVOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look quite right, seems like it should be:
#if NET
[SupportedOSPlatform ("maccatalyst14.0")]
[SupportedOSPlatform ("macos11.0")]
[SupportedOSPlatform ("ios14.0")]
[SupportedOSPlatform ("tvos16.1")]
#else
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[Mac (11, 0)]
[iOS (14, 0)]
[TV (16, 1)]
#endif
[StructLayout (LayoutKind.Sequential)]
public struct MTLAccelerationStructureSizes {
public nuint AccelerationStructureSize;
public nuint BuildScratchBufferSize;
public nuint RefitScratchBufferSize;
}
}
src/Metal/MTLIOCompression.cs
Outdated
=> MTLIOCompressionContextAppendData ((void*) GetCheckedHandle (), data, size); | ||
|
||
public void AppendData (byte [] data) | ||
=> AppendData (new ReadOnlySpan<byte> (data, 0, data.Length)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null check?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
src/metal.cs
Outdated
@@ -218,6 +222,13 @@ partial interface MTLBuffer : MTLResource { | |||
[return: NullAllowed] | |||
[return: Release] | |||
IMTLBuffer CreateRemoteBuffer (IMTLDevice device); | |||
|
|||
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0)] | |||
#if XAMCORE_r54_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're far away from vr54...
src/metal.cs
Outdated
#if !TVOS | ||
[MacCatalyst (14, 0), Mac (11, 0), iOS (13, 0), NoTV] | ||
[Abstract] // @required but we can't add abstract members in C# and keep binary compatibility | ||
#else | ||
#if XAMCORE_5_0 | ||
[Abstract] | ||
#endif | ||
[NoMacCatalyst, NoMac, NoiOS, TV (16,0)] | ||
|
||
#if XAMCORE_5_0 | ||
[Abstract] | ||
#endif | ||
|
||
#endif | ||
|
||
#else | ||
[MacCatalyst (14, 0), Mac (11, 0), iOS (13, 0), TV (16, 0)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not right, we won't end up with the correct availability attributes in XAMCORE_5_0: the Microsoft.tvOS.dll version will say it's the only platform, while the other platforms will say they all exist except tvOS. This is what we'd end up with once we define XAMCORE_5_0:
#if !TVOS
[Abstract]
[MacCatalyst (14, 0), Mac (11, 0), iOS (13, 0), NoTV]
#else
[Abstract]
[Abstract]
[NoMacCatalyst, NoMac, NoiOS, TV (16,0)]
#endif
(there will be two [Abstract] attributes for !TVOS as well)
This is simpler and correct I think:
#if XAMCORE_5_0
[Abstract]
[MacCatalyst (14, 0), Mac (11, 0), iOS (13, 0), TV (16, 0)]
#elif !TVOS
[Abstract]
[MacCatalyst (14, 0), Mac (11, 0), iOS (13, 0), NoTV]
#else
[NoMacCatalyst, NoMac, NoiOS, TV (16,0)]
#endif
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, @mandel-macaque just please doublecheck on the test results to be good before merging.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
📚 [PR Build] Artifacts 📚Packages generatedView packagesPipeline on Agent |
💻 [CI Build] Windows Integration Tests passed 💻✅ All Windows Integration Tests passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS M1 - Mac Ventura (13.0) passed 💻✅ All tests on macOS M1 - Mac Ventura (13.0) passed. Pipeline on Agent |
💻 [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) passed 💻✅ All tests on macOS M1 - Mac Big Sur (11.5) passed. Pipeline on Agent |
✅ API diff for current PR / commitLegacy Xamarin (No breaking changes).NET (No breaking changes)✅ API diff vs stableLegacy Xamarin (No breaking changes).NET (No breaking changes)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🚀 [CI Build] Test results 🚀Test results✅ All tests passed on VSTS: simulator tests. 🎉 All 235 tests passed 🎉 Tests counts✅ bcl: All 69 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
This PR brings all the changes from the new Metal APIs. During the review pay special attention to the changes done in the Protocols in order to add tvOS support.
The main problem we have had doing this PR is that tvOS was not done on time before the NET branching, that left us with a lot of memebers that were NOT added in tvOS that are abstract on dotnet, which has left use in a pickle.
Lets use the following code as an example.
Code found before this commit:
A naive approach would be to add just the tvOS suppor as follows:
The above change represents and API braking change on the donet tvOS dll because it adds a new Abstrtact members, so this is no an acceptable solution.
There is a second naive approach we can take which is as follows:
Yet again, the naive approach has an issue with it. In this case, all the extension methods that are generated for tvOS (something the generator writes when methods are not abstract) will be decorated with availability attributes for all the other platforms, which is incorrect and will make developers life worse.
That leaves us with the following approach:
With the above change, we do not add an abstract method in tvOS and we only add the tvOS abailabity attribute to the extension methods, and use NoiOS etc for all the other platforms.
The change had to be done to ALL methods that added tvOS support. The good news are that our cecil tests and our introspection tests catch the two naive approaces :)