pub struct Texture(/* private fields */);Expand description
A texture resource that stores formatted image data.
C++ equivalent: MTL::Texture
Implementations§
Source§impl Texture
impl Texture
Sourcepub fn texture_type(&self) -> TextureType
pub fn texture_type(&self) -> TextureType
Get the texture type.
C++ equivalent: TextureType textureType() const
Sourcepub fn pixel_format(&self) -> PixelFormat
pub fn pixel_format(&self) -> PixelFormat
Get the pixel format.
C++ equivalent: PixelFormat pixelFormat() const
Sourcepub fn width(&self) -> UInteger
pub fn width(&self) -> UInteger
Get the width of the texture.
C++ equivalent: NS::UInteger width() const
Sourcepub fn height(&self) -> UInteger
pub fn height(&self) -> UInteger
Get the height of the texture.
C++ equivalent: NS::UInteger height() const
Sourcepub fn depth(&self) -> UInteger
pub fn depth(&self) -> UInteger
Get the depth of the texture.
C++ equivalent: NS::UInteger depth() const
Sourcepub fn mipmap_level_count(&self) -> UInteger
pub fn mipmap_level_count(&self) -> UInteger
Get the number of mipmap levels.
C++ equivalent: NS::UInteger mipmapLevelCount() const
Sourcepub fn sample_count(&self) -> UInteger
pub fn sample_count(&self) -> UInteger
Get the sample count (for multisampled textures).
C++ equivalent: NS::UInteger sampleCount() const
Sourcepub fn array_length(&self) -> UInteger
pub fn array_length(&self) -> UInteger
Get the array length (for texture arrays).
C++ equivalent: NS::UInteger arrayLength() const
Sourcepub fn usage(&self) -> TextureUsage
pub fn usage(&self) -> TextureUsage
Get the texture usage flags.
C++ equivalent: TextureUsage usage() const
Check if this is a shareable texture.
C++ equivalent: bool isShareable() const
Sourcepub fn is_framebuffer_only(&self) -> bool
pub fn is_framebuffer_only(&self) -> bool
Check if this is a framebuffer-only texture.
C++ equivalent: bool isFramebufferOnly() const
Sourcepub fn first_mipmap_in_tail(&self) -> UInteger
pub fn first_mipmap_in_tail(&self) -> UInteger
Get the first mipmap level used in a texture view.
C++ equivalent: NS::UInteger firstMipmapInTail() const
Sourcepub fn tail_size_in_bytes(&self) -> UInteger
pub fn tail_size_in_bytes(&self) -> UInteger
Get the tail size in bytes for sparse textures.
C++ equivalent: NS::UInteger tailSizeInBytes() const
Sourcepub fn is_sparse(&self) -> bool
pub fn is_sparse(&self) -> bool
Check if the tail is sparse.
C++ equivalent: bool isSparse() const
Sourcepub fn gpu_resource_id(&self) -> ResourceID
pub fn gpu_resource_id(&self) -> ResourceID
Get the GPU resource ID for bindless access.
C++ equivalent: ResourceID gpuResourceID() const
Sourcepub fn allow_gpu_optimized_contents(&self) -> bool
pub fn allow_gpu_optimized_contents(&self) -> bool
Check if texture allows GPU-optimized contents.
C++ equivalent: bool allowGPUOptimizedContents() const
Sourcepub fn compression_type(&self) -> TextureCompressionType
pub fn compression_type(&self) -> TextureCompressionType
Get the texture compression type.
C++ equivalent: TextureCompressionType compressionType() const
Sourcepub fn swizzle(&self) -> TextureSwizzleChannels
pub fn swizzle(&self) -> TextureSwizzleChannels
Get the texture swizzle channels.
C++ equivalent: TextureSwizzleChannels swizzle() const
Sourcepub fn parent_texture(&self) -> Option<Texture>
pub fn parent_texture(&self) -> Option<Texture>
Get the parent texture (if this is a view).
C++ equivalent: Texture* parentTexture() const
Sourcepub fn parent_relative_level(&self) -> UInteger
pub fn parent_relative_level(&self) -> UInteger
Get the parent relative level (for texture views).
C++ equivalent: NS::UInteger parentRelativeLevel() const
Sourcepub fn parent_relative_slice(&self) -> UInteger
pub fn parent_relative_slice(&self) -> UInteger
Get the parent relative slice (for texture views).
C++ equivalent: NS::UInteger parentRelativeSlice() const
Sourcepub fn buffer(&self) -> Option<Buffer>
pub fn buffer(&self) -> Option<Buffer>
Get the buffer (if texture is backed by a buffer).
C++ equivalent: Buffer* buffer() const
Sourcepub fn buffer_offset(&self) -> UInteger
pub fn buffer_offset(&self) -> UInteger
Get the buffer offset (if texture is backed by a buffer).
C++ equivalent: NS::UInteger bufferOffset() const
Sourcepub fn buffer_bytes_per_row(&self) -> UInteger
pub fn buffer_bytes_per_row(&self) -> UInteger
Get the buffer bytes per row (if texture is backed by a buffer).
C++ equivalent: NS::UInteger bufferBytesPerRow() const
Sourcepub fn iosurface(&self) -> Option<*mut c_void>
pub fn iosurface(&self) -> Option<*mut c_void>
Get the IOSurface backing this texture, if any.
C++ equivalent: IOSurfaceRef iosurface() const
Returns an opaque pointer to the IOSurfaceRef, or None if the texture is not backed by an IOSurface.
Sourcepub fn iosurface_plane(&self) -> UInteger
pub fn iosurface_plane(&self) -> UInteger
Get the IOSurface plane index for this texture.
C++ equivalent: NS::UInteger iosurfacePlane() const
Sourcepub fn sparse_texture_tier(&self) -> TextureSparseTier
pub fn sparse_texture_tier(&self) -> TextureSparseTier
Get the sparse texture tier for this texture.
C++ equivalent: TextureSparseTier sparseTextureTier() const
Sourcepub fn remote_storage_texture(&self) -> Option<Texture>
pub fn remote_storage_texture(&self) -> Option<Texture>
Get the remote storage texture (for cross-process sharing).
C++ equivalent: Texture* remoteStorageTexture() const
Sourcepub fn new_remote_texture_view_for_device(
&self,
device: &Device,
) -> Option<Texture>
pub fn new_remote_texture_view_for_device( &self, device: &Device, ) -> Option<Texture>
Create a remote texture view for a different device.
C++ equivalent: Texture* newRemoteTextureViewForDevice(const Device*)
Sourcepub fn new_texture_view_with_pixel_format(
&self,
pixel_format: PixelFormat,
) -> Option<Texture>
pub fn new_texture_view_with_pixel_format( &self, pixel_format: PixelFormat, ) -> Option<Texture>
Create a texture view with a different pixel format.
C++ equivalent: Texture* newTextureView(PixelFormat)
Sourcepub fn new_texture_view(
&self,
pixel_format: PixelFormat,
texture_type: TextureType,
level_range: Range,
slice_range: Range,
) -> Option<Texture>
pub fn new_texture_view( &self, pixel_format: PixelFormat, texture_type: TextureType, level_range: Range, slice_range: Range, ) -> Option<Texture>
Create a texture view with different pixel format and texture type.
C++ equivalent: Texture* newTextureView(PixelFormat, TextureType, NS::Range levels, NS::Range slices)
Sourcepub fn new_texture_view_with_swizzle(
&self,
pixel_format: PixelFormat,
texture_type: TextureType,
level_range: Range,
slice_range: Range,
swizzle: TextureSwizzleChannels,
) -> Option<Texture>
pub fn new_texture_view_with_swizzle( &self, pixel_format: PixelFormat, texture_type: TextureType, level_range: Range, slice_range: Range, swizzle: TextureSwizzleChannels, ) -> Option<Texture>
Create a texture view with swizzle.
C++ equivalent: Texture* newTextureView(PixelFormat, TextureType, NS::Range, NS::Range, TextureSwizzleChannels)
Create a shared texture handle for cross-process sharing.
C++ equivalent: SharedTextureHandle* newSharedTextureHandle()
Sourcepub fn new_texture_view_with_descriptor(
&self,
descriptor: &TextureViewDescriptor,
) -> Option<Texture>
pub fn new_texture_view_with_descriptor( &self, descriptor: &TextureViewDescriptor, ) -> Option<Texture>
Create a texture view with a descriptor.
C++ equivalent: Texture* newTextureView(const TextureViewDescriptor*)
Sourcepub unsafe fn get_bytes(
&self,
pixel_bytes: *mut c_void,
bytes_per_row: UInteger,
bytes_per_image: UInteger,
region: Region,
mipmap_level: UInteger,
slice: UInteger,
)
pub unsafe fn get_bytes( &self, pixel_bytes: *mut c_void, bytes_per_row: UInteger, bytes_per_image: UInteger, region: Region, mipmap_level: UInteger, slice: UInteger, )
Get texture data bytes (full version with slice).
C++ equivalent: void getBytes(void*, NS::UInteger, NS::UInteger, MTL::Region, NS::UInteger, NS::UInteger)
§Safety
The pixel_bytes pointer must be valid for writing the requested data.
Sourcepub unsafe fn get_bytes_simple(
&self,
pixel_bytes: *mut c_void,
bytes_per_row: UInteger,
region: Region,
mipmap_level: UInteger,
)
pub unsafe fn get_bytes_simple( &self, pixel_bytes: *mut c_void, bytes_per_row: UInteger, region: Region, mipmap_level: UInteger, )
Get texture data bytes (simple version for 2D textures).
C++ equivalent: void getBytes(void*, NS::UInteger, MTL::Region, NS::UInteger)
§Safety
The pixel_bytes pointer must be valid for writing the requested data.
Sourcepub unsafe fn replace_region(
&self,
region: Region,
mipmap_level: UInteger,
slice: UInteger,
pixel_bytes: *const c_void,
bytes_per_row: UInteger,
bytes_per_image: UInteger,
)
pub unsafe fn replace_region( &self, region: Region, mipmap_level: UInteger, slice: UInteger, pixel_bytes: *const c_void, bytes_per_row: UInteger, bytes_per_image: UInteger, )
Replace a region of the texture (full version with slice).
C++ equivalent: void replaceRegion(MTL::Region, NS::UInteger, NS::UInteger, const void*, NS::UInteger, NS::UInteger)
§Safety
The pixel_bytes pointer must be valid for reading the data to copy.
Sourcepub unsafe fn replace_region_simple(
&self,
region: Region,
mipmap_level: UInteger,
pixel_bytes: *const c_void,
bytes_per_row: UInteger,
)
pub unsafe fn replace_region_simple( &self, region: Region, mipmap_level: UInteger, pixel_bytes: *const c_void, bytes_per_row: UInteger, )
Replace a region of the texture (simple version for 2D textures).
C++ equivalent: void replaceRegion(MTL::Region, NS::UInteger, const void*, NS::UInteger)
§Safety
The pixel_bytes pointer must be valid for reading the data to copy.
Sourcepub fn label(&self) -> Option<String>
pub fn label(&self) -> Option<String>
Get the label for this texture.
C++ equivalent: NS::String* label() const
Sourcepub fn set_label(&self, label: &str)
pub fn set_label(&self, label: &str)
Set the label for this texture.
C++ equivalent: void setLabel(const NS::String*)
Sourcepub fn device(&self) -> Device
pub fn device(&self) -> Device
Get the device that created this texture.
C++ equivalent: Device* device() const
Sourcepub fn resource_options(&self) -> ResourceOptions
pub fn resource_options(&self) -> ResourceOptions
Get the resource options.
C++ equivalent: ResourceOptions resourceOptions() const
Sourcepub fn allocated_size(&self) -> UInteger
pub fn allocated_size(&self) -> UInteger
Get the allocated size.
C++ equivalent: NS::UInteger allocatedSize() const