Bug 99604

Summary: kwin_x11 disabling compositing with mesa 17
Product: Mesa Reporter: Fabio Coatti <fabio.coatti>
Component: Drivers/DRI/i965Assignee: Intel 3D Bugs Mailing List <intel-3d-bugs>
Status: RESOLVED NOTOURBUG QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: kugel, lemody
Version: 17.0   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Fabio Coatti 2017-01-30 20:21:45 UTC
I gave a try to mesa 17.0.0_rc2 and Kwin (kde plasma 5.8.5) deactivated compositing with this message:

kwin_core: Failed to initialize compositing, compositing disabled
kwin_core: ShaderManager self test failed

Installing back mesa 13.0.3 the error disappeared and compositing worked again.

System: gentoo linux 
Intel KMS (no Xorg intel driver)
Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) (i5-3427U)
compiler:
gcc (Gentoo 5.4.0-r2 p1.2, pie-0.6.5) 5.4.0
plasma 5.8.5
kernel 4.9.6

I'm not sure if the issue is on mesa or kwin side, however it disappeared by downgrading mesa.

If more info is needed just let me know.
Comment 1 Fabio Coatti 2017-02-22 13:16:18 UTC
same issue with mesa 17.0.0
Comment 2 Emil Velikov 2017-02-22 14:52:25 UTC
Afaict i5-3427U is a Ivy Bridge - the i965 driver.

Fabio can you track down what's kwin is doing just before things fail (the error message is printed) ?
Comment 3 Fabio Coatti 2017-02-22 14:58:51 UTC
Yep, you are right, mesa is compiled with i965. Let me try to find out some more debug info, I'll post it here.
Comment 4 Fabio Coatti 2017-02-22 15:58:02 UTC
I've been able to get some debug info, so I have new messages:
libkwinglutils: Failed to compile vertex shader: 
"0:2(1): preprocessor error: #version must appear on the first line\n\x00"
libkwinglutils: Failed to link shader: 
"error: no shaders attached to the program\n\x00"
kwin_core: OpenGL 2 compositing setup failed
kwin_core: Failed to initialize compositing, compositing disabled
Comment 5 Kenneth Graunke 2017-02-22 19:23:00 UTC
This makes no sense to me.  The requirement for #version being at the top has existed for years.  We changed our handling of #version slightly, but it should not have affected this.

It could be that KWin changed their shaders...but that also seems unlikely.  It's a pretty catastrophic failure, and I've been using KWin every day and I've never hit this issue.  Admittedly, I usually use OpenGL 3.1 mode, not GL 2.0 (in settings -> display -> compositor).  I just tried both with KWin 5.9.2 and they both seem to work fine.  Maybe we have different plugins/effects enabled?

