Bug 120811 - OpenGL screensavers "back to front"
Summary: OpenGL screensavers "back to front"
Status: RESOLVED FIXED
Alias: None
Product: kscreensaver
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: OpenSUSE Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: kscreensaver bugs tracking
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-26 13:55 UTC by Nick Battle
Modified: 2008-05-19 17:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Output of glxinfo (9.95 KB, text/plain)
2006-11-22 18:09 UTC, A. Pfaller
Details
Output of xdpyinfo (21.11 KB, text/plain)
2006-11-22 18:10 UTC, A. Pfaller
Details
Output of xscreensaver-gl-helper (5 bytes, text/plain)
2006-11-22 18:11 UTC, A. Pfaller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Battle 2006-01-26 13:55:39 UTC
Version:            (using KDE KDE 3.5.0)
Installed from:    SuSE RPMs

I recently installed SuSE 10.0 on an HP nc6120 laptop. It has an i915GM display chipset, and the OpenGL screen savers and glxgears work at a decent fps.

But I noticed that OpenGL *3D* screensavers, where objects go behind other objects, sometimes display incorrectly - the objects behind "show through" the ones in front(!). On closer inspection, this ONLY happens with these savers if they are launched as KDE screen savers. Launching them as stand-alone applications or using xscreensaver never produces the effect. With KDE it happens maybe 50% of the time.

Other OpenGL games all work perfectly.

It appears to affect all 3D savers, but for example glxgears, queens, glpipes and stairs all show the effect. It is very noticable.

The effect is also visible in the small "preview" and "settings" windows when selecting the screen saver to choose under Configure Desktop, though again, only about half of the time.

3D acceleration is working, and glxinfo reports:
OpenGL vendor string: Tungsten Graphics, Inc
OpenGL renderer string: Mesa DRI Intel® 915GM 20041217 x86/MMX/SSE2
OpenGL version string: 1.3 Mesa 6.2.1
Comment 1 Nick Battle 2006-01-27 10:13:43 UTC
I don't know whether this is relevant, but in the Desktop Configuration display, if the problem is exhibited in the small demo window, it *isn't* exhibited in the setup window, and vice versa. It almost as though every other execution gives the effect, but it's not as simple as that with the main display screen saver - this seems to consistently show the effect, or not, for a whole KDE session.
Comment 2 Nick Battle 2006-02-01 09:58:32 UTC
I think I can see what's going wrong here. Kscreensaver isn't setting the right "visual" for OpenGL screen savers.

You can reproduce the effect by running an OpenGL X screen saver directly and passing the "Default" X visual rather than the "GL" visual, though it seems to have to run full screen (-root) to show the effect.

It looks like KDE doesn't pass the -visual argument to the screen savers (according to a ps -ef). There is a program called xscreensaver-gl-helper which returns the id of the OpenGL visual (0x25 on my machine), but I'm not clear whether that's something that the savers themselves call, or something that xscreensaver calls itself. The visual is recorded in $HOME/.xscreensaver, but it looks like KDE uses ~/.kde/share/config/<name>rc to hold settings for each saver, and "visual" isn't one of the options.

Can anyone confirm whether does explain the problem?
Comment 3 Rex Dieter 2006-02-01 12:20:18 UTC
What version of xscreensaver are you using?  I ask because xscreensaver <= 4.21 had bugs that kde triggered.
Comment 4 Nick Battle 2006-02-01 12:25:21 UTC
SuSE 10.0 has xscreensaver 4.22. That's from Novell's website. I haven't confirmed it on the machine, but it is a clean SuSE installation.
Comment 5 Nick Battle 2006-02-02 13:42:17 UTC
I had the following feedback on this from Brian Paul on the Mesa mail list (I thought it might be a bug in the Mesa libraries). Apparently this is a recognised phenomenon, to do with X visuals and Z Buffers:


"A visual, specifically a GLX visual, describes a framebuffer's or 
window's pixel format in terms of number of bits of 
red,green,blue,alpha, size of the depth(Z) buffer, stencil buffer etc.

For hidden surface removal you need a depth buffer.  If the visual 
doesn't have a depth buffer, 3D rendering will appear strange as you 
described.

The default visual, used by the root window, may or may not have a 
Z/depth buffer.  Often it doesn't in an effort to reduce memory usage.

The 'glxinfo' program lists the attributes for each visual.

This issue has been around for a long time, I'm sure google would turn 
up more background info.

-Brian"
Comment 6 Nick Battle 2006-06-23 14:10:38 UTC
Just to follow up on this, I recently installed SuSE 10.1, which has KDE 3.5.3, and the problem still exists.
Comment 7 Nick Battle 2006-06-23 14:13:10 UTC
Oops! SuSE 10.1 is KDE 3.5.1, my apologies. :-)
Comment 8 A. Pfaller 2006-11-22 17:53:40 UTC
For me SuSEs 10.1 kdebase3-3.5.1-69.32 rpm (current from official update tree)
works fine but kdebase3-3.5.5-89.2 (from SuSE factory tree for 10.1) shows
the same problem.

I compiled and installed (only) kcm_screensaver from the current 3.5 branch
in my current 3.5.5 installation (factory tree) and the problem remained.
If I install (again only) kcm_screensaver rev. r595222 everything works as expected.

