Post

Replies

Boosts

Views

Activity

Reply to Slow performance on iPhone 12/Pro/Max when copying pixel data from metal texture
Hi again, This is for a totally different example. I trying to record a video from1 a custom MetalKit View. I am running the Profiler and I can get the slowdown by running a simple Performance analysis. My testing device is an iPhone 12 pro max. Not sure if the texture is too big, I am using the same as the screen size. Still unsure if that is the problem.       let region = MTLRegionMake2D(0, 0, texture.width, texture.height)       let frameTime = CACurrentMediaTime() - recordingStartTime       let presentationTime = CMTimeMakeWithSeconds(frameTime, preferredTimescale: 240)       CVPixelBufferLockBaseAddress(pixelBuffer, [])       let pixelBufferBytes = CVPixelBufferGetBaseAddress(pixelBuffer)!       let bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer)                     // TODO: - FIX PERFORMANCE       texture.getBytes(pixelBufferBytes, bytesPerRow: bytesPerRow, from: region, mipmapLevel: 0)       assetWriterPixelBufferInput.append(pixelBuffer, withPresentationTime: presentationTime)       CVPixelBufferUnlockBaseAddress(pixelBuffer, [])
Mar ’21