MTLDevice

1623 篇文章 22 订阅
1277 篇文章 12 订阅


Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


OBJECTIVE-C

@import Metal;

Availability


Available in iOS 8.0 and later 

The MTLDevice protocol defines the interface to a single graphics processor (GPU). You use an object that conforms to this protocol to query the capabilities of the processor and to allocate objects used to access those capabilities.

Your app does not define classes that implement this protocol; it is used by Metal to provide a device object to your app. To obtain a system device, call the MTLCreateSystemDefaultDevice function or select a result from the MTLCopyAllDevices function.

Most objects in Metal that perform graphics rendering and computational work are associated directly with a specific device. For example, texture objects are created by a device object and can be used only with that device. Most methods on a MTLDevice object create non-transient objects, including command queues, resources (such as buffers and textures), and pipeline states. These objects can be expensive to create and you are encouraged to create them soon after your app launches and reuse them throughout the lifetime of your app. Avoid creating these objects in performance sensitive code.

Identifying Properties

Creating Command Queues

Creating Command Objects Needed to Render Graphics

Creating Command Objects Needed to Perform Computational Tasks

  • Asynchronously creates a new compute pipeline state object that represents a compiled compute function.

    Declaration

    OBJECTIVE-C

    - (void)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                              completionHandler:(MTLNewComputePipelineStateCompletionHandler)completionHandler

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    completionHandler

    A block of code that is invoked when the logic to create the compute pipeline state object is completed.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    Availability

    Available in iOS 8.0 and later.

  • Asynchronously creates a new compute pipeline state object that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (void)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                                        options:(MTLPipelineOption)options
                              completionHandler:(MTLNewComputePipelineStateWithReflectionCompletionHandler)completionHandler

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    options

    The type of reflection information that should be returned.

    completionHandler

    A block of code that is invoked when the logic to create the compute pipeline state object is completed.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    Availability

    Available in iOS 8.0 and later.

  • Synchronously creates a new compute pipeline state object that represents a compiled compute function.

    Declaration

    OBJECTIVE-C

    - (id<MTLComputePipelineState>)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                                                                 error:(NSError * _Nullable *)error

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    error

    An error object that describes the problem, or nil if the operation succeeded.

    Return Value

    A new object that can be used as a compute pipeline state.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    HANDLING ERRORS IN SWIFT:

    In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language (Swift 2.1) and Error Handling in Using Swift with Cocoa and Objective-C (Swift 2.1).

    Availability

    Available in iOS 8.0 and later.

  • Synchronously creates a new compute pipeline state object that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (id<MTLComputePipelineState>)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                                                               options:(MTLPipelineOption)options
                                                            reflection:(MTLAutoreleasedComputePipelineReflection *)reflection
                                                                 error:(NSError * _Nullable *)error

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    options

    The type of reflection information that should be returned.

    reflection

    Reflection data about the compute function, including details about function arguments.

    error

    An error object that describes the problem, or nil if the operation succeeded.

    Return Value

    A new object that can be used as a compute pipeline state.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    HANDLING ERRORS IN SWIFT:

    In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language (Swift 2.1) and Error Handling in Using Swift with Cocoa and Objective-C (Swift 2.1).

    Availability

    Available in iOS 8.0 and later.

  • Asynchronously creates a new compute pipeline state object, from a compute pipeline descriptor, that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (void)newComputePipelineStateWithDescriptor:(MTLComputePipelineDescriptor *)descriptor
                                          options:(MTLPipelineOption)options
                                completionHandler:(MTLNewComputePipelineStateWithReflectionCompletionHandler)completionHandler

    Parameters
    descriptor

    A descriptor object that contains compute properties.

    options

    The type of reflection information that should be returned.

    completionHandler

    A block of code that is invoked when the logic to create the compute pipeline state object is completed.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    Availability

    Available in iOS 9.0 and later.

  • Synchronously creates a new compute pipeline state object, from a compute pipeline descriptor, that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (id<MTLComputePipelineState>)newComputePipelineStateWithDescriptor:(MTLComputePipelineDescriptor *)descriptor
                                                                 options:(MTLPipelineOption)options
                                                              reflection:(MTLAutoreleasedComputePipelineReflection *)reflection
                                                                   error:(NSError * _Nullable *)error

    Parameters
    descriptor

    A descriptor object that contains compute properties.

    options

    The type of reflection information that should be returned.

    reflection

    Reflection data about the compute function, including details about function arguments.

    error

    An error object that describes the problem, or nil if the operation succeeded.

    Return Value

    A new object with the compiled compute pipeline state.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    HANDLING ERRORS IN SWIFT:

    In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language (Swift 2.1) and Error Handling in Using Swift with Cocoa and Objective-C (Swift 2.1).

    Availability

    Available in iOS 9.0 and later.

Data Types

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


OBJECTIVE-C

@import Metal;

Availability


Available in iOS 8.0 and later 

