---
title: MTLSize
framework: metal
role: symbol
role_heading: Structure
path: metal/mtlsize
---

# MTLSize

A type that represents one, two, or three dimensions of a type instance, such as an array or texture.

## Declaration

```swift
struct MTLSize
```

## Mentioned in

Converting between pixel regions and sparse tile regions Calculating threadgroup and grid sizes Creating a rasterization rate map

## Overview

Overview Metal has many types that represent arrays of discrete elements, such as: A texture, which has an array of pixel elements A thread grid, which has an array of computational threads Types and methods that work with these array-like types frequently have an MTLSize property or parameter that refers to the extents of a specific instance of the type, or a region within the instance. important: Treat each size instance as a measure of something in 3D, even if it represents something with only one or two dimensions, by assigning 1 to the irrelevant dimensions. The following are some examples for setting a size for an instance that has less than three dimentions: For a 2D texture that has a height and width of 5, set a size’s depth property to 1 so that it represents [5, 5, 1]. For a 1D array with length 42, set a size’s height, depth properties to 1, so that it represents [42, 1, 1].

## Topics

### Creating a size instance

- [init()](metal/mtlsize/init().md)
- [init(width:height:depth:)](metal/mtlsize/init(width:height:depth:).md)
- [MTLSizeMake(_:_:_:)](metal/mtlsizemake(_:_:_:).md)

### Accessing a size’s dimensions

- [width](metal/mtlsize/width.md)
- [height](metal/mtlsize/height.md)
- [depth](metal/mtlsize/depth.md)

## Relationships

### Conforms To

- [BitwiseCopyable](swift/bitwisecopyable.md)
- [Sendable](swift/sendable.md)

## See Also

### Indirect compute commands

- [MTLIndirectComputeCommand](metal/mtlindirectcomputecommand.md)
- [MTLRegion](metal/mtlregion.md)
- [MTLOrigin](metal/mtlorigin.md)
- [MTLStageInRegionIndirectArguments](metal/mtlstageinregionindirectarguments.md)
- [MTLDispatchThreadgroupsIndirectArguments](metal/mtldispatchthreadgroupsindirectarguments.md)
