summaryrefslogtreecommitdiffstats
path: root/src/render/renderers/opengl/renderer/renderer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix and improve FBO handlingPaul Lemire2020-02-171-2/+9
| | | | | | | | | | | | | | FBO need to be rebuild when one of the attachments directly or indirectly changes. By direct change we mean one of the FBO attachment texture being resized or the list of attachments changing. By indirect we mean when texture resource is recreated internally by the engine. Failure to handle this cases resulted in FBO referencing invalid attachments. Change-Id: I8dd4c08e464eed7fb0eeefd61a4158304ab4245f Task-number: QTBUG-64757 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Destroy FBOs when RenderTarget node is destroyedPaul Lemire2020-02-131-0/+7
| | | | | | | | It appears we never destroyed FBOs which lead to bugs when destroying and recreating a RenderTarget Change-Id: I99b3df95b821670aa3bbd63209ff9bcc21afbf79 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Merge remote-tracking branch 'origin/5.14.0' into 5.14Qt Forward Merge Bot2019-12-131-2/+1
|\ | | | | | | Change-Id: Ibf5f508eec94be4bae2df3ce2e1511de696dcd72
| * Fix OnDemand rendering with Scene3Dv5.14.0-rc2v5.14.0Paul Lemire2019-12-041-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using OnDemand rendering, Scene3D would lock if nothing in the scene were to change. By being blocked, it would also not process jobs for other aspects (input, logics). That would prevent things like a CameraController from running, which in turn would make it impossible to move the camera and trigger a change in the scene to request rendering. Additionally, Scene3D would ignore whether the Qt3D renderer actually needed rendering or not as it was watching on its own the changeArbiter for changes to decide whether rendering was required or not. This would ignore the case where Qt3D needs multiple frames to render a correct frame (e.g loading buffers, shaders at frame n, rebuilding commands at frame n+1) Scene3D now asks the Qt3D renderer by calling the shouldRender() function to decide whether rendering is needed or not, in addition to watching the changeArbiter. Regardless of whether rendering is needed, it now let each aspect process jobs. This ensures things like FrameAction/Input are processed. Then, Scene3D decides whether full rendering is required or whether it only has to be called to allow the Qt3D simulation loop to proceed for the next frame. If the latter, it does it so as not to have QtQuick trigger a redraw. Change-Id: I870f773c224286d6b7ec0f6045319e51e09cbf8e Task-number: QTBUG-80521 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Fill as much as what we can when building the RCPaul Lemire2019-12-031-68/+0
|/ | | | | | | | Avoids repeating that process over and over again in the submission phase. Change-Id: Ie2fa36842cd7280f7c966381238e90dd2dbaa821 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Compute renderables/computables/lights once instead of once per RVPaul Lemire2019-10-291-4/+108
| | | | | | | | All RV end up using exactly the same vector before filtering it down on per RV specifics. No point in compute RV times the same thing. Change-Id: Ia674095627771c8e9ada090fa47623cbbbd8a3f8 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Renderer: build cache data for new RenderViewsPaul Lemire2019-10-221-8/+11
| | | | | Change-Id: I95690444badaf573b9e2775b50c61113de8d1c77 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* ComputeCommand/SubtreeEnabler use direct sync job to update frontendPaul Lemire2019-10-221-15/+21
| | | | | Change-Id: I773955df33f0b4dcdaa0953633761ff82f3d0da4 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Convent SendBufferCaptureJob to direct syncPaul Lemire2019-10-211-7/+18
| | | | | Change-Id: I8d5bc69cb75d73e628f08d70b2e40d665c39802b Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Split RenderCommand generation and uniform updatePaul Lemire2019-10-211-49/+54
| | | | | | | | | | | | | | | | In most cases, we can generate the RenderCommands once and reuse them in subsequent frames only updating the uniforms. We still have to copy the RenderCommands as the renderer renders while we start preparing the next frame. This is still faster than regenerating them entirely. Regenerating the entire commands will happen only when FrameGraph or Scene structure changes. That should rarely be happening on a per frame basis. Next step could be to look at how to only update commands for Entity with Parameters that have changed. Change-Id: I202870850a46fcd3946f81bffddb7027d192f374 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Merge remote-tracking branch '5.13' into 5.14Paul Lemire2019-10-171-1/+2
|\ | | | | | | Change-Id: I39797b5e48cb627638443e20eed207af6ae86c9c
| * Renderer: check context thread before destroying resourcesPaul Lemire2019-10-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only try to cleanup the resources if we know we are called from the right thread. releaseGraphicsResources can be called from 2 places: - Scene3DCleaner when using Scene3D (when closing the window) - AspectThread when the RenderAspect gets unregistered In configurations where the context lives in the main thread (Scene3D + single threaded render loop / ANGLE), the RenderAspect gets unregistered before the Scene3DCleaner has had time to call releaseGraphicsResources. This means that we won't release the resources ourselved and that the driver will have to do that for us. This has been fixed properly in 5.14 with the AspectThread removal. Task-number: QTBUG-60971 Change-Id: I49c1c2f74ad09e7162b988f87bac65863f8490d8 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Paul Lemire2019-10-151-0/+14
|\| | | | | | | Change-Id: I44133fbc9b93e96918463b0b0891ee5ab7db9f2c
| * Make sure right screen is set on QOpenGLContext and QOffscreenSurfaceAndy Shaw2019-10-101-0/+14
| | | | | | | | | | | | | | | | | | | | When the Qt3D window is on a specific screen, then it needs to ensure that any supporting QOpenGLContexts and QOffscreenSurfaces are set to be using that same screen or it will fail to render the content. Change-Id: Ief4f3e88bf6f71862bc5dace0cb0bddcdf3a98b5 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | ShaderBuilder: ensure no old updates are left overPaul Lemire2019-10-141-2/+2
| | | | | | | | | | | | | | Could result in trying to send updates to nodes which have been destroyed. Change-Id: I3709277e5005f25ec8cb9efe0a2152f879bea89f Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Convert Shader/ShaderBuilder jobs to use direct syncPaul Lemire2019-10-141-41/+49
| | | | | | | | | | Change-Id: Ia56ba6176c86e34904611ae57e682ac9d52c79f7 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Rebuild Material Caches when Shaders are dirtyPaul Lemire2019-10-101-1/+2
| | | | | | | | | | | | | | As the cache depends on both Material/FrameGraph and Shaders. Change-Id: I87c8ab20f37f111aa24c83401ee689f9e96681eb Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Remove CommandThread/GLCommandsPaul Lemire2019-10-081-21/+1
| | | | | | | | | | | | | | | | This has always been disabled, no point in keeping something we don't use. Can always be reverted later if we find it's actually required. Change-Id: Icc488b986cee90911a8b46cc88152938e786c1da Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Update sendTextureChangesToFrontend to use direct syncPaul Lemire2019-10-071-9/+27
| | | | | | | | | | Change-Id: I9356186ca27518c32ae189d7e432969b767612e9 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Renderer: remove redundant setter callPaul Lemire2019-09-301-2/+0
| | | | | | | | | | Change-Id: I3829f621958d98b50563a2a8ed782aec1a7ceb65 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Renderer: cache traversal of FrameGraphPaul Lemire2019-09-301-17/+18
| | | | | | | | | | | | | | Will be retraversed only when something in the FrameGraph has changed Change-Id: Ibb43f8f2928b10a584f468fb13f1d4773c7fcebb Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | RenderView:buildDrawRenderCommands: only set Command members that matterPaul Lemire2019-09-301-6/+5
| | | | | | | | | | | | | | | | Some values where overridden in Renderer::prepareSubmission so no point in spending time setting them in the first place Change-Id: Iceea0cbe044b883d0797aebd7487f8f6b29ac542 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Support transient enablement in QSubtreeEnablerMichael Brasser2019-09-241-0/+24
| | | | | | | | | | Change-Id: I422cf0fb0991319b0f54e5a26b9b3694cb093454 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | Remove backend entity hierarchy rebuilding jobsJim Albamont2019-09-201-16/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | We no longer need to have a special job to rebuild the entity hierarchy as parent nodes can now always be resolved on the backend either at creation time or while reparenting. The NodePostConstructorInit ensure that all backend nodes are created from the top down so a node can always find it's parent. Change-Id: I9dcfb64b62e2e02b89b1ae59efb41f25dfc09eae Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | Fix deprecation warnings related to QBasicAtomicIntegerFriedemann Kleint2019-09-191-10/+10
| | | | | | | | | | | | | | | | | | Use loadRelaxed(), storeRelaxed(), fixing warnings like: renderers/opengl/renderer/renderer.cpp:451:22: warning: ‘void QBasicAtomicInteger<T>::store(T) [with T = int]’ is deprecated: Use storeRelaxed [-Wdeprecated-declarations] qt3d/src/render/renderers/opengl/renderer/renderer_p.h:188:61: warning: ‘T QBasicAtomicInteger<T>::load() const [with T = int]’ is deprecated: Use loadRelaxed [-Wdeprecated-declarations] Change-Id: Ica946808969e7f311c98e30d1a61c1b4fa22f66a Reviewed-by: Liang Qi <liang.qi@qt.io>
* | Remove QBackendNodeFactory since it's no longer neededMike Krus2019-09-051-2/+1
| | | | | | | | | | | | | | | | (wasn't really needed before) Change-Id: I213da50ec995015e7a70f2ea1e5c5557f038be0e Reviewed-by: Jim Albamont <jim.albamont@kdab.com> Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Use sync method when initializing new backend nodesMike Krus2019-08-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | If the node type supports syncing, use that rather than the creation message. The message is still needed since that is passed to the instantiation functor (none of qt3d's classes appear to use anything but the node id, but can't be sure no other classes do, and can't add other virtual method without breaking BC). Change-Id: Id99f448070b8722a7809b968798772c9eb3c8397 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Renderer renderSynchronous: allow skipping swap buffer stepPaul Lemire2019-08-071-3/+12
| | | | | | | | | | | | | | Needed for cases where Scene3D is used as an Underlay Change-Id: I13889efc146d278a6331000f886b8fcb33448f65 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Make Scene3D rendering use the Manual Qt3D drive modePaul Lemire2019-08-071-39/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This now makes Scene3D rendering fully synchronous and blocking: - All Qt3D jobs have to be executed before we can render the GL commands This makes the blocking mode that could be activated with SCENE3D_BLOCKING_RENDERMODE the default behavior now and therefore we could remove references to it in the code. This now means that Qt3D and QtQuick will be rendering at the same refresh rate, which in most cases won't be noticeable and will ensure that content from Qt3D scenes matches content from QtQuick scenes. The only downside is if the Qt3D rendering takes longer than the time expected by QtQuick, the whole QtQuick rendering will be slowed down. Previously the QtQuick rendering might have still run at 60fps while the Qt3D rendering at a lower fps. Now the QtQuick fps would be the same as the Qt3D fps. That being said, the old behavior also meant that if Qt3D didn't catch up, the delay between QtQuick and Qt3D would only increase frame after frame. This change allow to simplify the internals by making Scene3D and regular Qt3D use the same code paths internally. Please note that Scene3D relies on QQuickWindow::afterAnimating being called each frame. When using a QQuickRenderControl this means you might have to call it manually as part of your rendering code. Task-number: QTBUG-72385 Change-Id: I887daf6df632e296a892b844e738a67e973fee7f Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-311-1/+1
|\| | | | | | | | | | | | | Conflicts: tests/manual/manual.pro Change-Id: I15d497da84d3fe684c3a598831171d6aed7534ca
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-231-1/+1
| |\ | | | | | | | | | Change-Id: I2a66e9344b72524431885bdf5f59fcaedb94c718
| | * Renderer: use last known good surface to reset render statesPaul Lemire2019-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were instead checking against the last surface used (which could be null) instead of the last known good surface to reset the render states. This could result in not resetting the render states and keeping dangling pointers around. To know if we can render, we check find the first non null surface in the list of RV. In most cases we can safelly assume that if first RV has a surface, all following ones will likely use the same surface. If we have no good surface we skip the rendering. However in the case you have a FG where the first RV has a surface but not the last one (which wouldn't really make sense but can happen if you mess up), we could end up in the above case where surface is nullptr though we have partially rendered something for the RV which had valid surfaces. Change-Id: I902b8c7a943ad2ca7e2f487873f73990cf8db433 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | | Merge remote-tracking branch 'origin/5.13' into devPaul Lemire2019-06-031-1/+4
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/render/renderers/opengl/renderer/renderer.cpp tests/auto/render/textures/tst_textures.cpp Change-Id: I4da0eafe7ddd4dd822c3dcb5f5fa826653a335b4
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-05-291-1/+1
| |\| | | | | | | | | | Change-Id: I9e9214906c5cda56d0bcc98678c77be69189699d
| | * Clean up warningsMike Krus2019-05-281-1/+1
| | | | | | | | | | | | | | | Change-Id: I1ddad305359586481021e85f6e4a470d3a6521b0 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
| * | Iterate on child handlesMike Krus2019-05-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolving list of handles as list of node pointers introduces extra heap memory allocation (via QVector) which can cause locking with high number of threads. Added Entity::traverse() methods to apply a functor to all entitied in a sub-tree. Change-Id: I239ab30ac8ac53ba83666a147015d58465d76eb2 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | | Scene3D: Revise render loop and synchronizationAnton Kreuzkamp2019-05-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, the Scene3DRenderer marked the sg-node dirty in render, which would then already mark it dirty for the next frame. This only works as long as we always render, which is undesireble in some cases. fa12f14b2 changed rendering to not always happen anymore. Thus, that commit broke rendering under certain circumstances. Now, Scene3DRenderer listens on a signal from the QChangeArbiter about new pending changes. In reaction to this signal, we set an internal dirty-flag in Scene3DRenderer. Only if this flag is set, synchronization and rendering will happen on the Qt3D side. Change-Id: I3b33faa5d60c270bd9b903b0e34c8fa24e2e29fd Task-number: QTBUG-69985 Task-number: QTBUG-72923 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | | Merge remote-tracking branch 'origin/5.13' into devPaul Lemire2019-05-091-3/+20
|\| | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/render/backend/abstractrenderer_p.h src/render/renderers/opengl/renderer/renderer.cpp tests/auto/render/renderer/tst_renderer.cpp Change-Id: Ib6da858f10bec57bdb1002bd8fa4172304d118f2
| * | Merge remote-tracking branch 5.12 into 5.13Paul Lemire2019-04-261-3/+23
| |\| | | | | | | | | | Change-Id: I42affdd02bddb5205b9f2455f0c5e5efbd414dd8
| | * Cache light/renderable/computable vectorsJames Turner2019-04-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | This avoids running these jobs when lights / renderables have not changed in a frame Change-Id: I604180fe3442ab67648c4ba5d9effb8639c68ef7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
| | * Fix Entity parenting hierarchyJim Albamont2019-04-041-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the initial Entity backend node hierarchy is created it skips over any non-entity nodes to ensure that Entities are only parented to other Entities. Calling QNode::setParent breaks this when reparenting Entities to non-entity nodes. Fix by sending a new "parentEntityUpdated" property update that backend Entity nodes listen for. They keep the id of their new parent and flag the need to rebuild the entity hierarchy. This triggers a new job to clear the children and parents of every backend Entity, then rebuilds the hierarchy using the stored parent ID in each Entity. This is much more forgiving of creation/parenting ordering issues and shouldn't be less performant because any Entity reparent was previously marking everything dirty anyway. Add a new test from QTBUG-73905 that creates 4 cylinders and manipulates the parents in different ways. Add a new test to tst_nodes to reparent a QEntity to a QNode and ensure the entity finds it's correct QEntity parent. Add a new test to tst_entity to ensure backend nodes correctly handle the new parenting events. Task-number: QTBUG-73905 Change-Id: Iab0203947d89bbed2868b3629fbde879675fe568 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | | Merge remote-tracking branch origin/5.13 into devPaul Lemire2019-04-151-6/+7
|\| | | | | | | | | | | Change-Id: Ib5c04e9941aeea1a4cd27519b94b9a53e8349ea3
| * | Merge branch '5.12' into 5.13Paul Lemire2019-04-021-5/+7
| |\| | | | | | | | | | Change-Id: If17511da64dd666a536408aa3cb3178ef6db0403
| | * Fix: rebuild material and layer caches when FrameGraph tree is dirtyPaul Lemire2019-02-191-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This could otherwise result in black screens when the FrameGraph tree is updated and no other change is sent. Screen would remain black until some other element with dirty changes triggers a cache rebuild. Change-Id: Iac43965f06d1d644de14e6a6c8768e035bed69a6 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | | Make it possible to partially update a texturePaul Lemire2019-03-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Introduce QTextureDataUpdate which contains information about the update - QAbstractTexture::updateTexture function added - Add manual test texture-updates-cpp - Add unit tests for GLTexture and complete other texture tests Change-Id: I1b792f2075830ce05cc8e04cc68110141b5571d6 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | | Rework internal Texture HandlingPaul Lemire2019-03-041-101/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove internal GLTexture sharing - Remove dataFunctor data sharing - Simplify the overall texture process: 1) Look for dirty textures (either a property on QTexture or a referenced QTextureImage has changed) 2) Update GL Resources - Create a GLTexture for a given Texture if it doesn't exist - Update GLTexture to reflect Texture state - Perform actual GL texture creation and or upload (call functors at this point) - Cleanup GLTextures when matching Texture node has been destroyed This will provide an easier maintenance over time as it drastically simplifies the handling of textures and removes most of the coupling. Furthermore this will make it possible to send texture updates on a QTexture node to update texture content without having to declare QTextureImages which would not have been (or would have been a lot harder) to do. In practice, I doubt most people were even aware of the internal texture sharing in the first place. [ChangeLog][Qt3DRender] Textures: internal data sharing removed Change-Id: I02867c8105e29eb1e193884e3899062f795f32f4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | | Cache light/renderable/computable vectorsJames Turner2019-02-201-0/+7
|/ / | | | | | | | | | | | | | | This avoids running these jobs when lights / renderables have not changed in a frame Change-Id: I604180fe3442ab67648c4ba5d9effb8639c68ef7 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2019-01-101-1/+2
|\| | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: Ie8a4bf768bffba61dca9e315151c035be7b48723
| * Recompute bounding volumes when buffer changesPaul Lemire2019-01-071-1/+2
| | | | | | | | | | | | | | | | | | | | Right now the bounding volumes would be computed only when a geometry is marked dirty, which essentially means only when the geometry is first loaded. However, if a geometry buffer were to change, we need to recompute the bounding volume. Change-Id: Ie3fb83d1cc11a3bbfbe2b9828e9f8d7c302d175b Reviewed-by: Mike Krus <mike.krus@kdab.com>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2018-12-111-7/+10
|\| | | | | | | | | | | | | Conflicts: src/render/renderers/opengl/textures/gltexture.cpp Change-Id: I57e9a296dc15f0b5dc3af3664f698bdc799c4bb5