Make some aspects affecting performance configurable in kwinrc,

group [Translucency]:
GLMode=TFP|SHM|Fallback - select rendering mode
GLAlwaysRebind=<bool> - force rebinding a texture
GLDirect=<bool> - direct rendering
CCMAIL: kwin@kde.org


svn path=/branches/work/kwin_composite/; revision=606268
This commit is contained in:
Luboš Luňák 2006-11-19 20:13:49 +00:00
parent 6e54bae328
commit b956650b2d
4 changed files with 56 additions and 24 deletions

View file

@ -174,9 +174,8 @@ unsigned long Options::updateSettings()
CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing"));
//translucency settings - TODO
config->setGroup( "Notification Messages" );
useTranslucency = config->readEntry("UseTranslucency", QVariant(false)).toBool();
config->setGroup( "Translucency");
useTranslucency = config->readEntry("UseTranslucency", QVariant(true)).toBool();
translucentActiveWindows = config->readEntry("TranslucentActiveWindows", QVariant(false)).toBool();
activeWindowOpacity = uint((config->readEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
translucentInactiveWindows = config->readEntry("TranslucentInactiveWindows", QVariant(false)).toBool();
@ -195,6 +194,16 @@ unsigned long Options::updateSettings()
removeShadowsOnResize = config->readEntry("RemoveShadowsOnResize", QVariant(true)).toBool();
onlyDecoTranslucent = config->readEntry("OnlyDecoTranslucent", QVariant(false)).toBool();
QString glmode = config->readEntry("GLMode", "TFP" ).upper();
if( glmode == "TFP" )
glMode = GLTFP;
else if( glmode == "SHM" )
glMode = GLSHM;
else
glMode = GLFallback;
glAlwaysRebind = config->readEntry("GLAlwaysRebind", false );
glDirect = config->readEntry("GLDirect", true );
// Read button tooltip animation effect from kdeglobals
// Since we want to allow users to enable window decoration tooltips
// and not kstyle tooltips and vise-versa, we don't read the

View file

@ -299,6 +299,11 @@ class Options : public KDecorationOptions
uint inactiveWindowShadowSize;
uint dockShadowSize;
bool onlyDecoTranslucent;
enum GLMode { GLTFP, GLSHM, GLFallback };
GLMode glMode;
bool glAlwaysRebind;
bool glDirect;
private:
WindowOperation OpTitlebarDblClick;

View file

@ -162,26 +162,7 @@ SceneOpenGL::SceneOpenGL( Workspace* ws )
if( !hasGLXVersion( 1, 3 ) && !hasGLExtension( "GLX_SGIX_fbconfig" ))
return;
strict_binding = false; // not needed now
// select mode - try TFP first, then SHM, otherwise fallback mode
shm_mode = false;
tfp_mode = ( glXBindTexImageEXT != NULL && glXReleaseTexImageEXT != NULL );
if( tfp_mode )
{
if( !findConfig( drawable_tfp_attrs, &fbcdrawable ))
{
tfp_mode = false;
if( !findConfig( drawable_attrs, &fbcdrawable ))
assert( false );
}
}
else
if( !findConfig( drawable_attrs, &fbcdrawable ))
assert( false );
if( !tfp_mode && initShm())
shm_mode = true;
// use copy buffer hack from glcompmgr (called COPY_BUFFER there) - nvidia drivers older than
// 1.0-9xxx don't update pixmaps properly, so do a copy first
copy_buffer_hack = !tfp_mode && !shm_mode; // TODO detect that it's nvidia < 1.0-9xxx driver
selectMode();
initBuffer(); // create destination buffer
int vis_buffer, vis_drawable;
glXGetFBConfigAttrib( display(), fbcbuffer, GLX_VISUAL_ID, &vis_buffer );
@ -243,6 +224,41 @@ SceneOpenGL::~SceneOpenGL()
checkGLError( "Cleanup" );
}
void SceneOpenGL::selectMode()
{
// select mode - try TFP first, then SHM, otherwise fallback mode
shm_mode = false;
tfp_mode = false;
if( options->glMode == Options::GLTFP )
{
if( initTfp())
tfp_mode = true;
else if( initShm())
shm_mode = true;
}
else if( options->glMode == Options::GLSHM )
{
if( initShm())
shm_mode = true;
else if( initTfp())
tfp_mode = true;
}
if( !tfp_mode && !findConfig( drawable_attrs, &fbcdrawable ))
assert( false );
// use copy buffer hack from glcompmgr (called COPY_BUFFER there) - nvidia drivers older than
// 1.0-9xxx don't update pixmaps properly, so do a copy first
copy_buffer_hack = !tfp_mode && !shm_mode; // TODO detect that it's nvidia < 1.0-9xxx driver
}
bool SceneOpenGL::initTfp()
{
if( glXBindTexImageEXT == NULL || glXReleaseTexImageEXT == NULL )
return false;
if( !findConfig( drawable_tfp_attrs, &fbcdrawable ))
return false;
return true;
}
bool SceneOpenGL::initShm()
{
int major, minor;
@ -291,7 +307,7 @@ void SceneOpenGL::cleanupShm()
void SceneOpenGL::initRenderingContext()
{
bool direct_rendering = true;
bool direct_rendering = options->glDirect;
KXErrorHandler errs;
ctxbuffer = glXCreateNewContext( display(), fbcbuffer, GLX_RGBA_TYPE, NULL,
direct_rendering ? GL_TRUE : GL_FALSE );
@ -535,7 +551,7 @@ void SceneOpenGL::Window::free()
void SceneOpenGL::Window::bindTexture()
{
if( texture != 0 && toplevel->damage().isEmpty()
&& !tfp_mode ) // TODO interestingly this makes tfp slower with some gfx cards
&& !options->glAlwaysRebind ) // interestingly with some gfx cards always rebinding is faster
{
// texture doesn't need updating, just bind it
glBindTexture( GL_TEXTURE_RECTANGLE_ARB, texture );

View file

@ -38,6 +38,8 @@ class SceneOpenGL
virtual void paintSimpleScreen( int mask, QRegion region );
virtual void paintBackground( QRegion region );
private:
void selectMode();
bool initTfp();
bool initShm();
void cleanupShm();
void initBuffer();