PDA

View Full Version : Wine - wglShareLists and GLX



RoderickC
11-03-2008, 04:03 AM
Hi,

In Wine we emulate WGL using GLX. Except for some corner cases this is a nice 1:1 mapping. In one of these cases namely wglShareLists we are having issues and we have a solution in mind but we don't know the impact of it well yet.

GLX requires you to specify contexts to share lists with at context creation time but WGL (except for WGL_ARB_create_context) can only share contexts using wglShareLists. You call this function after you have created contexts.

For Wine this isn't nice at all and to work around this issue we delay context creation either until wglMakeCurrent or wglShareLists depending on the flow in the program. This works fine for apps which behave like this:
context1 = wglCreateContext(..)
context2 = wglCreateContext(..)
wglShareLists(context1, context2)
In this case we would recreate context1.

Cases which don't work fine are like this:
context1 = wglCreateContext(..)
wglMakeCurrent(context1)
context2 = wglCreateContext(..)
wglMakeCurrent(context2)
wglShareLists(context1, context2)
In this case we need to recreate one of the contexts but will lose information. We would have to copy states over but glXCopyContext is broken in most drivers and limited to indirect rendering on most drivers.

The solution we have in mind for this issue is to share lists between all contexts we create. Most apps want this anyway. I have no idea how drivers implement context sharing, so I don't know how bad this idea is. Does anyone have suggestions?

The only issue I can think of is that this could cause memory leaks in case a program creates a temporary context in which it allocates a bunch of textures and other resources which won't get cleaned up after destroying the temp context.

Thanks,
Roderick