Sign in to follow this  
dimensionX

Multithreading + OpenGL

Recommended Posts

dimensionX    100
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
dimensionX    100
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
dimensionX    100
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
_the_phantom_    11250
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
_the_phantom_    11250
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
dimensionX    100
Quote:
Original post by Shannon Barber
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.


Yes, for each thread I make the context current once and use EXT_framebuffer_object for rest of the processing.

Phantom:- Where did you find those GDC05 presentation. Could you please post the link here ?

Omaha:- How do I know whether the system has SMP-drivers ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by dimensionX
Quote:
Original post by Shannon Barber
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.


Yes, for each thread I make the context current once and use EXT_framebuffer_object for rest of the processing.



what are you processing if i may ask? (renderfarm?)

Share this post


Link to post
Share on other sites
dimensionX    100
System Configuration:-
--------------------
1) '2' AMD Opteron 64-bit processors
2) '2' Geforce 7800 GTX GPUs (NOT connected in SLI)
3) '4' VGA Monitors, 2 monitors to each graphics card (Horizontal span mode) i.e I have to 2 horizontal spans one on each graphics card. I had also disabled Vsync for both cards. Each horzontal span is (2048 * 768). Also for the 2nd horizontal span, I set it to extended desktop mode.

Situation:- (Refresh rates are set to 60Hz)
---------
1) Horizontal Span + Extended desktop mode + GLUT window size (4096 * 768)
FPS = 20

2) Horizontal Span + Extended desktop mode + GLUT window size (2048 * 768) - window doesn't cross the 1st GPUs boundry. FPS = 20

3) Horizontal Span + Extended desktop DISABLED + GLUT window size (2048 * 768)
FPS = 45

My FPS halves when I use extended desktop mode (although my window does not span the 2nd GPU, CASE 2). So I guess it is not the problem of loosing hardware acceleration when using multiple GPUs. I cannot bring down the refresh rates.

How can I get around this problem ?

Share this post


Link to post
Share on other sites
dimensionX    100
Solved the problem partly. It was the glTexSubImage2D call that was the killer.

Now I have another problem. My current version works with Win32 with WS_OVERLAPPED | WS_VISIBLE. When I try the WS_POPUP for fullscreen on both horizontal spans, my fps severly drops. Also I am using glewInit(). I call it once per window since each window maps to a different GPU. I hope the multithreading is not the issue with glewInit()

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
btw how exactly do you go about assigning each thread to each cpu


im assuming you are using beginthread((void *)funct(void),size_t,(void *)arg);
??? (process.h)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this