aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgthreadedrenderloop_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QtQuick: Fix conflicting definition of helper windowFor in CMake Unity ↵Friedemann Kleint2023-02-091-0/+2
| | | | | | | | | | | | | (Jumbo) builds Make them member functions. As a drive-by use range-based/std::as_const and use QList. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I2fb5632a076b6ccff1bd387bf95cc2ddedd4e0d9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Reset the bad-vsync counters on window resizeLaszlo Agocs2022-01-311-0/+1
| | | | | | | | | | | OpenGL implementations such as NVIDIA on Windows (but presumably others as well) break the presentation rate when resizing a window. D3D and Vulkan would stick closely to the normal rate. In any case, resetting the counters on a resize is a good idea because we do not really care about inconsistencies during a resize. Change-Id: I173daf8a7aefca3d24779102b9354c923478d424 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
* sg: Add logic in threaded loop to recognize the lack of proper vsyncLaszlo Agocs2022-01-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attempt to recognize that something is wrong with throttling and fall back to system timers (i.e. do the same what we would do if there were more than one windows, or when we knew that swap interval was set to 0 explicitly). This aims to eliminate the well-known visual problems (i.e. too fast advancing animations) when running with the default threaded render loops on systems where vsync-based throttling is disfunctional. A common example would be certain virtual machines. Traditionally the solution here has been to run with QSG_RENDER_LOOP=basic. This will, in many cases, not be necessary from now on. As with any of the existing system timer fallback logic, this does nothing for render thread animations (the animators, such as XAnimator and friends). Those work as before: if there is no vsync, they will advance too fast, no solution for that (apart from not using animators). Another slight downside is that animations may still appear running too fast for the first few frames because we average the results from a number of frames before deciding something is wrong with the window. [ChangeLog][QtQuick] The threaded render loop of Qt Quick can now potentially recognize that the graphics stack in a particular system is broken and does not provide vsync-based throttling. This can now automatically trigger falling back to using regular system timers to advance animations. (meaning one does not need to manually switch over to the 'basic' render loop or explicitly disable vsync on the window) Note however that this does not affect render thread animations (the so-called animators, such as XAnimator). Those will continue to advance based on the presentation rate no matter what. Fixes: QTBUG-99952 Change-Id: Ied7614c9149fa3cae32d8e0aab35f614bc86a3ac Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Output the thread and window in the render loop timing printsLaszlo Agocs2020-09-091-0/+2
| | | | | | | | Also fixes a plain bug in the basic render loop: using static to measure elapsed time is broken in a multi-window setup. Change-Id: Ie81fd9f4ec274f8ef095a8be7f280173f143de04 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Render loops: ignore update reqs during the main polish stepLaszlo Agocs2020-09-071-0/+1
| | | | | | | | | | | | The classic example is Shape, which needs to dirty the QQuickItem in updatePolish() in order to get it picked up in the synchronize step. That part is fine, but we do not want maybeUpdate() to issue a requestUpdate() then since we are effectively in progress of doing an update, so having another full round of polish/sync/render is a waste. Task-number: QTBUG-86089 Change-Id: Ie41563b34da17e7134631791ed024b31e87e21e3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Document internally the animation handling in the threaded loopLaszlo Agocs2020-09-071-1/+1
| | | | | | | | | | Also rename the incomprehensibly named maybePostPolishRequest(), because it is just a call to QWindow::requestUpdate() nowadays. postUpdateRequest() makes it clear what it is. Task-number: QTBUG-86089 Change-Id: I4c9ca1336c26d163772368067eda0f1ef84b9d97 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Make render loops OpenGL cleanLaszlo Agocs2020-06-081-3/+0
| | | | | | | Task-number: QTBUG-84718 Task-number: QTBUG-84623 Change-Id: I14392c365a52ecc410362500bbe29b4dd7953007 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Quick: Don't qualify OpenGL includesUlf Hermann2020-01-271-1/+1
| | | | | | | | | | | | | The headers are moving from QtGui to QtOpenGL. By avoiding the qualification we can keep them compiling either way. Also, add opengl-private to make the types available. Also removed the QGraphicsRotation hack to get access to the projected rotation function of QMatrix4x4. The function is public now. Task-number: QTBUG-74409 Change-Id: I216e8ca09f8e247f96627b081308e3a57c55c29c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add the graphics api independent scenegraph portLaszlo Agocs2019-07-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt in via environment variables: QSG_RHI=1 -> enable using QRhi instead of GL QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default (the default is d3d11 on Windows, metal on Mac, gl elsewhere) Or force a given rhi backend via the existing QQuickWindow::setSceneGraphBackend(). Otherwise the default behavior is the same as before, the rhi code path is never active by default. -no-opengl builds are supported in the sense that they work and default to the software backend. However, the rhi code path cannot currently be used in such builds, even though QRhi from qtbase is fully functional with Vulkan, D3D, or Metal even when qtbase was configured with -no-opengl. This cannot be utilized by Quick atm due to OpenGL usage being all over the place in the sources corresponding to the default backend, and those host the rhi code path as well. This will be cleaned up hopefully in Qt 6, with the removal all direct OpenGL usage. Other env.vars.: QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer (assuming the system is set up for this) QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too) QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both merged/unmerged, convert when needed - with some rhi backends this is implicit) QSG_RENDER_LOOP -> to override the render loop as usual. The default with RHI is threaded for Metal, threaded for Vulkan on Windows, basic for Vulkan on Linux and Android (to be checked later), while the existing rules apply for OpenGL. Not supported when running with QRhi: - particles - compressed atlases (though this is transparent to the apps) - QSGRenderNode - QQuickRenderControl - QQuickFramebufferObject - certain QQuickWindow functionality that depends directly on OpenGL - anisotropic filtering for textures - native text may lack some gamma correction - QSGEngine applicability unclear - some QML profiler logs may be incorrect or irrelevant Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix leaking scene graph rendering contextsSimon Hausmann2019-03-151-0/+3
| | | | | | | | | | | | | | | | When using the threaded render loop, the rendering thread assumes ownership of the rendering context. If the rendering thread is never started, that context is leaked. This happens in tests sometimes when we create and destroy a window without waiting for exposure. So this patch maintains the ownership in the render loop for created contexts until the per-window thread is started. Task-number: QTBUG-74348 Change-Id: Ifa397fab0833c82110ac4571c1e3790351c43afd Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* headers: Add missing override and remove redundant virtualAlexander Volkov2016-12-071-15/+15
| | | | | | Change-Id: Ifa816ebcd79372afca42dbd0dc0ecde006bb688a Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-061-0/+11
| | | | | | Task-number: QTBUG-48594 Change-Id: Ifc207938de7f0c8995fc712df92665f222612647 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* Added a new render job stage: NoStageMiikka Heikkinen2015-04-151-0/+1
| | | | | | | | | | | | | NoStage allows scheduling jobs for immediate execution on the renderer thread. [ChangeLog][QtQuick][QQuickWindow] Added a render job stage: NoStage Task-number: QTBUG-44953 Change-Id: I918c79f1d095bc27d911a88d81376d146a04313c Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com> Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
* Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-03-031-0/+1
|\ | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4numberobject.cpp Change-Id: I4e66a03ef4d99cec192c9da30c028fd8c1f4ac0d
| * Fix memory leak of QSGContext object in QSGThreadedRenderLoopjian liang2015-02-241-0/+1
| | | | | | | | | | | | | | Add destructor for QSGThreadedRenderLoop to destory QSGContext object. Change-Id: I479947eb35a5d7888d45655a9b8e2ece5e30bc33 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* | Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* | Use QWindow::requestUpdate in threaded renderloop.Gunnar Sletta2014-10-161-3/+2
|/ | | | | | | | | The default implementation is the same as what we do with the exhaust delay, but it is now possible for platforms to line it up with vsync so the GUI thread doesn't spend so much time being blocked. Change-Id: Ie126f00a1be978608bf2a1db33d80d7f0458590d Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Sync QQuickWindow::update() up with polishAndSync().Gunnar Sletta2014-09-171-0/+1
| | | | | | | | | | | | | | | When calling QQuickWindow::update() on the GUI thread, we would immediately flag the render thread that a repaint was needed and then schedule a polishAndSync. If the render thread completed the current frame before the GUI thread got to polishAndSync, it would repaint right away without syncing with GUI first. Instead of sending the repaint right away, register the need for a full repaint in the window and set it as part of the next sync phase. Change-Id: Ia731fb46724cc79f5391422213b069de9362d002 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-05-101-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/plugins/accessible/quick/quick.pro src/quick/items/qquickpincharea.cpp src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp src/quick/scenegraph/qsgthreadedrenderloop.cpp Manually adjusted for TestHTTPServer constructor change: tests/auto/quick/qquickimage/tst_qquickimage.cpp Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
| * Pass the actual window format to the offscreen surface during cleanupLaszlo Agocs2014-03-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the requested format (we don't have anything else since the platform window is gone) is wrong on EGL implementations that offer a different set of configurations for window and pbuffer surfaces, because we may end up with a pbuffer surface that is incompatible with the context/window due to having different color buffer sizes. To be absolutely sure that the surface is compatible, store the actual surface format so that it is available even after the platform window is gone. Change-Id: Id17c25439c463d4c37af95fc90f336d3f67c6427 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
| * Fix potential crash during shutdown for QQuickWindowsGunnar Sletta2014-03-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The cleanup() function would deregister the render loop from all windows the render loop had seen, but the render loop doesn't see windows until the window gets a showEvent and for some implementations it was removed as a result of hideEvent. So add explicit tracking to QSGRenderLoop which is managed by QQuickWindow's constructor and destructor. With this, we no longer need the lists from the subclasses, so these functions are removed again. Change-Id: I05e5507ad57e23c80bacd99752654cc7d0890dc1 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
| * Make sure QSGRenderLoop is cleaned up cleanly.Gunnar Sletta2014-03-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | e13547c595913c58e6bd6a5ed80fdc729fae7d47 used a global static to clean up QSGRenderLoop which is triggered very late, potentially after SG backend API plugins have been unloaded. This results in crashes when used in combination with scenegraph-playgrounds's customcontext. Partially revert the change and instead clean up at the time of QApp::aboutToQuit and make sure we also disconnect cleanly from all QQuickWindows. This change also ensures that QSGRenderLoop::windowDestroyed() gets called for all QQuickWindows registered with the render loop. This ensures that rendering stops and that scene graph nodes and resources will be cleaned up regardless of whether the application has remembered to delete the window or not. This is a good thing as it makes the scene graph shutdown a bit cleaner. Change-Id: I9cb9093979f8eac05542f118a6ff9cfe5c84f745 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* | Compress touch events in QQuickWindow.Gunnar Sletta2014-05-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of sending multiple touch updates per frame, we store the last one and flush the pending events just before we enter into the scene graph sync phase. [ChangeLog][QtQuick] QQuickWindow will compresses touch events and delivers at most one touch event per frame. Done-with: Robin Burchell <robin.burchell@jollamobile.com> Change-Id: Ia0169bc4a3f0da67709b91ca65c326934b55d372 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* | Try to simplify the threaded render loop.Gunnar Sletta2014-03-241-7/+7
|/ | | | | | | | | | | | | | | | | | | | This beast has grown and grown for some time so it was time to take step back and look at a few of the problems again. 1. show/hide vs exposed/obscured. There is really no reason why we should even bother with show. It only adds the window to a list, we can do that in handleExposure and simplify things a bit. 2. Expose, polish, repaint, sync stuff was growing increasingly complex with multiple waits and several events and states interacting. So I merged the expose into the sync and passed that information along to the render thread. The render thread now knows if the sync is for a normal state-sync or an expose. For a normal sync it will wake GUI right away. For an expose, it waits until after the renderpass has completed and the frame is swapped. Change-Id: I0b9e5135215662a43fb4ff2a51438e33c845c4a7 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Reset the expose cycle when polishAndSync aborts.Gunnar Sletta2014-03-051-1/+1
| | | | | | | | | | | | | | | On platforms with misbehaving expose behavior, we will get and exposure, even though the window is not renderable. This results in the renderthread being in the "wait for polish" state while the GUI thread goes back to "no state". Check for this and reset render thread's expose cycle when it is hit. Task-number: QTBUG-37201 Change-Id: I6a6c89d9016301ff19443f88a2c182012b4eb65f Reviewed-by: Ulf Hermann <ulf.hermann@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Revert 99480d5420c0beea6771be582c039b550a4461f5Gunnar Sletta2013-11-271-2/+0
| | | | | | | | | | | | | The Mac OS X platform plugin has been fixed so that this hack is no longer needed. Not to mention that it breaks on XCB. We keep the warning about bad exposes from the plugin in debug mode. These are still useful for tracking down future bugs. Task-number: QTBUG-35143 Change-Id: I5125f7ae2b7fd77c55e9a29b10aa5434598a9ea9 Reviewed-by: Ulf Hermann <ulf.hermann@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Be even more tolerant towards broken platform behavior.Gunnar Sletta2013-11-221-0/+2
| | | | | | | | | | When the platform (Mac in particular) sends us exposes for windows which are not renderable, we store it for later and fake expose events when we get resized. Task-number: QTCREATORBUG-10814 Change-Id: I909bb5a920550589322afd97ae1834884754cf81 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use one render loop per QQuickWindowGunnar Sletta2013-10-301-12/+16
| | | | | | | | | | | | | | | | | | | See the task for the full reasoning behind this patch. The threaded renderloop has been refactored to have one window per thread. This is mostly a simplification of the current code path where for loops over multiple windows are turned into if (window). The QSGContext has been split into two classes, QSGRenderContext for which there is one per OpenGLContext. The rest of the patch is name changes and a couple of cleanups in the hopes of simplifying this change. Task-number: QTBUG-33993 Change-Id: I31c81f9694d7da7474a72333169be38de62613c4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Fix license headers of QtQuick sources.Gunnar Sletta2013-09-301-1/+1
| | | | | Change-Id: I3750c47640bf21c3567c5fa1c4667e3e2552942e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Allow QtQuick private headers to be used with QT_NO_KEYWORDS.Jocelyn Turcotte2013-09-121-1/+1
| | | | | | | | | | | This is necessary for the QtWebEngine module. This also adds an empty nokeywords test using the same mechanism as qtbase/tests/auto/tools/moc/no-keywords.h to find conflicts at compile time. Change-Id: I9df541720797dd61f078178c2af68ead18ff8bfe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Set incubation controller when a Window{} is loaded via QQmlApplicationEngineAlan Alpert2013-06-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | This was the one convenience that was lost when transitioning templates from QQuickView + Item{} to QQmlApplicationEngine + Window{}. As the default window incubation controller was tied to the first window's frameSwapped, we could easily run into a situation where a secondary window required incubation while the first window was idle. This would then starve the incubation controller. Instead make it so that the renderloop emits "timeToIncubate" once it is done with a renderpass over all windows, so the incubator gets to run once and exactly once per vsync when animating. The incubator logic was also flawed in that it could post a lot of events to itself as a result of incubatingObjectCountChanged and thus starve system events while processing incubation requests. Now we start a timer and don't start it again until we have completed an incubation pass. Task-number: QTBUG-31203 Change-Id: Iea9e2c81efb46bb7875c70ccda0cdc4b3b3e58e7 Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Remove resize hook from QSGRenderLoop, exposureChanged is enough.Gunnar Sletta2013-04-041-2/+0
| | | | | | | | | After much back and forth, I think we have settled on the right approach in QtGui, which is that resizeEvent is pretty much useless as the action happens on the following exposeEvent(). Change-Id: I5e87bda89853907d041f56acf9a2895e540c41f0 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
* Improved animations in the new render loopGunnar Sletta2013-02-191-1/+4
| | | | | | | | | | | | | | | | | | | | To advance animations in line with vsync, we used a dedicated event from the rendering thread which we fired immediately after sync. This is a bit elaborate as we know in Gui when sync is complete and we can just animate there and then. This means we can remove all animation logic from the rendering thread, making it simpler. I also updated the syncAndRender pass so that it does not render anything if the scene graph reported no changes during the sync pass. This will prevent non-visual animations and property updates from triggering render passes which will save quite a few cycles. Change-Id: I62bb5484f0673f99abe726fca5a9b424f6b0a317 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-281-4/+0
| | | | | | | | | | | The macro was made empty in qtbase/ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Ia07e99676e0134fde5e32880edb95e57c779a7ff Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Alan Alpert <aalpert@rim.com>
* Complete rewrite of threaded render loop.Gunnar Sletta2013-01-181-0/+125
This change starts using the superior implementation of the scene graph render loop which has been worked on in the scenegraph-playground project for a while. It uses a far more straightforward locking/sync paradigm compared to the existing one and is less deadlock and error prone. It also enables the scene graph thread to run on its own when the GUI thread is blocked, enabling threaded animations. This changes also introduces a naming change inside Qt Quick from "Window Manager" -> "Render Loop" as that fits better to what the code does. Change-Id: I1c2170ee04fcbef79660bd7dae6cace647cdb276 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>