---
title: "init(buffer:descriptor:)"
framework: metalperformanceshaders
role: symbol
role_heading: Initializer
path: "metalperformanceshaders/mpsmatrix/init(buffer:descriptor:)"
---

# init(buffer:descriptor:)

Initializes a matrix with a buffer.

## Declaration

```swift
init(buffer: any MTLBuffer, descriptor: MPSMatrixDescriptor)
```

## Parameters

- `buffer`: The buffer that stores the matrix data.
- `descriptor`: The matrix descriptor.

## Return Value

Return Value A valid MPSMatrix object or nil, if failure.

## Discussion

Discussion The dimensions and stride of the matrix are specified by the MPSMatrixDescriptor object. The size of the provided MTLBuffer object must be large enough to store the following amount of bytes: (descriptor.rows-1) * descriptor.rowBytes + descriptor.columns * (element size)
