Interface MTLTexture

  • All Superinterfaces:
    MTLResource

    public interface MTLTexture
    extends MTLResource
    [@protocol] MTLTexture 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. API-Since: 8.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean allowGPUOptimizedContents()
      [@property] allowGPUOptimizedContents Allow GPU-optimization for the contents texture.
      long arrayLength()
      [@property] arrayLength The number of array elements in this MTLTexture.
      @Nullable MTLBuffer buffer()
      [@property] 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()
      [@property] bufferBytesPerRow The bytesPerRow of the buffer this texture view was created from, or 0 if this is not a texture view.
      long bufferOffset()
      [@property] bufferOffset The offset of the buffer this texture view was created from, or 0 if this is not a texture view.
      long compressionType()
      [@property] compressionType Returns the compression type of the texture See the compressionType property on MTLTextureDescriptor API-Since: 15.0
      long depth()
      [@property] depth The depth of this MTLTexture instance in pixels.
      long firstMipmapInTail()
      [@property] firstMipmapInTail For sparse textures this property returns index of first mipmap that is packed in tail.
      void getBytesBytesPerRowBytesPerImageFromRegionMipmapLevelSlice​(@NotNull org.moe.natj.general.ptr.VoidPtr pixelBytes, long bytesPerRow, long bytesPerImage, MTLRegion region, long level, long slice)
      getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: Copies a block of pixels from a texture slice into the application's memory.
      void getBytesBytesPerRowFromRegionMipmapLevel​(@NotNull org.moe.natj.general.ptr.VoidPtr pixelBytes, long bytesPerRow, MTLRegion region, long level)
      getBytes:bytesPerRow:fromRegion:mipmapLevel: Convenience for getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: that doesn't require slice related arguments
      MTLResourceID gpuResourceID()
      [@property] gpuResourceID Handle of the GPU resource suitable for storing in an Argument Buffer API-Since: 16.0
      long height()
      [@property] height The height of the MTLTexture instance in pixels.
      @Nullable IOSurfaceRef iosurface()
      [@property] iosurface If this texture was created from an IOSurface, this returns a reference to that IOSurface.
      long iosurfacePlane()
      [@property] iosurfacePlane If this texture was created from an IOSurface, this returns the plane of the IOSurface from which the texture was created.
      boolean isFramebufferOnly()
      [@property] framebufferOnly If YES, this texture can only be used with a MTLAttachmentDescriptor, and cannot be used as a texture argument for MTLRenderCommandEncoder, MTLBlitCommandEncoder, or MTLComputeCommandEncoder.
      boolean isShareable()
      [@property] shareable If YES, this texture can be shared with other processes.
      boolean isSparse()
      API-Since: 13.0
      long mipmapLevelCount()
      [@property] mipmapLevelCount The number of mipmap levels in each slice of this MTLTexture.
      @Nullable MTLSharedTextureHandle newSharedTextureHandle()
      newSharedTextureHandle Create a new texture handle, that can be shared across process addres space boundaries.
      @Nullable MTLTexture newTextureViewWithPixelFormat​(long pixelFormat)
      newTextureViewWithPixelFormat: Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format.
      @Nullable MTLTexture newTextureViewWithPixelFormatTextureTypeLevelsSlices​(long pixelFormat, long textureType, NSRange levelRange, NSRange sliceRange)
      newTextureViewWithPixelFormat:textureType:levels:slices: 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.
      @Nullable MTLTexture newTextureViewWithPixelFormatTextureTypeLevelsSlicesSwizzle​(long pixelFormat, long textureType, NSRange levelRange, NSRange sliceRange, MTLTextureSwizzleChannels swizzle)
      newTextureViewWithPixelFormat:textureType:levels:slices: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.
      long parentRelativeLevel()
      [@property] parentRelativeLevel The base level of the texture this texture view was created from, or 0 if this is not a texture view.
      long parentRelativeSlice()
      [@property] parentRelativeSlice The base slice of the texture this texture view was created from, or 0 if this is not a texture view.
      @Nullable MTLTexture parentTexture()
      [@property] 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()
      [@property] pixelFormat The MTLPixelFormat that is used to interpret this texture's contents.
      void replaceRegionMipmapLevelSliceWithBytesBytesPerRowBytesPerImage​(MTLRegion region, long level, long slice, @NotNull org.moe.natj.general.ptr.ConstVoidPtr pixelBytes, long bytesPerRow, long bytesPerImage)
      replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: Copy a block of pixel data from the caller's pointer into a texture slice.
      void replaceRegionMipmapLevelWithBytesBytesPerRow​(MTLRegion region, long level, @NotNull org.moe.natj.general.ptr.ConstVoidPtr pixelBytes, long bytesPerRow)
      replaceRegion:mipmapLevel:withBytes:bytesPerRow: Convenience for replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: that doesn't require slice related arguments
      @Nullable MTLResource rootResource()
      Deprecated.
      long sampleCount()
      [@property] sampleCount The number of samples in each pixel of this MTLTexture.
      MTLTextureSwizzleChannels swizzle()
      [@property] swizzle The channel swizzle used when reading or sampling from this texture API-Since: 13.0
      long tailSizeInBytes()
      [@property] tailSizeInBytes Amount of memory in bytes required to map sparse texture tail.
      long textureType()
      [@property] type The type of this texture.
      long usage()
      [@property] usage Description of texture usage.
      long width()
      [@property] width The width of the MTLTexture instance in pixels.
    • Method Detail

      • arrayLength

        long arrayLength()
        [@property] arrayLength The number of array elements in this MTLTexture. For non-Array texture types, arrayLength is 1.
      • buffer

        @Nullable
        @Nullable MTLBuffer buffer()
        [@property] 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. API-Since: 9.0
      • bufferBytesPerRow

        long bufferBytesPerRow()
        [@property] bufferBytesPerRow The bytesPerRow of the buffer this texture view was created from, or 0 if this is not a texture view. API-Since: 9.0
      • bufferOffset

        long bufferOffset()
        [@property] bufferOffset The offset of the buffer this texture view was created from, or 0 if this is not a texture view. API-Since: 9.0
      • depth

        long depth()
        [@property] depth The depth of this MTLTexture instance in pixels. If this MTLTexture is not a 3D texture, the depth is 1
      • getBytesBytesPerRowBytesPerImageFromRegionMipmapLevelSlice

        void getBytesBytesPerRowBytesPerImageFromRegionMipmapLevelSlice​(@NotNull
                                                                        @NotNull org.moe.natj.general.ptr.VoidPtr pixelBytes,
                                                                        long bytesPerRow,
                                                                        long bytesPerImage,
                                                                        MTLRegion region,
                                                                        long level,
                                                                        long slice)
        getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: Copies a block of pixels from a texture slice into the application's memory.
      • getBytesBytesPerRowFromRegionMipmapLevel

        void getBytesBytesPerRowFromRegionMipmapLevel​(@NotNull
                                                      @NotNull org.moe.natj.general.ptr.VoidPtr pixelBytes,
                                                      long bytesPerRow,
                                                      MTLRegion region,
                                                      long level)
        getBytes:bytesPerRow:fromRegion:mipmapLevel: Convenience for getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice: that doesn't require slice related arguments
      • height

        long height()
        [@property] height The height of the MTLTexture instance in pixels.
      • isFramebufferOnly

        boolean isFramebufferOnly()
        [@property] framebufferOnly 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.
      • mipmapLevelCount

        long mipmapLevelCount()
        [@property] mipmapLevelCount The number of mipmap levels in each slice of this MTLTexture.
      • newTextureViewWithPixelFormat

        @Nullable
        @Nullable MTLTexture newTextureViewWithPixelFormat​(long pixelFormat)
        newTextureViewWithPixelFormat: Create a new texture which shares the same storage as the source texture, but with a different (but compatible) pixel format.
      • newTextureViewWithPixelFormatTextureTypeLevelsSlices

        @Nullable
        @Nullable MTLTexture newTextureViewWithPixelFormatTextureTypeLevelsSlices​(long pixelFormat,
                                                                                  long textureType,
                                                                                  NSRange levelRange,
                                                                                  NSRange sliceRange)
        newTextureViewWithPixelFormat:textureType:levels:slices: 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. API-Since: 9.0
      • parentRelativeLevel

        long parentRelativeLevel()
        [@property] parentRelativeLevel The base level of the texture this texture view was created from, or 0 if this is not a texture view. API-Since: 9.0
      • parentRelativeSlice

        long parentRelativeSlice()
        [@property] parentRelativeSlice The base slice of the texture this texture view was created from, or 0 if this is not a texture view. API-Since: 9.0
      • parentTexture

        @Nullable
        @Nullable MTLTexture parentTexture()
        [@property] 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. API-Since: 9.0
      • pixelFormat

        long pixelFormat()
        [@property] pixelFormat The MTLPixelFormat that is used to interpret this texture's contents.
      • replaceRegionMipmapLevelSliceWithBytesBytesPerRowBytesPerImage

        void replaceRegionMipmapLevelSliceWithBytesBytesPerRowBytesPerImage​(MTLRegion region,
                                                                            long level,
                                                                            long slice,
                                                                            @NotNull
                                                                            @NotNull org.moe.natj.general.ptr.ConstVoidPtr pixelBytes,
                                                                            long bytesPerRow,
                                                                            long bytesPerImage)
        replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: Copy a block of pixel data from the caller's pointer into a texture slice.
      • replaceRegionMipmapLevelWithBytesBytesPerRow

        void replaceRegionMipmapLevelWithBytesBytesPerRow​(MTLRegion region,
                                                          long level,
                                                          @NotNull
                                                          @NotNull org.moe.natj.general.ptr.ConstVoidPtr pixelBytes,
                                                          long bytesPerRow)
        replaceRegion:mipmapLevel:withBytes:bytesPerRow: Convenience for replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage: that doesn't require slice related arguments
      • rootResource

        @Nullable
        @Deprecated
        @Nullable MTLResource rootResource()
        Deprecated.
        [@property] 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. API-Since: 8.0 Deprecated-Since: 10.0 Deprecated-Message: Use parentTexture or buffer instead
      • sampleCount

        long sampleCount()
        [@property] sampleCount The number of samples in each pixel of this MTLTexture. If this texture is any type other than 2DMultisample, samples is 1.
      • textureType

        long textureType()
        [@property] type The type of this texture.
      • usage

        long usage()
        [@property] usage Description of texture usage.
      • width

        long width()
        [@property] width The width of the MTLTexture instance in pixels.
      • iosurface

        @Nullable
        @Nullable IOSurfaceRef iosurface()
        [@property] 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. API-Since: 11.0
      • iosurfacePlane

        long iosurfacePlane()
        [@property] 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. API-Since: 11.0
      • allowGPUOptimizedContents

        boolean allowGPUOptimizedContents()
        [@property] 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. API-Since: 12.0
      • firstMipmapInTail

        long firstMipmapInTail()
        [@property] 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. API-Since: 13.0
      • isShareable

        boolean isShareable()
        [@property] shareable 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. API-Since: 13.0
      • isSparse

        boolean isSparse()
        API-Since: 13.0
      • newSharedTextureHandle

        @Nullable
        @Nullable MTLSharedTextureHandle newSharedTextureHandle()
        newSharedTextureHandle Create a new texture handle, that can be shared across process addres space boundaries. API-Since: 13.0
      • newTextureViewWithPixelFormatTextureTypeLevelsSlicesSwizzle

        @Nullable
        @Nullable MTLTexture newTextureViewWithPixelFormatTextureTypeLevelsSlicesSwizzle​(long pixelFormat,
                                                                                         long textureType,
                                                                                         NSRange levelRange,
                                                                                         NSRange sliceRange,
                                                                                         MTLTextureSwizzleChannels swizzle)
        newTextureViewWithPixelFormat:textureType:levels:slices: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. API-Since: 13.0
      • swizzle

        MTLTextureSwizzleChannels swizzle()
        [@property] swizzle The channel swizzle used when reading or sampling from this texture API-Since: 13.0
      • tailSizeInBytes

        long tailSizeInBytes()
        [@property] tailSizeInBytes Amount of memory in bytes required to map sparse texture tail. API-Since: 13.0
      • compressionType

        long compressionType()
        [@property] compressionType Returns the compression type of the texture See the compressionType property on MTLTextureDescriptor API-Since: 15.0
      • gpuResourceID

        MTLResourceID gpuResourceID()
        [@property] gpuResourceID Handle of the GPU resource suitable for storing in an Argument Buffer API-Since: 16.0