Lightning: How fast can you rotate an image?
summary
A concrete benchmark: achieve 16 ms per frame to match 60 FPS for a 720p buffer (~3.1 MB per frame). Two practical paths are measured: CPU using vectorized routines from Accelerate (avoid bytewise loops), and GPU using Metal by creating textures via CVMetalTexture and running vertex/fragment shaders. Notes on tradeoffs: chroma subsampling halves memory, CPU/GPU share memory so explicit synchronization and triple buffering are required; Metal wins performance at the cost of complexity.
AI-written summary · about
chapters (11)
- 0:00Start
- 0:55What is an image?
- 1:16RGBA/ARGB/BGRA Colorspace
- 2:444:2:0 Chroma subsampling
- 4:32Rotating a BGRA CVPixelBuffer by 90 degrees
- 5:02Rotating a 420 BiPlanar YCbCr CVPixelBuffer by 90 degrees
- 5:33Attempt #1 - Naive Implementation
- 6:53Attempt #2 - Use Accelerate
- 7:20Attempt #2 - Problems
- 9:54Wrap the CVPixelBuffer in a Texture
- 10:18Vertex & Fragment Shaders








