Commit Graph

30 Commits

Author SHA1 Message Date
Paul Lemire 3c5848a923 Compute renderables/computables/lights once instead of once per RV
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>
2019-10-29 07:50:32 +01:00
Paul Lemire 7eb01e9532 Split RenderCommand generation and uniform update
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>
2019-10-21 13:35:38 +02:00
Mike Krus 7c044beea8 Clean up includes
Remove include statements for classes that are no longer used. Makes
it easier to find remaining use cases that need addressed before
complete removal in Qt 6.

Change-Id: I60529ba1929ad64b162d3847d5df47cde2a60dad
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2019-10-01 15:16:46 +01:00
Paul Lemire 6a9609f895 Use direct access to remove backend nodes
- Stop using messages
- Remove QSceneObserverInterface
- Ensure backend node creation/destruction is done at the right time

Change-Id: I470825af344ab65bf05e93fc149b61d1b9eefc96
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2019-09-16 10:39:23 +02:00
Mike Krus c1b1bbbb72 Use sync method when initializing new backend nodes
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>
2019-08-29 08:32:29 +02:00
Friedemann Kleint 0e25e5402e Fix some deprecation warnings
jobs/qaspectjobmanager.cpp:90:72: warning: 'T* QWeakPointer<T>::data() const [with T = Qt3DCore::QAspectJob]' is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations]
defaults/qtexturematerial.cpp:66:431: warning: 'QVariant qVariantFromValue(const T&) [with T = QGenericMatrix<3, 3, float>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
...
testpostmanarbiter.cpp:75:51: warning: 'static QVector<T> QVector<T>::fromStdVector(const std::vector<T>&) [with T = QSharedPointer<Qt3DCore::QSceneChange>]' is deprecated: Use QVector<T>(vector.begin(), vector.end()) instead. [-Wdeprecated-declarations]
tst_qray3d.cpp:510:100: warning: 'QVariant qVariantFromValue(const T&) [with T = Qt3DRender::RayCasting::QRay3D]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
tst_renderviewbuilder.cpp:331:120: warning: 'T* QWeakPointer<T>::data() const [with T = Qt3DCore::QAspectJob]' is deprecated: Use toStrongRef() instead, and data() on the returned QSharedPointer [-Wdeprecated-declarations]
...

Change-Id: I446f3ddeb7aa2c5698d2a976fa163b443e01cc0c
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2019-05-28 13:53:41 +02:00
Paul Lemire bad9cd31fc Merge remote-tracking branch origin/5.13 into dev
Change-Id: Ib5c04e9941aeea1a4cd27519b94b9a53e8349ea3
2019-04-15 14:30:59 +00:00
James Turner eedd6402ec Cache light/renderable/computable vectors
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>
2019-02-20 09:57:01 +00:00
Paul Lemire 3c585d6d23 Fix: rebuild material and layer caches when FrameGraph tree is dirty
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>
2019-02-19 14:23:06 +00:00
Paul Lemire f6a0587ef0 Fix race condition when executing multiple filterlayerjobs at once
The updating of referenced layer ids for each Entity should only be performed
once and not by multiple jobs. Therefore, this update was moved into a
dedicated job which is now a dependency of the filterentityjob instances.

Change-Id: Ie8ecc49a7c6c7d41a1f1f0d18619b5e142b68204
Task-number: QTBUG-68942
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2018-06-25 04:39:23 +00:00
Paul Lemire 643b6f7adf MaterialParameterGathererJob: remove unneeded renderer member
Change-Id: I05bef741048fbb29fab261b48f48a20d1d131bcc
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2018-03-19 13:07:04 +00:00
Paul Lemire 00b7e4b76a Perform Shader loading within frame
- CommandThread has been improved to not use an exec loop and properly
  instantiate its own GL context + GraphicsContext that is bound to an
  offscreen surface
- The dirtyShaderGathering job has been renamed and now performs the loading
  of shaders and their introspection. It is also run before the
  materiaparameter gathering, so that these jobs and the following can assume
  a shader is ready

Change-Id: I6d99b3a104bd96530dc45f4b05d3aaac09d2d077
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2018-03-16 11:21:07 +00:00
Paul Lemire 461194b0aa RenderThread: fix races with texture and buffer
Add dependencies to ensure we won't allow the RenderThread to proceed if we
haven't completed the execution of the texture and buffer gatherer jobs.

Change-Id: Iaad67be893738b948bf26ca903f3bff7f16a1b88
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2018-02-28 12:15:42 +00:00
Paul Lemire bf0b3bdf5a Fix race between RenderThread and ShaderGathererJob
By setting the proper dependency which ensures we are done looking for
dirtyShaders by the time updateGLResources in the RenderThread is executed.

Patch provided by svenn-arne.dragly@qt.io

Change-Id: I4515cbfc3a391f887a42178220e6f0814a707745
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2018-02-28 12:15:37 +00:00
Paul Lemire 3dff7c204d Revert "Keep rendering in sync with aspect jobs by adding barriers"
This reverts commit 4631964843.

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>
2018-02-28 10:44:49 +00:00
Sean Harmer 6e82860f19 Merge remote-tracking branch 'origin/5.10' into 5.11
Conflicts:
	src/animation/doc/src/qt3danimation-module.qdoc
	src/render/backend/abstractrenderer_p.h
	src/render/backend/buffervisitor_p.h
	src/render/backend/renderer.cpp
	src/render/backend/renderer_p.h
	src/render/backend/triangleboundingvolume_p.h
	src/render/backend/trianglesextractor_p.h
	src/render/frontend/sphere_p.h
	src/render/jobs/calcboundingvolumejob.cpp
	src/render/jobs/job_common_p.h
	src/render/jobs/pickboundingvolumejob.cpp
	src/render/jobs/pickboundingvolumejob_p.h
	src/render/jobs/pickboundingvolumeutils.cpp
	src/render/jobs/renderviewjobutils_p.h
	tests/auto/render/boundingsphere/tst_boundingsphere.cpp
	tests/auto/render/commons/testrenderer.h
	tests/auto/render/raycasting/tst_raycasting.cpp
	tests/auto/render/render.pro
	tests/auto/render/renderer/tst_renderer.cpp