If your Mesa is built with debugging symbols, you can obtain the broken shader by doing:
<ssh in - don't do this from X>
$ DISPLAY=:0 gdb --args kwin_x11 --replace
(gdb) break glcpp_error
(gdb) run
Breakpoint 1, glcpp_error (locp=0x7fffffffc228, parser=0x77cc40,
(gdb) up
#1  0x00007ffff10e1251 in glcpp_parser_parse (parser=0x77cc40)
(gdb) up
#2  0x00007ffff1220036 in glcpp_preprocess (ralloc_ctx=0x77af90, 
(gdb) printf "%s", *shader
Comment 6 Fabio Coatti 2017-02-22 19:40:33 UTC
According to the configuration, kde is using OpenGL 3.1

If I switch to mesa 13.X, with the same kwin binary the issue does not arises.

I'm compiling mesa with debug, I'll report back in a short while.
Comment 7 Fabio Coatti 2017-02-22 20:41:10 UTC
I'm probably doing something wrong, as I'm getting an error from gdb (both kwin and mesa are compiled with debug enabled:
CFLAGS= "-ggdb -02 -pipe" 
CXXFLAGS="${CFLAGS}"


cova@calvin ~ $ DISPLAY=:0 gdb --args kwin_x11 --replace
GNU gdb (Gentoo 7.12.1 vanilla) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from kwin_x11...Reading symbols from /usr/lib64/debug//usr/bin/kwin_x11.debug...done.
done.
(gdb) break glcpp_error
Function "glcpp_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (glcpp_error) pending.
(gdb) run
Starting program: /usr/bin/kwin_x11 --replace
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[New LWP 19183]
[New LWP 19184]
Comment 8 Fabio Coatti 2017-02-28 07:53:35 UTC
(same info reported on kde bug tracker, bug https://bugs.kde.org/show_bug.cgi?id=376801, ut maybe this can be useful so I'm posting also here, forgive me if you consider this a duplicate.

Kwin complains due to different results from this call across mesa versions:

glReadnPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 4, data);

that appears in kwinglutils.cpp, line 594 or so:


static bool checkPixel(int x, int y, const QVector4D &expected, const char *file, int line)                                                                                                     
{                                                                                                                                                                                               
    uint8_t data[4];                                                                                                                                                                            
    glReadnPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, 4, data);                                                                                                                              
                                                                                                                                                                                                
    const QVector4D pixel{data[0] / 255.f, data[1] / 255.f, data[2] / 255.f, data[3] / 255.f};                                                                                                  
                                                                                                                                                                                                
    if (fuzzyCompare(pixel, expected))                                                                                                                                                          
        return true;                                                                                                                                                                            
                                                                                                                                                                                                
    QMessageLogger(file, line, nullptr).warning() << "Pixel was" << pixel << "expected" << expected;                                                                                            
    return false;                                                                                                                                                                               
}     

With mesa17, I get this:

(never mind the numbers after pixel2, it is my addition to the code for no real purpose :) )

feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(1, 0, 0, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 0, 1, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(1, 1, 1, 1) pixel2 QVector4D(0, 0, 0, 192)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0.760784, 0, 0, 0) expected QVector4D(0.44882, 0.14882, 0.14882, 1) pixel2 QVector4D(194, 0, 0, 0)                                  
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0.760784, 0, 0, 0) expected QVector4D(0.50064, 0.80064, 0.50064, 1) pixel2 QVector4D(194, 0, 0, 0)                                  
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0.760784, 0, 0, 0) expected QVector4D(0.05054, 0.05054, 0.35054, 1) pixel2 QVector4D(194, 0, 0, 0)                                  
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0.760784, 0, 0, 0) expected QVector4D(1, 1, 1, 1) pixel2 QVector4D(194, 0, 0, 0)                                                    
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0.3, 0, 0, 0.6) pixel2 QVector4D(0, 0, 0, 192)                                                
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 0.4, 0, 0.6) pixel2 QVector4D(0, 0, 0, 192)                                                
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0, 0, 0.5, 0.6) pixel2 QVector4D(0, 0, 0, 192)                                                
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0.3, 0.4, 0.5, 0.6) pixel2 QVector4D(0, 0, 0, 192)                                            
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0.134646, 0.044646, 0.044646, 0.6) pixel2 QVector4D(0, 0, 0, 192)                             
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0.200256, 0.320256, 0.200256, 0.6) pixel2 QVector4D(0, 0, 0, 192)                             
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0.02527, 0.02527, 0.17527, 0.6) pixel2 QVector4D(0, 0, 0, 192)                                
feb 27 23:22:14 calvin kwin_x11[19991]: Pixel was QVector4D(0, 0, 0, 0.752941) expected QVector4D(0.360172, 0.390172, 0.420172, 0.6) pixel2 QVector4D(0, 0, 0, 192)                             
feb 27 23:22:14 calvin kwin_x11[19991]: kwin_core: ShaderManager self test failed                                                                                                               
feb 27 23:22:14 calvin kwin_x11[19991]: kwin_core: Failed to initialize compositing, compositing disabled   


While with mesa13 i get the following:

