summaryrefslogtreecommitdiff
path: root/src/quick3d/imports/scene3d/scene3drenderer_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie Gérard2022-06-221-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: I8105424281eed871037fa6c463871ca8829876b5 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 2f1bc82b35209aacd8d214a3c7e8e725bee85de6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Update QtQuick API to build with 5.15Mike Krus2021-01-111-0/+2
| | | | | | | Haven't tried to run anything, it just builds Change-Id: I6c2c2a949bc3892a363697cf38f1608af87c303c Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Scene3D: handle flipping based on the RHI backend in usePaul Lemire2020-11-261-0/+4
| | | | | | | | | | | | | | | Qt3D handles flipping based on whether the RHI backend in use requires it or not. Scene3D would also flip the content (ignoring the fact that the content was already in the correct orientation). This resulted in cases where a Qt 3D scene rendered with Scene3D would be flipped while the same scene rendered on its own (with Qt3DWindow) would be correct. Change-Id: I9fc2a01f63713ed3dbafaf896dfd9457d7160653 Task-number: QTBUG-87842 Pick-to: 6.0 6.0.0 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Finish removing traces of Scene3DViewMike Krus2020-10-281-1/+0
| | | | | Change-Id: I450e53cc716235db1bc0675c904466050e17296d Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Remove Scene3DViews supportPaul Lemire2020-08-261-2/+0
| | | | | | | | | | | | As making them work is currently not possible due to RHI limitations about not clearing when beginning a new render pass. We might be able to revert that patch later on. [ChangeLog] Remove Scene3DView support due to incompatibility with RHI Change-Id: I209a3c23033ea1997868d488ef89071eff3ec6ac Reviewed-by: Mike Krus <mike.krus@kdab.com>
* rhi: apply Scene3D changes from 5.15Paul Lemire2020-08-261-9/+21
| | | | | | | Should fix potential crash on shutdown Change-Id: If1b2180532d23ad8187b25014d0d3a51a7eb1ebe Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Scene3D refactoringPaul Lemire2020-08-101-1/+1
| | | | | | | | | | | The Scene3DRender is now in charge of instantiating the Scene3DSGNode - this allows to create the node only once we have a valid QSGTexture -> which otherwise lead in some cases to a Vulkan lost device event - simplifies the overally architecture slightly Change-Id: I4cf4502e9fb5ab636309c78a7527a9807fa231ba Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Refactor Scene3D to work with both RHI and GL Qt3D renderersPaul Lemire2020-07-291-12/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Depending on whether we are using RHI or GL we need to either trigger the rendering after the beforeRendering or beforeRenderPassRecording have been fired -> beforeRendering The RHI command buffer is set up but nothing has been recorded yet. This is what we want for the RHI backend but we will need to make sure we don't call begin/endFrame nor use swap chains other than the one QtQuick is using. This means RenderSurfaceSelector won't be possible. -> beforeRenderPassRecording The RHI command for buffer uploads have been uploaded but the actual RenderPass draw calls have yet to be made. The screen has been cleared already, so this is the best place for the GL backend which expects the screen to have been cleared. - The GL backend can use a QOpenGLFrameBufferObject but that is not possible with the RHI backend. - The RHI backend uses a custom QRhiRenderTarget that takes care of blitting its color attachment into a QRhiTexture which is then bound to a QSGTexture The overall Scene3DItem/Scene3DRender architecture remains the same: - processChange - Render Qt3D content into Texture - Set texture on a custom QSGNode quad Change-Id: Id6c317342d0a227d5295cbfefefc3ed12da160d7 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Use QList instead of QVector in implementation and docsJarek Kobus2020-07-091-2/+2
| | | | | | | | | Fix some const correctness. Use list-initialization. Task-number: QTBUG-84469 Change-Id: I9c56742581f48f89a3b02e4121fae414117c7a25 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Merge remote-tracking branch 'origin/5.15' into devMike Krus2020-04-271-6/+9
|\ | | | | | | Change-Id: Id669d5c1aab29965eac0dabd1cb497e908dac23e
| * Allow for when a Scene3D item switches screensAndy Shaw2020-03-131-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a Scene3D item switches screens then it will need to be reinitalized so that the supporting contexts, offscreen surfaces are set to use the same screen and not the original one. This ensures that the item is still rendered correctly on the new screen. This includes a manual test using QQuickWidget in separate windows that enables it going from one screen to the other. This is a fresh version after the previous version was found to have a bug shown in the scene3d-loader test which has now been resolved. Change-Id: I3c711e894018db52ec00a8a5d2e0fb0128743ab1 Done-with: Antti Kokko <antti.kokko@qt.io> Fixes: QTBUG-79192 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Mike Krus <mike.krus@kdab.com>
| * Revert "Allow for when a Scene3D item switches screens"Paul Lemire2020-02-181-9/+6
| | | | | | | | | | | | | | | | | | This reverts commit 648b7459e8a6ce8ce1f115a14da63d546b743439. Reason for revert: Introduces QTBUG-82275 Change-Id: I5514ad58707c086eaaab3203773614c939e461e8 Reviewed-by: Mike Krus <mike.krus@kdab.com>
| * Allow for when a Scene3D item switches screensAndy Shaw2020-02-071-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a Scene3D item switches screens then it will need to be reinitalized so that the supporting contexts, offscreen surfaces are set to use the same screen and not the original one. This ensures that the item is still rendered correctly on the new screen. This includes a manual test using QQuickWidget in separate windows that enables it going from one screen to the other. Fixes: QTBUG-79192 Change-Id: Id5bbc0d30d04ea4a945463238868b68283df0543 Reviewed-by: Mike Krus <mike.krus@kdab.com> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* | Fix deprecations and warningsMike Krus2020-02-261-0/+1
|/ | | | | | | | | | | In particular: - QHash::unite deprecated - QQuickWindow::createTextureFromId deprecated - also removed unused or deprecated code, and fixed out of order initialization Change-Id: Ia583654fcfcd654ca388575aa7716c282b134e33 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Fix OnDemand rendering with Scene3Dv5.14.0-rc2v5.14.05.14.0Paul Lemire2019-12-041-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Introduce Scene3DViewPaul Lemire2019-08-271-0/+5
| | | | | | | | | | Allows to render several 3D scenes using a single Scene3D. To be used when you need multiple Scene3D instances. [ChangeLog] Introduce Scene3DView to render multiple distinct 3D scenes Change-Id: I5d51c5935218cc84c15d57def3703aa0d92040ba Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Refactor Scene3D internals prior to Scene3DView introductionPaul Lemire2019-08-271-1/+1
| | | | | Change-Id: I6c9313616587c7930560a5abd962ad73d0bfff70 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Scene3D: introduce compositingMode (FBO or Underlay)Paul Lemire2019-08-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The default compositing mode is FBO. One of the problematic aspects of Scene3D is its round trip through a FBO, which is moderately expensive on low-end hardware, although it makes it a fully fledged Qt Quick 2 item. If one wants MSAA then things are even worse, as an intermediate MS'ed FBO is needed, then resolving into the final one, whose color texture is then sampled. However, there's a significant use case for which these FBOs can be avoided, and that's the case of a 3D scene "below" other QQ2 content. In this setup, Qt3D can simply render to the screen, driven by QQ2; then QQ2 can draw on top. (It's the typical "underlay" scenario.) This can be enabled by setting the compositing mode to Underlay [ChangeLog] Scene3D add compositingMode property. Allows underlay rendering. Task-number: QTBUG-74977 Change-Id: I1ec5f5d60eab45835dbdb2596a7bf1b2ac3624e0 Reviewed-by: Mike Krus <mike.krus@kdab.com>
* Make Scene3D rendering use the Manual Qt3D drive modePaul Lemire2019-08-071-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Scene3D: Revise render loop and synchronizationAnton Kreuzkamp2019-05-281-0/+3
| | | | | | | | | | | | | | | | | | 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>
* Scene3D crashing on destructionMichael Dippold2018-09-271-0/+1
| | | | | | | | | | Moved logic accessing the Scene3DItem from the render function into an afterSynchronization call which has the main thread locked to prevent the race condition. Task-number: QTBUG-70747 Change-Id: I596d445512b5985c7dfb54d228fa0a5fcc596a27 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Revert "Keep rendering in sync with aspect jobs by adding barriers"Paul Lemire2018-02-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 46319648436814afb5a77755dde6681e304befaf. We want to be able to render one set of RenderViews for frame n while concurrently building RenderViews for frame n + 1. The reverted commit removed that behavior which reduced the CPU time available to prepare a frame. This would cause on some scenes a failure to meet the ~10ms budget we have to prepare a frame. This is therefore a regression. The root cause behind this regression is that a job cannot be executed until all the jobs which have been previously launched have completed. The proposed solution would be to instead add an OpenGL command thread that can be used to load graphics resources required for the RenderViews directly when required. This would in turn allow to cache RenderViews and keep the concurrent behavior of RenderView submission and creation. With that goal in mind, the following patches will be rebased and updated https://codereview.qt-project.org/#/c/189309/ https://codereview.qt-project.org/#/c/189310/ Change-Id: I4879047c45986a0e615e3aef7b7352f82a04a9da Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Keep rendering in sync with aspect jobs by adding barriersSvenn-Arne Dragly2018-02-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | This makes sure that jobs that depend on a specific state of the renderer (such as context being initialized) never run before this is the case. This reduces the number of possible race conditions and checks we need to do to ensure the jobs and the renderer are in the correct state. This way we no longer swap buffers when nothing has been rendered, which in turn makes sure that we only draw one frame when the render policy is OnDemand and there are no changes. This change also adds a number of assertions on pointers to resources to make it easier to detect missing job dependencies. Finally, this change overhauls the job dependencies in Renderer and RenderViewBuilder. Task-number: QTBUG-66024 Change-Id: I3e4e9dd0dd53b5c88f5c1b17d68df42f28eae794 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Merge remote-tracking branch 'origin/5.9.4' into 5.9Liang Qi2018-01-181-0/+3
|\ | | | | | | Change-Id: I9c8aa5d2010fcc622b9cce3031e58a46b74ea2fa
| * Scene3DRenderer: ensure window pointer stays the same while renderingv5.9.45.9.4Paul Lemire2018-01-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It appears that the pointer value for the window could in some cases be updated meanwhile we were rendering, which resulted in random crashes. We now save the window pointer to a member variable on startup or whenever the windowChanged signal is fired and use a mutex to ensure the pointer won't change while we are rendering. This also covers the case where the item is destroyed but the cross-thread signals are not received before rendering happens. Task-number: QTBUG-63897 Task-number: QTBUG-65407 Change-Id: I5f2797e2210b532f9086ed186959fce27ea9f514 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* | Scene3D: allow to force blocking renderingPaul Lemire2018-01-161-0/+1
|/ | | | | | | | | | | | | | | | When using Scene3D, when the jobs preparing the render commands for the 3D scene take too long (more than the QtQuick refresh rate), the Scene3D wouldn't render anything when QtQuick requested it to. Then, the next time it would be asked to render (next QtQuick frame), if the jobs have finished by then, it will render. If the jobs are still not ready, then the above process is repeated. This patch introduces an environment variable SCENE3D_BLOCKING_RENDERMODE which can be set to force Scene3D to wait (for at most 10ms) instead of returning immediately for the jobs being ready. Change-Id: I2db10e622570a7bc8a2e2cbaff113c110135cd3e Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Hook Scene3D cleanup on scenegraphInvalidated tooLaszlo Agocs2017-04-051-1/+3
| | | | | | | | | | | | | The invalidated signal is nice since it works in all cases, both with real QQuickWindows and ones driven via QQuickRenderControl (e.g. QQuickWidget). With QQuickWidget just relying on windowChanged is pretty bad since the window change comes way too late due to the diffeerences in widget handling internals. Task-number: QTBUG-52132 Change-Id: I8639e4d60514eeeb00fa9dda2329de6088f2a44d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Coding convention fix for Src/importscore, importsextras,5.8Robert Brock2017-04-011-2/+1
| | | | | | | | | importsinput, importsrender, importsscene3d Reordering the header includes to comply with Qt coding conventions Task-number: QTBUG-56185 Change-Id: I3b2b3ee60e397772bbcebac09b07c059fbd922db Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Replace Q_DECL_NOEXCEPT by Q_DECL_NOTHROWPaul Lemire2016-05-231-1/+1
| | | | | | Change-Id: Ia991da557483704055e0ccf17b4a6b273568a1ba Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Unify license header usageAntti Kokko2016-01-261-11/+14
| | | | | | | Update old header.LGPL3 to header.LGPL Change-Id: I8eac0cd6bbc276a56df487249cc459c0d4fab165 Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* Refactor the scene3d classes into one class per pair of filesSean Harmer2016-01-181-0/+113
No functional changes. Change-Id: I5895e3bcaf65fb7524e6adb10bca1f8c6fdb6c44 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>