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

# setTexture(_:index:)

Binds a texture to the texture argument table, allowing compute kernels to access its data on the GPU.

## Declaration

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

## Parameters

- `texture`: An doc://com.apple.metal/documentation/Metal/MTLTexture instance to bind to the texture argument table.
- `index`: The index the texture binds to in the texture argument table.

## See Also

### Binding textures

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