Interface MTLDevice


  • public interface MTLDevice
    [@protocol] MTLDevice MTLDevice represents a processor capable of data parallel computations
    • Method Detail

      • heapBufferSizeAndAlignWithLengthOptions

        MTLSizeAndAlign heapBufferSizeAndAlignWithLengthOptions​(long length,
                                                                long options)
        heapBufferSizeAndAlignWithLength:options: Determine the byte size of buffers when sub-allocated from a heap. This method can be used to help determine the required heap size.
      • heapTextureSizeAndAlignWithDescriptor

        MTLSizeAndAlign heapTextureSizeAndAlignWithDescriptor​(MTLTextureDescriptor desc)
        heapTextureSizeAndAlignWithDescriptor: Determine the byte size of textures when sub-allocated from a heap. This method can be used to help determine the required heap size.
      • maxThreadsPerThreadgroup

        MTLSize maxThreadsPerThreadgroup()
        [@property] maxThreadsPerThreadgroup The maximum number of threads along each dimension.
      • name

        java.lang.String name()
        [@property] name The full name of the vendor device.
      • newBufferWithBytesLengthOptions

        MTLBuffer newBufferWithBytesLengthOptions​(org.moe.natj.general.ptr.ConstVoidPtr pointer,
                                                  long length,
                                                  long options)
        newBufferWithBytes:length:options: Create a buffer by allocating new memory and specifing the initial contents to be copied into it.
      • newBufferWithBytesNoCopyLengthOptionsDeallocator

        MTLBuffer newBufferWithBytesNoCopyLengthOptionsDeallocator​(org.moe.natj.general.ptr.VoidPtr pointer,
                                                                   long length,
                                                                   long options,
                                                                   MTLDevice.Block_newBufferWithBytesNoCopyLengthOptionsDeallocator deallocator)
        newBufferWithBytesNoCopy:length:options:deallocator: Create a buffer by wrapping an existing part of the address space.
      • newBufferWithLengthOptions

        MTLBuffer newBufferWithLengthOptions​(long length,
                                             long options)
        newBufferWithLength:options: Create a buffer by allocating new memory.
      • newCommandQueue

        MTLCommandQueue newCommandQueue()
        newCommandQueue Create and return a new command queue. Command Queues created via this method will only allow up to 64 non-completed command buffers.
        Returns:
        The new command queue object
      • newCommandQueueWithMaxCommandBufferCount

        MTLCommandQueue newCommandQueueWithMaxCommandBufferCount​(long maxCommandBufferCount)
        newCommandQueueWithMaxCommandBufferCount Create and return a new command queue with a given upper bound on non-completed command buffers.
        Returns:
        The new command queue object
      • newComputePipelineStateWithDescriptorOptionsReflectionError

        MTLComputePipelineState newComputePipelineStateWithDescriptorOptionsReflectionError​(MTLComputePipelineDescriptor descriptor,
                                                                                            long options,
                                                                                            org.moe.natj.general.ptr.Ptr<MTLComputePipelineReflection> reflection,
                                                                                            org.moe.natj.general.ptr.Ptr<NSError> error)
        newComputePipelineStateWithDescriptor:options:reflection:error: Create and compile a new MTLComputePipelineState object synchronously.
      • newComputePipelineStateWithFunctionError

        MTLComputePipelineState newComputePipelineStateWithFunctionError​(MTLFunction computeFunction,
                                                                         org.moe.natj.general.ptr.Ptr<NSError> error)
        newComputePipelineStateWithDescriptor:error: Create and compile a new MTLComputePipelineState object synchronously.
      • newComputePipelineStateWithFunctionOptionsReflectionError

        MTLComputePipelineState newComputePipelineStateWithFunctionOptionsReflectionError​(MTLFunction computeFunction,
                                                                                          long options,
                                                                                          org.moe.natj.general.ptr.Ptr<MTLComputePipelineReflection> reflection,
                                                                                          org.moe.natj.general.ptr.Ptr<NSError> error)
        newComputePipelineStateWithDescriptor:options:reflection:error: Create and compile a new MTLComputePipelineState object synchronously.
      • newDefaultLibrary

        MTLLibrary newDefaultLibrary()
        newDefaultLibrary Returns the default library for the main bundle. use newDefaultLibraryWithBundle:error: to get an NSError in case of failure.
      • newDefaultLibraryWithBundleError

        MTLLibrary newDefaultLibraryWithBundleError​(NSBundle bundle,
                                                    org.moe.natj.general.ptr.Ptr<NSError> error)
        newDefaultLibraryWithBundle:error: Returns the default library for a given bundle.
        Returns:
        A pointer to the library, nil if an error occurs.
      • newFence

        MTLFence newFence()
        newFence Create a new MTLFence object
      • newHeapWithDescriptor

        MTLHeap newHeapWithDescriptor​(MTLHeapDescriptor descriptor)
        newHeapWithDescriptor: Create a new heap with the given descriptor.
      • newLibraryWithDataError

        MTLLibrary newLibraryWithDataError​(NSObject data,
                                           org.moe.natj.general.ptr.Ptr<NSError> error)
        newLibraryWithData: Load a MTLLibrary from a dispatch_data_t
        Parameters:
        data - A metallib file already loaded as data in the form of dispatch_data_t.
        error - An error if we fail to open the metallib data.
      • newLibraryWithFileError

        MTLLibrary newLibraryWithFileError​(java.lang.String filepath,
                                           org.moe.natj.general.ptr.Ptr<NSError> error)
        newLibraryWithFile: Load a MTLLibrary from a metallib file.
      • newLibraryWithSourceOptionsError

        MTLLibrary newLibraryWithSourceOptionsError​(java.lang.String source,
                                                    MTLCompileOptions options,
                                                    org.moe.natj.general.ptr.Ptr<NSError> error)
        newLibraryWithSource:options:error: Load a MTLLibrary from source.
      • newRenderPipelineStateWithDescriptorError

        MTLRenderPipelineState newRenderPipelineStateWithDescriptorError​(MTLRenderPipelineDescriptor descriptor,
                                                                         org.moe.natj.general.ptr.Ptr<NSError> error)
        newRenderPipelineStateWithDescriptor:error: Create and compile a new MTLRenderPipelineState object synchronously.
      • newRenderPipelineStateWithDescriptorOptionsReflectionError

        MTLRenderPipelineState newRenderPipelineStateWithDescriptorOptionsReflectionError​(MTLRenderPipelineDescriptor descriptor,
                                                                                          long options,
                                                                                          org.moe.natj.general.ptr.Ptr<MTLRenderPipelineReflection> reflection,
                                                                                          org.moe.natj.general.ptr.Ptr<NSError> error)
        newRenderPipelineStateWithDescriptor:options:reflection:error: Create and compile a new MTLRenderPipelineState object synchronously and returns additional reflection information.
      • newTextureWithDescriptor

        MTLTexture newTextureWithDescriptor​(MTLTextureDescriptor descriptor)
        newTextureWithDescriptor: Allocate a new texture with privately owned storage.
      • supportsFeatureSet

        boolean supportsFeatureSet​(long featureSet)
        supportsFeatureSet: Returns TRUE if the feature set is supported by this MTLDevice.
      • supportsTextureSampleCount

        boolean supportsTextureSampleCount​(long sampleCount)
        supportsTextureSampleCount: Query device if it support textures with a given sampleCount.
        Returns:
        BOOL value. If YES, device supports the given sampleCount for textures. If NO, device does not support the given sampleCount.
      • areProgrammableSamplePositionsSupported

        boolean areProgrammableSamplePositionsSupported()
        [@property] programmableSaplePositionsSupported Query device for programmable sample position support.
        Returns:
        BOOL value. If YES, the device supports programmable sample positions. If NO, the device does not.
      • areRasterOrderGroupsSupported

        boolean areRasterOrderGroupsSupported()
        [@property] rasterOrderGroupsSupported Query device for raster order groups support.
        Returns:
        BOOL value. If YES, the device supports raster order groups. If NO, the device does not.
      • argumentBuffersSupport

        long argumentBuffersSupport()
        [@property] argumentBuffersSupport Query support tier for Argument Buffers.
        Returns:
        MTLArgumentBuffersTier enum value.
      • currentAllocatedSize

        long currentAllocatedSize()
        [@property] currentAllocatedSize The current size in bytes of all resources allocated by this device
      • getDefaultSamplePositionsCount

        void getDefaultSamplePositionsCount​(MTLSamplePosition positions,
                                            long count)
        getDefaultSamplePositions:count: Retrieve the default sample positions.
        Parameters:
        positions - The destination array for default sample position data.
        count - Specifies the sample count for which to retrieve the default positions, the length of the positions array, and must be set to a valid sample count.
      • maxThreadgroupMemoryLength

        long maxThreadgroupMemoryLength()
        [@property] maxThreadgroupMemoryLength The maximum threadgroup memory available, in bytes.
      • minimumLinearTextureAlignmentForPixelFormat

        long minimumLinearTextureAlignmentForPixelFormat​(long format)
        minimumLinearTextureAlignmentForPixelFormat: Returns the minimum alignment required for offset and rowBytes when creating a linear texture. An error is thrown for queries with invalid pixel formats (depth, stencil, or compressed formats).
      • newArgumentEncoderWithArguments

        MTLArgumentEncoder newArgumentEncoderWithArguments​(NSArray<? extends MTLArgumentDescriptor> arguments)
        newArgumentEncoderWithArguments:count: Creates an argument encoder for an array of argument descriptors which will be encoded sequentially.
      • newLibraryWithURLError

        MTLLibrary newLibraryWithURLError​(NSURL url,
                                          org.moe.natj.general.ptr.Ptr<NSError> error)
        newLibraryWithURL: Load a MTLLibrary from a metallib file.
      • newRenderPipelineStateWithTileDescriptorOptionsReflectionError

        MTLRenderPipelineState newRenderPipelineStateWithTileDescriptorOptionsReflectionError​(MTLTileRenderPipelineDescriptor descriptor,
                                                                                              long options,
                                                                                              org.moe.natj.general.ptr.Ptr<MTLRenderPipelineReflection> reflection,
                                                                                              org.moe.natj.general.ptr.Ptr<NSError> error)
        newRenderPipelineStateWithTileDescriptor:options:reflection:error: Create and compile a new MTLRenderPipelineState object synchronously given a MTLTileRenderPipelineDescriptor.
      • newTextureWithDescriptorIosurfacePlane

        MTLTexture newTextureWithDescriptorIosurfacePlane​(MTLTextureDescriptor descriptor,
                                                          IOSurfaceRef iosurface,
                                                          long plane)
        newTextureWithDescriptor:iosurface:plane Create a new texture from an IOSurface.
        Parameters:
        descriptor - A description of the properties for the new texture.
        iosurface - The IOSurface to use as storage for the new texture.
        plane - The plane within the IOSurface to use.
        Returns:
        A new texture object.
      • readWriteTextureSupport

        long readWriteTextureSupport()
        [@property] readWriteTextureSupport Query support tier for read-write texture formats.
        Returns:
        MTLReadWriteTextureTier enum value.
      • registryID

        long registryID()
        [@property] registryID Returns the IORegistry ID for the Metal device The registryID value for a Metal device is global to all tasks, and may be used to identify the GPU across task boundaries.
      • convertSparsePixelRegionsToTileRegionsWithTileSizeAlignmentModeNumRegions

        default void convertSparsePixelRegionsToTileRegionsWithTileSizeAlignmentModeNumRegions​(MTLRegion pixelRegions,
                                                                                               MTLRegion tileRegions,
                                                                                               MTLSize tileSize,
                                                                                               long mode,
                                                                                               long numRegions)
        * @method convertSparsePixelRegions:toTileRegions:withTileSize:alignmentMode:numRegions: * @abstract Converts regions in pixels to regions in sparse tiles using specified alignment mode. Tile size can be obtained from tileSizeWithTextureType:pixelFormat:sampleCount: method.
      • convertSparseTileRegionsToPixelRegionsWithTileSizeNumRegions

        default void convertSparseTileRegionsToPixelRegionsWithTileSizeNumRegions​(MTLRegion tileRegions,
                                                                                  MTLRegion pixelRegions,
                                                                                  MTLSize tileSize,
                                                                                  long numRegions)
        * @method convertSparseTileRegions:toPixelRegions:withTileSize:numRegions: * @abstract Convertes region in sparse tiles to region in pixels Tile size can be obtained from tileSizeWithTextureType:pixelFormat:sampleCount: method.
      • hasUnifiedMemory

        boolean hasUnifiedMemory()
        [@property] hasUnifiedMemory Returns YES if this GPU shares its memory with the rest of the machine (CPU, etc.) Some GPU architectures do not have dedicated local memory and instead only use the same memory shared with the rest of the machine. This property will return YES for GPUs that fall into that category.
      • maxArgumentBufferSamplerCount

        long maxArgumentBufferSamplerCount()
        [@property] maxArgumentBufferSamplerCount The maximum number of unique argument buffer samplers per app. This limit is only applicable to samplers that have their supportArgumentBuffers property set to true. A MTLSamplerState object is considered unique if the configuration of its originating MTLSamplerDescriptor properties is unique. For example, two samplers with equal minFilter values but different magFilter values are considered unique.
      • maxBufferLength

        long maxBufferLength()
      • minimumTextureBufferAlignmentForPixelFormat

        long minimumTextureBufferAlignmentForPixelFormat​(long format)
        minimumTextureBufferAlignmentForPixelFormat: Returns the minimum alignment required for offset and rowBytes when creating a texture buffer from a buffer.
      • newEvent

        MTLEvent newEvent()
        newEvent Returns a new single-device non-shareable Metal event object
      • newIndirectCommandBufferWithDescriptorMaxCommandCountOptions

        MTLIndirectCommandBuffer newIndirectCommandBufferWithDescriptorMaxCommandCountOptions​(MTLIndirectCommandBufferDescriptor descriptor,
                                                                                              long maxCount,
                                                                                              long options)
        newIndirectCommandBufferWithDescriptor:maxCommandCount:options Creates a new indirect command buffer with the given descriptor and count. The returned buffer can be safely executed without first encoding into (but is wasteful).
        Parameters:
        descriptor - The descriptor encodes the maximum logical stride of each command.
        maxCount - The maximum number of commands that this buffer can contain.
        options - The options for the indirect command buffer.
      • newRasterizationRateMapWithDescriptor

        MTLRasterizationRateMap newRasterizationRateMapWithDescriptor​(MTLRasterizationRateMapDescriptor descriptor)
        newRasterizationRateMapWithDescriptor: Creates a new variable rasterization rate map with the given descriptor. If '[self supportsRasterizationRateMapWithLayerCount:descriptor.layerCount]' returns NO, or descriptor.screenSize describes an empty region, the result will always be nil.
        Returns:
        A MTLRasterizationRateMap instance that can be used for rendering on this MTLDevice, or nil if the device does not support the combination of parameters stored in the descriptor.
      • newSharedEvent

        MTLSharedEvent newSharedEvent()
        newSharedEvent Returns a shareable multi-device event.
      • newSharedEventWithHandle

        MTLSharedEvent newSharedEventWithHandle​(MTLSharedEventHandle sharedEventHandle)
        newSharedEventWithHandle Creates a shareable multi-device event from an existing shared event handle.
      • newSharedTextureWithDescriptor

        MTLTexture newSharedTextureWithDescriptor​(MTLTextureDescriptor descriptor)
        newSharedTextureWithDescriptor Create a new texture that can be shared across process boundaries. This texture can be shared between process boundaries but not between different GPUs, by passing its MTLSharedTextureHandle.
        Parameters:
        descriptor - A description of the properties for the new texture.
        Returns:
        A new texture object.
      • newSharedTextureWithHandle

        MTLTexture newSharedTextureWithHandle​(MTLSharedTextureHandle sharedHandle)
        newSharedTextureWithHandle Recreate shared texture from received texture handle. This texture was shared between process boundaries by other process using MTLSharedTextureHandle. Current process will now share it with other processes and will be able to interact with it (but still in scope of the same GPUs).
        Parameters:
        sharedHandle - Handle to shared texture in this process space.
        Returns:
        A new texture object.
      • sparseTileSizeInBytes

        long sparseTileSizeInBytes()
        [@property] sparseTileSizeInBytes Returns the number of bytes required to map one sparse texture tile.
      • sparseTileSizeWithTextureTypePixelFormatSampleCount

        MTLSize sparseTileSizeWithTextureTypePixelFormatSampleCount​(long textureType,
                                                                    long pixelFormat,
                                                                    long sampleCount)
        sparseTileSizeWithTextureType:pixelFormat:sampleCount: Returns tile size for sparse texture with given type, pixel format and sample count.
      • supportsFamily

        boolean supportsFamily​(long gpuFamily)
        supportsFamily: Returns TRUE if the GPU Family is supported by this MTLDevice.
      • supportsRasterizationRateMapWithLayerCount

        boolean supportsRasterizationRateMapWithLayerCount​(long layerCount)
        supportsRasterizationRateMapWithLayerCount: Query device for variable rasterization rate support with the given number of layers.
        Parameters:
        layerCount - The number of layers for which to query device support.
        Returns:
        YES if the device supports creation of rendering using a MTLRasterizationRateMap with the given number of layers.
      • supportsVertexAmplificationCount

        boolean supportsVertexAmplificationCount​(long count)
        [@property] supportsVertexAmplificationCount: Query device for vertex amplification support.
        Parameters:
        count - The amplification count to check
        Returns:
        BOOL value. If YES, the device supports vertex amplification with the given count. If NO, the device does not.
      • areBarycentricCoordsSupported

        boolean areBarycentricCoordsSupported()
        [@property] barycentricsSupported Query device for Barycentric coordinates support; deprecated, use supportsShaderBarycentricCoordinates
        Returns:
        BOOL value. If YES, the device barycentric coordinates
      • counterSets

        NSArray<?> counterSets()
        [@property] counterSets Returns the set of Counter Sets exposed by the device.
      • newBinaryArchiveWithDescriptorError

        MTLBinaryArchive newBinaryArchiveWithDescriptorError​(MTLBinaryArchiveDescriptor descriptor,
                                                             org.moe.natj.general.ptr.Ptr<NSError> error)
        newBinaryArchiveWithDescriptor:error: Creates a MTLBinaryArchive using the configuration in the descriptor.
        Parameters:
        descriptor - The descriptor for the configuration of the binary archive to create.
        error - If an error occurs during creation, this parameter is updated to describe the failure.
        Returns:
        On success, the created MTLBinaryArchive. On failure, nil.
        See Also:
        MTLBinaryArchive
      • newCounterSampleBufferWithDescriptorError

        MTLCounterSampleBuffer newCounterSampleBufferWithDescriptorError​(MTLCounterSampleBufferDescriptor descriptor,
                                                                         org.moe.natj.general.ptr.Ptr<NSError> error)
        newCounterSampleBufferWithDescriptor:error: Given a counter sample buffer descriptor, allocate a new counter sample buffer. This may return nil if the counters may not all be collected simultaneously.
        Parameters:
        descriptor - The descriptor to create a sample buffer for
        error - An error return on failure.
      • newDynamicLibraryError

        MTLDynamicLibrary newDynamicLibraryError​(MTLLibrary library,
                                                 org.moe.natj.general.ptr.Ptr<NSError> error)
        newDynamicLibrary:error: Creates a MTLDynamicLibrary by compiling the code in a MTLLibrary.
        Parameters:
        library - The MTLLibrary from which to compile code. This library must have .type set to MTLLibraryTypeDynamic.
        error - If an error occurs during creation, this parameter is updated to describe the failure.
        Returns:
        On success, the MTLDynamicLibrary containing compiled code. On failure, nil.
        See Also:
        MTLDynamicLibrary
      • newDynamicLibraryWithURLError

        MTLDynamicLibrary newDynamicLibraryWithURLError​(NSURL url,
                                                        org.moe.natj.general.ptr.Ptr<NSError> error)
        newDynamicLibraryWithURL:error: Creates a MTLDynamicLibrary by loading compiled code from a file.
        Parameters:
        url - The file URL from which to load. If the file contains no compiled code for this device, compilation is attempted as with newDynamicLibrary:error:
        error - If an error occurs during creation, this parameter is updated to describe the failure.
        Returns:
        On success, the MTLDynamicLibrary containing compiled code (either loaded or compiled). On failure, nil.
        See Also:
        MTLDynamicLibrary
      • sampleTimestampsGpuTimestamp

        void sampleTimestampsGpuTimestamp​(org.moe.natj.general.ptr.LongPtr cpuTimestamp,
                                          org.moe.natj.general.ptr.LongPtr gpuTimestamp)
        sampleTimestamps:gpuTimestamp: Sample the CPU and GPU timestamps as closely as possible.
        Parameters:
        cpuTimestamp - The timestamp on the CPU
        gpuTimestamp - The timestamp on the GPU
      • supportsCounterSampling

        boolean supportsCounterSampling​(long samplingPoint)
        supportsCounterSampling: Query device for counter sampling points support.
        Parameters:
        samplingPoint - Query index
        Returns:
        BOOL value. If YES, the device supports counter sampling at given point.
      • supportsDynamicLibraries

        boolean supportsDynamicLibraries()
        [@property] supportsDynamicLibraries Query device support for compiling dynamic libraries.
        Returns:
        BOOL value. If YES, the device supports compiling dynamic libraries. If NO, the devices does not.
      • supportsFunctionPointers

        boolean supportsFunctionPointers()
      • supportsPullModelInterpolation

        boolean supportsPullModelInterpolation()
        [@property] supportsPullModelInterpolation Query device for pull model interpolation support which allows a fragment shader to compute multiple interpolations (at center, at centroid, at offset, at sample) of a fragment input.
        Returns:
        BOOL value. If YES, the device supports pull model interpolation. If NO, the device does not.
      • supportsRaytracing

        boolean supportsRaytracing()
      • supportsShaderBarycentricCoordinates

        boolean supportsShaderBarycentricCoordinates()
        [@property] supportsShaderBarycentricCoordinates Query device for Barycentric Coordinates support.
        Returns:
        BOOL value. If YES, the device supports barycentric coordinates. If NO, the device does not.