<!--
{
  "documentType" : "article",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/resource-creation",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Resource creation"
}
-->

# Resource creation

Load assets with input/output queues and make various resource instances, such as buffers, textures, acceleration structures, and memory heaps.

## Topics

### Working with resource heaps

[`func makeHeap(descriptor: MTLHeapDescriptor) -> (any MTLHeap)?`](/documentation/Metal/MTLDevice/makeHeap(descriptor:))

Creates a new GPU heap instance.

[`func heapBufferSizeAndAlign(length: Int, options: MTLResourceOptions) -> MTLSizeAndAlign`](/documentation/Metal/MTLDevice/heapBufferSizeAndAlign(length:options:))

Returns the size and alignment, in bytes, of a buffer if you create it from a heap.

[`func heapTextureSizeAndAlign(descriptor: MTLTextureDescriptor) -> MTLSizeAndAlign`](/documentation/Metal/MTLDevice/heapTextureSizeAndAlign(descriptor:))

Returns the size and alignment, in bytes, of a texture if you create it from a heap.

[`func heapAccelerationStructureSizeAndAlign(size: Int) -> MTLSizeAndAlign`](/documentation/Metal/MTLDevice/heapAccelerationStructureSizeAndAlign(size:))

Returns the size and alignment, in bytes, of an acceleration structure if you create it from a heap.

[`func heapAccelerationStructureSizeAndAlign(descriptor: MTLAccelerationStructureDescriptor) -> MTLSizeAndAlign`](/documentation/Metal/MTLDevice/heapAccelerationStructureSizeAndAlign(descriptor:))

Returns the size and alignment, in bytes, of an acceleration structure if you create it from a heap with a descriptor.

[`struct MTLSizeAndAlign`](/documentation/Metal/MTLSizeAndAlign)

The size and alignment of a resource, in bytes.

### Creating buffers

[`var maxBufferLength: Int`](/documentation/Metal/MTLDevice/maxBufferLength)

The largest amount of memory, in bytes, that a GPU device can allocate to a buffer instance.

[`func makeBuffer(length: Int, options: MTLResourceOptions) -> (any MTLBuffer)?`](/documentation/Metal/MTLDevice/makeBuffer(length:options:))

Creates a buffer the method clears with zero values.

[`func makeBuffer(bytes: UnsafeRawPointer, length: Int, options: MTLResourceOptions) -> (any MTLBuffer)?`](/documentation/Metal/MTLDevice/makeBuffer(bytes:length:options:))

Allocates a new buffer of a given length and initializes its contents by copying existing data into it.

[`func makeBuffer(bytesNoCopy: UnsafeMutableRawPointer, length: Int, options: MTLResourceOptions, deallocator: ((UnsafeMutableRawPointer, Int) -> Void)?) -> (any MTLBuffer)?`](/documentation/Metal/MTLDevice/makeBuffer(bytesNoCopy:length:options:deallocator:))

Creates a buffer that wraps an existing contiguous memory allocation.

### Creating textures

[`func makeTexture(descriptor: MTLTextureDescriptor) -> (any MTLTexture)?`](/documentation/Metal/MTLDevice/makeTexture(descriptor:))

Creates a new texture instance.

[`func makeTexture(descriptor: MTLTextureDescriptor, iosurface: IOSurfaceRef, plane: Int) -> (any MTLTexture)?`](/documentation/Metal/MTLDevice/makeTexture(descriptor:iosurface:plane:))

Creates a texture instance that uses I/O surface to store its underlying data.

[`func makeSharedTexture(descriptor: MTLTextureDescriptor) -> (any MTLTexture)?`](/documentation/Metal/MTLDevice/makeSharedTexture(descriptor:))

Creates a texture that you can share across process boundaries.

[`func makeSharedTexture(handle: MTLSharedTextureHandle) -> (any MTLTexture)?`](/documentation/Metal/MTLDevice/makeSharedTexture(handle:))

Creates a texture that references a shared texture.

[`func minimumLinearTextureAlignment(for: MTLPixelFormat) -> Int`](/documentation/Metal/MTLDevice/minimumLinearTextureAlignment(for:))

Returns the minimum alignment the GPU device requires to create a linear texture from a buffer.

[`func minimumTextureBufferAlignment(for: MTLPixelFormat) -> Int`](/documentation/Metal/MTLDevice/minimumTextureBufferAlignment(for:))

Returns the minimum alignment the GPU device requires to create a texture buffer from a buffer.

### Creating samplers

[`func supportsTextureSampleCount(Int) -> Bool`](/documentation/Metal/MTLDevice/supportsTextureSampleCount(_:))

Returns a Boolean value that indicates whether the GPU can sample a texture with a specific number of sample points.

[`func makeSamplerState(descriptor: MTLSamplerDescriptor) -> (any MTLSamplerState)?`](/documentation/Metal/MTLDevice/makeSamplerState(descriptor:))

Creates a sampler state instance.

[`func getDefaultSamplePositions(sampleCount: Int) -> [MTLSamplePosition]`](/documentation/Metal/MTLDevice/getDefaultSamplePositions(sampleCount:))

Returns the default sample locations based on the number of samples.

[`- (void) getDefaultSamplePositions:(MTLSamplePosition *) positions count:(NSUInteger) count;`](/documentation/Metal/MTLDevice/getDefaultSamplePositions:count:)

Retrieves the default sample positions for a specific sample count.

### Working with sparse textures

