---
title: "setTexture(_:index:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlargumentencoder/settexture(_:index:)"
---

# setTexture(_:index:)

Encodes a reference to a texture into the argument buffer.

## Declaration

```swift
func setTexture(_ texture: (any MTLTexture)?, index: Int)
```

## Parameters

- `texture`: A texture the method encodes.
- `index`: The index of a texture within the argument buffer. The value corresponds to either the index ID of a declaration in Metal Shading Language (MSL) or the doc://com.apple.metal/documentation/Metal/MTLArgumentDescriptor/index property of an doc://com.apple.metal/documentation/Metal/MTLArgumentDescriptor instance.

## See Also

### Encoding textures

- [setTextures(_:range:)](metal/mtlargumentencoder/settextures(_:range:).md)
