<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>315114</bug_id>
          
          <creation_ts>2013-02-14 07:58:47 +0000</creation_ts>
          <short_desc>KWin fails to initialize OpenGL ES on Mali-604T</short_desc>
          <delta_ts>2013-02-20 07:06:07 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>kwin</product>
          <component>scene-opengl</component>
          <version>4.10.0</version>
          <rep_platform>Gentoo Packages</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.10.1</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Vladimir">civil.over</reporter>
          <assigned_to name="KWin default assignee">kwin-bugs-null</assigned_to>
          
          
          <cf_commitlink>http://commits.kde.org/kde-workspace/df22c649eb92aa4af8bccf0431bdff7a7152e2bd</cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1341593</commentid>
    <comment_count>0</comment_count>
    <who name="Vladimir">civil.over</who>
    <bug_when>2013-02-14 07:58:47 +0000</bug_when>
    <thetext>kwin fails to initialize OpenGL ES backed with &quot;query surface failed&quot; error. Kwin 4.9.5 works fine.

Reproducible: Always

Steps to Reproduce:
1. Start KDE on Mali 604T
Actual Results:  
No working composite avaliable

Expected Results:  
Working composite.

Problem seems to be in this code:
    if (eglQuerySurface(dpy, surface, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &amp;surfaceHasSubPost) == EGL_FALSE) {
        kError(1212) &lt;&lt; &quot;query surface failed&quot;;
        return false;
    }

If you look in http://www.khronos.org/registry/egl/extensions/NV/EGL_NV_post_sub_buffer.txt, EGL_FALSE means that mali604 does not support eglPostSubBufferNV and eglSwapBuffers should be used instead. KWIN 4.9 ignores return code, but in 4.10 behavior changed and now it&apos;s fatal error, tough kwin seems to support eglSwapBuffers. If you comment out this check, everything works (but segfaults inside libGLES, but it&apos;s problem of vendor&apos;s libGL, not of kwin).

Changes was introduced in kde-workspace commit 4606e3b82d4f4a3f2478390e26cc135854841f8f.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341594</commentid>
    <comment_count>1</comment_count>
      <attachid>77277</attachid>
    <who name="Vladimir">civil.over</who>
    <bug_when>2013-02-14 08:00:15 +0000</bug_when>
    <thetext>Created attachment 77277
kwin-4.10.0-egl.patch

AFAIK if check for EGL_POST_SUB_BUFFER_SUPPORTED_NV fails, it shouldn&apos;t be fatal error, so this part of code should be reverted to it&apos;s state before commit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341596</commentid>
    <comment_count>2</comment_count>
      <attachid>77279</attachid>
    <who name="Vladimir">civil.over</who>
    <bug_when>2013-02-14 08:10:53 +0000</bug_when>
    <thetext>Created attachment 77279
kwin-4.10.0-egl.patch

Sorry, first patch was malformed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341598</commentid>
    <comment_count>3</comment_count>
    <who name="Martin Flöser">mgraesslin</who>
    <bug_when>2013-02-14 08:15:21 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; If you look in
&gt; http://www.khronos.org/registry/egl/extensions/NV/EGL_NV_post_sub_buffer.txt,
&gt; EGL_FALSE means that mali604 does not support eglPostSubBufferNV and
&gt; eglSwapBuffers should be used instead.
You missread this section. It states that you should add that paragraph to the spec on page 37. This page describes how the value passed to eglQuerySurface is updated. That means if it is not present value should be set to EGL_FALSE not the return value of this function.

For this most important is the last paragraph of chapter 3.5.6:

&quot;eqlQuerySurface returns EGL_FALSE on failure and value is not updated. If attribute is not a valid EGL surface attribute, then an EGL_BAD_ATTRIBUTE error is generated. If surface is not a valid EGLSurface then an EGL_BAD_SURFACE error is generated.&quot;

