PDA

View Full Version : QT4 mess up the OpenGL context ?



fev
19th October 2009, 10:25
Originally this was posted here: http://www.qtforum.org/article/26669/qt4-mess-up-the-opengl-context.html



Hi, I may have a bug about QT4 to submit to you.
The whole discussion can be found here
http://www.cairo-dock.org/bg_topic.php?t=2156, but here is a summary :
Cairo-Dock is an appli that draws on a RGBA GLX visual, that is to say draw with openGL on a window with real transparency.
Some users have noticed that if the dock is launched, VLC will crashes when trying to start it.
Little by little we've outlined a set of programs that will systematically crash or behave in a strange way if the dock is launched, or after it has been launched (SmPlayer & KMplayer will be transparent, Skype and VirtualBox will have some similar problems too, etc).
In the list of concerned programs, we noticed that all are QT4-based. No Gnome program are affected (for instance Totem), nor common X programs (like Mplayer). The dock works flawlessly with Compiz or any other window manager (including Kwin), the WM does not seem to affect the problem. Being under KDE or Gnome doesn't change anything too, only using qt instead of gtk seems to have an impact.


export XLIB_SKIP_ARGB_VISUALS=1

before launching VLC and the other will make them behave normally.

here is a debug from VLC after the crash :


VLC media player 1.0.0-git Goldeneye
X Error: BadMatch (invalid parameter attributes) 8
Major opcode: 2 (X_ChangeWindowAttributes)
Resource id: 0x6800035
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::begin: Paint device returned engine == 0, type: 1
[????????] x11 video output error: X11 request 147.3 failed with error code 8:
BadMatch (invalid parameter attributes)
[????????] x11 video output notice: buggy X11 server claims shared memory
[????????] x11 video output notice: support though it does not work (OpenSSH?)
[????????] x11 video output error: X11 request 147.3 failed with error code 8:
BadMatch (invalid parameter attributes)
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 147 (MIT-SHM)
Minor opcode of failed request: 3 (X_ShmPutImage)
Serial number of failed request: 63
Current serial number in output stream: 64

So we are thinking that maybe there is a problem in QT4 concerning its openGL part.
I would greatly appreciate your help to solve this mistery !

In case you want to check, the code of the project can be found on :
svn checkout svn://svn.berlios.de/cairo-dock/trunk
the OpenGL stuff is all located in cairo-dock-draw-opengl.c
here is a sample, how I get the openGL config, since it seems to be the problem; maybe you will notice some big mistake :


GdkGLConfig *cairo_dock_get_opengl_config (gboolean bForceOpenGL, gboolean *bHasBeenForced) // taken from a MacSlow's exemple.
{
GdkGLConfig *pGlConfig = NULL;

Display *XDisplay = cairo_dock_get_Xdisplay ();

GLXFBConfig *pFBConfigs;
XRenderPictFormat *pPictFormat = NULL;
int doubleBufferAttributes[] = {
GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DOUBLEBUFFER, True,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_ALPHA_SIZE, 1,
GLX_DEPTH_SIZE, 1,
GLX_STENCIL_SIZE, 1,
None};


XVisualInfo *pVisInfo = NULL;
int i, iNumOfFBConfigs = 0;
cd_debug ("cherchons les configs ...");
pFBConfigs = glXChooseFBConfig (XDisplay,
DefaultScreen (XDisplay),
doubleBufferAttributes,
&iNumOfFBConfigs);

cd_debug (" -> %d FBConfig(s)", iNumOfFBConfigs);
for (i = 0; i < iNumOfFBConfigs; i++)
{
pVisInfo = glXGetVisualFromFBConfig (XDisplay, pFBConfigs[i]);
if (!pVisInfo)
{
cd_warning ("this FBConfig has no visual.");
continue;
}

pPictFormat = XRenderFindVisualFormat (XDisplay, pVisInfo->visual);
if (!pPictFormat)
{
cd_warning ("this visual has an unknown format.");
XFree (pVisInfo);
pVisInfo = NULL;
continue;
}

if (pPictFormat->direct.alphaMask > 0)
{
cd_message ("Strike, found a GLX visual with alpha-support !");
*bHasBeenForced = FALSE;
break;
}

XFree (pVisInfo);
pVisInfo = NULL;
}
if (pFBConfigs)
XFree (pFBConfigs);

if (pVisInfo == NULL && bForceOpenGL)
{
cd_warning ("we could not get an ARGB-visual, trying to get an RGB one...");
*bHasBeenForced = TRUE;
doubleBufferAttributes[13] = 0;
pFBConfigs = glXChooseFBConfig (XDisplay,
DefaultScreen (XDisplay),
doubleBufferAttributes,
&iNumOfFBConfigs);
cd_message ("got %d FBConfig(s) this time", iNumOfFBConfigs);
for (i = 0; i < iNumOfFBConfigs; i++)
{
pVisInfo = glXGetVisualFromFBConfig (XDisplay, pFBConfigs[i]);
if (!pVisInfo)
{
cd_warning ("this FBConfig has no visual.");
}
else
break;
}
if (pVisInfo == NULL)
{
cd_warning ("still no visual, this is the last chance");
pVisInfo = glXChooseVisual (XDisplay,
DefaultScreen (XDisplay),
doubleBufferAttributes);
}
}
if (pVisInfo != NULL)
{
cd_message ("ok, got a visual");
pGlConfig = gdk_x11_gl_config_new_from_visualid (pVisInfo->visualid);
XFree (pVisInfo);
}
else
{
cd_warning ("couldn't find a suitable GLX Visual, OpenGL can't be used.\n (sorry to say that, but your graphic card and/or its driver is crappy)");
g_bUseOpenGL = FALSE;
}

return pGlConfig;
}