---
title: "fill(buffer:range:value:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtl4computecommandencoder/fill(buffer:range:value:)"
---

# fill(buffer:range:value:)

Encodes a command that fills a buffer with a constant value for each byte.

## Declaration

```swift
func fill(buffer: any MTLBuffer, range: Range<Int>, value: UInt8)
```

## Parameters

- `buffer`: A MTLBuffer instance the command assigns each byte in range to value.
- `range`: A range of bytes within the buffer the command assigns value to. The range’s count property needs to be greater than 0.
- `value`: The value to write to each byte.