Now assuming the driver does not know about the extension (we are pre-context creation so we cannot check for extensions) it will return EGL_FALSE and set an EGL_BAD_ATTRIBUTE error. Given that it sets an error we would block the compositor anyway as we break on error (see eglonxbackend.cpp line 143).

The proper solution must therefore to check whether the call generated a EGL_BAD_ATTRIBUTE and then set surfaceHasSubPost to false and continue. In case of other error we still need to break.

That said: I&apos;m of course unable to test this as I&apos;m lacking hardware.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341602</commentid>
    <comment_count>4</comment_count>
      <attachid>77281</attachid>
    <who name="Martin Flöser">mgraesslin</who>
    <bug_when>2013-02-14 08:21:44 +0000</bug_when>
    <thetext>Created attachment 77281
Possible patch

Please try this patch whether it solves the problem. It includes the changes I described in the comment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341613</commentid>
    <comment_count>5</comment_count>
      <attachid>77285</attachid>
    <who name="Vladimir">civil.over</who>
    <bug_when>2013-02-14 09:12:00 +0000</bug_when>
    <thetext>Created attachment 77285
kwin-4.10.0-egl.patch

AFAIK patch is not correct.
1) surfaceHasSubPost is already set to 0 in constructor (line 32), so no need to explicitly set it to false
2) EGL_FALSE is 0, so why set it to EGL_FALSE? surfaceHasSubPost is used internally, to choose what function to use (eglSwapBuffer or eglPostSubBufferNV).
3) It&apos;ll be strange if eglQuerySurface returns EGL_FALSE, but eglGetError is EGL_SUCCESS. Is it possible at all?

I think it&apos;s better just to change if statmenet to check if eglGetError is not EGL_BAD_ATTRIBUTE.

So I&apos;ve attached patch that I suggest. With it, composition works for me. I can try yours too, but later today, if it&apos;s needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341623</commentid>
    <comment_count>6</comment_count>
    <who name="Martin Flöser">mgraesslin</who>
    <bug_when>2013-02-14 09:53:56 +0000</bug_when>
    <thetext>After working around driver bugs for 5 years I do not trust drivers any more. So I expect the worst. Reasoning behind the checks below.

(In reply to comment #5)
&gt; AFAIK patch is not correct.
&gt; 1) surfaceHasSubPost is already set to 0 in constructor (line 32), so no
&gt; need to explicitly set it to false
maybe the driver changed the value (even if it is not supposed to do so)? Doing the explicit setting does not hurt.
&gt; 3) It&apos;ll be strange if eglQuerySurface returns EGL_FALSE, but eglGetError is
&gt; EGL_SUCCESS. Is it possible at all?
According to the spec: there should be an error set. But maybe the driver did not set it?
&gt; So I&apos;ve attached patch that I suggest. With it, composition works for me. I
&gt; can try yours too, but later today, if it&apos;s needed.
Please give it a try. I prefer to have here a little bit more code and to assume the worst than to assume that it will work :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341869</commentid>
    <comment_count>7</comment_count>
    <who name="Vladimir">civil.over</who>
    <bug_when>2013-02-14 19:53:55 +0000</bug_when>
    <thetext>Yes, it works for me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1343579</commentid>
    <comment_count>8</comment_count>
    <who name="Martin Flöser">mgraesslin</who>
    <bug_when>2013-02-20 07:06:07 +0000</bug_when>
    <thetext>Git commit df22c649eb92aa4af8bccf0431bdff7a7152e2bd by Martin Gräßlin.
Committed on 20/02/2013 at 08:03.
Pushed by graesslin into branch &apos;KDE/4.10&apos;.

Do not abort EGL backend creation if EGL_NV_post_sub_buffer isn&apos;t supported

In case the extension is not present eglQuerySurface returns EGL_FALSE
when querying for EGL_POST_SUB_BUFFER_SUPPORTED_NV and sets an
EGL_BAD_ATTRIBUTE error state. If this is the case it&apos;s not an error we
should abort on, but one we should ignore as it&apos;s the same as extension
not supported.
FIXED: 4.10.1

