Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-110758

Qt6/wayland QNativeInterface doesn't succeed in wrapping existing EGL context

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.3.1
    • QPA: Wayland
    • None
    • Fedora 37, libdrm 2.4.112, libwayland-egl 1.21.0, mesa 22.2.3
      AMD 4700U integrated graphics
    • Linux/Wayland

    Description

      Originally discovered in Qt5 as part of https://bugreports.qt.io/browse/QTBUG-82528 however as the relevant interfaces have changed for Qt6, I am opening a new issue for that specifically.

      Crux is that this code (full reproducer attached) fails to create the native context

      QOpenGLContext *context = new QOpenGLContext();
      context->create();
      auto egl = context->nativeInterface<QNativeInterface::QEGLContext>();
      QOpenGLContext *native = egl->fromNative (egl->nativeContext(), egl->display());

      From a quick trip through the debugger, on my local system there seems to be a dynamic_cast that fails in this case inside the QNativeInterface::QEGLContext::fromNative() function.

      (gdb) disassemble
      Dump of assembler code for function _ZN16QNativeInterface11QEGLContext10fromNativeEPvS1_P14QOpenGLContext:
         0x00007ffff72fbc10 <+0>:	endbr64 
         0x00007ffff72fbc14 <+4>:	mov    0x1e5d45(%rip),%rax        # 0x7ffff74e1960
         0x00007ffff72fbc1b <+11>:	push   %r12
         0x00007ffff72fbc1d <+13>:	push   %rbp
         0x00007ffff72fbc1e <+14>:	push   %rbx
         0x00007ffff72fbc1f <+15>:	mov    %rdi,%rbx
         0x00007ffff72fbc22 <+18>:	mov    (%rax),%rdi
         0x00007ffff72fbc25 <+21>:	test   %rdi,%rdi
         0x00007ffff72fbc28 <+24>:	je     0x7ffff72fbc70 <_ZN16QNativeInterface11QEGLContext10fromNativeEPvS1_P14QOpenGLContext+96>
         0x00007ffff72fbc2a <+26>:	mov    %rsi,%rbp
         0x00007ffff72fbc2d <+29>:	mov    %rdx,%r12
         0x00007ffff72fbc30 <+32>:	mov    0x1e5831(%rip),%rsi        # 0x7ffff74e1468
         0x00007ffff72fbc37 <+39>:	mov    0x1e6032(%rip),%rdx        # 0x7ffff74e1c70
         0x00007ffff72fbc3e <+46>:	mov    $0xfffffffffffffffe,%rcx
         0x00007ffff72fbc45 <+53>:	call   0x7ffff6d4b0d0 <__dynamic_cast@plt>
         0x00007ffff72fbc4a <+58>:	mov    %rax,%rdi
         0x00007ffff72fbc4d <+61>:	test   %rax,%rax
      => 0x00007ffff72fbc50 <+64>:	je     0x7ffff72fbc70 <_ZN16QNativeInterface11QEGLContext10fromNativeEPvS1_P14QOpenGLContext+96>
         0x00007ffff72fbc52 <+66>:	mov    (%rax),%rax
         0x00007ffff72fbc55 <+69>:	mov    %r12,%rcx
         0x00007ffff72fbc58 <+72>:	mov    %rbp,%rdx
         0x00007ffff72fbc5b <+75>:	mov    %rbx,%rsi
         0x00007ffff72fbc5e <+78>:	pop    %rbx
         0x00007ffff72fbc5f <+79>:	pop    %rbp
         0x00007ffff72fbc60 <+80>:	mov    0x10(%rax),%rax
         0x00007ffff72fbc64 <+84>:	pop    %r12
         0x00007ffff72fbc66 <+86>:	jmp    *%rax
         0x00007ffff72fbc68 <+88>:	nopl   0x0(%rax,%rax,1)
         0x00007ffff72fbc70 <+96>:	pop    %rbx
         0x00007ffff72fbc71 <+97>:	xor    %eax,%eax
         0x00007ffff72fbc73 <+99>:	pop    %rbp
         0x00007ffff72fbc74 <+100>:	pop    %r12
         0x00007ffff72fbc76 <+102>:	ret    
      End of assembler dump.
      (gdb) info registers 
      rax            0x0                 0
      rbx            0x5bbe80            6012544
      rcx            0x435e50            4415056
      rdx            0x0                 0
      rsi            0x7fffffffd650      140737488344656
      rdi            0x0                 0
      rbp            0x5771f0            0x5771f0
      rsp            0x7fffffffd6a0      0x7fffffffd6a0
      r8             0x435e50            4415056
      r9             0x7ffff74cb7d8      140737342388184
      r10            0x3c                60
      r11            0x7ffff72fbc10      140737340488720
      r12            0x0                 0
      r13            0x1                 1
      r14            0x403db0            4210096
      r15            0x7ffff7ffd000      140737354125312
      rip            0x7ffff72fbc50      0x7ffff72fbc50 <QNativeInterface::QEGLContext::fromNative(void*, void*, QOpenGLContext*)+64>
      eflags         0x246               [ PF ZF IF ]
      cs             0x33                51
      ss             0x2b                43
      ds             0x0                 0
      es             0x0                 0
      fs             0x0                 0
      gs             0x0                 0
      (gdb) ni
      0x00007ffff72fbc70 in QNativeInterface::QEGLContext::fromNative (context=0x5bbe80, display=<optimized out>, shareContext=<optimized out>) at /usr/src/debug/qt6-qtbase-6.3.1-4.fc37.x86_64/src/gui/platform/unix/qunixnativeinterface.cpp:167
      167	}
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            ystreet00 Matthew Waters
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes