Are GLES 2.0 calls synchronous or asynchronous on Android and iOS?
When will it block CPU and wait for GPU to complete sent commands?
I believe glReadPixels and glGetTexImage will definitely block thread and wait for all gl commands to complete.
After some tests I feel like multi threaded app may gain performance even on single core device because GL calls are synchronous and GPU blocks CPU.
Is there any reference either gl* calls are synchronous or not on iOS and Android.
I know in general it is not synchronous.
Does it make sense to have 2 threads: one thread to make GL calls and other thread to run physics to give CPU some work when GL blocks main thread ?
Most OpenGL commands do not block the execution of the program. Anything that sets state or issues a draw call just puts a command in the GPU pushbuffer and immediately returns. You do not have to wait for the command to reach the GPU, or for a model to finish drawing before the next command is issued.
The exception is anything which requests state from the GPU, such as
glGet.../glRead...operations. This requires the GPU to flush it’s instruction queue so that it can return the correct value to you. These can cause lengthy stalls, and are thus recommended to be used sparingly as needed.That depends. Generally if you’re stalling waiting for the GPU, it’s because you immediately need to get some value to continue in your calculations. If there is work you can do in the background that does not depend on this, it can make sense to offload that to another thread.