title: Detecting if a MTLTexture is blank
body: <p>I am trying to determine if a MTLTexture (in bgra8Unorm format) is blank by calculating the sum of all the R G B and A components of each of its pixels.</p>
  
  <p>This function intends to do this by adding adjacent floats in memory after a texture has been copied to a pointer. However I have determined that this function ends up returning false nomatter the MTLTexture given.</p>
  
  <p>What is wrong with this function?</p>
  
  <pre><code>func anythingHere(_ texture: MTLTexture) -&gt; Bool {
          let width = texture.width
          let height = texture.height
          let bytesPerRow = width * 4
  
          let data = UnsafeMutableRawPointer.allocate(bytes: bytesPerRow * height, alignedTo: 4)
          defer {
              data.deallocate(bytes: bytesPerRow * height, alignedTo: 4)
          }
  
          let region = MTLRegionMake2D(0, 0, width, height)
          texture.getBytes(data, bytesPerRow: bytesPerRow, from: region, mipmapLevel: 0)
          var bind = data.assumingMemoryBound(to: UInt8.self)
  
          var sum:UInt8 = 0;
          for i in 0..&lt;width*height {
              sum += bind.pointee
              bind.advanced(by: 1)
          }
          return sum != 0
  }
  </code></pre>