Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Zero-copy rendering with Qt FBO and dmabuf EGLImage – Shared context issue
Forum Updated to NodeBB v4.3 + New Features

Zero-copy rendering with Qt FBO and dmabuf EGLImage – Shared context issue

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 1 Posters 95 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SweerItTerS Offline
    SweerItTerS Offline
    SweerItTer
    wrote last edited by SweerItTer
    #1

    Posted on stackoverflow: How to achieve zero-copy rendering from Qt QPainter to dmabuf using shared EGL contexts?

    I am building a zero-copy rendering pipeline on RK3568 (Mali-G52, Qt 5.x with EGL backend).

    The idea is:

    • Import a dmabuf into an EGLImageKHR
    • Bind it to a GL texture
    • Render Qt UI (QOpenGLFramebufferObject) directly into this texture

    The problem:

    • To create an EGLImageKHR, I need a valid EGLDisplay.
    • Qt’s QOpenGLContext does not expose the underlying EGLDisplay.
    • In Qt5, QOpenGLContext::nativeHandle() always returns QVariant(null).
    • Even if I try setNativeHandle(), it only echoes back what I set — Qt still creates its own internal EGL context.

    Minimal test code:

    QOpenGLContext* ctx = new QOpenGLContext;
    ctx->create();
    
    qDebug() << ctx->nativeHandle(); // always null
    
    QVariant nativeHandle = QVariant::fromValue<void*>(eglGetCurrentContext());
    ctx->setNativeHandle(nativeHandle);
    
    qDebug() << ctx->nativeHandle(); // echoes back, but not really used
    

    This results in two isolated contexts:

    • Qt’s internal context (used by QPainter / QFBO rendering)
    • My native EGLContext (used to create EGLImageKHR from dmabuf)

    Since these are not shared, Qt cannot render directly into the dmabuf-backed texture. That breaks the zero-copy requirement, because the only fallback is copying with glBlitFramebuffer or PBOs.

    My question:
    Is there any supported way in Qt5 to:

    1. Make QOpenGLContext share resources with an existing native EGLContext, or
    2. Retrieve the actual EGLDisplay / EGLContext from Qt so that I can create the EGLImageKHR inside the same context?

    Goal: Render Qt FBO content directly into dmabuf (via EGLImage), without extra copies.

    1 Reply Last reply
    0
    • SweerItTerS Offline
      SweerItTerS Offline
      SweerItTer
      wrote last edited by
      #2

      makeQCurrent();
      eglDisplay_ = eglGetCurrentDisplay();
      eglCtx_ = eglGetCurrentContext();
      if (eglDisplay_ == EGL_NO_DISPLAY || eglCtx_ == EGL_NO_CONTEXT) {
      fprintf(stderr, "[Core] Cannot get native EGL resources form qt.\n");
      }
      doneQCurrent();
      ————————————————
      版权声明:本文为CSDN博主「SweerItTer」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
      原文链接:https://blog.csdn.net/qq_40087136/article/details/151912946

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved