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 { ... }
}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§
Sourcefn rootResource(&self) -> Option<Retained<ProtocolObject<dyn MTLResource>>>
👎Deprecated: Use parentTexture or buffer instead
fn rootResource(&self) -> Option<Retained<ProtocolObject<dyn MTLResource>>>
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.
Sourcefn parentTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
fn parentTexture(&self) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
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.
Sourcefn parentRelativeLevel(&self) -> NSUInteger
fn parentRelativeLevel(&self) -> NSUInteger
The base level of the texture this texture view was created from, or 0 if this is not a texture view.
Sourcefn parentRelativeSlice(&self) -> NSUInteger
fn parentRelativeSlice(&self) -> NSUInteger
The base slice of the texture this texture view was created from, or 0 if this is not a texture view.
Sourcefn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
Available on crate feature MTLBuffer only.
fn buffer(&self) -> Option<Retained<ProtocolObject<dyn MTLBuffer>>>
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.
Sourcefn bufferOffset(&self) -> NSUInteger
fn bufferOffset(&self) -> NSUInteger
The offset of the buffer this texture view was created from, or 0 if this is not a texture view.
Sourcefn bufferBytesPerRow(&self) -> NSUInteger
fn bufferBytesPerRow(&self) -> NSUInteger
The bytesPerRow of the buffer this texture view was created from, or 0 if this is not a texture view.
Sourcefn iosurface(&self) -> Option<Retained<IOSurfaceRef>>
Available on crate feature objc2-io-surface only.
fn iosurface(&self) -> Option<Retained<IOSurfaceRef>>
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.
Sourcefn iosurfacePlane(&self) -> NSUInteger
fn iosurfacePlane(&self) -> NSUInteger
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.
Sourcefn textureType(&self) -> MTLTextureType
fn textureType(&self) -> MTLTextureType
The type of this texture.
Sourcefn pixelFormat(&self) -> MTLPixelFormat
Available on crate feature MTLPixelFormat only.
fn pixelFormat(&self) -> MTLPixelFormat
MTLPixelFormat only.The MTLPixelFormat that is used to interpret this texture’s contents.
Sourcefn width(&self) -> NSUInteger
fn width(&self) -> NSUInteger
The width of the MTLTexture instance in pixels.
Sourcefn height(&self) -> NSUInteger
fn height(&self) -> NSUInteger
The height of the MTLTexture instance in pixels.
. height is 1 if the texture is 1D.
Sourcefn depth(&self) -> NSUInteger
fn depth(&self) -> NSUInteger
The depth of this MTLTexture instance in pixels.
If this MTLTexture is not a 3D texture, the depth is 1
Sourcefn mipmapLevelCount(&self) -> NSUInteger
fn mipmapLevelCount(&self) -> NSUInteger
The number of mipmap levels in each slice of this MTLTexture.
Sourcefn sampleCount(&self) -> NSUInteger
fn sampleCount(&self) -> NSUInteger
The number of samples in each pixel of this MTLTexture.
If this texture is any type other than 2DMultisample, samples is 1.
Sourcefn arrayLength(&self) -> NSUInteger
fn arrayLength(&self) -> NSUInteger
The number of array elements in this MTLTexture.
For non-Array texture types, arrayLength is 1.
Sourcefn usage(&self) -> MTLTextureUsage
fn usage(&self) -> MTLTextureUsage
Description of texture usage.
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.
Sourcefn isFramebufferOnly(&self) -> bool
fn isFramebufferOnly(&self) -> bool
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.
Sourcefn firstMipmapInTail(&self) -> NSUInteger
fn firstMipmapInTail(&self) -> NSUInteger
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.
Sourcefn tailSizeInBytes(&self) -> NSUInteger
fn tailSizeInBytes(&self) -> NSUInteger
Amount of memory in bytes required to map sparse texture tail.
fn isSparse(&self) -> bool
Sourcefn allowGPUOptimizedContents(&self) -> bool
fn allowGPUOptimizedContents(&self) -> bool
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.
Sourcefn compressionType(&self) -> MTLTextureCompressionType
fn compressionType(&self) -> MTLTextureCompressionType
Returns the compression type of the texture
See the compressionType property on MTLTextureDescriptor
Sourcefn gpuResourceID(&self) -> MTLResourceID
Available on crate feature MTLTypes only.
fn gpuResourceID(&self) -> MTLResourceID
MTLTypes only.Handle of the GPU resource suitable for storing in an Argument Buffer
Sourceunsafe 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,
)
Available on crate feature MTLTypes only.
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, )
MTLTypes only.Copies a block of pixels from a texture slice into the application’s memory.
§Safety
pixel_bytes must be a valid pointer.
Sourceunsafe 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,
)
Available on crate feature MTLTypes only.
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, )
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.
Sourceunsafe fn getBytes_bytesPerRow_fromRegion_mipmapLevel(
&self,
pixel_bytes: NonNull<c_void>,
bytes_per_row: NSUInteger,
region: MTLRegion,
level: NSUInteger,
)
Available on crate feature MTLTypes only.
unsafe fn getBytes_bytesPerRow_fromRegion_mipmapLevel( &self, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, region: MTLRegion, level: NSUInteger, )
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.
Sourceunsafe fn replaceRegion_mipmapLevel_withBytes_bytesPerRow(
&self,
region: MTLRegion,
level: NSUInteger,
pixel_bytes: NonNull<c_void>,
bytes_per_row: NSUInteger,
)
Available on crate feature MTLTypes only.
unsafe fn replaceRegion_mipmapLevel_withBytes_bytesPerRow( &self, region: MTLRegion, level: NSUInteger, pixel_bytes: NonNull<c_void>, bytes_per_row: NSUInteger, )
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.
Sourcefn newTextureViewWithPixelFormat(
&self,
pixel_format: MTLPixelFormat,
) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
Available on crate feature MTLPixelFormat only.
fn newTextureViewWithPixelFormat( &self, pixel_format: MTLPixelFormat, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
MTLPixelFormat only.Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format.
Sourceunsafe fn newTextureViewWithPixelFormat_textureType_levels_slices(
&self,
pixel_format: MTLPixelFormat,
texture_type: MTLTextureType,
level_range: NSRange,
slice_range: NSRange,
) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
Available on crate feature MTLPixelFormat only.
unsafe fn newTextureViewWithPixelFormat_textureType_levels_slices( &self, pixel_format: MTLPixelFormat, texture_type: MTLTextureType, level_range: NSRange, slice_range: NSRange, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
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
levelRangemight not be bounds-checked.sliceRangemight not be bounds-checked.
Create a new texture handle, that can be shared across process addres space boundaries.
Sourcefn newTextureViewWithDescriptor(
&self,
descriptor: &MTLTextureViewDescriptor,
) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
fn newTextureViewWithDescriptor( &self, descriptor: &MTLTextureViewDescriptor, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
Create a new texture which shares the same storage as the source texture, but with different (but compatible) properties specified by the descriptor
Sourcefn remoteStorageTexture(
&self,
) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
fn remoteStorageTexture( &self, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
For Metal texture objects that are remote views, this returns the texture associated with the storage on the originating device.
Sourcefn newRemoteTextureViewForDevice(
&self,
device: &ProtocolObject<dyn MTLDevice>,
) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
Available on crate feature MTLDevice only.
fn newRemoteTextureViewForDevice( &self, device: &ProtocolObject<dyn MTLDevice>, ) -> Option<Retained<ProtocolObject<dyn MTLTexture>>>
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.
Sourcefn swizzle(&self) -> MTLTextureSwizzleChannels
fn swizzle(&self) -> MTLTextureSwizzleChannels
The channel swizzle used when reading or sampling from this texture
Sourceunsafe 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>>>
Available on crate feature MTLPixelFormat only.
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>>>
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
levelRangemight not be bounds-checked.sliceRangemight not be bounds-checked.
Sourcefn sparseTextureTier(&self) -> MTLTextureSparseTier
fn sparseTextureTier(&self) -> MTLTextureSparseTier
Query support tier for sparse textures.