Change-Id: I76633bc5a5a065e5f9ea62cc16563377e5c693a3
2018-02-15 20:59:03 +00:00
Paul Lemire 437a33de93 Render: Use SIMD Vectors and Matrices in the backend
Change-Id: I19b3b2f8fcb06eb2bc600ebe370465dd15a8eabc
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2018-02-02 13:58:34 +00:00
Svenn-Arne Dragly 4631964843 Keep rendering in sync with aspect jobs by adding barriers
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>
2018-02-02 10:20:11 +00:00
Laszlo Agocs bfb58a7fff Merge remote-tracking branch 'origin/5.10' into dev
Change-Id: Ib51c8311ce78b2fec62dd0c09cb943a85a7d0b2b
2017-12-13 10:47:04 +01:00
Svenn-Arne Dragly f660c65709 Cache material parameter gatherer results
Change-Id: I0660f876d7d967d552f7982c3e33e7c971c9abb4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2017-12-06 11:10:34 +00:00
Svenn-Arne Dragly d2a2e3a0e7 Improve performance for finding entities in subset
Using set_intersection reduces the time spent in this
function by almost 90 %.

Change-Id: I993930ad8e017d58352dfe504fa593e11860e6a7
Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io>
Reviewed-by: Christian Stromme <christian.stromme@qt.io>
2017-12-04 11:30:20 +00:00
Paul Lemire f2557d3683 Fix rendering following LayersDirty
The LayersDirty flag on the renderer was being checked within a running
QAspectJob, which resulted in broken rendering (since the flag is cleared
before running the jobs).
Also in the case of Scene3D we could end up resetting the LayersDirty flag
even though we hadn't really rebuilt the caches. Overhaul this part to make it
more robust. The render views now always look into the caches and we schedule
job to rebuilt the caches instead of doing both at the same time.
Updated unit tests accordining and removed the access of the renderer's dirty
bits within jobs.

Change-Id: Id6b415ba86c91754a960aec3fd88af1ddc21ebe0
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2017-11-16 09:52:22 +00:00
Svenn-Arne Dragly cda9cecde5 Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
	src/render/backend/abstractrenderer_p.h
	src/render/backend/layer.cpp
	src/render/backend/layer_p.h
	src/render/backend/render-backend.pri
	src/render/backend/renderer_p.h
	src/render/backend/renderviewbuilder.cpp
	tests/auto/render/renderer/tst_renderer.cpp
	tests/auto/render/renderviewbuilder/tst_renderviewbuilder.cpp

Change-Id: I5c1b649052992e1b3483d549ddc188c8450e927f
2017-11-15 12:55:31 +01:00
Svenn-Arne Dragly e20de2c1fd Add layer entity filter caching
Also add all dirty flag enums found in dev.

Change-Id: Ib364773002a3170aef66e7b365a0a41d8e60bd92
Reviewed-by: Svenn-Arne Dragly <svenn-arne.dragly@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2017-11-14 21:36:29 +00:00
Paul Lemire 5fc71fa768 Renderer: launch proximity filter job
Also added a manual test example

Change-Id: Ib560dcfdd5e0996cb40d892886c94212e3f8e32d
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2017-08-19 09:42:03 +00:00
Paul Lemire 4b9ba03e0b Fix and improve layer filtering
We now handle the case where multiple LayerFilter nodes are nested
within the same FrameGraphBranch. We also have improved the Accept/Discard
into Accept Any/All and Discard Any/All which should now handle all
filtering cases.

We now build a list of layerIds stored into Entity based on the recursive
flags on the layers being set. This allows to make layer filtering simpler
but the layerIds list building step will need to be improved as a follow up
commit

Unit tests updated

Change-Id: I93451493e41c6c9486defa7e88eaee073a9bc932
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2017-08-18 13:56:05 +00:00
Sean Harmer a3e323ff40 Add a job to calculate the skinning matrix palette for a skeleton
Change-Id: Id70f17592935543053137a37b70b6c2f8b7000ed
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2017-08-10 10:41:20 +00:00
Wieland Hagen 8d019d6517 Correct filtering of disabled entities
FilterLayerEntityJob would not check for the enabled-ness of
parent entities, if present.

We introduce another job that checks for each entity, whether
it is enabled or not. Jobs that need to access this flag must
take care to add a dependency on the UpdateTreeEnabledJob

Task-number: QTBUG-56235
Change-Id: Ic087fc8e9efdd4829cdb18ae3e8430344f6ecf43
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2017-01-05 08:45:00 +00:00
Paul Lemire 98358ce567 RenderViewBuilder: add dependency on technique filtering
Change-Id: Icdc4f2b66454db9e585bf7bcf724811b18e86421
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
2016-12-12 13:48:34 +00:00
Paul Lemire 9c8cdbeea0 Add unit tests for RenderViewBuilder
Change-Id: I52b088804d836100b268a2b0998fe0a1cd86cf77
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2016-12-12 11:41:07 +00:00