multi threading functionality ?

Hi,


Usually on phones the load times can be a kill.
The best solution is to split the running and rendering thread.

Does PVR has any lib for creating threads ? What problems and tips to following when seperating out the rendering thread ?

Also, please excuse me but is there a way (pseudo code is appreciated) to specify the loading thread to run for a set time and then yield back to continue later ?

Thanks,
Madan

Hi Madan,

Unfortunately, we don’t provide a library for threading.

If you want to add threading to your applications, it’s best for performance to have a single thread for your rendering that calls all of your GL functions, including functions for loading textures, shaders etc.

Thanks,
Joe



Thanks for the reply Joe !!

For a fact, would you know if pthread would work the same for iOS and android devices ? 

My intention is to make a responsive UI and am exploring alternatives.

Hi Madan,


It should be noted that this is from personal experience, but yes, pthreads are supported on iOS and Android.  The bank end implementation may differ, but the specification is quite clear on how pthread functionality should work, so it should work the same on both.

You may want to double check a few things however, to my understanding, neither OS is entirely POSIX compliant, and thus its not guaranteed that all of the pthread functionality exists.  For example, Bionic, the name for Android native C library support, does not include pthread_rwlock.

So yes, you can use pthread, but I would double check on the specifics of what is and isn’t available on the relevant OSs website.

On iOS, have you looked at Grand Central Dispatch?

Thanks,
Bob

I’m not sure if threading behaves the same way on the two OSs. It would be best to refer to the iOS and Android documentation for this information.

Unless your rendering thread is being blocked by other CPU work (e.g. handling network connections) or CPU workload is the bottleneck, then using multiple threads is unlikely to improve the responsiveness of your UI. Have you tried running PVRTune on your target Android device/s?

…and yes, Joe is entirely correct.  Threading does not automatically mean a performance boost, sometimes the overhead of all the locking and unlocking etc, never mind the debugging time. can cost more than you gain, so before you do that, try running Tune on your device to see if you need it at all.  

You should also be aware that GL contexts are entirely thread-specific. You can use functionality such as share groups to share GL objects across threads, however. This is quite API specific: on iOS EAGLContext contains functionality for retrieving and setting share group properties and on Android I believe the various EGL functions such as eglCreateContext are used to do the same.