feb 28 08:27:59 calvin kwin_x11[2713]: kwin_core: Initializing OpenGL compositing                                                                                                               
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 1, 0, 1) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 255, 0, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 1, 0, 1) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 255, 0, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 1, 0, 1) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 255, 0, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 1, 0, 1) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 255, 0, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(1, 0, 0, 1) expected QVector4D(1, 0, 0, 1) pixel2 QVector4D(255, 0, 0, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 1, 0, 1) expected QVector4D(0, 1, 0, 1) pixel2 QVector4D(0, 255, 0, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 0, 1, 1) expected QVector4D(0, 0, 1, 1) pixel2 QVector4D(0, 0, 255, 255)                                                          
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(1, 1, 1, 1) expected QVector4D(1, 1, 1, 1) pixel2 QVector4D(255, 255, 255, 255)                                                      
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.447059, 0.14902, 0.14902, 1) expected QVector4D(0.44882, 0.14882, 0.14882, 1) pixel2 QVector4D(114, 38, 38, 255)                   
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.501961, 0.8, 0.501961, 1) expected QVector4D(0.50064, 0.80064, 0.50064, 1) pixel2 QVector4D(128, 204, 128, 255)                    
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.0509804, 0.0509804, 0.34902, 1) expected QVector4D(0.05054, 0.05054, 0.35054, 1) pixel2 QVector4D(13, 13, 89, 255)                 
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(1, 1, 1, 1) expected QVector4D(1, 1, 1, 1) pixel2 QVector4D(255, 255, 255, 255)                                                      
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.298039, 0, 0, 0.6) expected QVector4D(0.3, 0, 0, 0.6) pixel2 QVector4D(76, 0, 0, 153)                                              
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 0.4, 0, 0.6) expected QVector4D(0, 0.4, 0, 0.6) pixel2 QVector4D(0, 102, 0, 153)                                                  
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0, 0, 0.501961, 0.6) expected QVector4D(0, 0, 0.5, 0.6) pixel2 QVector4D(0, 0, 128, 153)                                             
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.298039, 0.4, 0.501961, 0.6) expected QVector4D(0.3, 0.4, 0.5, 0.6) pixel2 QVector4D(76, 102, 128, 153)                             
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.133333, 0.0431373, 0.0431373, 0.6) expected QVector4D(0.134646, 0.044646, 0.044646, 0.6) pixel2 QVector4D(34, 11, 11, 153)         
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.2, 0.321569, 0.2, 0.6) expected QVector4D(0.200256, 0.320256, 0.200256, 0.6) pixel2 QVector4D(51, 82, 51, 153)                     
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.0235294, 0.0235294, 0.176471, 0.6) expected QVector4D(0.02527, 0.02527, 0.17527, 0.6) pixel2 QVector4D(6, 6, 45, 153)              
feb 28 08:27:59 calvin kwin_x11[2713]: Pixel was QVector4D(0.360784, 0.388235, 0.419608, 0.6) expected QVector4D(0.360172, 0.390172, 0.420172, 0.6) pixel2 QVector4D(92, 99, 107, 153) 


So maybe something causes the two versions (13 and 17) to give different results to the same api call.

HTH.
Comment 9 Thomas Martitz 2017-03-12 21:06:58 UTC
I can confirm this issue. kwin stopped enabling compisiting after updating Arch Linux mesa packages to 17.0.1-2.

System: Arch Linux 64bit
Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
Mesa 17.0.1-2
KDE Plasma 5.9.3-1
Kernel 4.10.1-1-ARCH
Comment 10 Tapani Pälli 2018-01-16 06:02:35 UTC
Ping, is this one still happening? I haven't seen this myself when using KDE (and debugging other bugs).
Comment 11 Tapani Pälli 2018-01-29 12:34:34 UTC
As described in the bug mentioned by comment #8, this happened due to shader test giving false positives and plasma thus disabling compositing. This has been fixed in kwin compositor. Resolving as NOTOURBUG.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.