The MTLDevice protocol defines the interface to a single graphics processor (GPU). You use an object that conforms to this protocol to query the capabilities of the processor and to allocate objects used to access those capabilities.

Your app does not define classes that implement this protocol; it is used by Metal to provide a device object to your app. To obtain a system device, call the MTLCreateSystemDefaultDevice function or select a result from the MTLCopyAllDevices function.

Most objects in Metal that perform graphics rendering and computational work are associated directly with a specific device. For example, texture objects are created by a device object and can be used only with that device. Most methods on a MTLDevice object create non-transient objects, including command queues, resources (such as buffers and textures), and pipeline states. These objects can be expensive to create and you are encouraged to create them soon after your app launches and reuse them throughout the lifetime of your app. Avoid creating these objects in performance sensitive code.

Identifying Properties

Creating Command Queues

Creating Command Objects Needed to Render Graphics

Creating Command Objects Needed to Perform Computational Tasks

  • Asynchronously creates a new compute pipeline state object that represents a compiled compute function.

    Declaration

    OBJECTIVE-C

    - (void)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                              completionHandler:(MTLNewComputePipelineStateCompletionHandler)completionHandler

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    completionHandler

    A block of code that is invoked when the logic to create the compute pipeline state object is completed.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    Availability

    Available in iOS 8.0 and later.

  • Asynchronously creates a new compute pipeline state object that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (void)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                                        options:(MTLPipelineOption)options
                              completionHandler:(MTLNewComputePipelineStateWithReflectionCompletionHandler)completionHandler

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    options

    The type of reflection information that should be returned.

    completionHandler

    A block of code that is invoked when the logic to create the compute pipeline state object is completed.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    Availability

    Available in iOS 8.0 and later.

  • Synchronously creates a new compute pipeline state object that represents a compiled compute function.

    Declaration

    OBJECTIVE-C

    - (id<MTLComputePipelineState>)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                                                                 error:(NSError * _Nullable *)error

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    error

    An error object that describes the problem, or nil if the operation succeeded.

    Return Value

    A new object that can be used as a compute pipeline state.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    HANDLING ERRORS IN SWIFT:

    In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language (Swift 2.1) and Error Handling in Using Swift with Cocoa and Objective-C (Swift 2.1).

    Availability

    Available in iOS 8.0 and later.

  • Synchronously creates a new compute pipeline state object that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (id<MTLComputePipelineState>)newComputePipelineStateWithFunction:(id<MTLFunction>)function
                                                               options:(MTLPipelineOption)options
                                                            reflection:(MTLAutoreleasedComputePipelineReflection *)reflection
                                                                 error:(NSError * _Nullable *)error

    Parameters
    function

    A function object to be compiled into a compute pipeline state object.

    options

    The type of reflection information that should be returned.

    reflection

    Reflection data about the compute function, including details about function arguments.

    error

    An error object that describes the problem, or nil if the operation succeeded.

    Return Value

    A new object that can be used as a compute pipeline state.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    HANDLING ERRORS IN SWIFT:

    In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language (Swift 2.1) and Error Handling in Using Swift with Cocoa and Objective-C (Swift 2.1).

    Availability

    Available in iOS 8.0 and later.

  • Asynchronously creates a new compute pipeline state object, from a compute pipeline descriptor, that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (void)newComputePipelineStateWithDescriptor:(MTLComputePipelineDescriptor *)descriptor
                                          options:(MTLPipelineOption)options
                                completionHandler:(MTLNewComputePipelineStateWithReflectionCompletionHandler)completionHandler

    Parameters
    descriptor

    A descriptor object that contains compute properties.

    options

    The type of reflection information that should be returned.

    completionHandler

    A block of code that is invoked when the logic to create the compute pipeline state object is completed.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    Availability

    Available in iOS 9.0 and later.

  • Synchronously creates a new compute pipeline state object, from a compute pipeline descriptor, that represents a compiled compute function and returns additional reflection information.

    Declaration

    OBJECTIVE-C

    - (id<MTLComputePipelineState>)newComputePipelineStateWithDescriptor:(MTLComputePipelineDescriptor *)descriptor
                                                                 options:(MTLPipelineOption)options
                                                              reflection:(MTLAutoreleasedComputePipelineReflection *)reflection
                                                                   error:(NSError * _Nullable *)error

    Parameters
    descriptor

    A descriptor object that contains compute properties.

    options

    The type of reflection information that should be returned.

    reflection

    Reflection data about the compute function, including details about function arguments.

    error

    An error object that describes the problem, or nil if the operation succeeded.

    Return Value

    A new object with the compiled compute pipeline state.

    Discussion

    To use the compute pipeline state for a compute pass, call the setComputePipelineState: method of aMTLComputeCommandEncoder object with the MTLComputePipelineState object.

    HANDLING ERRORS IN SWIFT:

    In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language (Swift 2.1) and Error Handling in Using Swift with Cocoa and Objective-C (Swift 2.1).

    Availability

    Available in iOS 9.0 and later.

Data Types

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值