title: MTLTexture from CMSampleBuffer has 0 bytesPerRow
body: <p>I am converting the CMSampleBuffer argument in the captureOutput function of my AVCaptureVideoDataOuput delegate into a MTLTexture like so (side note, I have set the pixel format of the video output to kCVPixelFormatType_32BGRA):</p>
  
  <pre><code>func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!) {
  
      let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)!
      let width = CVPixelBufferGetWidth(imageBuffer)
      let height = CVPixelBufferGetHeight(imageBuffer)
      var outTexture: CVMetalTexture? = nil
  
      var textCache : CVMetalTextureCache?
      CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, metalDevice, nil, &amp;textCache)
  
      var textureRef : CVMetalTexture?
      CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault, textCache!, imageBuffer, nil, MTLPixelFormat.bgra8Unorm, width, height, 0, &amp;textureRef)
      let texture = CVMetalTextureGetTexture(textureRef!)!
  
      print(texture.bufferBytesPerRow)
  }
  </code></pre>
  
  <p>The issue is when I print the bytes per row of the texture, it always prints 0, which is problematic because I later try to convert the texture back into a UIImage using the methodology in this article: <a href="https://www.invasivecode.com/weblog/metal-image-processing" rel="nofollow noreferrer">https://www.invasivecode.com/weblog/metal-image-processing</a>. Why is the texture I receive seemingly empty? I know the CMSampleBuffer property is fine because I can convert it into a UIIMage and draw it like so:</p>
  
  <pre><code>    let myPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)
      let myCIimage = CIImage(cvPixelBuffer: myPixelBuffer!)
      let image = UIImage(ciImage: myCIimage)
      self.imageView.image = image
  </code></pre>