PDA

View Full Version : seek the documents about the relationship of OpenGL & multithread



pango
12-25-2003, 06:36 AM
Is there some documents talk about the multithread and OpenGL?I found some ogl functions will consume more time,so can I do other rendering in a seprated thread while that slow functions was doing?Just like the multithread feature of some OS,OpenGL can do more than one rendering at a same time?

mcbastian
12-25-2003, 08:10 AM
I don't think OpenGL can do multiple renderings on one viewport.
You can try to split your gl-commends into multiple threads, but this can cause a mess-up, because one thread could be in a glBegin()-glEnd() and another thread calls glGenTextures() or something.
It also doesn't make much sense with double-buffering.
It may work if you have multiple rendering-contexts, but I'm not sure...

Bastian

dorbie
12-25-2003, 09:14 AM
The problem is that OpenGL tends to run on graphics hardware, not the CPU. Threaded implementations tend to focus on making the OpenGL implementation thread safe however you may not realize much of a performance win with good hardware. There are AFAIK thread safe implementations that let multiple threads call OpenGL but it won't make the GFX hardware run faster, it helps your parallelize application code & dispatch.

There has been effort to use MP systems to accelerate geometry transform but that era may have passed and AFAIK it was done automatically and that era may have passed with the entire graphics pipe on the GPU.

For multithreaded application you may want to consider making your application code run in parallel with your rendering code, and remember that the pimary objective would be to improve scheduling of dispatch with your code but you may experience more noise due to scheduling stalls etc on some sysyems that defeats the purpose.

[This message has been edited by dorbie (edited 12-25-2003).]