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. Toggle VSync during runtime with QtQuick/QSG
QtWS25 Last Chance

Toggle VSync during runtime with QtQuick/QSG

Scheduled Pinned Locked Moved Unsolved General and Desktop
qsgrenderthreadquickscene graph
2 Posts 2 Posters 1.8k 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.
  • athairusA Offline
    athairusA Offline
    athairus
    wrote on last edited by
    #1

    From what I can tell, the use of VSync is implicitly defined by the value of the environment variable QSG_RENDER_LOOP. If (for example on Windows) it is set to windows, the default, it will use VSync. If set to basic, it'll run its own internal timer (qtdeclarative/src/scenegraph/qsgrenderloop.cpp:455). You can verify that it's not VSync'd by the tearing you'll observe while in fullscreen. Why it doesn't tear while windowed I'm not sure (I imagine the way the compositor works has something to do with it).

    Anyway, this environment variable is read during startup. It seems that once set, this is immutable for the lifetime of the QQuickWindow. I'd like something better than that. I'd like to be able to turn it on or off on demand, like virtually all modern PC games do. The way I see it, I have two approaches:

    • Use QQuickRenderControl
    • Extend the built-in render loops, somehow

    The first approach seems to be the most straightforward. An example exists that creates a custom threaded render loop. However, what gave me pause was this comment at the top of window_multithreaded.cpp:

    This is similar to the built-in threaded
    render loop, but does not support all the features.

    Then there's the second approach. All I really want to do is (what I hope) a minor tweak to the default threaded renderer. I don't want to sign up for patching/maintaining my custom threaded renderer to reach feature parity with the default one.

    The only change I think I need to do is not block on vblank and use a custom timer to control rendering, just like the basic loop does. Of course, I'll need some way to tell the render loop whether or not to use VSync.

    Only problem with this approach is it's looking like a rabbit hole. In order to override QSGRenderLoop::instance() with my own type of loop, I'll have to override QQuickWindowPrivate::init, and so on and so forth. Sounds like even more of a maintainability nightmare than the first approach.

    Which approach do you guys recommend?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I'd recommend posting this question to the interest mailing list. You'll find there Qt's developers/maintainers (this forum is more user oriented)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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