programloop(){ some cpu only stuff; capture; some more cpu only stuff; render;}
Also you will need to handle the first capture since it will occur before any rendering. Simple enough.
This way be padding out the space you can give the GPU some free time to get the rendering out of the way before capture and vise versa and you can make use of that time with the cpu coding of your app.