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. What thread rules for Scene Graph with OpenGL?
Forum Updated to NodeBB v4.3 + New Features

What thread rules for Scene Graph with OpenGL?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 990 Views 1 Watching
  • 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.
  • W Offline
    W Offline
    wspilot
    wrote on 4 Feb 2014, 15:00 last edited by
    #1

    Hi,
    I am trying to find out how threads works in the graphics scene .
    Using the "Scene Graph - OpenGL Under QML":http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html example.
    It's a QQuickItem with OpenGL within its paint function.
    Reading the "Qt Quick Scene Graph":http://qt-project.org/doc/qt-5.0/qtquick/qtquick-visualcanvas-scenegraph.html , it says that the rendering is done in a separate thread.
    So, I have monitored the threads during execution:
    [D] Ogl::handleWindowChanged:30 : 0x6c835740
    [D] Ogl::handleWindowChanged:38 : 0x6c835740
    [D] Ogl::handleWindowChanged:40 : 0x6c835740
    [D] Ogl::handleWindowChanged:44 : 0x6c835740
    [D] Ogl::sync:118 - sync: 0x67fffb40
    So, starting from the 'sync' function in my (QQuickItem based) ogl object, all is executed in another thread.
    Is this change caused by (win = the QQuickView object):
    @connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection);@
    ?
    Forcing to run the sync slot in the new thread?
    More general: how do I know what is run in which thread?
    My final ogl object needs lots of data (from objects in the main/GUI thread) to be used during rendering...
    Thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agocs
      wrote on 5 Feb 2014, 11:34 last edited by
      #2

      beforeSynchronizing and beforeRendering are emitted on scenegraph's render thread. You are connected using DirectConnection and therefore sync() is called on that thread. This is how it should be, you cannot have the sync and painting function executed on your gui thread, they must be done on the render thread.

      Follow the pattern used in the example: in sync() copy the necessary data from the gui thread. In paint() perform drawing using the copy of the data.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wspilot
        wrote on 5 Feb 2014, 12:15 last edited by
        #3

        That is clear. Thanks a lot!
        Data is to much to copy (textures, 3D and more).
        I'll have a look how serialize: force the GUI thread to wait.

        1 Reply Last reply
        0

        1/3

        4 Feb 2014, 15:00

        • 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