/*!
@brief 返回對首選系統(tǒng)默認Metal設(shè)備的引用。
@discussion 在Mac OS X系統(tǒng)上支持自動圖形切換,調(diào)用這種獲得Metal器件的API將使系統(tǒng)切換到高功率GPU。在支持多個GPU的其他系統(tǒng)上询微,它將返回GPU與主顯示相關(guān)聯(lián)武通。*/
@available(iOS 8.0, *)
public func MTLCreateSystemDefaultDevice() -> MTLDevice?
/*!
@brief 返回系統(tǒng)中的所有Metal設(shè)備鞭光。
@discussion 這個API不會導(dǎo)致系統(tǒng)切換設(shè)備,并根據(jù)它認為合適的標準來決定使用哪個GPU來使用應(yīng)用程序日戈。
*/
@available(iOS 8.0, *)
public enum MTLFeatureSet : UInt {
@available(iOS 8.0, *)
case iOS_GPUFamily1_v1
@available(iOS 8.0, *)
case iOS_GPUFamily2_v1
@available(iOS 9.0, *)
case iOS_GPUFamily1_v2
@available(iOS 9.0, *)
case iOS_GPUFamily2_v2
@available(iOS 9.0, *)
case iOS_GPUFamily3_v1
@available(iOS 10.0, *)
case iOS_GPUFamily1_v3
@available(iOS 10.0, *)
case iOS_GPUFamily2_v3
@available(iOS 10.0, *)
case iOS_GPUFamily3_v2
}
/*!
@enum MTLPipelineOption
@abstract 控制管道(pipeline)的創(chuàng)建
*/
@available(iOS 8.0, *)
public struct MTLPipelineOption : OptionSet {
public init(rawValue: UInt)
public static var argumentInfo: MTLPipelineOption { get }
public static var bufferTypeInfo: MTLPipelineOption { get }
}
/*!
@abstract 表示內(nèi)存大小和字節(jié)對齊另凌。
*/
public struct MTLSizeAndAlign {
public var size: Int
public var align: Int
public init()
public init(size: Int, align: Int)
}
/* Convenience typedef谱轨,它可以很容易地聲明某些返回類型的存儲。 */
public typealias MTLAutoreleasedRenderPipelineReflection = MTLRenderPipelineReflection
public typealias MTLAutoreleasedComputePipelineReflection = MTLComputePipelineReflection
public typealias MTLNewLibraryCompletionHandler = (MTLLibrary?, Error?) -> Swift.Void
public typealias MTLNewRenderPipelineStateCompletionHandler = (MTLRenderPipelineState?, Error?) -> Swift.Void
public typealias MTLNewRenderPipelineStateWithReflectionCompletionHandler = (MTLRenderPipelineState?, MTLRenderPipelineReflection?, Error?) -> Swift.Void
public typealias MTLNewComputePipelineStateCompletionHandler = (MTLComputePipelineState?, Error?) -> Swift.Void
public typealias MTLNewComputePipelineStateWithReflectionCompletionHandler = (MTLComputePipelineState?, MTLComputePipelineReflection?, Error?) -> Swift.Void
/*!
@protocol MTLDevice
@abstract MTLDevice 表示能夠進行數(shù)據(jù)并行計算的處理器
*/
@available(iOS 8.0, *)
public protocol MTLDevice : NSObjectProtocol {
/*!
@property name
@abstract 供應(yīng)商設(shè)備的全名途茫。
*/
public var name: String? { get }
/*!
@property maxThreadsPerThreadgroup
@abstract 每個維度上的最大線程數(shù)碟嘴。
*/
@available(iOS 9.0, *)
public var maxThreadsPerThreadgroup: MTLSize { get }
/*!
@method newCommandQueue
@brief 創(chuàng)建并返回一個新的命令隊列。通過此方法創(chuàng)建的命令隊列只允許64個未完成的命令緩沖區(qū)囊卜。
@return 新的命令隊列對象
*/
public func makeCommandQueue() -> MTLCommandQueue
/*!
@method newCommandQueueWithMaxCommandBufferCount
@brief 創(chuàng)建并返回一個包含未完成的命令緩沖區(qū)的新命令隊列。
@return 新的命令隊列對象
*/
public func makeCommandQueue(maxCommandBufferCount: Int) -> MTLCommandQueue
/*!
@method heapTextureSizeAndAlignWithDescriptor:
@abstract 當從堆中分配時错沃,確定紋理的字節(jié)大小栅组。
@discussion 此方法可用于幫助確定所需的堆大小。
*/
@available(iOS 10.0, *)
public func heapTextureSizeAndAlign(descriptor desc: MTLTextureDescriptor) -> MTLSizeAndAlign
/*!
@method heapBufferSizeAndAlignWithLength:options:
@abstract 從堆中分配子分配時枢析,確定緩沖區(qū)的字節(jié)大小玉掸。
@discussion 此方法可用于幫助確定所需的堆大小。
*/
@available(iOS 10.0, *)
public func heapBufferSizeAndAlign(length: Int, options: MTLResourceOptions = []) -> MTLSizeAndAlign
/*!
@method newHeapWithDescriptor:
@abstract 創(chuàng)建帶有給定描述符的新堆醒叁。
*/
@available(iOS 10.0, *)
public func makeHeap(descriptor: MTLHeapDescriptor) -> MTLHeap
/*!
@method newBufferWithLength:options:
@brief Create a buffer by allocating new memory.
*/
public func makeBuffer(length: Int, options: MTLResourceOptions = []) -> MTLBuffer
/*!
@method newBufferWithBytes:length:options:
@brief 通過分配新的內(nèi)存創(chuàng)建緩沖區(qū)司浪。
*/
public func makeBuffer(bytes pointer: UnsafeRawPointer, length: Int, options: MTLResourceOptions = []) -> MTLBuffer
/*!
@method newBufferWithBytesNoCopy:length:options:deallocator:
@brief 通過封裝地址空間的現(xiàn)有部分來創(chuàng)建緩沖區(qū)。
*/
public func makeBuffer(bytesNoCopy pointer: UnsafeMutableRawPointer, length: Int, options: MTLResourceOptions = [], deallocator: ((UnsafeMutableRawPointer, Int) -> Swift.Void)? = nil) -> MTLBuffer
/*!
@method newDepthStencilStateWithDescriptor:
@brief 創(chuàng)建一個深度/模板測試狀態(tài)對象把沼。
*/
public func makeDepthStencilState(descriptor: MTLDepthStencilDescriptor) -> MTLDepthStencilState
/*!
@method newTextureWithDescriptor:
@abstract 使用私有存儲分配新紋理啊易。
*/
public func makeTexture(descriptor: MTLTextureDescriptor) -> MTLTexture
/*!
@method newSamplerStateWithDescriptor:
@abstract 創(chuàng)建一個新的取樣器。
*/
public func makeSamplerState(descriptor: MTLSamplerDescriptor) -> MTLSamplerState
/*!
@method newDefaultLibrary
@abstract 返回主包的默認庫饮睬。
@discussion 使用newDefaultLibraryWithBundle:錯誤:得到一個NSError在失敗的情況下租谈。
*/
public func newDefaultLibrary() -> MTLLibrary?
/*
@method newDefaultLibraryWithBundle:error:
@abstract 返回給定bundle的默認庫
@return 一個指向庫的指針,如果出現(xiàn)錯誤捆愁,則為nil割去。
*/
@available(iOS 10.0, *)
public func makeDefaultLibrary(bundle: Bundle) throws -> MTLLibrary
/*!
@method newLibraryWithFile:
@abstract 從一個Metal庫文件加載一個MTLLibrary。
*/
public func makeLibrary(filepath: String) throws -> MTLLibrary
/*!
@method newLibraryWithData:
@abstract 從dispatch_data_t加載一個MTLLibrary
@param data 已經(jīng)以dispatch_data_t的形式加載的Metal庫文件昼丑。
@param error 如果我們沒有打開Metal庫數(shù)據(jù)呻逆,會出現(xiàn)錯誤。
*/
public func makeLibrary(data: __DispatchData) throws -> MTLLibrary
/*!
@method newLibraryWithSource:options:error:
@abstract 從源裝載一個MTLLibrary菩帝。
*/
public func makeLibrary(source: String, options: MTLCompileOptions?) throws -> MTLLibrary
/*!
@method newLibraryWithSource:options:completionHandler:
@abstract 從源裝載一個MTLLibrary咖城。
*/
public func makeLibrary(source: String, options: MTLCompileOptions?, completionHandler: @escaping Metal.MTLNewLibraryCompletionHandler)
/*!
@method newRenderPipelineStateWithDescriptor:error:
@abstract 同步創(chuàng)建和編譯一個新的mtlrender管道對象茬腿。
*/
public func makeRenderPipelineState(descriptor: MTLRenderPipelineDescriptor) throws -> MTLRenderPipelineState
/*!
@method newRenderPipelineStateWithDescriptor:options:reflection:error:
@abstract 創(chuàng)建并編譯一個新的mtlrender管線對象,并返回額外的反射信息酒繁。
*/
public func makeRenderPipelineState(descriptor: MTLRenderPipelineDescriptor, options: MTLPipelineOption, reflection: AutoreleasingUnsafeMutablePointer<MTLAutoreleasedRenderPipelineReflection?>?) throws -> MTLRenderPipelineState
/*!
@method newRenderPipelineState:completionHandler:
@abstract 異步創(chuàng)建和編譯一個新的mtlrender管線對象滓彰。
*/
public func makeRenderPipelineState(descriptor: MTLRenderPipelineDescriptor, completionHandler: @escaping Metal.MTLNewRenderPipelineStateCompletionHandler)
/*!
@method newRenderPipelineState:options:completionHandler:
@abstract 創(chuàng)建并編譯一個新的mtlrender管線對象,并返回額外的反射信息
*/
public func makeRenderPipelineState(descriptor: MTLRenderPipelineDescriptor, options: MTLPipelineOption, completionHandler: @escaping Metal.MTLNewRenderPipelineStateWithReflectionCompletionHandler)
/*!
@method newComputePipelineStateWithDescriptor:error:
@abstract 同步創(chuàng)建和編譯一個新的mtlcomputeUNK inestate對象州袒。
*/
public func makeComputePipelineState(function computeFunction: MTLFunction) throws -> MTLComputePipelineState
/*!
@method newComputePipelineStateWithDescriptor:options:reflection:error:
@abstract 同步創(chuàng)建和編譯一個新的mtlcomputeUNK inestate對象揭绑。
*/
public func makeComputePipelineState(function computeFunction: MTLFunction, options: MTLPipelineOption, reflection: AutoreleasingUnsafeMutablePointer<MTLAutoreleasedComputePipelineReflection?>?) throws -> MTLComputePipelineState
/*!
@method newComputePipelineStateWithDescriptor:completionHandler:
@abstract異步地創(chuàng)建和編譯一個新的mtlcomputeUNK inestate對象。
*/
public func makeComputePipelineState(function computeFunction: MTLFunction, completionHandler: @escaping Metal.MTLNewComputePipelineStateCompletionHandler)
/*!
@method newComputePipelineStateWithDescriptor:options:completionHandler:
@abstract異步地創(chuàng)建和編譯一個新的mtlcomputeUNK inestate對象郎哭。
*/
public func makeComputePipelineState(function computeFunction: MTLFunction, options: MTLPipelineOption, completionHandler: @escaping Metal.MTLNewComputePipelineStateWithReflectionCompletionHandler)
/*!
@method newComputePipelineStateWithDescriptor:options:reflection:error:
@abstract 同步創(chuàng)建和編譯一個新的mtlcomputeUNK inestate對象他匪。
*/
@available(iOS 9.0, *)
public func makeComputePipelineState(descriptor: MTLComputePipelineDescriptor, options: MTLPipelineOption, reflection: AutoreleasingUnsafeMutablePointer<MTLAutoreleasedComputePipelineReflection?>?) throws -> MTLComputePipelineState
/*!
@method newComputePipelineStateWithDescriptor:options:completionHandler:
@abstract異步地創(chuàng)建和編譯一個新的mtlcomputeUNK inestate對象。
*/
@available(iOS 9.0, *)
public func makeComputePipelineState(descriptor: MTLComputePipelineDescriptor, options: MTLPipelineOption, completionHandler: @escaping Metal.MTLNewComputePipelineStateWithReflectionCompletionHandler)
/*!
@method newFence
@abstract 創(chuàng)建一個新的MTLFence對象
*/
@available(iOS 10.0, *)
public func makeFence() -> MTLFence
/*!
@method supportsFeatureSet:
@abstract Returns TRUE if the feature set is supported by this MTLDevice.
*/
public func supportsFeatureSet(_ featureSet: MTLFeatureSet) -> Bool
/*!
@method supportsTextureSampleCount:
@brief 查詢設(shè)備夸研,如果它支持給定的sampleCount的紋理邦蜜。
@return BOOL value. 如果是,設(shè)備支持給定的紋理樣式亥至。如果沒有悼沈,設(shè)備不支持給定的sampleCount。
*/
@available(iOS 9.0, *)
public func supportsTextureSampleCount(_ sampleCount: Int) -> Bool
}