Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMatias Goldberg

Posted 28 May 2013 - 12:52 PM

I see you intent issueing OpenGL calls from multiple threads. As you said, this is a very bad idea, and I personally avoid them due to lots of issues in the past; unless you keep 100% independent GL context for each thread.

Otherwise switching contexts is so error-prone (and driver bugs may appear, to be honest) that any performance gain you intend to get from going multithreading is going to be nullified, or worse; just leave it single threaded.

 

If your logic needs to issue rendering calls, you're not abstracting enough rendering from logic. If you're on a tight schedule, well ok; but if you've got the time, take your time to rethink how the systems relate; and whenever logic needs something from OpenGL, it requests to the render thread, and periodically check for results arrived.

 

For what you describe, your project appears to involve a lot of image processing from what has been rendered already (am I right?) in that case, since your game logic is rendering, and could not be decoupled, you should go single-threaded and rely on a method more like what Hodgman described (map buffer from GPU to CPU, then issue N threads to work on the received image, wait for all of them to finish) for multithreaded approaches.


#1Matias Goldberg

Posted 28 May 2013 - 12:51 PM

I see you intent issueing OpenGL calls from multiple threads. As you said, this is a very bad idea, and I personally avoid them due to lots of issues in the past; unless you keep 100% independent GL context for each thread.

Otherwise switching contexts is so error-prone (and driver bugs may appear, to be honest) that any performance gain you intend to get from going multithreading is going to be nullified, or worse; just leave it single threaded.

 

If your logic needs to issue rendering calls, you're not abstracting enough rendering from logic. If you're on a tight schedule, well ok; but if you've got the time, take your time to rethink how the systems relate; and whenever logic needs something from OpenGL, it requests to the render thread, and periodically check for results arrived.

 

For what you describe, your appears to involve a lot of image processing from what has been rendered already (am I right?) in that case, since your game logic is rendering, and could not be decoupled, you should go single-threaded and rely on a method more like what Hodgman described (map buffer from GPU to CPU, then issue N threads to work on the received image, wait for all of them to finish) for multithreaded approaches.


PARTNERS