M  +7    -2    kwin/eglonxbackend.cpp

http://commits.kde.org/kde-workspace/df22c649eb92aa4af8bccf0431bdff7a7152e2bd</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77277</attachid>
            <date>2013-02-14 08:00:15 +0000</date>
            <delta_ts>2013-02-14 08:10:53 +0000</delta_ts>
            <desc>kwin-4.10.0-egl.patch</desc>
            <filename>kwin-egl.patch</filename>
            <type>text/plain</type>
            <size>1070</size>
            <attacher name="Vladimir">civil.over</attacher>
            
              <data encoding="base64">LS0tIGtkZS13b3Jrc3BhY2UtNC4xMC4wL2t3aW4vZWdsb254YmFja2VuZC5jcHAub2xkCTIwMTMt
MDItMTQgMDE6NDQ6MTMuNDA3MTc4ODM2ICswNDAwCisrKyBrZGUtd29ya3NwYWNlLTQuMTAuMC9r
d2luL2VnbG9ueGJhY2tlbmQuY3BwCTIwMTMtMDItMTQgMDE6NTI6MzEuNzg2MTg3NTE1ICswNDAw
CkBAIC0xMTksNyArMTE5LDcgQEAKIAogICAgIGlmIChlZ2xRdWVyeVN1cmZhY2UoZHB5LCBzdXJm
YWNlLCBFR0xfUE9TVF9TVUJfQlVGRkVSX1NVUFBPUlRFRF9OViwgJnN1cmZhY2VIYXNTdWJQb3N0
KSA9PSBFR0xfRkFMU0UpIHsKICAgICAgICAga0Vycm9yKDEyMTIpIDw8ICJxdWVyeSBzdXJmYWNl
IGZhaWxlZCI7Ci0gICAgICAgIHJldHVybiBmYWxzZTsKKy8vICAgICAgICByZXR1cm4gZmFsc2U7
CiAgICAgfQogCiAgICAgY29uc3QgRUdMaW50IGNvbnRleHRfYXR0cmlic1tdID0gewotLS0ga2Rl
LXdvcmtzcGFjZS00LjEwLjAva3dpbi9lZ2xvbnhiYWNrZW5kLmNwcC5vbGQJMjAxMy0wMi0xNCAw
MTo0NDoxMy40MDcxNzg4MzYgKzA0MDAKKysrIGtkZS13b3Jrc3BhY2UtNC4xMC4wL2t3aW4vZWds
b254YmFja2VuZC5jcHAJMjAxMy0wMi0xNCAxMTo1Nzo0My40NTQ4MTk4NjIgKzA0MDAKQEAgLTEx
NywxMCArMTE3LDcgQEAKIAogICAgIGVnbFN1cmZhY2VBdHRyaWIoZHB5LCBzdXJmYWNlLCBFR0xf
U1dBUF9CRUhBVklPUiwgRUdMX0JVRkZFUl9QUkVTRVJWRUQpOwogCi0gICAgaWYgKGVnbFF1ZXJ5
U3VyZmFjZShkcHksIHN1cmZhY2UsIEVHTF9QT1NUX1NVQl9CVUZGRVJfU1VQUE9SVEVEX05WLCAm
c3VyZmFjZUhhc1N1YlBvc3QpID09IEVHTF9GQUxTRSkgewotICAgICAgICBrRXJyb3IoMTIxMikg
PDwgInF1ZXJ5IHN1cmZhY2UgZmFpbGVkIjsKLSAgICAgICAgcmV0dXJuIGZhbHNlOwotICAgIH0K
KyAgICBlZ2xRdWVyeVN1cmZhY2UoZHB5LCBzdXJmYWNlLCBFR0xfUE9TVF9TVUJfQlVGRkVSX1NV
UFBPUlRFRF9OViwgJnN1cmZhY2VIYXNTdWJQb3N0KQogCiAgICAgY29uc3QgRUdMaW50IGNvbnRl
eHRfYXR0cmlic1tdID0gewogI2lmZGVmIEtXSU5fSEFWRV9PUEVOR0xFUwo=
</data>

          </attachment>
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77279</attachid>
            <date>2013-02-14 08:10:53 +0000</date>
            <delta_ts>2013-02-14 09:12:00 +0000</delta_ts>
            <desc>kwin-4.10.0-egl.patch</desc>
            <filename>kwin-egl.patch</filename>
            <type>text/plain</type>
            <size>621</size>
            <attacher name="Vladimir">civil.over</attacher>
            
              <data encoding="base64">LS0tIGtkZS13b3Jrc3BhY2UtNC4xMC4wL2t3aW4vZWdsb254YmFja2VuZC5jcHAub2xkCTIwMTMt
