[opengl] check drawable and context Visual IDs in wglMakeCurrent()

Tomas Carnecky tom at dbservice.com
Thu Mar 23 13:26:43 CST 2006

Tomas Carnecky wrote:
> Changelog:
>  - fail if the drawable and context Visual IDs don't match.
> why? because this will produce a BadMatch and crash the application so
> instead of the crash rather return GL_FALSE and let the application
> handle it.

Please don't apply this patch yet. It fixes one case but there is more
to be aware of.

This BadMatch bug is triggered if an application creates a window (with
a default Visual ID) and a custom (non-default) pixel format, the IDs
were  0x21 and 0x23 in my case (glxinfo/xdpyinfo report Visual ID in the
range from 0x21 to 0x70).

But! I've seen that World of Warcraft calls wglMakeCurrent() with a
darawable that has Visual ID 0x71 and a context with Visual ID 0x21. Now
0x71 is not defined (according to the glxino output) but it works fine,
eg. glXMakeCurrent() doesn't produce the X Error in that case.
So I went up the backtrace, into create_glxpixmap(). I let this function
fail if it would produce a X Error, eg. if "depth of pixmap does not
match the GLX_BUFFER_SIZE value of vis".
Then I had to modify wglMakeCurrent() to respect the create_glxpixmap()
failure and return FALSE. Works good so far, framerate in WoW went up
from ~20 to up to 70 fps, average is somewhere between 40-50 !!! This is

So.. in this attachment you'll find a patch that does what I've just
described. I can't test it on anything else than WoW, so if someone
would please review it and test with outher opengl/d3d applications it
would be great.

Also, it would be great if we could put the *Swap*Buffers() into their
own log domain, something like 'swapbuffers', because the trace is
usually useless, only when you explicitly look whether these functions
are called or not, otherwise they only fill the log with garbage.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-glx-pixmap.patch
Type: text/x-patch
Size: 4916 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20060323/c9a9049e/wine-glx-pixmap-0001.patch

More information about the wine-devel mailing list