Posted 11 April 2007 - 05:37 PM
Posted 11 April 2007 - 05:57 PM
Posted 11 April 2007 - 07:17 PM
there is no way to interact between different rendering contexts?
Posted 11 April 2007 - 07:25 PM
Posted 11 April 2007 - 08:00 PM
I can only tell you that in OpenGL/ES, which is a stripped down version of OpenGL for mobile devices, you can't simply share a context from multiple threads. Each glXXXX call will first get the current ThreadID and gets the gl-context "current" or associated with that thread.
The caveat is, that a context can only be current to one single thread. In a proper GL/ES implementation calls from the second thread will just be ignored, or if two contexts are made current to two threads, each thread only talks to its own OpenGL context.
I'm pretty sure that the Desktop-OpenGL behaves exactly the same.
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
Posted 11 April 2007 - 08:39 PM
Why would you want to have multithreaded access to one OpenGL state, anyway? It wouldn't improve performance or anything as far as I can tell. The CPU-side driver doesn't do very much work, it just queues up commands and DMAs and things to the GPU and sends them. The GPU has its own parallel execution and is orthogonal to any CPU threading.
A better way to do this would be to have the actors' persistent data stored in a monitor, which serializes access to the data (or a more sophisticated one allows simultaneous reads but serializes writes), and have the rendering thread and the actor updating thread both access that data through the monitor.
Posted 13 April 2007 - 04:39 PM
GL just isn't thread safe. It's such a shame...
Posted 13 April 2007 - 05:19 PM
I think you've misunderstood. It's completely thread-safe, that's why you can use OpenGL from two different applications simultaneously without them messing each other up.
In the case you mentioned, you could have the loading thread store data in memory buffers and let the rendering thread create the display lists. This is a better architectural approach IMHO, because the use of display lists (or vertex buffers, or whatever) is an aspect of the rendering implementation, and therefore the loading code shouldn't be aware of it (information hiding, low coupling).
You can share data between two contexts owned by the same thread, but not between different threads. While it would be possible for OpenGL to support data/state copying from one context to another owned by a different thread, I just don't see that there's any need or desire for this feature compelling enough for it to be worth implementing.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users