<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTL4ComputeCommandEncoder/fill(buffer:range:value:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "s:So25MTL4ComputeCommandEncoderP5MetalE4fill6buffer5range5valueySo9MTLBuffer_p_SnySiGs5UInt8VtF"
  },
  "title" : "fill(buffer:range:value:)"
}
-->

# fill(buffer:range:value:)

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

```
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.

---

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)