SVN commit 1088054 by lmurray: Revert r1082246 as it needs to be done in CompositingPrefs::detect() to work correctly but as doing it there defeats the purpose of moving the code to begin with there's no point in moving it. BUG: 226049 M +0 -3 compositingprefs.cpp M +8 -0 main.cpp M +0 -38 scene_opengl.cpp --- trunk/KDE/kdebase/workspace/kwin/compositingprefs.cpp #1088053:1088054 @@ -276,8 +276,6 @@ mRecommendCompositing = true; // Known driver specific options - // NOTE: GLX has already been loaded so we cannot change direct rendering mode here if the - // driver uses the LIBGL_ALWAYS_INDIRECT environment variable. if( mXgl ) { mStrictBinding = false; @@ -288,7 +286,6 @@ } else if( mDriver == "nvidia" ) { - mEnableDirectRendering = true; // Driver doesn't use LIBGL_ALWAYS_INDIRECT mStrictBinding = false; } //else if( mDriver == "fglrx" ) --- trunk/KDE/kdebase/workspace/kwin/main.cpp #1088053:1088054 @@ -496,6 +496,10 @@ if( KDE_signal( SIGHUP, KWin::sighandler ) == SIG_IGN ) KDE_signal( SIGHUP, SIG_IGN ); + // HACK: This is needed for AIGLX + if( qstrcmp( qgetenv( "KWIN_DIRECT_GL" ), "1" ) != 0 ) + setenv( "LIBGL_ALWAYS_INDIRECT","1", true ); + // HACK: this is needed to work around a Qt4.4.0RC1 bug (#157659) setenv( "QT_SLOW_TOPLEVEL_RESIZE", "1", true ); @@ -504,6 +508,10 @@ KWin::SessionSaveDoneHelper helper; KGlobal::locale()->insertCatalog( "kwin_effects" ); + // Announce when KWIN_DIRECT_GL is set for above HACK + if( qstrcmp( qgetenv( "KWIN_DIRECT_GL" ), "1" ) == 0 ) + kDebug( 1212 ) << "KWIN_DIRECT_GL set, not forcing LIBGL_ALWAYS_INDIRECT=1"; + fcntl( XConnectionNumber( KWin::display() ), F_SETFD, 1 ); QString appname; --- trunk/KDE/kdebase/workspace/kwin/scene_opengl.cpp #1088053:1088054 @@ -113,7 +113,6 @@ XShmSegmentInfo SceneOpenGL::shm; #endif -//static int firstWasDirect = -1; SceneOpenGL::SceneOpenGL( Workspace* ws ) : Scene( ws ) @@ -125,43 +124,6 @@ kDebug( 1212 ) << "No glx extensions available"; return; // error } - - // LIBGL_ALWAYS_INDIRECT: - // This environment variable causes the Mesa libGL to not load any DRI driver on the client's - // side at all. This has the side-effect of making the library behave differently when creating - // indirect rendering contexts for compositing. - // When a Mesa driver is using DRI1 compositing will only work in indirect rendering mode - // while when using DRI2 it's possible to use compositing with direct rendering. When running - // with direct rendering we have more OpenGL features available to us therefore it's the - // prefered mode to be running in. - // If AIGLX is enabled when we create an indirect rendering context without this variable set - // the context doesn't seem to be usable for compositing for some reason. Needs more research. - // In Mesa this variable is only read during the first call to glXQueryVersion() so it cannot - // be changed after GLX has already been used by KWin. - // Fglrx also uses this variable but I have yet to research how it acts under various - // conditions and what the optimal usage of it by KWin would be. - // -- lmurray (30th Jan, 2010) - // TODO: Set this variable only when explicitly running in indirect rendering mode. - //const int isDirect = options->glDirect ? 1 : 0; - //if( firstWasDirect == -1 ) - // firstWasDirect = isDirect; - //else - // if( isDirect != firstWasDirect ) - // // Switching indirect => direct won't take effect and direct => indirect will cause - // // compositing to not work at all on AIGLX systems. - // kWarning( 1212 ) << "Switched direct rendering mode while KWin was running. THIS IS UNSAFE!"; - //if( !options->glDirect ) - // { - // HACK: This is required for compositing to work on AIGLX - if( qstrcmp( qgetenv( "KWIN_DIRECT_GL" ), "1" ) != 0 ) - { - kDebug( 1212 ) << "Forcing LIBGL_ALWAYS_INDIRECT=1"; - setenv( "LIBGL_ALWAYS_INDIRECT", "1", true ); - } - else - kDebug( 1212 ) << "KWIN_DIRECT_GL set, not forcing LIBGL_ALWAYS_INDIRECT=1"; - // } - initGLX(); // check for FBConfig support if( !hasGLExtension( "GLX_SGIX_fbconfig" ) || !glXGetFBConfigAttrib || !glXGetFBConfigs ||