The changelog for r595223:
------------------------------------------------------------------------
r595223 | lunakl | 2006-10-13 17:19:30 +0200 (Fri, 13 Oct 2006) | 5 lines
Changed paths:
   M /branches/KDE/3.5/kdebase/kcontrol/screensaver/kswidget.cpp
   M /branches/KDE/3.5/kdebase/kdesktop/lock/lockprocess.cc

GLX_DEPTH_SIZE = size of the depth buffer (Z buffer)
GLX_BUFFER_SIZE = size of the color buffer (color depth)
BUG: 73813
------------------------------------------------------------------------

In case it matters:
Athlon 64 X2 3800 (64-bit install), Nvidia GeForce 6600, 
Nvidia Drivers Version 8776
Comment 9 Lubos Lunak 2006-11-22 18:02:49 UTC
Please attach(!) output of glxinfo, xdpyinfo and xscreensaver-gl-helper.
Comment 10 A. Pfaller 2006-11-22 18:09:46 UTC
Created attachment 18654 [details]
Output of glxinfo
Comment 11 A. Pfaller 2006-11-22 18:10:27 UTC
Created attachment 18655 [details]
Output of xdpyinfo
Comment 12 A. Pfaller 2006-11-22 18:11:19 UTC
Created attachment 18656 [details]
Output of xscreensaver-gl-helper
Comment 13 Lubos Lunak 2006-11-27 18:56:55 UTC
SVN commit 608489 by lunakl:

Try to find a visual with as many OpenGL features as possible.
Some screensavers don't look quite right without a Z-buffer.
BUG: 120811



 M  +33 -7     kcontrol/screensaver/kswidget.cpp  
 M  +36 -10    kdesktop/lock/lockprocess.cc  


--- trunk/KDE/kdebase/workspace/kcontrol/screensaver/kswidget.cpp #608488:608489
@@ -19,14 +19,40 @@
     int flags = 0;
     if( true /*mOpenGLVisual*/ )
     {
-        int attribs[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_BUFFER_SIZE, x11Depth(), None };
-        if( XVisualInfo* i = glXChooseVisual( x11Display(), x11Screen(), attribs ))
+        static int attribs[][ 15 ] =
         {
-            visual = i->visual;
-            colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
-            attrs.colormap = colormap;
-            flags |= CWColormap;
-            XFree( i );
+        #define R GLX_RED_SIZE
+        #define G GLX_GREEN_SIZE
+        #define B GLX_BLUE_SIZE
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, None },
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, None }
+        #undef R
+        #undef G
+        #undef B
+        };
+        for( unsigned int i = 0;
+             i < sizeof( attribs ) / sizeof( attribs[ 0 ] );
+             ++i )
+        {
+            if( XVisualInfo* info = glXChooseVisual( x11Display(), x11Screen(), attribs[ i ] ))
+            {
+                visual = info->visual;
+                colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
+                attrs.colormap = colormap;
+                flags |= CWColormap;
+                XFree( info );
+                break;
+            }
         }
     }
     Window w = XCreateWindow( x11Display(), parentWidget() ? parentWidget()->winId() : RootWindow( x11Display(), x11Screen()),
--- trunk/KDE/kdebase/workspace/kdesktop/lock/lockprocess.cc #608488:608489
@@ -416,17 +416,43 @@
 #ifdef HAVE_GLXCHOOSEVISUAL
     if( mOpenGLVisual )
     {
-        int attribs[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_BUFFER_SIZE, x11Depth(), None };
-        if( XVisualInfo* i = glXChooseVisual( x11Display(), x11Screen(), attribs ))
+        static int attribs[][ 15 ] =
         {
-            visual = i->visual;
-            static Colormap colormap = 0;
-            if( colormap != 0 )
-                XFreeColormap( x11Display(), colormap );
-            colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
-            attrs.colormap = colormap;
-            flags |= CWColormap;
-            XFree( i );
+        #define R GLX_RED_SIZE
+        #define G GLX_GREEN_SIZE
+        #define B GLX_BLUE_SIZE
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_DOUBLEBUFFER, None },
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, R, 8, G, 8, B, 8, GLX_DEPTH_SIZE, 8, None },
+            { GLX_RGBA, R, 4, G, 4, B, 4, GLX_DEPTH_SIZE, 4, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_DOUBLEBUFFER, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, GLX_STENCIL_SIZE, 1, None },
+            { GLX_RGBA, GLX_DEPTH_SIZE, 8, None }
+        #undef R
+        #undef G
+        #undef B
+        };
+        for( unsigned int i = 0;
+             i < sizeof( attribs ) / sizeof( attribs[ 0 ] );
+             ++i )
+        {
+            if( XVisualInfo* info = glXChooseVisual( x11Display(), x11Screen(), attribs[ i ] ))
+            {
+                visual = info->visual;
+                static Colormap colormap = 0;
+                if( colormap != 0 )
+                    XFreeColormap( x11Display(), colormap );
+                colormap = XCreateColormap( x11Display(), RootWindow( x11Display(), x11Screen()), visual, AllocNone );
+                attrs.colormap = colormap;
+                flags |= CWColormap;
+                XFree( info );
+                break;
+            }
         }
     }
 #endif
Comment 14 Klaus Vink Slott 2007-04-15 16:08:09 UTC
This seems to be related: I (and others http://www.thisishull.net/showthread.php?t=234364) still see similar bugs in KDE 3.5.5 release 45.4 on OpenSUSE 10.2 

Is the above fix included in the current distributed version?