MTLTexture

Trait MTLTexture 

Source
pub unsafe trait MTLTexture: MTLResource {
Show 39 methods // Provided methods fn rootResource(&self) -> Option<Retained<ProtocolObject<dyn MTLResource>>> where Self: Sized + Message { ... } fn parentTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } fn parentRelativeLevel(&self) -> NSUInteger where Self: Sized + Message { ... } fn parentRelativeSlice(&self) -> NSUInteger where Self: Sized + Message { ... } fn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>> where Self: Sized + Message { ... } fn bufferOffset(&self) -> NSUInteger where Self: Sized + Message { ... } fn bufferBytesPerRow(&self) -> NSUInteger where Self: Sized + Message { ... } fn iosurface(&self) -> Option<Retained<IOSurfaceRef>> where Self: Sized + Message { ... } fn iosurfacePlane(&self) -> NSUInteger where Self: Sized + Message { ... } fn textureType(&self) -> MTLTextureType where Self: Sized + Message { ... } fn pixelFormat(&self) -> MTLPixelFormat where Self: Sized + Message { ... } fn width(&self) -> NSUInteger where Self: Sized + Message { ... } fn height(&self) -> NSUInteger where Self: Sized + Message { ... } fn depth(&self) -> NSUInteger where Self: Sized + Message { ... } fn mipmapLevelCount(&self) -> NSUInteger where Self: Sized + Message { ... } fn sampleCount(&self) -> NSUInteger where Self: Sized + Message { ... } fn arrayLength(&self) -> NSUInteger where Self: Sized + Message { ... } fn usage(&self) -> MTLTextureUsage where Self: Sized + Message { ... } fn isShareable(&self) -> bool where Self: Sized + Message { ... } fn isFramebufferOnly(&self) -> bool where Self: Sized + Message { ... } fn firstMipmapInTail(&self) -> NSUInteger where Self: Sized + Message { ... } fn tailSizeInBytes(&self) -> NSUInteger where Self: Sized + Message { ... } fn isSparse(&self) -> bool where Self: Sized + Message { ... } fn allowGPUOptimizedContents(&self) -> bool where Self: Sized + Message { ... } fn compressionType(&self) -> MTLTextureCompressionType where Self: Sized + Message { ... } fn gpuResourceID(&self) -> MTLResourceID where Self: Sized + Message { ... } unsafe fn getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice( &self, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, bytes_per_image: NSUInteger, region: MTLRegion, level: NSUInteger, slice: NSUInteger, ) where Self: Sized + Message { ... } unsafe fn replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage( &self, region: MTLRegion, level: NSUInteger, slice: NSUInteger, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, bytes_per_image: NSUInteger, ) where Self: Sized + Message { ... } unsafe fn getBytes_bytesPerRow_fromRegion_mipmapLevel( &self, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, region: MTLRegion, level: NSUInteger, ) where Self: Sized + Message { ... } unsafe fn replaceRegion_mipmapLevel_withBytes_bytesPerRow( &self, region: MTLRegion, level: NSUInteger, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, ) where Self: Sized + Message { ... } fn newTextureViewWithPixelFormat( &self, pixel_format: MTLPixelFormat, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } unsafe fn newTextureViewWithPixelFormat_textureType_levels_slices( &self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, level_range: NSRange, slice_range: NSRange, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } fn newSharedTextureHandle(&self) -> Option<Retained<MTLSharedTextureHandle>> where Self: Sized + Message { ... } fn newTextureViewWithDescriptor( &self, descriptor: &MTLTextureViewDescriptor, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } fn remoteStorageTexture( &self, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } fn newRemoteTextureViewForDevice( &self, device: &ProtocolObject<dyn MTLDevice>, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } fn swizzle(&self) -> MTLTextureSwizzleChannels where Self: Sized + Message { ... } unsafe fn newTextureViewWithPixelFormat_textureType_levels_slices_swizzle( &self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, level_range: NSRange, slice_range: NSRange, swizzle: MTLTextureSwizzleChannels, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>> where Self: Sized + Message { ... } fn sparseTextureTier(&self) -> MTLTextureSparseTier where Self: Sized + Message { ... }
}
Available on crate features MTLAllocation and MTLResource and MTLTexture only.
Expand description

MTLTexture represents a collection of 1D, 2D, or 3D images.

Each image in a texture is a 1D, 2D, 2DMultisample, or 3D image. The texture contains one or more images arranged in a mipmap stack. If there are multiple mipmap stacks, each one is referred to as a slice of the texture. 1D, 2D, 2DMultisample, and 3D textures have a single slice. In 1DArray and 2DArray textures, every slice is an array element. A Cube texture always has 6 slices, one for each face. In a CubeArray texture, each set of six slices is one element in the array.