MDItMTQgMDE6NDQ6MTMuNDA3MTc4ODM2ICswNDAwCisrKyBrZGUtd29ya3NwYWNlLTQuMTAuMC9r
d2luL2VnbG9ueGJhY2tlbmQuY3BwCTIwMTMtMDItMTQgMTE6NTc6NDMuNDU0ODE5ODYyICswNDAw
CkBAIC0xMTcsMTAgKzExNyw3IEBACiAKICAgICBlZ2xTdXJmYWNlQXR0cmliKGRweSwgc3VyZmFj
ZSwgRUdMX1NXQVBfQkVIQVZJT1IsIEVHTF9CVUZGRVJfUFJFU0VSVkVEKTsKIAotICAgIGlmIChl
Z2xRdWVyeVN1cmZhY2UoZHB5LCBzdXJmYWNlLCBFR0xfUE9TVF9TVUJfQlVGRkVSX1NVUFBPUlRF
RF9OViwgJnN1cmZhY2VIYXNTdWJQb3N0KSA9PSBFR0xfRkFMU0UpIHsKLSAgICAgICAga0Vycm9y
KDEyMTIpIDw8ICJxdWVyeSBzdXJmYWNlIGZhaWxlZCI7Ci0gICAgICAgIHJldHVybiBmYWxzZTsK
LSAgICB9CisgICAgZWdsUXVlcnlTdXJmYWNlKGRweSwgc3VyZmFjZSwgRUdMX1BPU1RfU1VCX0JV
RkZFUl9TVVBQT1JURURfTlYsICZzdXJmYWNlSGFzU3ViUG9zdCkKIAogICAgIGNvbnN0IEVHTGlu
dCBjb250ZXh0X2F0dHJpYnNbXSA9IHsKICNpZmRlZiBLV0lOX0hBVkVfT1BFTkdMRVMK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77281</attachid>
            <date>2013-02-14 08:21:44 +0000</date>
            <delta_ts>2013-02-14 08:21:44 +0000</delta_ts>
            <desc>Possible patch</desc>
            <filename>egl.diff</filename>
            <type>text/plain</type>
            <size>782</size>
            <attacher name="Martin Flöser">mgraesslin</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL2t3aW4vZWdsb254YmFja2VuZC5jcHAgYi9rd2luL2VnbG9ueGJhY2tlbmQu
