Multithreading + OpenGL

Started by
15 comments, last by vNistelrooy 18 years, 7 months ago
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!
Advertisement
Your problem is a bit unclear... What is the exact problem?

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
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 ?
Just for the record, your hardware sounds orgasmic

cheers
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Quote:Original post by Ademan555
Just for the record, your hardware sounds orgasmic

cheers
-Dan


Thank you! Also enjoying experimenting with different GPU configurations.
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


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.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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.
I'm assuming you know all about setting processor affinity masks, and that you hvae SMP-capable drivers, etc?

This topic is closed to new replies.

Advertisement