I have a Metal texture, I want to access its data from Swift by making it a float4 array (so that I can access each pixel 4 color components).
I discovered this method
To complement @VasilyBodnarchuk's answer:
extension UnsafeMutableRawPointer { func toArray(to type: T.Type, capacity count: Int) -> [T] { return Array(UnsafeBufferPointer(start: bindMemory(to: type, capacity: count), count: count)) } }