Login  Register

Re: Multithreading

Posted by Demoscene Passivist on Jan 09, 2011; 7:34pm
URL: https://forum.jogamp.org/Multithreading-tp2221001p2222781.html

>Hopefully Demoscene or Julien can comment on this -- they've probably got direct experience doing it

Not really  as I generally avoid multithreading with OpenGL. I've tried mutlithreading when I begun with OpenGL but made really discouraging experiences regarding driver stability on a lot of platforms. All OpenGL calls I do are made from on single thread, tho I do data preprocessing on multiple threads to later feed the data to the single "OpenGL-API-Call" thread.

So my advise is if u have to release ur application to a broad range of different OpenGL drivers: DON'T USE MULTITHREADING! If u know the platform/driver implementation and can actively test ur application on that setup, feel free to try it out: It may work for u.

As ur only reason to do multithreading seems to be better performance be aware the most OpenGL drivers are already multithreaded by default. The driver kind of "caches" ur calls and processes them in parallel as good as possible. This works regardless of ur application is multithreading aware or not. See "Best Practices for Multi-threading" from NVidia for further information on that. The document also covers some tips on OpenGL bufffer objects and how tooptimize them for multithreading use.

>You'll probably have to do some experiments to find the fastest way, since the
>performance of multithreaded programs can be counter-intuitive.

Exactly, as Wade points out here be 100% that u really get a benefit from multithreading. Maybe the benefit will only be 10% or stg like that wich would not be worth the effort. Try to get ur application up and running as single threaded version first, then optimize it to use multithreading afterwards if u see that singlethreading is the bottleneck of ur application.

>I need to stream my terrain blocks from HD

As a last note: Maybe u can work around the problem of loading big chunks from HD by reducing geometry data using tesselation in conjunction with displacenment mapping ? Or a more advanced geometry representation like NURBS ? Textures are genereally much easier to stream coz they can be interpolated on the fly ...