[metalkit] Add new API from both beta 1 and beta 2 (#383)
This commit is contained in:
Родитель
dd79e15f3b
Коммит
eeb1d10713
|
@ -2,6 +2,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using XamCore.Foundation;
|
||||
using XamCore.ModelIO;
|
||||
using XamCore.ObjCRuntime;
|
||||
using XamCore.Metal;
|
||||
|
@ -20,6 +21,21 @@ namespace XamCore.Metal {
|
|||
throw new ArgumentException ("descriptor");
|
||||
return Runtime.GetNSObject<MTLVertexDescriptor> (MTKMetalVertexDescriptorFromModelIO (descriptor.Handle));
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[DllImport (Constants.MetalKitLibrary)]
|
||||
static extern /* MTLVertexDescriptor __nonnull */ IntPtr MTKMetalVertexDescriptorFromModelIOWithError (/* MDLVertexDescriptor __nonnull */ IntPtr modelIODescriptor, out IntPtr error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
public static MTLVertexDescriptor FromModelIO (MDLVertexDescriptor descriptor, out NSError error)
|
||||
{
|
||||
if (descriptor == null)
|
||||
throw new ArgumentException ("descriptor");
|
||||
IntPtr err;
|
||||
var vd = Runtime.GetNSObject<MTLVertexDescriptor> (MTKMetalVertexDescriptorFromModelIOWithError (descriptor.Handle, out err));
|
||||
error = Runtime.GetNSObject<NSError> (err);
|
||||
return vd;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -46,6 +46,54 @@ namespace XamCore.MetalKit {
|
|||
RemoveValue (MTKTextureLoaderKeys.TextureCpuCacheModeKey);
|
||||
}
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
public MTLStorageMode? TextureStorageMode {
|
||||
get {
|
||||
var val = GetNUIntValue (MTKTextureLoaderKeys.TextureStorageModeKey);
|
||||
if (val != null)
|
||||
return (MTLStorageMode)(uint) val;
|
||||
return null;
|
||||
}
|
||||
set {
|
||||
if (value.HasValue)
|
||||
SetNumberValue (MTKTextureLoaderKeys.TextureStorageModeKey, (nuint)(uint)value.Value);
|
||||
else
|
||||
RemoveValue (MTKTextureLoaderKeys.TextureStorageModeKey);
|
||||
}
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
public MTKTextureLoaderCubeLayout? CubeLayout {
|
||||
get {
|
||||
var val = GetNSStringValue (MTKTextureLoaderKeys.CubeLayoutKey);
|
||||
if (val == null)
|
||||
return null;
|
||||
return MTKTextureLoaderCubeLayoutExtensions.GetValue (val);
|
||||
}
|
||||
set {
|
||||
if (value.HasValue)
|
||||
SetStringValue (MTKTextureLoaderKeys.CubeLayoutKey, value.Value.GetConstant ());
|
||||
else
|
||||
RemoveValue (MTKTextureLoaderKeys.CubeLayoutKey);
|
||||
}
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
public MTKTextureLoaderOrigin? Origin {
|
||||
get {
|
||||
var val = GetNSStringValue (MTKTextureLoaderKeys.OriginKey);
|
||||
if (val == null)
|
||||
return null;
|
||||
return MTKTextureLoaderOriginExtensions.GetValue (val);
|
||||
}
|
||||
set {
|
||||
if (value.HasValue)
|
||||
SetStringValue (MTKTextureLoaderKeys.OriginKey, value.Value.GetConstant ());
|
||||
else
|
||||
RemoveValue (MTKTextureLoaderKeys.OriginKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using XamCore.Foundation;
|
||||
using XamCore.ModelIO;
|
||||
using XamCore.ObjCRuntime;
|
||||
using XamCore.Metal;
|
||||
|
@ -17,6 +18,21 @@ namespace XamCore.ModelIO {
|
|||
throw new ArgumentException ("descriptor");
|
||||
return Runtime.GetNSObject<MDLVertexDescriptor> (MTKModelIOVertexDescriptorFromMetal (descriptor.Handle));
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[DllImport (Constants.MetalKitLibrary)]
|
||||
static extern /* MDLVertexDescriptor __nonnull */ IntPtr MTKModelIOVertexDescriptorFromMetalWithError (/* MTLVertexDescriptor __nonnull */ IntPtr metalDescriptor, out /* NSError */ IntPtr error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
public static MDLVertexDescriptor FromMetal (MTLVertexDescriptor descriptor, out NSError error)
|
||||
{
|
||||
if (descriptor == null)
|
||||
throw new ArgumentException ("descriptor");
|
||||
IntPtr err;
|
||||
var vd = Runtime.GetNSObject<MDLVertexDescriptor> (MTKModelIOVertexDescriptorFromMetalWithError (descriptor.Handle, out err));
|
||||
error = Runtime.GetNSObject<NSError> (err);
|
||||
return vd;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
139
src/metalkit.cs
139
src/metalkit.cs
|
@ -11,6 +11,13 @@ using OpenTK;
|
|||
|
||||
namespace XamCore.MetalKit {
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Native]
|
||||
public enum MTKDisplayGamut : nuint {
|
||||
Srgb = 0,
|
||||
DisplayP3 = 1
|
||||
}
|
||||
|
||||
[iOS (9,0)][Mac (10,11, onlyOn64 : true)]
|
||||
[Static]
|
||||
interface MTKModel {
|
||||
|
@ -29,7 +36,7 @@ namespace XamCore.MetalKit {
|
|||
#else
|
||||
[BaseType (typeof (XamCore.UIKit.UIView))]
|
||||
#endif
|
||||
interface MTKView : NSCoding {
|
||||
interface MTKView : NSCoding, CALayerDelegate {
|
||||
|
||||
[Export ("initWithFrame:device:")]
|
||||
[DesignatedInitializer]
|
||||
|
@ -135,6 +142,10 @@ namespace XamCore.MetalKit {
|
|||
[Field ("MTKTextureLoaderOptionAllocateMipmaps")]
|
||||
NSString AllocateMipmapsKey { get; }
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Field ("MTKTextureLoaderOptionGenerateMipmaps")]
|
||||
NSString GenerateMipmapsKey { get; }
|
||||
|
||||
[Field ("MTKTextureLoaderOptionSRGB")]
|
||||
NSString SrgbKey { get; }
|
||||
|
||||
|
@ -143,17 +154,52 @@ namespace XamCore.MetalKit {
|
|||
|
||||
[Field ("MTKTextureLoaderOptionTextureCPUCacheMode")]
|
||||
NSString TextureCpuCacheModeKey { get; }
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Field ("MTKTextureLoaderOptionTextureStorageMode")]
|
||||
NSString TextureStorageModeKey { get; }
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Field ("MTKTextureLoaderOptionCubeLayout")]
|
||||
NSString CubeLayoutKey { get; }
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Field ("MTKTextureLoaderOptionOrigin")]
|
||||
NSString OriginKey { get; }
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
enum MTKTextureLoaderCubeLayout {
|
||||
[Field ("MTKTextureLoaderCubeLayoutVertical")]
|
||||
Vertical,
|
||||
}
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
enum MTKTextureLoaderOrigin {
|
||||
[Field ("MTKTextureLoaderOriginTopLeft")]
|
||||
TopLeft,
|
||||
[Field ("MTKTextureLoaderOriginBottomLeft")]
|
||||
BottomLeft,
|
||||
[Field ("MTKTextureLoaderOriginFlippedVertically")]
|
||||
FlippedVertically,
|
||||
}
|
||||
|
||||
[StrongDictionary ("MTKTextureLoaderKeys")]
|
||||
interface MTKTextureLoaderOptions {
|
||||
bool AllocateMipmaps { get; }
|
||||
bool Srgb { get; }
|
||||
bool AllocateMipmaps { get; set; }
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
bool GenerateMipmaps { get; }
|
||||
|
||||
bool Srgb { get; set; }
|
||||
}
|
||||
|
||||
[iOS (9,0)][Mac (10,11, onlyOn64 : true)]
|
||||
delegate void MTKTextureLoaderCallback ([NullAllowed] IMTLTexture texture, [NullAllowed] NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
delegate void MTKTextureLoaderArrayCallback (IMTLTexture[] textures, [NullAllowed] NSError error);
|
||||
|
||||
[iOS (9,0)][Mac (10,11, onlyOn64 : true)]
|
||||
[BaseType (typeof (NSObject))]
|
||||
[DisableDefaultCtor]
|
||||
|
@ -190,6 +236,22 @@ namespace XamCore.MetalKit {
|
|||
[return: NullAllowed]
|
||||
IMTLTexture FromUrl (NSUrl url, [NullAllowed] MTKTextureLoaderOptions options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTexturesWithContentsOfURLs:options:completionHandler:")]
|
||||
void FromUrls (NSUrl[] urls, [NullAllowed] NSDictionary options, MTKTextureLoaderArrayCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromUrls (urls, options == null ? null : options.Dictionary, completionHandler)")]
|
||||
void FromUrls (NSUrl[] urls, [NullAllowed] MTKTextureLoaderOptions options, MTKTextureLoaderArrayCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTexturesWithContentsOfURLs:options:error:")]
|
||||
IMTLTexture[] FromUrls (NSUrl[] urls, [NullAllowed] NSDictionary options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromUrls (urls, options == null ? null : options.Dictionary, out error)")]
|
||||
IMTLTexture[] FromUrls (NSUrl[] urls, [NullAllowed] MTKTextureLoaderOptions options, out NSError error);
|
||||
|
||||
[Export ("newTextureWithData:options:error:"), Internal]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromData (NSData data, [NullAllowed] NSDictionary options, out NSError error);
|
||||
|
@ -205,6 +267,75 @@ namespace XamCore.MetalKit {
|
|||
[Wrap ("FromCGImage (cgImage, options == null ? null : options.Dictionary, out error)")]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromCGImage (CGImage cgImage, [NullAllowed] MTKTextureLoaderOptions options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTextureWithName:scaleFactor:bundle:options:completionHandler:")]
|
||||
void FromName (string name, nfloat scaleFactor, [NullAllowed] NSBundle bundle, [NullAllowed] NSDictionary options, MTKTextureLoaderCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromName (name, scaleFactor, bundle, options == null ? null : options.Dictionary, completionHandler)")]
|
||||
void FromName (string name, nfloat scaleFactor, [NullAllowed] NSBundle bundle, [NullAllowed] MTKTextureLoaderOptions options, MTKTextureLoaderCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTextureWithName:scaleFactor:displayGamut:bundle:options:completionHandler:")]
|
||||
void FromName (string name, nfloat scaleFactor, MTKDisplayGamut displayGamut, [NullAllowed] NSBundle bundle, [NullAllowed] NSDictionary options, MTKTextureLoaderCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromName (name, scaleFactor, displayGamut, bundle, options == null ? null : options.Dictionary, completionHandler)")]
|
||||
void FromName (string name, nfloat scaleFactor, MTKDisplayGamut displayGamut, [NullAllowed] NSBundle bundle, [NullAllowed] MTKTextureLoaderOptions options, MTKTextureLoaderCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTexturesWithNames:scaleFactor:bundle:options:completionHandler:")]
|
||||
void FromNames (string[] names, nfloat scaleFactor, [NullAllowed] NSBundle bundle, [NullAllowed] NSDictionary options, MTKTextureLoaderArrayCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromNames (names, scaleFactor, bundle, options == null ? null : options.Dictionary, completionHandler)")]
|
||||
void FromNames (string[] names, nfloat scaleFactor, [NullAllowed] NSBundle bundle, [NullAllowed] MTKTextureLoaderOptions options, MTKTextureLoaderArrayCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTexturesWithNames:scaleFactor:displayGamut:bundle:options:completionHandler:")]
|
||||
void FromNames (string[] names, nfloat scaleFactor, MTKDisplayGamut displayGamut, [NullAllowed] NSBundle bundle, [NullAllowed] NSDictionary options, MTKTextureLoaderArrayCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromNames (names, scaleFactor, displayGamut, bundle, options == null ? null : options.Dictionary, completionHandler)")]
|
||||
void FromNames (string[] names, nfloat scaleFactor, MTKDisplayGamut displayGamut, [NullAllowed] NSBundle bundle, [NullAllowed] MTKTextureLoaderOptions options, MTKTextureLoaderArrayCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTextureWithName:scaleFactor:displayGamut:bundle:options:error:")]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromName (string name, nfloat scaleFactor, MTKDisplayGamut displayGamut, [NullAllowed] NSBundle bundle, [NullAllowed] NSDictionary options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromName (name, scaleFactor, displayGamut, bundle, options == null ? null : options.Dictionary, out error)")]
|
||||
void FromName (string name, nfloat scaleFactor, MTKDisplayGamut displayGamut, [NullAllowed] NSBundle bundle, [NullAllowed] MTKTextureLoaderOptions options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTextureWithMDLTexture:options:completionHandler:")]
|
||||
void FromTexture (MDLTexture texture, [NullAllowed] NSDictionary options, MTKTextureLoaderCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromTexture (texture, options == null ? null : options.Dictionary, completionHandler)")]
|
||||
void FromTexture (MDLTexture texture, [NullAllowed] MTKTextureLoaderOptions options, MTKTextureLoaderCallback completionHandler);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTextureWithMDLTexture:options:error:")]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromTexture (MDLTexture texture, [NullAllowed] NSDictionary options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromTexture (texture, options == null ? null : options.Dictionary, out error)")]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromTexture (MDLTexture texture, [NullAllowed] MTKTextureLoaderOptions options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Export ("newTextureWithName:scaleFactor:bundle:options:error:")]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromName (string name, nfloat scaleFactor, [NullAllowed] NSBundle bundle, [NullAllowed] NSDictionary options, out NSError error);
|
||||
|
||||
[iOS (10,0)][Mac (10,12, onlyOn64 : true)]
|
||||
[Wrap ("FromName (name, scaleFactor, bundle, options == null ? null : options.Dictionary, out error)")]
|
||||
[return: NullAllowed]
|
||||
IMTLTexture FromName (string name, nfloat scaleFactor, [NullAllowed] NSBundle bundle, [NullAllowed] MTKTextureLoaderOptions options, out NSError error);
|
||||
}
|
||||
|
||||
[iOS (9,0)][Mac (10,11, onlyOn64 : true)]
|
||||
|
@ -221,7 +352,7 @@ namespace XamCore.MetalKit {
|
|||
[iOS (9,0)][Mac (10,11, onlyOn64 : true)]
|
||||
[BaseType (typeof(NSObject))]
|
||||
[DisableDefaultCtor]
|
||||
interface MTKMeshBuffer : MDLMeshBuffer {
|
||||
interface MTKMeshBuffer : MDLMeshBuffer, MDLNamed {
|
||||
[Export ("buffer")]
|
||||
IMTLBuffer Buffer { get; }
|
||||
|
||||
|
|
|
@ -132,6 +132,19 @@ namespace Introspection {
|
|||
return true; // skip
|
||||
}
|
||||
break;
|
||||
// conformance added in Xcode 8 (iOS 10 / macOS 10.12)
|
||||
case "MDLNamed":
|
||||
switch (type.Name) {
|
||||
case "MTKMeshBuffer":
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case "CALayerDelegate":
|
||||
switch (type.Name) {
|
||||
case "MTKView":
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -132,6 +132,14 @@ namespace Introspection {
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
// now conforms to MDLName
|
||||
case "MTKMeshBuffer":
|
||||
switch (selectorName) {
|
||||
case "name":
|
||||
case "setName:":
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
// This ctors needs to be manually bound
|
||||
|
|
Загрузка…
Ссылка в новой задаче