Detect xgl and whether to use strict binding.

svn path=/trunk/KDE/kdebase/workspace/; revision=726357
This commit is contained in:
Luboš Luňák 2007-10-17 15:37:14 +00:00
parent 6daf4d3ec8
commit fef0d1ff29
3 changed files with 33 additions and 11 deletions

View file

@ -20,11 +20,14 @@ namespace KWin
{
CompositingPrefs::CompositingPrefs()
: mXgl( false )
, mEnableCompositing( false )
, mEnableVSync( true )
, mEnableDirectRendering( true )
, mStrictBinding( true )
{
mEnableCompositing = false;
mEnableVSync = true;
mEnableDirectRendering = true;
}
CompositingPrefs::~CompositingPrefs()
{
}
@ -163,26 +166,28 @@ void CompositingPrefs::detectDriverAndVersion()
mGLVendor = QString((const char*)glGetString( GL_VENDOR ));
mGLRenderer = QString((const char*)glGetString( GL_RENDERER ));
mGLVersion = QString((const char*)glGetString( GL_VERSION ));
mXgl = detectXgl();
kDebug() << "GL vendor is" << mGLVendor;
kDebug() << "GL renderer is" << mGLRenderer;
kDebug() << "GL version is" << mGLVersion;
kDebug() << "XGL:" << ( mXgl ? "yes" : "no" );
if( mGLRenderer.contains( "Intel" ))
{
{
mDriver = "intel";
QStringList words = mGLRenderer.split(" ");
mVersion = Version( words[ words.count() - 2 ] );
}
}
else if( mGLVendor.contains( "NVIDIA" ))
{
{
mDriver = "nvidia";
QStringList words = mGLVersion.split(" ");
mVersion = Version( words[ words.count() - 1 ] );
}
}
else
{
{
mDriver = "unknown";
}
}
kDebug() << "Detected driver" << mDriver << ", version" << mVersion.join(".");
#endif
@ -190,7 +195,13 @@ void CompositingPrefs::detectDriverAndVersion()
void CompositingPrefs::applyDriverSpecificOptions()
{
if( mDriver == "intel")
if( mXgl )
{
kDebug() << "xgl, enabling";
mEnableCompositing = true;
mStrictBinding = false;
}
else if( mDriver == "intel")
{
kDebug() << "intel driver, disabling vsync, enabling direct";
mEnableVSync = false;
@ -205,6 +216,7 @@ void CompositingPrefs::applyDriverSpecificOptions()
{
kDebug() << "nvidia driver, disabling vsync";
mEnableVSync = false;
mStrictBinding = false;
if( mVersion >= Version( "96.39" ))
{
kDebug() << "nvidia >= 96.39, enabling compositing";
@ -214,6 +226,11 @@ void CompositingPrefs::applyDriverSpecificOptions()
}
bool CompositingPrefs::detectXgl()
{ // Xgl apparently uses only this specific X version
return VendorRelease(display()) == 70000001;
}
CompositingPrefs::Version::Version( const QString& str ) :
QStringList()
{

View file

@ -44,17 +44,20 @@ public:
bool enableCompositing() const { return mEnableCompositing; }
bool enableVSync() const { return mEnableVSync; }
bool enableDirectRendering() const { return mEnableDirectRendering; }
bool strictBinding() const { return mStrictBinding; }
void detect();
QString driver() const { return mDriver; }
Version version() const { return mVersion; }
bool xgl() const { return mXgl; }
protected:
void detectDriverAndVersion();
void applyDriverSpecificOptions();
static bool detectXgl();
bool createGLXContext();
void deleteGLXContext();
@ -66,10 +69,12 @@ private:
QString mGLVersion;
QString mDriver;
Version mVersion;
bool mXgl;
bool mEnableCompositing;
bool mEnableVSync;
bool mEnableDirectRendering;
bool mStrictBinding;
#ifdef HAVE_OPENGL
GLXContext mGLContext;

View file

@ -180,7 +180,6 @@ unsigned long Options::updateSettings()
config.changeGroup("Translucency");
refreshRate = config.readEntry( "RefreshRate", 0 );
glStrictBinding = config.readEntry( "GLStrictBinding", false );
const HiddenPreviews hps[] = { HiddenPreviewsNever, HiddenPreviewsKeep, HiddenPreviewUpdate, HiddenPreviewsActive };
hiddenPreviews = hps[ qBound( 0, config.readEntry( "HiddenPreviews", 3 ), 3 ) ];
@ -231,6 +230,7 @@ void Options::reloadCompositingSettings(const CompositingPrefs& prefs)
glDirect = config.readEntry("GLDirect", prefs.enableDirectRendering() );
glVSync = config.readEntry("GLVSync", prefs.enableVSync() );
smoothScale = qBound( -1, config.readEntry( "GLTextureFilter", -1 ), 2 );
glStrictBinding = config.readEntry( "GLStrictBinding", prefs.strictBinding());
xrenderSmoothScale = config.readEntry("XRenderSmoothScale", false );
}