Bug 376801 - kwin disables compositing with mesa 17
Summary: kwin disables compositing with mesa 17
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (show other bugs)
Version: 5.9.3
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 381318 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-02-22 13:22 UTC by Fabio Coatti
Modified: 2017-07-05 14:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.10.4


Attachments
Debug info when running mesa 17 (5.94 KB, text/plain)
2017-07-05 04:53 UTC, Paul de Vrieze
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabio Coatti 2017-02-22 13:22:12 UTC
I just installed mesa 17 and I'm getting this message on kwin startup:

feb 22 14:07:24 calvin kwin_x11[2855]: kwin_core: ShaderManager self test failed
feb 22 14:07:24 calvin kwin_x11[2855]: kwin_core: Failed to initialize compositing, compositing disabled

kwin 5.9.2 / mesa 17.0.0 / xorg-server 1.19.1 /intel (KMS) /kernel 4.9.9 -> 4.10

Not sure it the issue is with mesa or kwin, opened a report also on mesa bugtracker:
https://bugs.freedesktop.org/show_bug.cgi?id=99604
Comment 1 Fabio Coatti 2017-02-22 13:22:50 UTC
forgot to say: mesa 13.X works fine
Comment 2 Martin Flöser 2017-02-22 15:49:39 UTC
if it worked before it indicates a regression mesa.
Comment 3 Fabio Coatti 2017-02-22 16:00:21 UTC
Likely; however I got this error message by setting KWIN_GL_DEBUG 1

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

I tried also to set 
QT_LOGGING_RULES "*.debug=true"

but I'm not sure that this change has been picked up, some suggestion on how to get more debug messages?
Comment 4 Martin Flöser 2017-02-22 21:05:13 UTC
> however I got this error message by setting KWIN_GL_DEBUG 1

unrelated, that's just a bug in the shader generator.
Comment 5 Martin Flöser 2017-02-22 21:08:10 UTC
> some suggestion on how to get more debug messages?

Unfortunately not. We have had the NVIDIA driver also break in the past for Quadro (only Quadro) cards in the self test and we didn't find any way to properly debug this.

A few ideas I have is to experiment with various settings. E.g. switch between OpenGL 2 and 3 in the compositor settings. Try using OpenGL ES. Switch between EGL and GLX. For the last things we only have env variables. https://community.kde.org/KWin/Environment_Variables
Comment 6 Fabio Coatti 2017-02-28 07:50:01 UTC
I've played around a little bit, and the reason that causes compositing to be switched off seems to be unexpected results from 
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)  

Maybe something has changed the behaviour of glReadnPixels across versions. Hoping to ease the process, I'll report the same data on mesa bug tracker.
Comment 7 Fabio Coatti 2017-03-05 08:06:37 UTC
the same behaviour is present in 5.9.3 Out of curiosity, I disabled the checks made by kwin (by returning a fake "True" result) and nothing blew up, now I'm running mesa 17 with kwin 5.9.3

This is not a really useful info to solve the issue, I guess, but at least could mean that the issue is not a major one :)
Comment 8 Martin Flöser 2017-03-05 15:47:03 UTC
It is useful. I'm going to just remove the self check. We have it 
failing on Nvidia and no on Mesa. In both cases is just the self check 
failing. Thus I assume we do something wrong during the setup. But a 
broken self check doesn't help us.
Comment 9 Christoph Feck 2017-06-28 02:17:42 UTC
*** Bug 381318 has been marked as a duplicate of this bug. ***
Comment 10 Martin Flöser 2017-06-28 16:08:51 UTC
I'm tempted to just disable the shader self test, but let's first try a little bit.

Can you please provide the output of:
qdbus org.kde.KWin /KWin supportInformation

when running the patched KWin?
Comment 11 Martin Flöser 2017-06-28 20:00:35 UTC
Phab request to disable shader self test on mesa 17: https://phabricator.kde.org/D6426
Comment 12 Fabio Coatti 2017-06-29 07:06:09 UTC
(In reply to Martin Flöser from comment #10)
> I'm tempted to just disable the shader self test, but let's first try a
> little bit.
> 
> Can you please provide the output of:
> qdbus org.kde.KWin /KWin supportInformation
> 
> when running the patched KWin?

Yes, sure; you mean the patch you sent on comment #11?
Comment 13 Krzysztof Nowicki 2017-06-29 12:39:24 UTC
*** Bug 372430 has been marked as a duplicate of this bug. ***
Comment 14 Martin Flöser 2017-06-29 16:13:48 UTC
> Yes, sure; you mean the patch you sent on comment #11?

Yes or with the one you already created.
Comment 15 Martin Flöser 2017-07-01 06:20:45 UTC
Git commit 43816119e9ec74df228b42163b087e51b7541884 by Martin Flöser.
Committed on 01/07/2017 at 06:19.
Pushed by graesslin into branch 'Plasma/5.10'.

Skip Shader self test for Mesa >= 17

Summary:
We are getting reports about the shader self test failing in a false
positive way on Mesa 17. We already have such false positve results
for NVIDIA quadro and went with disabling the self test.

Most likely our self test has a problem or the rendering of the first
frame has a problem. But disabling compositing because our rendering of
the first frame is broken, is too much.

Let's better be pro user here and disable the shader self test till we
fixed the root problem.
FIXED-IN: 5.10.4

Test Plan: It compiles.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6426

M  +4    -0    libkwineffects/kwinglutils.cpp

https://commits.kde.org/kwin/43816119e9ec74df228b42163b087e51b7541884
Comment 16 Paul de Vrieze 2017-07-05 04:53:28 UTC
Created attachment 106442 [details]
Debug info when running mesa 17

I've attached the support information. I made a before version as well, but the only differences are kwin version (5.10.2 instead of 5.10.3) and the mesa/opengl versions.
Comment 17 Martin Flöser 2017-07-05 14:53:15 UTC
@Paul: how come that you use OpenGL ES?
Comment 18 Paul de Vrieze 2017-07-05 14:59:50 UTC
@martin I am not sure about that configuration, but I believe that it was due to attempts to use wayland as well. I will try to have a look tomorrow, but it is one of those gentoo choice things. I hadn't realised that kwin was using es.