PDA

View Full Version : Sharing Textures between Displays



yang11
11-02-2005, 12:32 PM
Our PC has two FX7800 cards (a SLI machine but with SLI disabled). Each card has 2 DVI outputs, and each DVI output connects to a monitor.

To see if textures between different opengl contexts can be shared, I did the simple test as followed:

I created 2 opengl contexts, each has its own rendering window. I used my own Win API routines to create window instead of using glut, because glut can only allow 1 window be active at any given time.

// in opengl context0, I copied frame buffer => texid0:
glBindTexture (GL_TEXTURE_2D, texid0);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);

// in opengl context1, I copied frame buffer => texid1:
glBindTexture (GL_TEXTURE_2D, texid1);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);

After that, in my display function:

// bind texid1 to context0, and render it:
glBindTexture (GL_TEXTURE_2D, texid1);
// texture mapping and display it
//…

// texid0 => context1, render it…
glBindTexture (GL_TEXTURE_2D, texid0);
//render it…

My experiment results are:
1. If 2 windows are displayed in same monitor, their textures can be shared between each other.

2. But if the two windows are on different monitors (even within the same GPU), textures are NOT sharable. But if the windows are dragged together in a single monitor, texture sharing will work again.

I created a single window (but different glviewports) that spans all 4 monitors. I got the same results as above.

I am using the latest nvidia driver. And called the wglShareLists (…) twice to establish a mutual share (do I have to call it twice?).

It is really important for me if I can make textures shared!

Is anybody knows if it is possible to share textures between two windows that are on two separate Displays? If so, is there any sample code you can point me? Is there any special driver setting needed?

Thanks!

dimensionX
11-04-2005, 08:30 AM
- Connect the 2 monitors on each GPU in Horizontal Span mode.
- Now create two windows one on each span.
- Create textures in context0 and do not create any textures on context1 yet.
- Now call wglShareLists(), this should share texture objects across multiple contexts.
- Now load these textures using glTexImage2D and try drawing them.

It'll work.

V-man
11-04-2005, 06:03 PM
I think you should call wglShareLists before creating any textures or other GL objects.

dimensionX
11-05-2005, 12:44 PM
Atleast the MSDN specification says no GL resources must be allocated on the 2nd RC at the time of wglShareLists(). It doesn't say no GL resources in any RC. Also, I never had any problem doing as mentioned earlier.

Although I have one question:- How to delete shared texture/display objects/lists across two RC's without having to delete the RC's itself.
Should the aplication call delete on the same texture object in both the RC's ?

Kaya
11-09-2005, 12:04 AM
Sharing resources between two different physical devices is not possible. The idea behind sharing in OpenGL is that you do not need to recreate resource on one graphics card for a second context, while the same resources are already in the memory of the graphics card for another context.

If you want to create a new context on another device, then ther are no resources on that device that could be shared. You have to recreate them yourself.

HTH,
Kaya