public interface MTLTexture extends MTLResource
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.
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowGPUOptimizedContents()
[@property] allowGPUOptimizedContents
|
long |
arrayLength()
[@property] arrayLength
|
MTLBuffer |
buffer()
[@property] buffer
|
long |
bufferBytesPerRow()
[@property] bufferBytesPerRow
|
long |
bufferOffset()
[@property] bufferOffset
|
long |
compressionType()
[@property] compressionType
|
long |
depth()
[@property] depth
|
long |
firstMipmapInTail()
[@property] firstMipmapInTail
|
void |
getBytesBytesPerRowBytesPerImageFromRegionMipmapLevelSlice(org.moe.natj.general.ptr.VoidPtr pixelBytes,
long bytesPerRow,
long bytesPerImage,
MTLRegion region,
long level,
long slice)
getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice:
|
void |
getBytesBytesPerRowFromRegionMipmapLevel(org.moe.natj.general.ptr.VoidPtr pixelBytes,
long bytesPerRow,
MTLRegion region,
long level)
getBytes:bytesPerRow:fromRegion:mipmapLevel:
|
long |
height()
[@property] height
|
IOSurfaceRef |
iosurface()
[@property] iosurface
|
long |
iosurfacePlane()
[@property] iosurfacePlane
|
boolean |
isFramebufferOnly()
[@property] framebufferOnly
|
boolean |
isShareable()
[@property] shareable
|
boolean |
isSparse() |
long |
mipmapLevelCount()
[@property] mipmapLevelCount
|
MTLSharedTextureHandle |
newSharedTextureHandle()
newSharedTextureHandle
|
MTLTexture |
newTextureViewWithPixelFormat(long pixelFormat)
newTextureViewWithPixelFormat:
|
MTLTexture |
newTextureViewWithPixelFormatTextureTypeLevelsSlices(long pixelFormat,
long textureType,
NSRange levelRange,
NSRange sliceRange)
newTextureViewWithPixelFormat:textureType:levels:slices:
|
MTLTexture |
newTextureViewWithPixelFormatTextureTypeLevelsSlicesSwizzle(long pixelFormat,
long textureType,
NSRange levelRange,
NSRange sliceRange,
MTLTextureSwizzleChannels swizzle)
newTextureViewWithPixelFormat:textureType:levels:slices:swizzle:
|
long |
parentRelativeLevel()
[@property] parentRelativeLevel
|
long |
parentRelativeSlice()
[@property] parentRelativeSlice
|
MTLTexture |
parentTexture()
[@property] parentTexture
|
long |
pixelFormat()
[@property] pixelFormat
|
void |
replaceRegionMipmapLevelSliceWithBytesBytesPerRowBytesPerImage(MTLRegion region,
long level,
long slice,
org.moe.natj.general.ptr.ConstVoidPtr pixelBytes,
long bytesPerRow,
long bytesPerImage)
replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:
|
void |
replaceRegionMipmapLevelWithBytesBytesPerRow(MTLRegion region,
long level,
org.moe.natj.general.ptr.ConstVoidPtr pixelBytes,
long bytesPerRow)
replaceRegion:mipmapLevel:withBytes:bytesPerRow:
|
MTLResource |
rootResource()
[@property] rootResource
|
long |
sampleCount()
[@property] sampleCount
|
MTLTextureSwizzleChannels |
swizzle()
[@property] swizzle
|
long |
tailSizeInBytes()
[@property] tailSizeInBytes
|
long |
textureType()
[@property] type
|
long |
usage()
[@property] usage
|
long |
width()
[@property] width
|
allocatedSize, cpuCacheMode, device, hazardTrackingMode, heap, heapOffset, isAliasable, label, makeAliasable, resourceOptions, setLabel, setPurgeableState, storageModelong arrayLength()
The number of array elements in this MTLTexture.
For non-Array texture types, arrayLength is 1.
MTLBuffer buffer()
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.
long bufferBytesPerRow()
The bytesPerRow of the buffer this texture view was created from, or 0 if this is not a texture view.
long bufferOffset()
The offset of the buffer this texture view was created from, or 0 if this is not a texture view.
long depth()
The depth of this MTLTexture instance in pixels.
If this MTLTexture is not a 3D texture, the depth is 1
void getBytesBytesPerRowBytesPerImageFromRegionMipmapLevelSlice(org.moe.natj.general.ptr.VoidPtr pixelBytes,
long bytesPerRow,
long bytesPerImage,
MTLRegion region,
long level,
long slice)
Copies a block of pixels from a texture slice into the application's memory.
void getBytesBytesPerRowFromRegionMipmapLevel(org.moe.natj.general.ptr.VoidPtr pixelBytes,
long bytesPerRow,
MTLRegion region,
long level)
Convenience for getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: that doesn't require slice related arguments
long height()
The height of the MTLTexture instance in pixels.
boolean isFramebufferOnly()
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.
long mipmapLevelCount()
The number of mipmap levels in each slice of this MTLTexture.
MTLTexture newTextureViewWithPixelFormat(long pixelFormat)
Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format.
MTLTexture newTextureViewWithPixelFormatTextureTypeLevelsSlices(long pixelFormat, long textureType, NSRange levelRange, NSRange sliceRange)
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.
long parentRelativeLevel()
The base level of the texture this texture view was created from, or 0 if this is not a texture view.
long parentRelativeSlice()
The base slice of the texture this texture view was created from, or 0 if this is not a texture view.
MTLTexture parentTexture()
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.
long pixelFormat()
The MTLPixelFormat that is used to interpret this texture's contents.
void replaceRegionMipmapLevelSliceWithBytesBytesPerRowBytesPerImage(MTLRegion region, long level, long slice, org.moe.natj.general.ptr.ConstVoidPtr pixelBytes, long bytesPerRow, long bytesPerImage)
Copy a block of pixel data from the caller's pointer into a texture slice.
void replaceRegionMipmapLevelWithBytesBytesPerRow(MTLRegion region, long level, org.moe.natj.general.ptr.ConstVoidPtr pixelBytes, long bytesPerRow)
Convenience for replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: that doesn't require slice related arguments
MTLResource rootResource()
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.
long sampleCount()
The number of samples in each pixel of this MTLTexture.
If this texture is any type other than 2DMultisample, samples is 1.
long textureType()
The type of this texture.
long usage()
Description of texture usage.
long width()
The width of the MTLTexture instance in pixels.
IOSurfaceRef iosurface()
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.
long iosurfacePlane()
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.
boolean allowGPUOptimizedContents()
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.
long firstMipmapInTail()
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.
boolean isShareable()
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.
boolean isSparse()
MTLSharedTextureHandle newSharedTextureHandle()
Create a new texture handle, that can be shared across process addres space boundaries.
MTLTexture newTextureViewWithPixelFormatTextureTypeLevelsSlicesSwizzle(long pixelFormat, long textureType, NSRange levelRange, NSRange sliceRange, MTLTextureSwizzleChannels swizzle)
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.
MTLTextureSwizzleChannels swizzle()
The channel swizzle used when reading or sampling from this texture
long tailSizeInBytes()
Amount of memory in bytes required to map sparse texture tail.
long compressionType()
Returns the compression type of the texture
See the compressionType property on MTLTextureDescriptor