Y3BwCmluZGV4IDAxZDk3YzAuLmRjYjcwZDggMTAwNjQ0Ci0tLSBhL2t3aW4vZWdsb254YmFja2Vu
ZC5jcHAKKysrIGIva3dpbi9lZ2xvbnhiYWNrZW5kLmNwcApAQCAtMTE4LDggKzExOCwxMyBAQCBi
b29sIEVnbE9uWEJhY2tlbmQ6OmluaXRSZW5kZXJpbmdDb250ZXh0KCkKICAgICBlZ2xTdXJmYWNl
QXR0cmliKGRweSwgc3VyZmFjZSwgRUdMX1NXQVBfQkVIQVZJT1IsIEVHTF9CVUZGRVJfUFJFU0VS
VkVEKTsKIAogICAgIGlmIChlZ2xRdWVyeVN1cmZhY2UoZHB5LCBzdXJmYWNlLCBFR0xfUE9TVF9T
VUJfQlVGRkVSX1NVUFBPUlRFRF9OViwgJnN1cmZhY2VIYXNTdWJQb3N0KSA9PSBFR0xfRkFMU0Up
IHsKLSAgICAgICAga0Vycm9yKDEyMTIpIDw8ICJxdWVyeSBzdXJmYWNlIGZhaWxlZCI7Ci0gICAg
ICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgRUdMaW50IGVycm9yID0gZWdsR2V0RXJyb3IoKTsK
KyAgICAgICAgaWYgKGVycm9yICE9IEVHTF9TVUNDRVNTICYmIGVycm9yICE9IEVHTF9CQURfQVRU
UklCVVRFKSB7CisgICAgICAgICAgICBrRXJyb3IoMTIxMikgPDwgInF1ZXJ5IHN1cmZhY2UgZmFp
bGVkIjsKKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAg
ICAgICAgIHN1cmZhY2VIYXNTdWJQb3N0ID0gRUdMX0ZBTFNFOworICAgICAgICB9CiAgICAgfQog
CiAgICAgY29uc3QgRUdMaW50IGNvbnRleHRfYXR0cmlic1tdID0gewo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>77285</attachid>
            <date>2013-02-14 09:12:00 +0000</date>
            <delta_ts>2013-02-14 09:12:00 +0000</delta_ts>
            <desc>kwin-4.10.0-egl.patch</desc>
            <filename>kwin-egl-v2.patch</filename>
            <type>text/plain</type>
            <size>613</size>
            <attacher name="Vladimir">civil.over</attacher>
            
              <data encoding="base64">LS0tIGtkZS13b3Jrc3BhY2UtNC4xMC4wL2t3aW4vZWdsb254YmFja2VuZC5jcHAub2xkCTIwMTMt
MDItMTQgMDE6NDQ6MTMuNDA3MTc4ODM2ICswNDAwCisrKyBrZGUtd29ya3NwYWNlLTQuMTAuMC9r
d2luL2VnbG9ueGJhY2tlbmQuY3BwCTIwMTMtMDItMTQgMTI6MjA6MDQuNjQ0ODQzMjE4ICswNDAw
CkBAIC0xMTcsNyArMTE3LDcgQEAKIAogICAgIGVnbFN1cmZhY2VBdHRyaWIoZHB5LCBzdXJmYWNl
LCBFR0xfU1dBUF9CRUhBVklPUiwgRUdMX0JVRkZFUl9QUkVTRVJWRUQpOwogCi0gICAgaWYgKGVn
bFF1ZXJ5U3VyZmFjZShkcHksIHN1cmZhY2UsIEVHTF9QT1NUX1NVQl9CVUZGRVJfU1VQUE9SVEVE
X05WLCAmc3VyZmFjZUhhc1N1YlBvc3QpID09IEVHTF9GQUxTRSkgeworICAgIGlmICgoZWdsUXVl
cnlTdXJmYWNlKGRweSwgc3VyZmFjZSwgRUdMX1BPU1RfU1VCX0JVRkZFUl9TVVBQT1JURURfTlYs
ICZzdXJmYWNlSGFzU3ViUG9zdCkgPT0gRUdMX0ZBTFNFKSAmJiAoZWdsR2V0RXJyb3IoKSAhPSBF
R0xfQkFEX0FUVFJJQlVURSkpIHsKICAgICAgICAga0Vycm9yKDEyMTIpIDw8ICJxdWVyeSBzdXJm
YWNlIGZhaWxlZCI7CiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>