title: How to use UnsafeMutableRawPointer to fill an array?
body: <p>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).  </p>
  
  <p>I discovered this method of <code>MTLTexture</code> :  </p>
  
  <pre><code>getBytes(UnsafeMutableRawPointer, bytesPerRow: Int, bytesPerImage: Int, from: MTLRegion, mipmapLevel: Int, slice: Int)
  </code></pre>
  
  <p>I don't know at all how to use UnsafeMutableRawPointer, how it works, and how to get the data back into a simple Swift array.  </p>
  
  <p>My first attempt was to create a pointer and allocate enough space like that, but I don't even know if that's what I should do:  </p>
  
  <pre><code>var pointer = UnsafeMutableRawPointer.allocate(bytes: myTextureSizeInBytes, alignedTo: 0)  
  </code></pre>
  
  <p>Then I have no idea at all of how to get this data back into a standard Swift array...  </p>
  
  <p>Thank you.</p>