Jump to content
  • Advertisement
Sign in to follow this  
littlekid

OpenGL Is it better to have all opengl context on a single thread?

This topic is 2783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi suppose I create 1 - 4 windows each with their own opengl context that is shared. Is it better to have each context on a different thread?? Meaning, for e.g 4 opengl context would span over 4 thread. Or would it be more efficient to just place all contexts in a single thread and draw them.

for other resources such as vbo and textures, I am sharing among the context, hence I am not duplicating vbo or textures 4 times.

regards

Share this post


Link to post
Share on other sites
Advertisement

Hi suppose I create 1 - 4 windows each with their own opengl context that is shared. Is it better to have each context on a different thread?? Meaning, for e.g 4 opengl context would span over 4 thread. Or would it be more efficient to just place all contexts in a single thread and draw them.

for other resources such as vbo and textures, I am sharing among the context, hence I am not duplicating vbo or textures 4 times.

regards


If the contexts are in the sharing group (new approach since GL 3.0+), or are shared (pre-GL 3) they share textures and VBOs, so you don't need to duplicate them. Furthermore, sharing context is a concept invented for that purpose.


In one thread you can have just one context current at the time, so the question is: would it be faster to switch contexts or synchronize different threads and GL calls? It probably depends on OS and drivers, and on the use-cases. In any case, GL calls are serialized, so you cannot render faster in either cases (unless switching context lasts too long), but you are free to split tasks across multiple threads and use multiple CPU cores more efficiently.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!