Sharing Shader/Program objects across multiple rendering contexts

I am having trouble sharing Shader/Program objects across multiple rendering contexts.

Pseudo code:-

wglShareLists(rc0, rc1);
wglMakeCurrent(dc0, rc0);
CreateVertexShader vs;
CreateFragmentShader fs;
CreateProgramObject po;
Attach vs & fs to po;
wglMakeCurrent(0, 0);

wglMakeCurrent(dc1, rc1);
glUseProgram(po); -> “Error”

According to “gDebugger”, ‘rc1’ trying to use an OpenGL managed object that does not exist. No problems using it in ‘rc0’.

I also tried “Attaching” fs & vs to po in ‘rc1’, this gives me a different kind of error saying, OpenGL trying to attach an object ‘vs’ that does not exist.

I’m able to share DL, Texture objects, FBOs without any problem.

System Info:-

Dual CPU, 3 GHz each.
Dual GPU, NVIDIA 7800 GTX (operating in NON-SLI)

I create two windows such that win0 on gpu0 & win1 on gpu1.

Dual GPU programming is not trivial, you should try on the advanced topic.

The pseudo code is missing the glLinkProgram step. You say it works with one render context. When do you link it then?

Relic,

I just din’t mention it but I do the shader compilation and program linking.

wglShareLists(rc0, rc1);
wglMakeCurrent(dc0, rc0);
CreateVertexShader vs; -> Compile
CreateFragmentShader fs; -> Compile
CreateProgramObject po;
Attach vs & fs to po; -> Link
wglMakeCurrent(0, 0);

It works fine, and also gives me correct results in both rc0 & rc1 but its the “gDEBugger” that gives me the above mentioned error messages.

Did you check the return value of wglShareLists? I would hope so, since that would logically be the very first thing to check. If it returns FALSE, then you’re probably out of luck. And the failure is likely due to the fact that you have two GPUs.

Yes, I have cheched the return value of wglShareLists is TRUE (i.e shares RCs). I had checked all the return values, error messages (if any) while shader compilation and program linking, no problems. As I mentioned I also get the correct result out.

It’s the gDEBugger that complains.

Where are the gDEBugger staff who post messages about new releases ? May be you guys can answer…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.