Skip to content

Commit 1d18c72

Browse files
committed
[Metal] Implement Xcode 16.0 beta 1, beta 2 and beta 3 changes.
Note: there were no changes in beta 3. Draft because tests are needed for manual APIs, and the changes on the generator should be extracted to a separate PR. See the CoreSpotlight [PR](#20866) for more generator changes in this area.
1 parent 3789ab0 commit 1d18c72

24 files changed

+620
-494
lines changed

src/Metal/MTLCommandBuffer.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
using ObjCRuntime;
4+
5+
#nullable enable
6+
7+
namespace Metal {
8+
9+
public partial interface IMTLCommandBuffer {
10+
11+
/// <summary>Marks the specified residency sets as part of the current command buffer execution.</summary>
12+
public void UseResidencySets (IMTLResidencySet [] residencySets)
13+
{
14+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (residencySets, nameof (residencySets), UseResidencySets);
15+
}
16+
}
17+
}

src/Metal/MTLCommandQueue.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
3+
using ObjCRuntime;
4+
5+
#nullable enable
6+
7+
namespace Metal {
8+
9+
public partial interface IMTLCommandQueue {
10+
11+
/// <summary>Marks the specified residency sets as part of the current command buffer execution.</summary>
12+
public void AddResidencySets (IMTLResidencySet [] residencySets)
13+
{
14+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (residencySets, nameof (residencySets), AddResidencySets);
15+
}
16+
17+
/// <summary>Removes the specified residency sets from the current command buffer execution.</summary>
18+
public void RemoveResidencySets (IMTLResidencySet [] residencySets)
19+
{
20+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (residencySets, nameof (residencySets), RemoveResidencySets);
21+
}
22+
}
23+
}

src/Metal/MTLDevice.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@ public static IMTLDevice? SystemDefault {
5555
}
5656
}
5757

58-
#if MONOMAC || __MACCATALYST__
59-
6058
#if NET
6159
[SupportedOSPlatform ("maccatalyst15.0")]
6260
[SupportedOSPlatform ("macos")]
63-
[UnsupportedOSPlatform ("ios")]
64-
[UnsupportedOSPlatform ("tvos")]
61+
[SupportedOSPlatform ("ios18.0")]
62+
[SupportedOSPlatform ("tvos18.0")]
6563
#else
66-
[MacCatalyst (15,0)]
64+
[MacCatalyst (15, 0)]
65+
[iOS (18, 0), TV (18, 0)]
6766
#endif
6867
[DllImport (Constants.MetalLibrary)]
6968
unsafe static extern IntPtr MTLCopyAllDevices ();
7069

7170
#if NET
7271
[SupportedOSPlatform ("maccatalyst15.0")]
7372
[SupportedOSPlatform ("macos")]
74-
[UnsupportedOSPlatform ("ios")]
75-
[UnsupportedOSPlatform ("tvos")]
73+
[SupportedOSPlatform ("ios18.0")]
74+
[SupportedOSPlatform ("tvos18.0")]
7675
#else
77-
[MacCatalyst (15,0)]
76+
[MacCatalyst (15, 0)]
77+
[iOS (18, 0), TV (18, 0)]
7878
#endif
7979
public static IMTLDevice [] GetAllDevices ()
8080
{
@@ -84,8 +84,6 @@ public static IMTLDevice [] GetAllDevices ()
8484
return devices;
8585
}
8686

87-
#endif
88-
8987
#if MONOMAC
9088

9189
#if NET

