Sending kCVPixelBufferLock_ReadOnly flag to CVPixelBufferLockBaseAddress() calls because "Setting this flag improves performance by preventing Core Video from invalidating existing caches of the buffer’s contents."
Swapping the order of a few calls to be more correct.
- Release the textures before flushing the texture cache.
- Don't activate the shader program until the FBO has been set, just to be safe.
Removing pointless "if/else ([GPUImageContext deviceSupportsRedTextures])" that does the same for both cases.
Make sure the gl context is active for the current thread when rendering frames. (serial dispatch queues don't guarantee which thread they run on, just that they run in the order they were called).