<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLSize",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:@SA@MTLSize"
  },
  "title" : "MTLSize"
}
-->

# MTLSize

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

```
struct MTLSize
```

## 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`](/documentation/Metal/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`](/documentation/Metal/MTLSize/depth) property to `1` so that it represents `[5, 5, 1]`.
- For a 1D array with length `42`, set a size’s [`height`](/documentation/Metal/MTLSize/height), [`depth`](/documentation/Metal/MTLSize/depth) properties to `1`, so that it represents `[42, 1, 1]`.

## Topics

### Creating a size instance

[`init()`](/documentation/Metal/MTLSize/init())

Creates a default size instance by setting the initial values for its
width, height, and depth properties to zero.

[`init(width:height:depth:)`](/documentation/Metal/MTLSize/init(width:height:depth:))

Creates a size instance with values for its width, height, and depth properties.

[`MTLSizeMake(_:_:_:)`](/documentation/Metal/MTLSizeMake(_:_:_:))

Creates a size instance with values for its width, height, and depth properties.

### Accessing a size’s dimensions

[`width`](/documentation/Metal/MTLSize/width)

A value for the x-axis dimension.

[`height`](/documentation/Metal/MTLSize/height)

A value for the y-axis dimension.

[`depth`](/documentation/Metal/MTLSize/depth)

A value for the z-axis dimension.



---

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)