aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles/qquickparticlesystem_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Do less work when there are no active ImageParticle particlesMichael Brasser2021-02-061-0/+2
| | | | | | | | | | | Don't mark geometry and material as dirty if there is nothing to change. Task-number: QTBUG-41867 Change-Id: I016d2d76f4ebf731f5bfc931ba616ee5d074bc65 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit e3cb305a6a19bf394c1068a7e483e1c95e11c22b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Optimize particles vertex dataKaj Grönholm2020-11-091-1/+1
| | | | | | | | | | | | | | | | | | Use uchar instead of float for vertex data that doesn't need float. Continue using floats in shaders. Also remove animY2, which is same as animY1. These changes reduce memory usage especially when the amount of particles increases. Testing on windows, memory reductions with emitters/trailemitter example were: - OpenGL: 82.7 MB -> 76.5 MB - Vulkan: 130.8 MB -> 126.3 MB - D3D11: 143.7 MB -> 135.8 MB Task-number: QTBUG-88124 Change-Id: I8f8dcb3845323b0e69fb99b5bff830cd0f151a47 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* Cleanup and optimize particlesKaj Grönholm2020-11-051-5/+9
| | | | | | | | | | | | | | | Minor improvements while going through the particles sources: - Reduce getShadowDatum() calls - Remove unused m_lastLevel, reloadColor(), m_available m_velocityFromMovement, maximumAlive, m_pending, m_lastT, m_last_last_last_emitter, modelIndex - Color4ub structs can be assigned directly - Fix pri for shaders_ng files - Other minor refactoring Task-number: QTBUG-88124 Change-Id: I5768fed9f4b6379a698849c23436fa38169833a4 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Replace old Q_DECL statements with modern C++Allan Sandfeld Jensen2020-10-311-1/+1
| | | | | | | Since we depend on C++17 now, all of these can go. Change-Id: I0484fd4bb99e4367ec211c29146c316453729959 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove CustomParticleEirik Aavitsland2020-06-021-5/+0
| | | | | | | | | The implementation is intertwined with the direct GL path and not really portable to RHI. Fixes: QTBUG-78574 Change-Id: I6ac8707544c19a24661f07e0e6d2fc405e49cbff Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Particles: reduce memory allocations by flattening a setGiuseppe D'Angelo2020-05-271-1/+2
| | | | | | | | | | | | | | | | | | | | When an affector acts on a particle, it will add it to a set of "seen" particles. This means an allocation, per particle, per frame. In Qt 6 the problem is less dramatic due to the new QHash implementation, which uses "wider" buckets, but in Qt 5 this is hundreds of memory allocations (and deallocations) per frame. Just reimplement a minimal flat-set API for this use case, and replace the QSet usages with it. On a testcase with 200 active particles, this reduces memory allocations from ~20'000 per second to 0 when the scene is "stable". Pick-to: 5.15 Change-Id: I4be1e12a23b8dffca91955148532db243e383a4c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Add major version to all Q_REVISIONsUlf Hermann2020-02-191-0/+1
| | | | | Change-Id: Id72fbe10c16de61bd847773d0055d83cfe03f63c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-12-091-0/+2
|\ | | | | | | | | | | | | Conflicts: src/qml/common/qv4compileddata_p.h Change-Id: I1150c8cd0161f0e22137d383013751394ae64e18
| * Particle system: fix infinite loop after running for many hoursYulong Bai2019-12-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The infinite loop was triggered by several issues coincide together. In short, the direct cause is the particle's born time and lifespan were represented in 32 bit floats and not precise enough to pass aliveness check as time grows large. While the time grows large, the resolution of floating point decreases to the extent that resolution is even bigger than 2 milliseconds. Then it will fail to pass the aliveness check. Then, the dead particles will be treated alive and they are kept inserting into and popping out of the particles heap, which is similar to a live-lock. The fix is to separate freeing dead and inserting back alive ones in two different loops, ensure that the emitter can update time for next frame. There are still other issues: 1) as the times runs very long, the particle needs several frames's updates to actually make the states change noticeable, which means animation may become not so smooth after running for too long (like several days). May change particle's born/lifespan time to 64 bits in another patch. 2) the particle system's and animation's timers are 32 bit integers, after 2^31 milliseconds(24.8551348 days), they will overflow. May promote them to 64 bits in another patch. 3) as the time grows even larger such that the resolution is bigger than 16ms at 60 hz frame rate, the live-lock may occur again. Because the timer advances/delta will be not large enough to make dead ones reused. The next live-lock estimated time is 2^24*16 milliseconds = 3.10689185 days. The final fixes are 1) and 2) 4) may change the particle system's internal timer be set to arbitrary value (fast forward to large value) for easier writing autotest for above cases. Change-Id: I1190c0814c8197876b26dd4182dc4b065dd1ece6 Task-number: QTBUG-64138 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
* | Specify parameters of type registration in class declarationsUlf Hermann2019-09-261-0/+1
|/ | | | | | | | | | | | | | | | | | | | | Using this technique we can automatically register all necessary revisions and minor versions of a type, using the metaobject system. This greatly reduces the potential for mistakes and resulting incompatibilities between versions of imports. We assume that for each type we need to register all revisions of its super types and its attached type, and that the revisions match. That is, if you import version X of type A, you will also get version X of its attached type and of any super types. As we previously didn't take these dependencies into account when manually registering the types, a number of extra revisions are now registered for some types. Potentially, we can now generate the qmltypes files at compile time, using moc. Change-Id: I7abb8a5c39f5e63ad1a0cb41a783f2c91909491b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-0/+1
| | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Eliminate qmldevtools_buildUlf Hermann2019-05-311-0/+1
| | | | | | | | Move the relevant files into more fitting locations and build the devtools from only parser, compiler and qmldirparser. Change-Id: Ibf37a1187f36d02983f9f43c6622acb243785b7b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove QQmlV4HandleUlf Hermann2019-04-101-2/+1
| | | | | | | | This is just an alias for QV4::ReturnedValue. We can as well use the latter. Change-Id: Ibd2c038a3ca726b39a8f0f05e02922adb9fccbdb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* init variables where they are declared when possible (clang-tidy)Shawn Rutledge2018-02-261-6/+3
| | | | | | | | clang-tidy -p compile_commands.json $file -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' -header-filter='qtdeclarative' -fix Change-Id: I705f3235ff129ba68b0d8dad54a083e29fcead5f Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-1/+1
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace usage of QSignalMapper by lambdaOlivier Goffart2017-02-141-4/+1
| | | | | | | | | | | | | | | | | QSignalMapper ought to be deprecated soon. It simplifies the code, too. There is still one use in QQuickGenericShaderEffect which is a bit complicated to get rid of. A very similar use of QSignalMapper was in use in QQuickOpenGLShaderEffectCommon but was removed in commit 8c745d80, the same should be done for QQuickGenericShaderEffect. (Note the QueuedConnection in qquickparticlesystem is there because the QSignalMapper used to be in the main thread, meaning a round-trip via the event loop) Change-Id: I331b787becbad37f717035bf119bafd7a7214630 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Particles: add missing 'override'Anton Kudryavtsev2016-10-101-3/+3
| | | | | | | ... and drop redundant 'virtual' Change-Id: Id70a0b74724d231bae9b3803fcfe0514adb9f642 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Particles: half the number of calls to emittersChanged.Erik Verbruggen2016-03-081-0/+1
| | | | | | | | | | | | | When a particle emitter is not yet complete, calling emittersChanged through both groupChanged and systemChanged is unnecessary. Only connect to those signals once after the component is complete, and then call emittersChanged. Also do not call emittersChanged when the particle system component is not complete yet. Change-Id: I67543ce80c9235bd5f72d95352ec96e97a1cf66b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: factor out t^2.Erik Verbruggen2016-03-081-12/+20
| | | | | | | | | | | | According to IEEE754 a * t * t is not the same as a * (t * t), hence the compiler won't lift t^2 out as common expression when in another place 'a' is replaced with 'b'. Now for the particles this doesn't matter as it doesn't need super high precision, nor should any of the calculations come in overflow territory. So by manually introducing t_sq(uare), the compiler can remove duplicate t^2 calculations after inlining. Change-Id: Ibfdb054e34945d7e78eb993fdcedfae886472e83 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: consistently use floats for particle data calculations.Erik Verbruggen2016-03-081-56/+56
| | | | | | | | This removes float<->double conversions, which makes the auto-vectorized code even smaller. Change-Id: Ic4319b11a3248e3034b65e7be047d99cba84716b Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: make many QQuickParticleData members inlinable.Erik Verbruggen2016-03-081-7/+104
| | | | | | | | | | Calls to these functions often occur in sets of two (x, y) or even more (x, y, vx, vy, etc). By allowing the compiler to inline, it allows for many CSE opportunities. Also, if your compiler is reasonably good, it will also auto-vectorize the operations. Change-Id: I4bffe4826671dd60683b941a569fc6a7b4b34da7 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: replace a QSet<int> with a bit vector for group data.Erik Verbruggen2016-03-081-1/+61
| | | | | | | | | | | | | | | | | | | | | | | | | The reusableIndexes represented a "free-list". Now the allocation behavior in QQuickParticleGroupData::setSize was to grow by (large) chunks. That means that as soon setSize was called, a (big) number of hash entries was created, which are drained over time. This memory would stay around (and probably unused) as long as the group was alive. By using a bit vector, the amount of memory is much more compressed, and finding an entry takes less time. The FreeList "caches" the next free entry, because allocation and de-allocation behavior is that they occur bunches: allocate a number of particles, use them, allocate the same number. Test case: samegame, 1 player, click 1 set of 3 stones, quit. QQuickParticleSystem::emittersChanged(), before patch: - 21 instr. inclusive, 15M in QQuickParticleGroupData::setSize - 23,000 calls to QHashData::allocateNode after: - 13M instr. inclusive, 7M in QQuickParticleGroupData::setSize - 0 calls to QHashData::allocateNode Change-Id: If35ea5ed9b29129f210638f6f59275a24eb6afdc Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: Shrink QQuickParticleData by 2 pointers.Erik Verbruggen2016-03-081-25/+25
| | | | | | | | Samegame creates about 23,000 particles, so this reduces the memory by ~180kb on 32bit, so ~360kb on 64bit. Change-Id: I0581524ab232b474c5d43abeabd7ebf6174e740f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: reduce excessive hash accesses to a more passable level.Erik Verbruggen2016-03-041-2/+30
| | | | | | | | | | | | | | | | | | By caching the group id in the particle emitter, and groups in the painter. Test case: samegame, 1 player, click 1 set of 3 stones, quit. QQuickParticleSystem::emittersChanged(), before patch: - 64M instr. inclusive - 145,880 calls to findNode (29M instr.) after: - 21M instr. inclusive - 0 calls to findNode - 25 calls to QQuickParticlePainter::recalculateGroupIds (9800 instr. inclusive). Change-Id: I4aba9d50100513c6b7cdd230e30b3aecaf84485a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Particles: inline 4 methods.Erik Verbruggen2016-03-041-1/+20
| | | | | | | | | | | And when in the area, remove 3 unused functions. Benchmark: start samegame, click '1 player', quit. Valgrind result: removes/inlines ~90,000 calls. Change-Id: If911b19b46bf163f7fe678623c068f960296f17e Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Particles: code clean-up.Erik Verbruggen2016-03-041-5/+10
| | | | | | | | | | | Replace QHash<int, QQuickParticleGroupData*> groupData with a QVarLengthArray, and make sure that those integers (== indices) are continuous, re-used, and start at zero. That way a whole bunch of qhash calls, hash node creatrion/deletion, and other overhead is removed. Change-Id: Ie74fab8a3e3c7b6efa15b7b9ceff1d1a3e9820e9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* 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>
* Private export the ParticleSystem and AffectorAriel Molina R2015-11-241-4/+5
| | | | | | | | | | | | | | | | There are several special cases where the particle system is very useful for generating more than just eye candy. An example is a recreation of world weather/wind conditions as seen in http://earth.nullschool.net/ this patch allows for the implementation of similar systems. This patch does not adds features, just adds the macro Q_QUICK_PRIVATE_EXPORT in order to link the classes and derive custom C++ affectors for Qt Quick usage. Task-number: QTBUG-41502 Change-Id: I809d74676b3be73221840c694d7ca3eebe553c02 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* 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>
* QQuickParticleData: Reorganise fields to drop size from 208 to 200 bytes on ↵Robin Burchell2015-02-121-3/+8
| | | | | | | x86_64. Change-Id: Ide7a70baecf6d1ff3ec8160a2cb47f0bd9955e45 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* 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>
* Fix leaks in QQuickImageParticleJocelyn Turcotte2014-10-271-0/+3
| | | | | | | | | | | | | | | | Make sure that ImageData instances, m_shadowData as well as the QSGGeometry of particle nodes are destroyed together with their QQuickImageParticle. Also implement the assignment operator for QQuickParticleData to avoid its v8Datum pointer to be copied over to the shadow datum in getShadowDatum. This would cause a double delete of the QQuickV4ParticleData when trying to call clearShadows() in the destructor. Task-number: QTBUG-36782 Change-Id: Ie03f2be0415daeb7f4f6e5f92295a3ab26a62155 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.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>
* Allow QtQuick private headers to be used with QT_NO_KEYWORDS.Jocelyn Turcotte2013-09-121-3/+3
| | | | | | | | | | | 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>
* Port ParticleData to V4Simon Hausmann2013-06-121-2/+2
| | | | | Change-Id: Ifc48b73a2fbfda22d3c4419cb34dd5307107f688 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove v8 dependencies from QQmlV4HandleLars Knoll2013-05-081-1/+1
| | | | | Change-Id: I87d2183738ec7cfeea846a28f2b9aed79a233f68 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rename QQmlV8Handle to QQmlV4HandleLars Knoll2013-04-191-2/+2
| | | | | | | | | The handle wraps a V4 Value, so this is the better name for it. Also added some accessor methods to convert to and from V4 Values. Change-Id: I327c83feb5bd3be59909001489979e5a3a9d9e67 Reviewed-by: Simon Hausmann <simon.hausmann@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>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-101-1/+1
| | | | | | Change-Id: I6c3bd7bebe3d62d1cfd0fa6334544c9db8398c76 Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-231-24/+24
| | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: Ie7f5d49ed8235d7a7845ab68f99ad1c220e64d5c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Rename speed -> velocity in the particle systemAlan Alpert2012-06-291-1/+1
| | | | | | | | Matches the convention set in the QtQuick module, for example by ListView and Flickable. Change-Id: I8df57ed1ced8128723d790c30c00cc1b2062787d Reviewed-by: Bea Lam <bea.lam@nokia.com>
* Organize data members in QQuickParticleDataAlan Alpert2012-05-241-7/+13
| | | | | Change-Id: Ibf14dc0f9ef9e17225f07f31276085c9ca83d4f1 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
* Extract Particles code to an independent libraryMatthew Vogt2012-04-161-0/+379
QtQuick clients that do not use particles features should not have to load these classes. Task-number: QTBUG-25178 Change-Id: Ib15f7655dc4d821595e06f9160d2770375279027 Reviewed-by: Glenn Watson <glenn.watson@nokia.com>