Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding a QOpenGLWidget to a QWindow greatly impacts its performance

Adding a QOpenGLWidget to a QWindow greatly impacts its performance

Scheduled Pinned Locked Moved Unsolved General and Desktop
opengl5.12.7performance
3 Posts 2 Posters 1.7k 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.
  • M Offline
    M Offline
    Makutik
    wrote on 9 Mar 2020, 12:01 last edited by
    #1

    Hello everyone,

    I have an application that uses QGraphicsView and QGraphicsScene to display some fast changing jpeg images within a QGridLayout.
    Now, I have added a QOpenGLWidget to this layout. This alone (not even rendering something) was enough to drag down the performance of that window, i.e. operations like moving, resizing, or simple button presses are notably slower.
    This performance impact persists even when the QOpenGLWidget is deleted.

    This is probably related to the behavior described within the "alternatives" section of the QOpenGLWidget documentation, since I can use the described workaround to speed my application up again.

    Now, I am quite curious, what exactly causes these performance implications, especially due to it persisting after the widgets's deletion.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 9 Mar 2020, 12:14 last edited by Chris Kawa 3 Sept 2020, 12:15
      #2

      Hi and welcome.

      Normally widgets paint onto a pixmap and that pixmap is then painted to the window using double buffering. It happens on the CPU.
      Once you insert QOpenGLWidget the entire window is rendered using OpenGL and OpenGL scene is composited with the widgets pixmap. This means that every time you draw something in the widgets the pixmap needs to be uploaded to the GPU as a texture. This takes time and is what causes the slowdown. I suspect it stays slow after you delete the QOpenGLWidget because it doesn't get back to normal rendering, but I can only guess. I haven't looked at the internal code. When you use a separate OpenGL window in a container no CPU-GPU composition is done and that's why it should run faster. You will run into trouble when you try to overlay widgets on top of that OpenGL window though, because those are now separate surfaces. So it's a tradeoff - functionality or speed.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        Makutik
        wrote on 9 Mar 2020, 12:31 last edited by
        #3

        Thanks, so that is what "OpenGL-based composing" does under the hood!

        Is there any way to synchronize/batch my QGraphicsView updates, so that there is less of a performance impact?
        Or would it be preferable to switch the QGraphicsView-based widgets over to render their scene via OpenGL?

        1 Reply Last reply
        0

        1/3

        9 Mar 2020, 12:01

        • Login

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