Skip to content

Commit 6aca92c

Browse files
authored
[Metal] Implement Xcode 16.0 beta 1-6 changes. (#20895)
Note: there were no changes in beta 3, beta 4 or beta 5.
1 parent 02fe91b commit 6aca92c

28 files changed

+1011
-1703
lines changed

src/Metal/MTLCommandBuffer.cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
/// <param name="residencySets">The residency sets to mark.</param>
13+
public void UseResidencySets (params IMTLResidencySet [] residencySets)
14+
{
15+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (residencySets, nameof (residencySets), UseResidencySets);
16+
}
17+
}
18+
}

src/Metal/MTLCommandQueue.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
/// <param name="residencySets">The residency sets to mark.</param>
13+
public void AddResidencySets (params IMTLResidencySet [] residencySets)
14+
{
15+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (residencySets, nameof (residencySets), AddResidencySets);
16+
}
17+
18+
/// <summary>Removes the specified residency sets from the current command buffer execution.</summary>
19+
/// <param name="residencySets">The residency sets to mark.</param>
20+
public void RemoveResidencySets (params IMTLResidencySet [] residencySets)
21+
{
22+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (residencySets, nameof (residencySets), RemoveResidencySets);
23+
}
24+
}
25+
}

src/Metal/MTLDevice.cs

+8-10
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

+59-1
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>
@@ -1690,7 +1740,15 @@ public enum MTLFunctionOptions : ulong {
16901740
[MacCatalyst (14, 0)]
16911741
CompileToBinary = 1uL << 0,
16921742
[iOS (17, 0), TV (17, 0), MacCatalyst (17, 0), Mac (14, 0)]
1743+
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Use 'StoreFunctionInMetalPipelinesScript' instead.")]
1744+
[Deprecated (PlatformName.iOS, 18, 0, message: "Use 'StoreFunctionInMetalPipelinesScript' instead.")]
1745+
[Deprecated (PlatformName.TvOS, 18, 0, message: "Use 'StoreFunctionInMetalPipelinesScript' instead.")]
1746+
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Use 'StoreFunctionInMetalPipelinesScript' instead.")]
16931747
StoreFunctionInMetalScript = 1uL << 1,
1748+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
1749+
StoreFunctionInMetalPipelinesScript = 1 << 1,
1750+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0)]
1751+
FailOnBinaryArchiveMiss = 1 << 2,
16941752
}
16951753

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

src/Metal/MTLResidencySet.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
/// <param name="allocations">The allocations to add.</param>
13+
public void AddAllocations (params IMTLAllocation [] allocations)
14+
{
15+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (allocations, nameof (allocations), AddAllocations);
16+
}
17+
18+
/// <summary>Marks allocations to be removed the next time <see cref="Commit" /> is called.</summary>
19+
/// <param name="allocations">The allocations to remove.</param>
20+
public void RemoveAllocations (params IMTLAllocation [] allocations)
21+
{
22+
NativeObjectExtensions.CallWithPointerToFirstElementAndCount (allocations, nameof (allocations), RemoveAllocations);
23+
}
24+
}
25+
}

src/ObjCRuntime/INativeObject.cs

+19
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

+5
Original file line numberDiff line numberDiff line change
@@ -13230,6 +13230,11 @@ interface NSProcessInfo {
1323013230
[Export ("iOSAppOnMac")]
1323113231
bool IsiOSApplicationOnMac { [Bind ("isiOSAppOnMac")] get; }
1323213232
#endregion
13233+
13234+
[Field ("NSProcessInfoPerformanceProfileDidChangeNotification", "Metal")]
13235+
[Notification]
13236+
[TV (18, 0), Mac (15, 0), iOS (18, 0), MacCatalyst (18, 0), NoWatch]
13237+
NSString PerformanceProfileDidChangeNotification { get; }
1323313238
}
1323413239

1323513240
[NoWatch]

src/frameworks.sources

+3
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,8 @@ METAL_CORE_SOURCES = \
12231223
METAL_SOURCES = \
12241224
Metal/MTLArgumentEncoder.cs \
12251225
Metal/MTLBlitPassSampleBufferAttachmentDescriptorArray.cs \
1226+
Metal/MTLCommandBuffer.cs \
1227+
Metal/MTLCommandQueue.cs \
12261228
Metal/MTLCompat.cs \
12271229
Metal/MTLIOCompression.cs \
12281230
Metal/MTLComputeCommandEncoder.cs \
@@ -1234,6 +1236,7 @@ METAL_SOURCES = \
12341236
Metal/MTLRenderCommandEncoder.cs \
12351237
Metal/MTLRenderPassDescriptor.cs \
12361238
Metal/MTLRenderPassSampleBufferAttachmentDescriptorArray.cs \
1239+
Metal/MTLResidencySet.cs \
12371240
Metal/MTLResourceStateCommandEncoder.cs \
12381241
Metal/MTLResourceStatePassSampleBufferAttachmentDescriptorArray.cs \
12391242
Metal/MTLVertexDescriptor.cs \

0 commit comments

Comments
 (0)