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;
}
Topic:
Graphics & Games
SubTopic:
General
Tags: