PDA

View Full Version : what about multi_threading ?



Nikolai Timofeev
05-21-2006, 11:08 PM
Streaming -
threads independent contexts ?

Overmind
05-22-2006, 03:15 AM
I don't think it's a good idea to make OpenGL threadsafe per default, because it will certainly cost performance for everyone who doesn't want to use it. And the operations would have to be serialized anyway, because the GPU itself is not capable of doing multithreading.

After all, it's not that hard to synchronize access to the GPU yourself. Streaming for example is rather easy: Map the buffer in your rendering thread, write into the mapped buffer in another thread, unmap it in your rendering thread.

Nikolai Timofeev
05-22-2006, 11:03 PM
Ok.
Updating textures also with same way -
download data (async. mode) to the pixel buffer object, and than copy (TexSubImage)
it to the target texture. Memory overhead ?

Overmind
05-23-2006, 05:03 AM
Of course there is an additional memory overhead if you do it with PBO. The alternative would be to use a synchronous glTex(Sub)Image call in the render thread after you have loaded the texture from file in another thread.

This would trade performance for memory, but you still get the same performance as a hypothetical multithreaded implementation of OpenGL, where the driver has to serialize the operations.

ZbuffeR
05-23-2006, 06:05 AM
>> additional memory overhead if you do it with PBO
Why ? Can you elaborate, I am not fluent with the inner workings of PBO, but I though there was less memory overhead ? With glTexImage the driver often keep its own copy in local RAM.

Overmind
05-24-2006, 02:50 AM
That's system memory. We have plenty of that.

With PBO, you have to reserve video memory for the PBO plus you need memory for the texture itself. Of course, you can free the PBO when you are finished with uploading the texture, but if it's a dynamic texture you are never finished with uploading ;)