Most APIs that operate on individual images in a texture address those images via a tuple of a Slice, and Mipmap Level within that slice.

See also Apple’s documentation

Provided Methods§

Source

fn rootResource(&self) -> Option<Retained<ProtocolObject<dyn MTLResource>>>
where Self: Sized + Message,

👎Deprecated: Use parentTexture or buffer instead

The resource this texture was created from. It may be a texture or a buffer. If this texture is not reusing storage of another MTLResource, then nil is returned.

Source

fn parentTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

The texture this texture view was created from, or nil if this is not a texture view or it was not created from a texture.

Source

fn parentRelativeLevel(&self) -> NSUInteger
where Self: Sized + Message,

The base level of the texture this texture view was created from, or 0 if this is not a texture view.

Source

fn parentRelativeSlice(&self) -> NSUInteger
where Self: Sized + Message,

The base slice of the texture this texture view was created from, or 0 if this is not a texture view.

Source

fn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
where Self: Sized + Message,

Available on crate feature MTLBuffer only.

The buffer this texture view was created from, or nil if this is not a texture view or it was not created from a buffer.

Source

fn bufferOffset(&self) -> NSUInteger
where Self: Sized + Message,

The offset of the buffer this texture view was created from, or 0 if this is not a texture view.

Source

fn bufferBytesPerRow(&self) -> NSUInteger
where Self: Sized + Message,

The bytesPerRow of the buffer this texture view was created from, or 0 if this is not a texture view.

Source

fn iosurface(&self) -> Option<Retained<IOSurfaceRef>>
where Self: Sized + Message,

Available on crate feature objc2-io-surface only.

If this texture was created from an IOSurface, this returns a reference to that IOSurface. iosurface is nil if this texture was not created from an IOSurface.

Source

fn iosurfacePlane(&self) -> NSUInteger
where Self: Sized + Message,

If this texture was created from an IOSurface, this returns the plane of the IOSurface from which the texture was created. iosurfacePlane is 0 if this texture was not created from an IOSurface.

Source

fn textureType(&self) -> MTLTextureType
where Self: Sized + Message,

The type of this texture.

Source

fn pixelFormat(&self) -> MTLPixelFormat
where Self: Sized + Message,

Available on crate feature MTLPixelFormat only.

The MTLPixelFormat that is used to interpret this texture’s contents.

Source

fn width(&self) -> NSUInteger
where Self: Sized + Message,

The width of the MTLTexture instance in pixels.

Source

fn height(&self) -> NSUInteger
where Self: Sized + Message,

The height of the MTLTexture instance in pixels.

. height is 1 if the texture is 1D.

Source

fn depth(&self) -> NSUInteger
where Self: Sized + Message,

The depth of this MTLTexture instance in pixels.

If this MTLTexture is not a 3D texture, the depth is 1

Source

fn mipmapLevelCount(&self) -> NSUInteger
where Self: Sized + Message,

The number of mipmap levels in each slice of this MTLTexture.

Source

fn sampleCount(&self) -> NSUInteger
where Self: Sized + Message,

The number of samples in each pixel of this MTLTexture.

If this texture is any type other than 2DMultisample, samples is 1.

Source

fn arrayLength(&self) -> NSUInteger
where Self: Sized + Message,

The number of array elements in this MTLTexture.

For non-Array texture types, arrayLength is 1.

Source

fn usage(&self) -> MTLTextureUsage
where Self: Sized + Message,

Description of texture usage.

Source

fn isShareable(&self) -> bool
where Self: Sized + Message,

If YES, this texture can be shared with other processes.

Texture can be shared across process addres space boundaries through use of sharedTextureHandle and XPC.

Source

fn isFramebufferOnly(&self) -> bool
where Self: Sized + Message,

If YES, this texture can only be used with a MTLAttachmentDescriptor, and cannot be used as a texture argument for MTLRenderCommandEncoder, MTLBlitCommandEncoder, or MTLComputeCommandEncoder. Furthermore, when this property’s value is YES, readPixels/writePixels may not be used with this texture.

Textures obtained from CAMetalDrawables may have this property set to YES, depending on the value of frameBufferOnly passed to their parent CAMetalLayer. Textures created directly by the application will not have any restrictions.

Source

fn firstMipmapInTail(&self) -> NSUInteger
where Self: Sized + Message,