src/Metal/MTLEnums.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,55 @@ public enum MTLPixelFormat : ulong {
405405
[NoiOS]
406406
[NoMacCatalyst]
407407
BC7_RGBAUnorm_sRGB = 153,
408+
409+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
410+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
411+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
412+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
408413
PVRTC_RGB_2BPP = 160,
414+
415+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
416+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
417+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
418+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
409419
PVRTC_RGB_2BPP_sRGB = 161,
420+
421+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
422+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
423+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
424+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
410425
PVRTC_RGB_4BPP = 162,
426+
427+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
428+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
429+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
430+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
411431
PVRTC_RGB_4BPP_sRGB = 163,
432+
433+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
434+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
435+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
436+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
412437
PVRTC_RGBA_2BPP = 164,
438+
439+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
440+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
441+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
442+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
413443
PVRTC_RGBA_2BPP_sRGB = 165,
444+
445+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
446+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
447+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
448+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
414449
PVRTC_RGBA_4BPP = 166,
450+
451+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
452+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
453+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use ASTC/ETC2/BC formats instead.")]
454+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use ASTC/ETC2/BC formats instead.")]
415455
PVRTC_RGBA_4BPP_sRGB = 167,
456+
416457
EAC_R11Unorm = 170,
417458
EAC_R11Snorm = 172,
418459
EAC_RG11Unorm = 174,
@@ -966,7 +1007,14 @@ public enum MTLArgumentAccess : ulong {
9661007
[Flags]
9671008
public enum MTLPipelineOption : ulong {
9681009
None,
969-
ArgumentInfo,
1010+
#if !XAMCORE_5_0
1011+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use 'BindingInfo' instead.")]
1012+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use 'BindingInfo' instead.")]
1013+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use 'BindingInfo' instead.")]
1014+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'BindingInfo' instead.")]
1015+
ArgumentInfo = 1 << 0,
1016+
#endif
1017+
BindingInfo = 1 << 0,
9701018
BufferTypeInfo,
9711019
[iOS (14, 0)]
9721020
[TV (14, 0)]
@@ -1109,6 +1157,8 @@ public enum MTLLanguageVersion : ulong {
11091157
v3_0 = (3uL << 16) + 0,
11101158
[iOS (17, 0), TV (17, 0), MacCatalyst (17, 0), Mac (14, 0), NoWatch]
11111159
v3_1 = (3uL << 16) + 1,
1160+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
1161+
v3_2 = (3ul << 16) + 2,
11121162
}
11131163

11141164
/// <summary>Enumerates values that indicate whether to clip or clamp depth values.</summary>
@@ -1691,6 +1741,8 @@ public enum MTLFunctionOptions : ulong {
16911741
CompileToBinary = 1uL << 0,
16921742
[iOS (17, 0), TV (17, 0), MacCatalyst (17, 0), Mac (14, 0)]
16931743
StoreFunctionInMetalScript = 1uL << 1,
1744+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
1745+
FailOnBinaryArchiveMiss = 1 << 2,
16941746
}
16951747

16961748
[Flags, Mac (11, 0), iOS (14, 0), TV (16, 0)]

src/Metal/MTLResidencySet.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
3+
using ObjCRuntime;
4+
5+
#nullable enable
6+
7+
namespace Metal {
8+
9+
public partial interface IMTLResidencySet {
10+
11+
/// <summary>Adds allocations to be committed the next time <see cref="Commit" /> is called.</summary>
12+
public void AddAllocations (IMTLAllocation [] allocations)
13+
{
14+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (allocations, nameof (allocations), AddAllocations);
15+
}
16+
17+
/// <summary>Marks allocations to be removed the next time <see cref="Commit" /> is called.</summary>
18+
public void RemoveAllocations (IMTLAllocation [] allocations)
19+
{
20+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (allocations, nameof (allocations), RemoveAllocations);
21+
}
22+
}
23+
}

src/ObjCRuntime/INativeObject.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ public static NativeHandle GetCheckedHandle (this INativeObject self)
5555
return h;
5656
}
5757
#endif
58+
59+
internal static void CallWithPointerToFirstElementAndCount<T> (T [] array, string arrayVariableName, Action<IntPtr, nuint> callback)
60+
where T : INativeObject
61+
{
62+
if (array is null)
63+
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (arrayVariableName);
64+
65+
var handles = new IntPtr [array.Length];
66+
for (var i = 0; i < handles.Length; i++)
67+
handles [i] = array [i].GetNonNullHandle (arrayVariableName + $"[{i}]");
68+
69+
unsafe {
70+
fixed (IntPtr* handlesPtr = handles) {
71+
callback ((IntPtr) handlesPtr, (nuint) handles.Length);
72+
}
73+
}
74+
75+
GC.KeepAlive (array);
76+
}
5877
}
5978
#endif
6079
}

src/foundation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13179,6 +13179,11 @@ interface NSProcessInfo {
1317913179
[Export ("iOSAppOnMac")]
1318013180
bool IsiOSApplicationOnMac { [Bind ("isiOSAppOnMac")] get; }
1318113181
#endregion
13182+
13183+
[Field ("NSProcessInfoPerformanceProfileDidChangeNotification", "Metal")]
13184+
[Notification]
13185+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
13186+
NSString PerformanceProfileDidChangeNotification { get; }
1318213187
}
1318313188

1318413189
[NoWatch]

src/frameworks.sources

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,8 @@ METAL_CORE_SOURCES = \
12041204
METAL_SOURCES = \
12051205
Metal/MTLArgumentEncoder.cs \
12061206
Metal/MTLBlitPassSampleBufferAttachmentDescriptorArray.cs \
1207+
Metal/MTLCommandBuffer.cs \
1208+
Metal/MTLCommandQueue.cs \
12071209
Metal/MTLCompat.cs \
12081210
Metal/MTLIOCompression.cs \
12091211
Metal/MTLComputeCommandEncoder.cs \
@@ -1215,6 +1217,7 @@ METAL_SOURCES = \
12151217
Metal/MTLRenderCommandEncoder.cs \
12161218
Metal/MTLRenderPassDescriptor.cs \
12171219
Metal/MTLRenderPassSampleBufferAttachmentDescriptorArray.cs \
1220+
Metal/MTLResidencySet.cs \
12181221
Metal/MTLResourceStateCommandEncoder.cs \
12191222
Metal/MTLResourceStatePassSampleBufferAttachmentDescriptorArray.cs \
12201223
Metal/MTLVertexDescriptor.cs \

0 commit comments

Comments
 (0)