Jump to content
  • Advertisement
Sign in to follow this  
dimensionX

Multithreading + OpenGL

This topic is 4827 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

System Configuration:- -------------------- 1) '2' AMD Opteron 64-bit processors 2) '2' Geforce 7800 GTX GPUs (NOT connected in SLI) Problem:- ------- 1) Created Win0 (hDC0, hRC0) that maps to GPU0 and Win1 (hDC1, hRC1) that maps to GPU1. 2) Now I've created two threads, and trying to render to their respective windows. Inside the ThreadProc() (using Win32 Threads): ThreadProc(LPVOID tData) { wglMakeCurrent(tData->hDC, tData->hRC); GLCommands...... } Each thread calls the same function but with different tData. I also map Thread0-to-CPU0 and Thread1-to-CPU1. So, Thread0:- wglMakeCurrent(hDC0, hRC0); Thread1:- wglMakeCurrent(hDC1, hRC1); Can multiple (hDC, hRC) be active at the sametime. Bare in mind there are two different windows that map to two Physical GPUs. Also at any given time only one window is current (in focus). Two windows do not overlap. win0 = CreateWindow(0, 0, 2048, 768); win1 = CreateWindow(2048, 0, 2048, 768); Thanks!

Share this post


Link to post
Share on other sites
Advertisement
you can have multiple contexts active at the same time as long as they are in different threads and you dont try to activate a context while it is current in another thread

Share this post


Link to post
Share on other sites
Quote:
Original post by Toolmaker
Your problem is a bit unclear... What is the exact problem?


I haven't actually implemented this.

I want to create two windows one on each GPU. Then create two threads to render into these windows simultaneously.

I have two threads, each one is running on a different CPU. Each thread calls wglMakeCurrent(hDC, hRC) (their respective hDC,hRC pair). Since the two threads are running on different CPUs they are running in parallel. So each thread calls its wglMakeCurrent(). Can multiple hDC,hRC pairs be current at the sametime ?

Share this post


Link to post
Share on other sites
Quote:
Original post by Ademan555
Just for the record, your hardware sounds orgasmic

cheers
-Dan


Thank you! Also enjoying experimenting with different GPU configurations.

Share this post


Link to post
Share on other sites
Quote:
Original post by dimensionX
Can multiple hDC,hRC pairs be current at the sametime ?


Quote:
Original post by _the_phantom_
you can have multiple contexts active at the same time as long as they are in different threads and you dont try to activate a context while it is current in another thread


Share this post


Link to post
Share on other sites
I'd be interested in how this turns out, I did some test with threaded rendering before, but switching an OGL context in and out is a very expensive operation.

Share this post


Link to post
Share on other sites
yeah, context switching is a killer, which is why everyone is glad to see the back of pbuffers.

What the OP is doing on the other hand should work perfectly, as he'll only have to make the context current once per thread as long as he keeps rendering to the same context from the same thread.

There was some stuff from the GDC05 presentations which briefly touched on MT rendering with OGL, the OGL forum FAQ has some links to the pdfs and videos from it.

Share this post


Link to post
Share on other sites
I'm assuming you know all about setting processor affinity masks, and that you hvae SMP-capable drivers, etc?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!