[`func sparseTileSize(textureType: MTLTextureType, pixelFormat: MTLPixelFormat, sampleCount: Int, sparsePageSize: MTLSparsePageSize) -> MTLSize`](/documentation/Metal/MTLDevice/sparseTileSize(textureType:pixelFormat:sampleCount:sparsePageSize:))

Returns the dimensions of a sparse tile for a texture that has a specific sparse page size.

[`func sparseTileSize(with: MTLTextureType, pixelFormat: MTLPixelFormat, sampleCount: Int) -> MTLSize`](/documentation/Metal/MTLDevice/sparseTileSize(with:pixelFormat:sampleCount:))

Returns the dimensions of a sparse tile for a texture.

[`func sparseTileSizeInBytes(sparsePageSize: MTLSparsePageSize) -> Int`](/documentation/Metal/MTLDevice/sparseTileSizeInBytes(sparsePageSize:))

Returns the size, in bytes, of a sparse tile the GPU device creates with a specific page size.

[`var sparseTileSizeInBytes: Int`](/documentation/Metal/MTLDevice/sparseTileSizeInBytes)

Returns the size, in bytes, of a sparse tile the GPU device creates using a default page size.

[`func convertSparsePixelRegions(UnsafePointer<MTLRegion>, toTileRegions: UnsafeMutablePointer<MTLRegion>, withTileSize: MTLSize, alignmentMode: MTLSparseTextureRegionAlignmentMode, numRegions: Int)`](/documentation/Metal/MTLDevice/convertSparsePixelRegions(_:toTileRegions:withTileSize:alignmentMode:numRegions:))

Converts a list of sparse pixel regions to tile regions.

[`func convertSparseTileRegions(UnsafePointer<MTLRegion>, toPixelRegions: UnsafeMutablePointer<MTLRegion>, withTileSize: MTLSize, numRegions: Int)`](/documentation/Metal/MTLDevice/convertSparseTileRegions(_:toPixelRegions:withTileSize:numRegions:))

Converts a list of sparse tile regions to pixel regions.

[`enum MTLSparsePageSize`](/documentation/Metal/MTLSparsePageSize)

The page size options, in kilobytes, for sparse textures.

[`enum MTLSparseTextureRegionAlignmentMode`](/documentation/Metal/MTLSparseTextureRegionAlignmentMode)

Options used when converting between a pixel-based region within a texture to a tile-based region.

### Creating acceleration structures for ray tracing

[`func makeAccelerationStructure(descriptor: MTLAccelerationStructureDescriptor) -> (any MTLAccelerationStructure)?`](/documentation/Metal/MTLDevice/makeAccelerationStructure(descriptor:))

Creates a new ray-tracing acceleration structure from a descriptor.

[`func makeAccelerationStructure(size: Int) -> (any MTLAccelerationStructure)?`](/documentation/Metal/MTLDevice/makeAccelerationStructure(size:))

Creates a new acceleration structure with a specific size.

[`func accelerationStructureSizes(descriptor: MTLAccelerationStructureDescriptor) -> MTLAccelerationStructureSizes`](/documentation/Metal/MTLDevice/accelerationStructureSizes(descriptor:))

Returns the buffer sizes the GPU device needs to build, refit, and store an acceleration structure.

[`struct MTLAccelerationStructureSizes`](/documentation/Metal/MTLAccelerationStructureSizes)

The expected sizes for a ray-tracing acceleration structure.

### Creating argument buffer encoders

[`var argumentBuffersSupport: MTLArgumentBuffersTier`](/documentation/Metal/MTLDevice/argumentBuffersSupport)

Returns the GPU device’s support tier for argument buffers.

[`var maxArgumentBufferSamplerCount: Int`](/documentation/Metal/MTLDevice/maxArgumentBufferSamplerCount)

The maximum number of unique argument buffer samplers per app.

[`func makeArgumentEncoder(arguments: [MTLArgumentDescriptor]) -> (any MTLArgumentEncoder)?`](/documentation/Metal/MTLDevice/makeArgumentEncoder(arguments:))

Creates a new argument encoder for an array of arguments.

[`func makeArgumentEncoder(bufferBinding: any MTLBufferBinding) -> any MTLArgumentEncoder`](/documentation/Metal/MTLDevice/makeArgumentEncoder(bufferBinding:))

Creates a new argument encoder for a buffer binding.

### Creating fences and events

[`func makeFence() -> (any MTLFence)?`](/documentation/Metal/MTLDevice/makeFence())

Creates a new memory fence instance.

[`func makeEvent() -> (any MTLEvent)?`](/documentation/Metal/MTLDevice/makeEvent())

Creates a new event instance that you can use to synchronize commands and resources within the same GPU device.

[`func makeSharedEvent() -> (any MTLSharedEvent)?`](/documentation/Metal/MTLDevice/makeSharedEvent())

Creates a new shared event instance that you can use to synchronize commands and resources across different GPU devices.

[`func makeSharedEvent(handle: MTLSharedEventHandle) -> (any MTLSharedEvent)?`](/documentation/Metal/MTLDevice/makeSharedEvent(handle:))

Recreates a shared event from a handle.

### Creating rasterization rate maps

[`func supportsRasterizationRateMap(layerCount: Int) -> Bool`](/documentation/Metal/MTLDevice/supportsRasterizationRateMap(layerCount:))

Returns a Boolean value that indicates whether the GPU can create a rasterization rate map with a specific number of layers.

[`func makeRasterizationRateMap(descriptor: MTLRasterizationRateMapDescriptor) -> (any MTLRasterizationRateMap)?`](/documentation/Metal/MTLDevice/makeRasterizationRateMap(descriptor:))

Creates a rasterization rate map instance.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)