Buffer declaration: why not uint64_t possible?

This is my function:

kernel void shaderFunction(device uint64_t* result, uint index [[thread_position_in_grid]]) 
{
...
}

This is the error:

Invalid type 'device uint64_t *' (aka 'device unsigned long *') for buffer declaration

When I looked in the Metal Specification, section scalar data types, uint64_t should be possible? Unless those can't be used to declare a buffer, but what types can then be used? And how can I use 64 bit data? (see: https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf)

Replies

I found this link: https://developer.apple.com/documentation/metal/mtldatatype. But still get an error when trying to use 'ulong'.

Invalid type 'device ulong *' (aka 'device unsigned long *') for buffer declaration

This is the buffer code in swift:

guard let buffer = device.makeBuffer(bytes: &array64Bit, length: MemoryLayout<UInt64>.stride * array64Bit.count) else {
            throw InitError.bufferIsNil
}
self.bufferResult = buffer
[...]
commandEncoder.setBuffer(bufferResult, offset: 0, index: 0)
[...]
let bufferResultPtr = bufferResult.contents().assumingMemoryBound(to: UInt64.self)
let bufferResultArray = UnsafeMutableBufferPointer(start: bufferResultPtr, count: array64Bit.count)

This is the buffer code in metal:

kernel void shaderFunction(device ulong* result,
                       uint index [[thread_position_in_grid]])
{
    result[index] = result[index] + 1;
}

For uint64_t, the specification states "Since Metal 2.2". So you have to compile to that, and make sure your iOS/macOS target is correct.