For sparse textures this property returns index of first mipmap that is packed in tail. Mapping this mipmap level will map all subsequent mipmap levels.

Source

fn tailSizeInBytes(&self) -> NSUInteger
where Self: Sized + Message,

Amount of memory in bytes required to map sparse texture tail.

Source

fn isSparse(&self) -> bool
where Self: Sized + Message,

Source

fn allowGPUOptimizedContents(&self) -> bool
where Self: Sized + Message,

Allow GPU-optimization for the contents texture. The default value is true.

Useful for opting-out of GPU-optimization when implicit optimization (e.g. RT writes) is regressing CPU-read-back performance. See the documentation for optimizeContentsForGPUAccess: and optimizeContentsForCPUAccess: APIs.

Source

fn compressionType(&self) -> MTLTextureCompressionType
where Self: Sized + Message,

Returns the compression type of the texture

See the compressionType property on MTLTextureDescriptor

Source

fn gpuResourceID(&self) -> MTLResourceID
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Handle of the GPU resource suitable for storing in an Argument Buffer

Source

unsafe fn getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice( &self, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, bytes_per_image: NSUInteger, region: MTLRegion, level: NSUInteger, slice: NSUInteger, )
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Copies a block of pixels from a texture slice into the application’s memory.

§Safety

pixel_bytes must be a valid pointer.

Source

unsafe fn replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage( &self, region: MTLRegion, level: NSUInteger, slice: NSUInteger, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, bytes_per_image: NSUInteger, )
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Copy a block of pixel data from the caller’s pointer into a texture slice.

§Safety

pixel_bytes must be a valid pointer.

Source

unsafe fn getBytes_bytesPerRow_fromRegion_mipmapLevel( &self, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, region: MTLRegion, level: NSUInteger, )
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Convenience for getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: that doesn’t require slice related arguments

§Safety

pixel_bytes must be a valid pointer.

Source

unsafe fn replaceRegion_mipmapLevel_withBytes_bytesPerRow( &self, region: MTLRegion, level: NSUInteger, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, )
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Convenience for replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: that doesn’t require slice related arguments

§Safety

pixel_bytes must be a valid pointer.

Source

fn newTextureViewWithPixelFormat( &self, pixel_format: MTLPixelFormat, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

Available on crate feature MTLPixelFormat only.

Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format.

Source

unsafe fn newTextureViewWithPixelFormat_textureType_levels_slices( &self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, level_range: NSRange, slice_range: NSRange, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

Available on crate feature MTLPixelFormat only.

Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format, texture type, levels and slices.

§Safety
  • levelRange might not be bounds-checked.
  • sliceRange might not be bounds-checked.
Source

fn newSharedTextureHandle(&self) -> Option<Retained<MTLSharedTextureHandle>>
where Self: Sized + Message,

Create a new texture handle, that can be shared across process addres space boundaries.

Source

fn newTextureViewWithDescriptor( &self, descriptor: &MTLTextureViewDescriptor, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

Create a new texture which shares the same storage as the source texture, but with different (but compatible) properties specified by the descriptor

Source

fn remoteStorageTexture( &self, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

For Metal texture objects that are remote views, this returns the texture associated with the storage on the originating device.

Source

fn newRemoteTextureViewForDevice( &self, device: &ProtocolObject<dyn MTLDevice>, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

Available on crate feature MTLDevice only.

On Metal devices that support peer to peer transfers, this method is used to create a remote texture view on another device within the peer group. The receiver must use MTLStorageModePrivate or be backed by an IOSurface.

Source

fn swizzle(&self) -> MTLTextureSwizzleChannels
where Self: Sized + Message,

The channel swizzle used when reading or sampling from this texture

Source

unsafe fn newTextureViewWithPixelFormat_textureType_levels_slices_swizzle( &self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, level_range: NSRange, slice_range: NSRange, swizzle: MTLTextureSwizzleChannels, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
where Self: Sized + Message,

Available on crate feature MTLPixelFormat only.

Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format, texture type, levels, slices and swizzle.

§Safety
  • levelRange might not be bounds-checked.
  • sliceRange might not be bounds-checked.
Source

fn sparseTextureTier(&self) -> MTLTextureSparseTier
where Self: Sized + Message,

Query support tier for sparse textures.

Trait Implementations§

Source§

impl ProtocolType for dyn MTLTexture

Source§

const NAME: &'static str = "MTLTexture"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn MTLTexture
where T: ?Sized + Message + MTLTexture,

Implementations on Foreign Types§

Source§

impl<T> MTLTexture for ProtocolObject<T>
where T: ?Sized + MTLTexture,

Implementors§