---
title: "constantData(at:)"
framework: metal
role: symbol
role_heading: Instance Method
path: "metal/mtlargumentencoder/constantdata(at:)"
---

# constantData(at:)

Returns a pointer to an inline, constant-data argument within the argument buffer.

## Declaration

```swift
func constantData(at index: Int) -> UnsafeMutableRawPointer
```

## Parameters

- `index`: The index of an inline, constant-data argument 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.

## Return Value

Return Value A pointer to the location in the buffer to which you should write the constant data.

## Discussion

Discussion Constants declared contiguously in the Metal shading language (in an array or structure) are contiguous in memory. You can encode contiguous ranges of inlined constant data through a pointer to the first constant. To encode inlined constant data into the argument buffer, perform a memory copy operation from your data’s source pointer to the returned destination pointer.
