Best practice for main loop - Raspberry Pi Forums
i'm sorry if it's been asked before, couldn't find searching on forum. i'm trying find best way cpu , gpu work in parallel. here simple main loop, starting point:
afaik, unlike desktop gpu, mobile gpus (like 1 in raspberry pi) start rendering when frame over. there way tell gpu frame on , it's ok start rendering @ (1)?
looks me multi-threading wouldn't much, unless play thread priorities (something i've been discouraged rely on). suppose move computation thread; signaling other thread @ (2) (the other thread might start working without gpu having started rendering), , signaling other thread @ (3) late (the cpu has wasted time waiting gpu finish rendering).
advice?
code: select all
for each frame: glclear(...); gluseprogram(...); ... // no more gl commands // (1) computation on cpu // (2) eglswapbuffers(...); // (3)
looks me multi-threading wouldn't much, unless play thread priorities (something i've been discouraged rely on). suppose move computation thread; signaling other thread @ (2) (the other thread might start working without gpu having started rendering), , signaling other thread @ (3) late (the cpu has wasted time waiting gpu finish rendering).
advice?
you use glflush() after you've finished gl commands explicitly send buffered commands driver has queued, may make things worse depending on how hardware & driver work. whilst sending commands current frame, gpu processing both vertices of previous frame , fragments of frame before (*). explicitly flushing buffers upset balance, plus, glflush() might not able optimise things not writing depth buffer memory won't need done on swapbuffers() it's discarded/cleared straight after (**).
can try, i've been under impression unless need to, don't need call glflush (or glfinish same, blocks until done).
(*) or whilst processing previous frame's fragments, resources temporarily shared facilitate processing current frame's vertices send them. don't know how vc4 manages resources.
(**) powervr optimisation think, not sure vc4
can try, i've been under impression unless need to, don't need call glflush (or glfinish same, blocks until done).
(*) or whilst processing previous frame's fragments, resources temporarily shared facilitate processing current frame's vertices send them. don't know how vc4 manages resources.
(**) powervr optimisation think, not sure vc4
raspberrypi
Comments
Post a Comment