summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/backend/abstractrenderer_p.h3
-rw-r--r--src/render/backend/backendnode_p.h2
-rw-r--r--src/render/backend/cameralens.cpp1
-rw-r--r--src/render/backend/cameralens_p.h2
-rw-r--r--src/render/backend/computecommand.cpp30
-rw-r--r--src/render/backend/computecommand_p.h8
-rw-r--r--src/render/backend/entity.cpp20
-rw-r--r--src/render/backend/entity_p.h14
-rw-r--r--src/render/backend/entityaccumulator.cpp99
-rw-r--r--src/render/backend/entityaccumulator_p.h83
-rw-r--r--src/render/backend/entityvisitor.cpp113
-rw-r--r--src/render/backend/entityvisitor_p.h95
-rw-r--r--src/render/backend/managers_p.h5
-rw-r--r--src/render/backend/nodemanagers.cpp2
-rw-r--r--src/render/backend/nodemanagers_p.h77
-rw-r--r--src/render/backend/platformsurfacefilter_p.h2
-rw-r--r--src/render/backend/render-backend.pri4
-rw-r--r--src/render/backend/resourceaccessor_p.h2
-rw-r--r--src/render/backend/trianglesvisitor_p.h2
-rw-r--r--src/render/framegraph/blitframebuffer.cpp8
-rw-r--r--src/render/framegraph/cameraselectornode.cpp5
-rw-r--r--src/render/framegraph/clearbuffers.cpp6
-rw-r--r--src/render/framegraph/dispatchcompute.cpp11
-rw-r--r--src/render/framegraph/framegraph.pri14
-rw-r--r--src/render/framegraph/framegraphnode.cpp16
-rw-r--r--src/render/framegraph/framegraphnode_p.h4
-rw-r--r--src/render/framegraph/layerfilternode.cpp5
-rw-r--r--src/render/framegraph/memorybarrier.cpp2
-rw-r--r--src/render/framegraph/proximityfilter.cpp8
-rw-r--r--src/render/framegraph/qblitframebuffer.cpp54
-rw-r--r--src/render/framegraph/qblitframebuffer.h2
-rw-r--r--src/render/framegraph/qbuffercapture.h2
-rw-r--r--src/render/framegraph/qcameraselector.h2
-rw-r--r--src/render/framegraph/qclearbuffers.h2
-rw-r--r--src/render/framegraph/qdispatchcompute.h2
-rw-r--r--src/render/framegraph/qframegraphnode.h2
-rw-r--r--src/render/framegraph/qframegraphnodecreatedchange.h2
-rw-r--r--src/render/framegraph/qfrustumculling.h2
-rw-r--r--src/render/framegraph/qlayerfilter.h2
-rw-r--r--src/render/framegraph/qmemorybarrier.h2
-rw-r--r--src/render/framegraph/qnodraw.h2
-rw-r--r--src/render/framegraph/qproximityfilter.h2
-rw-r--r--src/render/framegraph/qrendercapture.h4
-rw-r--r--src/render/framegraph/qrenderpassfilter.h2
-rw-r--r--src/render/framegraph/qrenderstateset.h2
-rw-r--r--src/render/framegraph/qrendersurfaceselector.h2
-rw-r--r--src/render/framegraph/qrendersurfaceselector_p.h2
-rw-r--r--src/render/framegraph/qrendertargetselector.h2
-rw-r--r--src/render/framegraph/qsetfence.cpp174
-rw-r--r--src/render/framegraph/qsetfence.h86
-rw-r--r--src/render/framegraph/qsetfence_p.h82
-rw-r--r--src/render/framegraph/qsortpolicy.h2
-rw-r--r--src/render/framegraph/qtechniquefilter.h2
-rw-r--r--src/render/framegraph/qtechniquefilter_p.h2
-rw-r--r--src/render/framegraph/qviewport.h2
-rw-r--r--src/render/framegraph/qwaitfence.cpp219
-rw-r--r--src/render/framegraph/qwaitfence.h98
-rw-r--r--src/render/framegraph/qwaitfence_p.h85
-rw-r--r--src/render/framegraph/rendercapture.cpp1
-rw-r--r--src/render/framegraph/renderpassfilternode.cpp8
-rw-r--r--src/render/framegraph/rendersurfaceselector.cpp17
-rw-r--r--src/render/framegraph/rendertargetselectornode.cpp8
-rw-r--r--src/render/framegraph/setfence.cpp79
-rw-r--r--src/render/framegraph/setfence_p.h80
-rw-r--r--src/render/framegraph/sortpolicy.cpp2
-rw-r--r--src/render/framegraph/statesetnode.cpp4
-rw-r--r--src/render/framegraph/techniquefilternode.cpp8
-rw-r--r--src/render/framegraph/viewportnode.cpp3
-rw-r--r--src/render/framegraph/waitfence.cpp107
-rw-r--r--src/render/framegraph/waitfence_p.h85
-rw-r--r--src/render/frontend/qabstractfunctor.cpp7
-rw-r--r--src/render/frontend/qabstractfunctor.h2
-rw-r--r--src/render/frontend/qcamera.h2
-rw-r--r--src/render/frontend/qcamera_p.h2
-rw-r--r--src/render/frontend/qcameralens.h2
-rw-r--r--src/render/frontend/qcameralens_p.h2
-rw-r--r--src/render/frontend/qcomputecommand.cpp102
-rw-r--r--src/render/frontend/qcomputecommand.h15
-rw-r--r--src/render/frontend/qcomputecommand_p.h9
-rw-r--r--src/render/frontend/qlayer.h2
-rw-r--r--src/render/frontend/qlayer_p.h2
-rw-r--r--src/render/frontend/qlevelofdetail.h2
-rw-r--r--src/render/frontend/qlevelofdetail_p.h2
-rw-r--r--src/render/frontend/qlevelofdetailboundingsphere.h2
-rw-r--r--src/render/frontend/qlevelofdetailswitch.h2
-rw-r--r--src/render/frontend/qpickingsettings.cpp8
-rw-r--r--src/render/frontend/qpickingsettings.h5
-rw-r--r--src/render/frontend/qpickingsettings_p.h2
-rw-r--r--src/render/frontend/qrenderaspect.cpp15
-rw-r--r--src/render/frontend/qrenderaspect.h2
-rw-r--r--src/render/frontend/qrenderaspect_p.h2
-rw-r--r--src/render/frontend/qrenderplugin_p.h2
-rw-r--r--src/render/frontend/qrenderpluginfactory_p.h2
-rw-r--r--src/render/frontend/qrenderpluginfactoryif_p.h2
-rw-r--r--src/render/frontend/qrendersettings.h2
-rw-r--r--src/render/frontend/qrendersettings_p.h2
-rw-r--r--src/render/frontend/qrendertarget.h2
-rw-r--r--src/render/frontend/qrendertarget_p.h2
-rw-r--r--src/render/frontend/qrendertargetoutput.h2
-rw-r--r--src/render/frontend/qrendertargetoutput_p.h2
-rw-r--r--src/render/frontend/sphere_p.h4
-rw-r--r--src/render/geometry/attribute.cpp11
-rw-r--r--src/render/geometry/geometry.cpp39
-rw-r--r--src/render/geometry/geometry_p.h10
-rw-r--r--src/render/geometry/qattribute.h2
-rw-r--r--src/render/geometry/qattribute_p.h2
-rw-r--r--src/render/geometry/qbuffer.h2
-rw-r--r--src/render/geometry/qbuffer_p.h2
-rw-r--r--src/render/geometry/qbufferdatagenerator.h2
-rw-r--r--src/render/geometry/qgeometry.cpp56
-rw-r--r--src/render/geometry/qgeometry.h10
-rw-r--r--src/render/geometry/qgeometry_p.h5
-rw-r--r--src/render/geometry/qgeometryfactory.h2
-rw-r--r--src/render/geometry/qgeometryrenderer.h2
-rw-r--r--src/render/geometry/qgeometryrenderer_p.h2
-rw-r--r--src/render/geometry/qmesh.h2
-rw-r--r--src/render/geometry/qmesh_p.h2
-rw-r--r--src/render/io/qaxisalignedboundingbox_p.h2
-rw-r--r--src/render/io/qgeometryloaderfactory_p.h2
-rw-r--r--src/render/io/qgeometryloaderinterface_p.h2
-rw-r--r--src/render/io/qsceneexporter_p.h2
-rw-r--r--src/render/io/qsceneexportfactory_p.h2
-rw-r--r--src/render/io/qsceneexportplugin_p.h2
-rw-r--r--src/render/io/qsceneimporter_p.h2
-rw-r--r--src/render/io/qsceneimportfactory_p.h2
-rw-r--r--src/render/io/qsceneimportplugin_p.h2
-rw-r--r--src/render/io/qsceneloader.h2
-rw-r--r--src/render/io/qsceneloader_p.h2
-rw-r--r--src/render/io/qurlhelper_p.h2
-rw-r--r--src/render/jobs/calcboundingvolumejob.cpp96
-rw-r--r--src/render/jobs/calcboundingvolumejob_p.h2
-rw-r--r--src/render/jobs/computefilteredboundingvolumejob.cpp22
-rw-r--r--src/render/jobs/computefilteredboundingvolumejob_p.h5
-rw-r--r--src/render/jobs/expandboundingvolumejob.cpp30
-rw-r--r--src/render/jobs/expandboundingvolumejob_p.h5
-rw-r--r--src/render/jobs/filterlayerentityjob_p.h2
-rw-r--r--src/render/jobs/framecleanupjob.cpp26
-rw-r--r--src/render/jobs/framecleanupjob_p.h2
-rw-r--r--src/render/jobs/frustumcullingjob.cpp43
-rw-r--r--src/render/jobs/frustumcullingjob_p.h3
-rw-r--r--src/render/jobs/job_common_p.h3
-rw-r--r--src/render/jobs/pickboundingvolumejob.cpp16
-rw-r--r--src/render/jobs/pickboundingvolumeutils.cpp165
-rw-r--r--src/render/jobs/pickboundingvolumeutils_p.h27
-rw-r--r--src/render/jobs/raycastingjob.cpp50
-rw-r--r--src/render/jobs/sendbuffercapturejob.cpp6
-rw-r--r--src/render/jobs/sendbuffercapturejob_p.h3
-rw-r--r--src/render/jobs/sendrendercapturejob_p.h2
-rw-r--r--src/render/jobs/updateentityhierarchyjob_p.h2
-rw-r--r--src/render/jobs/updateentitylayersjob.cpp17
-rw-r--r--src/render/jobs/updateentitylayersjob_p.h2
-rw-r--r--src/render/jobs/updatelevelofdetailjob.cpp255
-rw-r--r--src/render/jobs/updatelevelofdetailjob_p.h8
-rw-r--r--src/render/jobs/updatemeshtrianglelistjob_p.h2
-rw-r--r--src/render/jobs/updateshaderdatatransformjob_p.h2
-rw-r--r--src/render/jobs/updateskinningpalettejob.cpp22
-rw-r--r--src/render/jobs/updateskinningpalettejob_p.h1
-rw-r--r--src/render/jobs/updatetreeenabledjob.cpp22
-rw-r--r--src/render/jobs/updatetreeenabledjob_p.h5
-rw-r--r--src/render/jobs/updateworldboundingvolumejob_p.h2
-rw-r--r--src/render/jobs/updateworldtransformjob.cpp21
-rw-r--r--src/render/jobs/updateworldtransformjob_p.h6
-rw-r--r--src/render/lights/qabstractlight.h2
-rw-r--r--src/render/lights/qabstractlight_p.h2
-rw-r--r--src/render/lights/qdirectionallight.h2
-rw-r--r--src/render/lights/qdirectionallight_p.h2
-rw-r--r--src/render/lights/qenvironmentlight.h2
-rw-r--r--src/render/lights/qenvironmentlight_p.h2
-rw-r--r--src/render/lights/qpointlight.h2
-rw-r--r--src/render/lights/qpointlight_p.h2
-rw-r--r--src/render/lights/qspotlight.h2
-rw-r--r--src/render/lights/qspotlight_p.h2
-rw-r--r--src/render/materialsystem/qeffect.h2
-rw-r--r--src/render/materialsystem/qeffect_p.h2
-rw-r--r--src/render/materialsystem/qfilterkey.h2
-rw-r--r--src/render/materialsystem/qfilterkey_p.h2
-rw-r--r--src/render/materialsystem/qgraphicsapifilter.h2
-rw-r--r--src/render/materialsystem/qgraphicsapifilter_p.h4
-rw-r--r--src/render/materialsystem/qmaterial.h2
-rw-r--r--src/render/materialsystem/qmaterial_p.h2
-rw-r--r--src/render/materialsystem/qparameter.h2
-rw-r--r--src/render/materialsystem/qparameter_p.h2
-rw-r--r--src/render/materialsystem/qrenderpass.h2
-rw-r--r--src/render/materialsystem/qshaderdata.h4
-rw-r--r--src/render/materialsystem/qshaderdata_p.h2
-rw-r--r--src/render/materialsystem/qshaderprogram.h2
-rw-r--r--src/render/materialsystem/qshaderprogrambuilder.cpp155
-rw-r--r--src/render/materialsystem/qshaderprogrambuilder.h21
-rw-r--r--src/render/materialsystem/qshaderprogrambuilder_p.h6
-rw-r--r--src/render/materialsystem/qtechnique.h2
-rw-r--r--src/render/materialsystem/shaderbuilder.cpp33
-rw-r--r--src/render/materialsystem/shaderbuilder_p.h2
-rw-r--r--src/render/materialsystem/shadercache_p.h2
-rw-r--r--src/render/materialsystem/technique_p.h2
-rw-r--r--src/render/picking/objectpicker.cpp15
-rw-r--r--src/render/picking/objectpicker_p.h5
-rw-r--r--src/render/picking/qabstractraycaster.cpp4
-rw-r--r--src/render/picking/qabstractraycaster.h2
-rw-r--r--src/render/picking/qabstractraycaster_p.h2
-rw-r--r--src/render/picking/qobjectpicker.cpp37
-rw-r--r--src/render/picking/qobjectpicker.h7
-rw-r--r--src/render/picking/qobjectpicker_p.h5
-rw-r--r--src/render/picking/qpickevent.h2
-rw-r--r--src/render/picking/qpickevent_p.h2
-rw-r--r--src/render/picking/qpicklineevent.h2
-rw-r--r--src/render/picking/qpickpointevent.h2
-rw-r--r--src/render/picking/qpicktriangleevent.h2
-rw-r--r--src/render/picking/qraycaster.h2
-rw-r--r--src/render/picking/qraycasterhit.h2
-rw-r--r--src/render/picking/qscreenraycaster.h2
-rw-r--r--src/render/qt3drender_global.h6
-rw-r--r--src/render/qt3drender_global_p.h2
-rw-r--r--src/render/raycasting/boundingsphere_p.h2
-rw-r--r--src/render/raycasting/qabstractcollisionqueryservice_p.h2
-rw-r--r--src/render/raycasting/qboundingvolume_p.h2
-rw-r--r--src/render/raycasting/qboundingvolumeprovider_p.h2
-rw-r--r--src/render/raycasting/qcollisionqueryresult_p.h2
-rw-r--r--src/render/raycasting/qray3d_p.h8
-rw-r--r--src/render/raycasting/qraycastingservice_p.h2
-rw-r--r--src/render/renderers/opengl/graphicshelpers/glfence_p.h73
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelperes2.cpp27
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelperes2_p.h6
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelperes3.cpp52
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelperes3_p.h6
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl2.cpp28
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl2_p.h6
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp32
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2_p.h6
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp32
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3_p.h6
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp35
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpergl4_p.h6
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelperinterface_p.h9
-rw-r--r--src/render/renderers/opengl/graphicshelpers/graphicshelpers.pri1
-rw-r--r--src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp29
-rw-r--r--src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h9
-rw-r--r--src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext.cpp23
-rw-r--r--src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext_p.h4
-rw-r--r--src/render/renderers/opengl/jobs/filtercompatibletechniquejob_p.h2
-rw-r--r--src/render/renderers/opengl/jobs/materialparametergathererjob_p.h2
-rw-r--r--src/render/renderers/opengl/jobs/renderviewjobutils.cpp12
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp162
-rw-r--r--src/render/renderers/opengl/renderer/renderer_p.h17
-rw-r--r--src/render/renderers/opengl/renderer/renderview.cpp5
-rw-r--r--src/render/renderers/opengl/renderer/renderview_p.h10
-rw-r--r--src/render/renderers/opengl/textures/gltexture.cpp260
-rw-r--r--src/render/renderers/opengl/textures/gltexture_p.h8
-rw-r--r--src/render/renderstates/qalphacoverage.h2
-rw-r--r--src/render/renderstates/qalphatest.h2
-rw-r--r--src/render/renderstates/qblendequation.h2
-rw-r--r--src/render/renderstates/qblendequation_p.h2
-rw-r--r--src/render/renderstates/qblendequationarguments.h2
-rw-r--r--src/render/renderstates/qblendequationarguments_p.h2
-rw-r--r--src/render/renderstates/qclipplane.h2
-rw-r--r--src/render/renderstates/qclipplane_p.h2
-rw-r--r--src/render/renderstates/qcolormask.h2
-rw-r--r--src/render/renderstates/qcolormask_p.h2
-rw-r--r--src/render/renderstates/qcullface.h2
-rw-r--r--src/render/renderstates/qcullface_p.h2
-rw-r--r--src/render/renderstates/qdepthtest.h2
-rw-r--r--src/render/renderstates/qdepthtest_p.h2
-rw-r--r--src/render/renderstates/qdithering.h2
-rw-r--r--src/render/renderstates/qfrontface.h2
-rw-r--r--src/render/renderstates/qfrontface_p.h2
-rw-r--r--src/render/renderstates/qlinewidth.h2
-rw-r--r--src/render/renderstates/qmultisampleantialiasing.h2
-rw-r--r--src/render/renderstates/qnodepthmask.h2
-rw-r--r--src/render/renderstates/qpointsize.h2
-rw-r--r--src/render/renderstates/qpointsize_p.h2
-rw-r--r--src/render/renderstates/qpolygonoffset.h2
-rw-r--r--src/render/renderstates/qpolygonoffset_p.h2
-rw-r--r--src/render/renderstates/qrenderstate.h2
-rw-r--r--src/render/renderstates/qrenderstate_p.h2
-rw-r--r--src/render/renderstates/qscissortest.h2
-rw-r--r--src/render/renderstates/qscissortest_p.h2
-rw-r--r--src/render/renderstates/qseamlesscubemap.h2
-rw-r--r--src/render/renderstates/qstencilmask.h2
-rw-r--r--src/render/renderstates/qstencilmask_p.h2
-rw-r--r--src/render/renderstates/qstenciloperation.h2
-rw-r--r--src/render/renderstates/qstenciloperation_p.h2
-rw-r--r--src/render/renderstates/qstenciloperationarguments.h2
-rw-r--r--src/render/renderstates/qstenciloperationarguments_p.h2
-rw-r--r--src/render/renderstates/qstenciltest.h2
-rw-r--r--src/render/renderstates/qstenciltest_p.h2
-rw-r--r--src/render/renderstates/qstenciltestarguments.h2
-rw-r--r--src/render/renderstates/qstenciltestarguments_p.h2
-rw-r--r--src/render/texture/apitexturemanager_p.h14
-rw-r--r--src/render/texture/qabstracttexture.cpp114
-rw-r--r--src/render/texture/qabstracttexture.h16
-rw-r--r--src/render/texture/qabstracttexture_p.h8
-rw-r--r--src/render/texture/qabstracttextureimage.h2
-rw-r--r--src/render/texture/qabstracttextureimage_p.h2
-rw-r--r--src/render/texture/qpaintedtextureimage.h2
-rw-r--r--src/render/texture/qpaintedtextureimage_p.h2
-rw-r--r--src/render/texture/qtexture.cpp63
-rw-r--r--src/render/texture/qtexture.h41
-rw-r--r--src/render/texture/qtexture_p.h2
-rw-r--r--src/render/texture/qtexturedata.h2
-rw-r--r--src/render/texture/qtexturegenerator.h2
-rw-r--r--src/render/texture/qtextureimage.h2
-rw-r--r--src/render/texture/qtextureimage_p.h2
-rw-r--r--src/render/texture/qtextureimagedata.h2
-rw-r--r--src/render/texture/qtextureimagedatagenerator.h2
-rw-r--r--src/render/texture/qtexturewrapmode.h2
-rw-r--r--src/render/texture/texture.cpp61
-rw-r--r--src/render/texture/texture_p.h14
306 files changed, 4050 insertions, 797 deletions
diff --git a/src/render/backend/abstractrenderer_p.h b/src/render/backend/abstractrenderer_p.h
index cd662b84d..69e71dece 100644
--- a/src/render/backend/abstractrenderer_p.h
+++ b/src/render/backend/abstractrenderer_p.h
@@ -87,7 +87,7 @@ class BackendNode;
class OffscreenSurfaceHelper;
class Shader;
-class QT3DRENDERSHARED_PRIVATE_EXPORT AbstractRenderer
+class Q_3DRENDERSHARED_PRIVATE_EXPORT AbstractRenderer
{
public:
virtual ~AbstractRenderer() {}
@@ -155,6 +155,7 @@ public:
virtual bool shouldRender() = 0;
virtual void skipNextFrame() = 0;
+ virtual QVector<Qt3DCore::QAspectJobPtr> preRenderingJobs() = 0;
virtual QVector<Qt3DCore::QAspectJobPtr> renderBinJobs() = 0;
virtual Qt3DCore::QAspectJobPtr pickBoundingVolumeJob() = 0;
virtual Qt3DCore::QAspectJobPtr rayCastingJob() = 0;
diff --git a/src/render/backend/backendnode_p.h b/src/render/backend/backendnode_p.h
index 8db68b11d..f94033c1a 100644
--- a/src/render/backend/backendnode_p.h
+++ b/src/render/backend/backendnode_p.h
@@ -64,7 +64,7 @@ namespace Render {
class RenderBackendResourceAccessor;
-class QT3DRENDERSHARED_PRIVATE_EXPORT BackendNode : public Qt3DCore::QBackendNode
+class Q_3DRENDERSHARED_PRIVATE_EXPORT BackendNode : public Qt3DCore::QBackendNode
{
public:
BackendNode(Qt3DCore::QBackendNode::Mode mode = ReadOnly);
diff --git a/src/render/backend/cameralens.cpp b/src/render/backend/cameralens.cpp
index b540b24c8..42635bad7 100644
--- a/src/render/backend/cameralens.cpp
+++ b/src/render/backend/cameralens.cpp
@@ -145,6 +145,7 @@ void CameraLens::computeSceneBoundingVolume(QNodeId entityId,
ComputeFilteredBoundingVolumeJobPtr job(new GetBoundingVolumeWithoutCameraJob(this, commandId));
job->addDependency(m_renderer->expandBoundingVolumeJob());
job->setRoot(root);
+ job->setManagers(nodeManagers);
job->ignoreSubTree(camNode);
m_renderAspect->scheduleSingleShotJob(job);
}
diff --git a/src/render/backend/cameralens_p.h b/src/render/backend/cameralens_p.h
index d00358fb8..80a1715cf 100644
--- a/src/render/backend/cameralens_p.h
+++ b/src/render/backend/cameralens_p.h
@@ -80,7 +80,7 @@ private:
QRenderAspect *m_renderAspect;
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT CameraLens : public BackendNode
+class Q_3DRENDERSHARED_PRIVATE_EXPORT CameraLens : public BackendNode
{
public:
CameraLens();
diff --git a/src/render/backend/computecommand.cpp b/src/render/backend/computecommand.cpp
index 2b23df9aa..349941965 100644
--- a/src/render/backend/computecommand.cpp
+++ b/src/render/backend/computecommand.cpp
@@ -40,7 +40,6 @@
#include "computecommand_p.h"
#include <Qt3DCore/qnode.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
-#include <Qt3DRender/qcomputecommand.h>
#include <Qt3DRender/private/qcomputecommand_p.h>
#include <Qt3DRender/private/abstractrenderer_p.h>
@@ -51,7 +50,9 @@ namespace Qt3DRender {
namespace Render {
ComputeCommand::ComputeCommand()
- : BackendNode(ReadOnly)
+ : BackendNode(ReadWrite)
+ , m_frameCount(0)
+ , m_runType(QComputeCommand::Continuous)
{
m_workGroups[0] = 1;
m_workGroups[1] = 1;
@@ -68,6 +69,8 @@ void ComputeCommand::cleanup()
m_workGroups[0] = 1;
m_workGroups[1] = 1;
m_workGroups[2] = 1;
+ m_frameCount = 0;
+ m_runType = QComputeCommand::Continuous;
}
void ComputeCommand::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
@@ -77,6 +80,8 @@ void ComputeCommand::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePt
m_workGroups[0] = data.workGroupX;
m_workGroups[1] = data.workGroupY;
m_workGroups[2] = data.workGroupZ;
+ m_runType = data.runType;
+ m_frameCount = data.frameCount;
if (m_renderer != nullptr)
BackendNode::markDirty(AbstractRenderer::ComputeDirty);
}
@@ -91,11 +96,30 @@ void ComputeCommand::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
m_workGroups[1] = propertyChange->value().toInt();
else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupZ"))
m_workGroups[2] = propertyChange->value().toInt();
- markDirty(AbstractRenderer::AllDirty);
+ else if (propertyChange->propertyName() == QByteArrayLiteral("frameCount"))
+ m_frameCount = propertyChange->value().toInt();
+ else if (propertyChange->propertyName() == QByteArrayLiteral("runType"))
+ m_runType = static_cast<QComputeCommand::RunType>(propertyChange->value().toInt());
+ markDirty(AbstractRenderer::ComputeDirty);
}
BackendNode::sceneChangeEvent(e);
}
+// Called from buildComputeRenderCommands in a job
+void ComputeCommand::updateFrameCount()
+{
+ // Disable frontend node when reaching 0
+ --m_frameCount;
+ if (m_frameCount <= 0) {
+ setEnabled(false);
+ auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
+ e->setPropertyName("enabled");
+ e->setValue(false);
+ notifyObservers(e);
+ }
+}
+
} // Render
} // Qt3DRender
diff --git a/src/render/backend/computecommand_p.h b/src/render/backend/computecommand_p.h
index fb8ca39ff..10e10fd25 100644
--- a/src/render/backend/computecommand_p.h
+++ b/src/render/backend/computecommand_p.h
@@ -52,6 +52,7 @@
//
#include <Qt3DRender/private/backendnode_p.h>
+#include <Qt3DRender/qcomputecommand.h>
QT_BEGIN_NAMESPACE
@@ -73,10 +74,17 @@ public:
inline int x() const Q_DECL_NOTHROW { return m_workGroups[0]; }
inline int y() const Q_DECL_NOTHROW { return m_workGroups[1]; }
inline int z() const Q_DECL_NOTHROW { return m_workGroups[2]; }
+ inline int frameCount() const Q_DECL_NOTHROW { return m_frameCount; }
+ inline QComputeCommand::RunType runType() const Q_DECL_NOTHROW { return m_runType; }
+
+ // Called from a job
+ void updateFrameCount();
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
int m_workGroups[3];
+ int m_frameCount;
+ QComputeCommand::RunType m_runType;
};
} // Render
diff --git a/src/render/backend/entity.cpp b/src/render/backend/entity.cpp
index d8d04aef1..bf128b508 100644
--- a/src/render/backend/entity.cpp
+++ b/src/render/backend/entity.cpp
@@ -289,6 +289,26 @@ QVector<Entity *> Entity::children() const
return childrenVector;
}
+void Entity::traverse(const std::function<void(Entity *)> &operation)
+{
+ operation(this);
+ for (const HEntity &handle : qAsConst(m_childrenHandles)) {
+ Entity *child = m_nodeManagers->renderNodesManager()->data(handle);
+ if (child != nullptr)
+ child->traverse(operation);
+ }
+}
+
+void Entity::traverse(const std::function<void(const Entity *)> &operation) const
+{
+ operation(this);
+ for (const HEntity &handle : m_childrenHandles) {
+ const Entity *child = m_nodeManagers->renderNodesManager()->data(handle);
+ if (child != nullptr)
+ child->traverse(operation);
+ }
+}
+
Matrix4x4 *Entity::worldTransform()
{
return m_nodeManagers->worldMatrixManager()->data(m_worldTransform);
diff --git a/src/render/backend/entity_p.h b/src/render/backend/entity_p.h
index afa7dbf23..b4c9541f2 100644
--- a/src/render/backend/entity_p.h
+++ b/src/render/backend/entity_p.h
@@ -107,6 +107,8 @@ public:
QVector<HEntity> childrenHandles() const { return m_childrenHandles; }
QVector<Entity *> children() const;
bool hasChildren() const { return !m_childrenHandles.empty(); }
+ void traverse(const std::function<void(Entity *)> &operation);
+ void traverse(const std::function<void(const Entity *)> &operation) const;
Matrix4x4 *worldTransform();
const Matrix4x4 *worldTransform() const;
@@ -220,25 +222,25 @@ private:
#define ENTITY_COMPONENT_TEMPLATE_SPECIALIZATION(Type, Handle) \
/* Handle */ \
template<> \
- QT3DRENDERSHARED_PRIVATE_EXPORT Handle Entity::componentHandle<Type>() const; \
+ Q_3DRENDERSHARED_PRIVATE_EXPORT Handle Entity::componentHandle<Type>() const; \
/* Component */ \
template<> \
- QT3DRENDERSHARED_PRIVATE_EXPORT Type *Entity::renderComponent<Type>() const; \
+ Q_3DRENDERSHARED_PRIVATE_EXPORT Type *Entity::renderComponent<Type>() const; \
/* Uuid */ \
template<> \
- QT3DRENDERSHARED_PRIVATE_EXPORT Qt3DCore::QNodeId Entity::componentUuid<Type>() const;
+ Q_3DRENDERSHARED_PRIVATE_EXPORT Qt3DCore::QNodeId Entity::componentUuid<Type>() const;
#define ENTITY_COMPONENT_LIST_TEMPLATE_SPECIALIZATION(Type, Handle) \
/* Handle */ \
template<> \
- QT3DRENDERSHARED_PRIVATE_EXPORT QVector<Handle> Entity::componentsHandle<Type>() const; \
+ Q_3DRENDERSHARED_PRIVATE_EXPORT QVector<Handle> Entity::componentsHandle<Type>() const; \
/* Component */ \
template<> \
- QT3DRENDERSHARED_PRIVATE_EXPORT QVector<Type *> Entity::renderComponents<Type>() const; \
+ Q_3DRENDERSHARED_PRIVATE_EXPORT QVector<Type *> Entity::renderComponents<Type>() const; \
/* Uuid */ \
template<> \
- QT3DRENDERSHARED_PRIVATE_EXPORT Qt3DCore::QNodeIdVector Entity::componentsUuid<Type>() const;
+ Q_3DRENDERSHARED_PRIVATE_EXPORT Qt3DCore::QNodeIdVector Entity::componentsUuid<Type>() const;
#define ENTITY_COMPONENT_TEMPLATE_IMPL(Type, Handle, Manager, variable) \
/* Handle */ \
diff --git a/src/render/backend/entityaccumulator.cpp b/src/render/backend/entityaccumulator.cpp
new file mode 100644
index 000000000..f003420dd
--- /dev/null
+++ b/src/render/backend/entityaccumulator.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "entityaccumulator_p.h"
+#include "entityvisitor_p.h"
+
+QT_USE_NAMESPACE
+using namespace Qt3DRender::Render;
+
+namespace {
+
+class Accumulator : public EntityVisitor
+{
+public:
+ Accumulator(std::function<bool(Entity *)> predicate, NodeManagers *manager)
+ : EntityVisitor(manager)
+ , m_predicate(predicate)
+ {
+ }
+
+ EntityVisitor::Operation visit(Entity *entity) override {
+ if (m_predicate(entity))
+ m_entities << entity;
+ return Continue;
+ }
+
+ QVector<Entity *> m_entities;
+
+private:
+ std::function<bool(Entity *)> m_predicate;
+};
+
+}
+
+EntityAccumulator::EntityAccumulator(NodeManagers *manager)
+ : m_manager(manager)
+ , m_predicate([](Entity*) { return true; })
+{
+
+}
+
+EntityAccumulator::EntityAccumulator(std::function<bool (Entity *)> predicate, NodeManagers *manager)
+ : m_manager(manager)
+ , m_predicate(predicate)
+{
+
+}
+
+/*!
+ * \internal
+ *
+ * Call this to traverse the scene graph and return all entities for
+ * which the predicate returns true.
+ *
+ * Can be useful to get all the entities that contain a specific type
+ * of component.
+ */
+QVector<Entity *> EntityAccumulator::apply(Entity *root) const
+{
+ Accumulator a(m_predicate, m_manager);
+ a.apply(root);
+ return a.m_entities;
+}
diff --git a/src/render/backend/entityaccumulator_p.h b/src/render/backend/entityaccumulator_p.h
new file mode 100644
index 000000000..69656815f
--- /dev/null
+++ b/src/render/backend/entityaccumulator_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_ENTITYACCUMULATOR_H
+#define QT3DRENDER_RENDER_ENTITYACCUMULATOR_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/private/entity_p.h>
+#include <Qt3DRender/private/qt3drender_global_p.h>
+#include <QVector>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+class NodeManagers;
+
+class Q_3DRENDERSHARED_PRIVATE_EXPORT EntityAccumulator
+{
+public:
+ EntityAccumulator(NodeManagers *manager);
+ EntityAccumulator(std::function<bool(Entity*)> predicate, NodeManagers *manager);
+
+ QVector<Entity *> apply(Entity *root) const;
+
+private:
+ NodeManagers *m_manager;
+ std::function<bool(Entity *)> m_predicate;
+};
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_ENTITYACCUMULATOR_H
diff --git a/src/render/backend/entityvisitor.cpp b/src/render/backend/entityvisitor.cpp
new file mode 100644
index 000000000..87dd353bb
--- /dev/null
+++ b/src/render/backend/entityvisitor.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "entityvisitor_p.h"
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
+
+QT_USE_NAMESPACE
+using namespace Qt3DRender::Render;
+
+EntityVisitor::EntityVisitor(NodeManagers *manager)
+ : m_manager(manager)
+ , m_pruneDisabled(false)
+{
+
+}
+
+EntityVisitor::~EntityVisitor() = default;
+
+/*!
+ * \internal
+ *
+ * Override in derived class to do work on the current entity
+ *
+ * Return value (Continue, Prune, Stop) will affect traversal
+ */
+EntityVisitor::Operation EntityVisitor::visit(Entity *entity) {
+ // return false to stop traversal
+ if (!entity)
+ return Stop;
+ return Continue;
+}
+
+/*!
+ * \internal
+ *
+ * If true, disabled entities and all their children will be ignored
+ * during traversal
+ *
+ */
+bool EntityVisitor::pruneDisabled() const
+{
+ return m_pruneDisabled;
+}
+
+void EntityVisitor::setPruneDisabled(bool pruneDisabled)
+{
+ m_pruneDisabled = pruneDisabled;
+}
+
+/*!
+ * \internal
+ *
+ * Call on the root of the tree that should be traversed.
+ * Returns false if any visit resulted in Stop
+ */
+bool EntityVisitor::apply(Entity *root) {
+ if (!root)
+ return false;
+ if (m_pruneDisabled && !root->isEnabled())
+ return true;
+
+ const auto op = visit(root);
+ if (op == Stop)
+ return false;
+ if (op == Prune)
+ return true;
+
+ const auto childrenHandles = root->childrenHandles();
+ for (const HEntity &handle : childrenHandles) {
+ Entity *child = m_manager->renderNodesManager()->data(handle);
+ if (child != nullptr && !apply(child))
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/render/backend/entityvisitor_p.h b/src/render/backend/entityvisitor_p.h
new file mode 100644
index 000000000..2f4f1c813
--- /dev/null
+++ b/src/render/backend/entityvisitor_p.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_ENTITYVISITOR_H
+#define QT3DRENDER_RENDER_ENTITYVISITOR_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+namespace Render {
+
+class Entity;
+class NodeManagers;
+
+class Q_AUTOTEST_EXPORT EntityVisitor
+{
+public:
+ enum Operation {
+ Continue, //! continue traversal
+ Prune, //! don't traverse children
+ Stop //! abort traversal
+ };
+
+ EntityVisitor(NodeManagers *manager);
+ virtual ~EntityVisitor();
+
+ virtual Operation visit(Entity *entity = nullptr);
+
+ bool pruneDisabled() const;
+ void setPruneDisabled(bool pruneDisabled);
+
+ bool apply(Entity *root);
+
+protected:
+ NodeManagers *m_manager;
+
+private:
+ bool m_pruneDisabled;
+};
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_ENTITYVISITOR_H
diff --git a/src/render/backend/managers_p.h b/src/render/backend/managers_p.h
index fc2a0b479..f28dbe768 100644
--- a/src/render/backend/managers_p.h
+++ b/src/render/backend/managers_p.h
@@ -72,6 +72,7 @@
#include <Qt3DRender/private/shaderdata_p.h>
#include <Qt3DRender/private/handle_types_p.h>
#include <Qt3DRender/private/glbuffer_p.h>
+#include <Qt3DRender/private/glfence_p.h>
#include <Qt3DRender/private/textureimage_p.h>
#include <Qt3DRender/private/attribute_p.h>
#include <Qt3DRender/private/geometry_p.h>
@@ -317,6 +318,10 @@ class GLBufferManager : public Qt3DCore::QResourceManager<
{
};
+class GLFenceManager : public QHash<Qt3DCore::QNodeId, GLFence>
+{
+};
+
class TextureImageManager : public Qt3DCore::QResourceManager<
TextureImage,
Qt3DCore::QNodeId,
diff --git a/src/render/backend/nodemanagers.cpp b/src/render/backend/nodemanagers.cpp
index 5db35082d..584ddd65c 100644
--- a/src/render/backend/nodemanagers.cpp
+++ b/src/render/backend/nodemanagers.cpp
@@ -85,6 +85,7 @@ NodeManagers::NodeManagers()
, m_parameterManager(new ParameterManager())
, m_shaderDataManager(new ShaderDataManager())
, m_glBufferManager(new GLBufferManager())
+ , m_glFenceManager(new GLFenceManager())
, m_bufferManager(new BufferManager())
, m_attributeManager(new AttributeManager())
, m_geometryManager(new GeometryManager())
@@ -128,6 +129,7 @@ NodeManagers::~NodeManagers()
delete m_parameterManager;
delete m_shaderDataManager;
delete m_glBufferManager;
+ delete m_glFenceManager;
delete m_textureImageManager;
delete m_bufferManager;
delete m_attributeManager;
diff --git a/src/render/backend/nodemanagers_p.h b/src/render/backend/nodemanagers_p.h
index 9277d4385..4ef1f4927 100644
--- a/src/render/backend/nodemanagers_p.h
+++ b/src/render/backend/nodemanagers_p.h
@@ -87,6 +87,7 @@ class AttachmentManager;
class ParameterManager;
class ShaderDataManager;
class GLBufferManager;
+class GLFenceManager;
class TextureImageManager;
class FilterKeyManager;
class FrameGraphManager;
@@ -145,7 +146,7 @@ class OpenGLVertexArrayObject;
class ResourceAccessor;
-class QT3DRENDERSHARED_PRIVATE_EXPORT NodeManagers
+class Q_3DRENDERSHARED_PRIVATE_EXPORT NodeManagers
{
public:
NodeManagers();
@@ -210,6 +211,7 @@ public:
inline ParameterManager *parameterManager() const Q_DECL_NOEXCEPT { return m_parameterManager; }
inline ShaderDataManager *shaderDataManager() const Q_DECL_NOEXCEPT { return m_shaderDataManager; }
inline GLBufferManager *glBufferManager() const Q_DECL_NOEXCEPT { return m_glBufferManager; }
+ inline GLFenceManager *glFenceManager() const Q_DECL_NOEXCEPT { return m_glFenceManager; }
inline TextureImageManager *textureImageManager() const Q_DECL_NOEXCEPT { return m_textureImageManager; }
inline BufferManager *bufferManager() const Q_DECL_NOEXCEPT { return m_bufferManager; }
inline AttributeManager *attributeManager() const Q_DECL_NOEXCEPT { return m_attributeManager; }
@@ -255,6 +257,7 @@ private:
ParameterManager *m_parameterManager;
ShaderDataManager *m_shaderDataManager;
GLBufferManager *m_glBufferManager;
+ GLFenceManager *m_glFenceManager;
BufferManager *m_bufferManager;
AttributeManager *m_attributeManager;
GeometryManager *m_geometryManager;
@@ -276,97 +279,97 @@ private:
// Specializations
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT CameraManager *NodeManagers::manager<CameraLens>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT CameraManager *NodeManagers::manager<CameraLens>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT EntityManager *NodeManagers::manager<Entity>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT EntityManager *NodeManagers::manager<Entity>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT MaterialManager *NodeManagers::manager<Material>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT MaterialManager *NodeManagers::manager<Material>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT MatrixManager *NodeManagers::manager<QMatrix4x4*>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT MatrixManager *NodeManagers::manager<QMatrix4x4*>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT VAOManager *NodeManagers::manager<OpenGLVertexArrayObject>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT VAOManager *NodeManagers::manager<OpenGLVertexArrayObject>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ShaderManager *NodeManagers::manager<Shader>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderManager *NodeManagers::manager<Shader>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilderManager *NodeManagers::manager<ShaderBuilder>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilderManager *NodeManagers::manager<ShaderBuilder>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT TechniqueManager *NodeManagers::manager<Technique>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT TechniqueManager *NodeManagers::manager<Technique>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT EffectManager *NodeManagers::manager<Effect>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT EffectManager *NodeManagers::manager<Effect>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT RenderPassManager *NodeManagers::manager<RenderPass>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT RenderPassManager *NodeManagers::manager<RenderPass>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT TextureManager *NodeManagers::manager<Texture>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT TextureManager *NodeManagers::manager<Texture>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT TextureDataManager *NodeManagers::manager<QTextureImageData>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT TextureDataManager *NodeManagers::manager<QTextureImageData>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT LayerManager *NodeManagers::manager<Layer>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT LayerManager *NodeManagers::manager<Layer>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT LevelOfDetailManager *NodeManagers::manager<LevelOfDetail>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT LevelOfDetailManager *NodeManagers::manager<LevelOfDetail>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT FilterKeyManager *NodeManagers::manager<FilterKey>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT FilterKeyManager *NodeManagers::manager<FilterKey>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT FrameGraphManager *NodeManagers::manager<FrameGraphNode*>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT FrameGraphManager *NodeManagers::manager<FrameGraphNode*>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT TransformManager *NodeManagers::manager<Transform>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT TransformManager *NodeManagers::manager<Transform>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT RenderTargetManager *NodeManagers::manager<RenderTarget>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT RenderTargetManager *NodeManagers::manager<RenderTarget>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT SceneManager *NodeManagers::manager<Scene>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT SceneManager *NodeManagers::manager<Scene>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT AttachmentManager *NodeManagers::manager<RenderTargetOutput>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT AttachmentManager *NodeManagers::manager<RenderTargetOutput>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ParameterManager *NodeManagers::manager<Parameter>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ParameterManager *NodeManagers::manager<Parameter>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ShaderDataManager *NodeManagers::manager<ShaderData>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderDataManager *NodeManagers::manager<ShaderData>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT GLBufferManager *NodeManagers::manager<GLBuffer>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT GLBufferManager *NodeManagers::manager<GLBuffer>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT TextureImageManager *NodeManagers::manager<TextureImage>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT TextureImageManager *NodeManagers::manager<TextureImage>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT BufferManager *NodeManagers::manager<Buffer>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT BufferManager *NodeManagers::manager<Buffer>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT AttributeManager *NodeManagers::manager<Attribute>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT AttributeManager *NodeManagers::manager<Attribute>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT GeometryManager *NodeManagers::manager<Geometry>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT GeometryManager *NodeManagers::manager<Geometry>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT GeometryRendererManager *NodeManagers::manager<GeometryRenderer>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT GeometryRendererManager *NodeManagers::manager<GeometryRenderer>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ObjectPickerManager *NodeManagers::manager<ObjectPicker>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ObjectPickerManager *NodeManagers::manager<ObjectPicker>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT RayCasterManager *NodeManagers::manager<RayCaster>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT RayCasterManager *NodeManagers::manager<RayCaster>() const Q_DECL_NOEXCEPT;
//template<>
-//QT3DRENDERSHARED_PRIVATE_EXPORT BoundingVolumeDebugManager *NodeManagers::manager<BoundingVolumeDebug>() const Q_DECL_NOEXCEPT;
+//Q_3DRENDERSHARED_PRIVATE_EXPORT BoundingVolumeDebugManager *NodeManagers::manager<BoundingVolumeDebug>() const Q_DECL_NOEXCEPT;
template<>
LightManager *NodeManagers::manager<Light>() const Q_DECL_NOEXCEPT;
@@ -375,19 +378,19 @@ template<>
EnvironmentLightManager *NodeManagers::manager<EnvironmentLight>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ComputeCommandManager *NodeManagers::manager<ComputeCommand>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ComputeCommandManager *NodeManagers::manager<ComputeCommand>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT RenderStateManager *NodeManagers::manager<RenderStateNode>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT RenderStateManager *NodeManagers::manager<RenderStateNode>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT ArmatureManager *NodeManagers::manager<Armature>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT ArmatureManager *NodeManagers::manager<Armature>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT SkeletonManager *NodeManagers::manager<Skeleton>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT SkeletonManager *NodeManagers::manager<Skeleton>() const Q_DECL_NOEXCEPT;
template<>
-QT3DRENDERSHARED_PRIVATE_EXPORT JointManager *NodeManagers::manager<Joint>() const Q_DECL_NOEXCEPT;
+Q_3DRENDERSHARED_PRIVATE_EXPORT JointManager *NodeManagers::manager<Joint>() const Q_DECL_NOEXCEPT;
} // Render
diff --git a/src/render/backend/platformsurfacefilter_p.h b/src/render/backend/platformsurfacefilter_p.h
index 425ef303e..4fb43bae1 100644
--- a/src/render/backend/platformsurfacefilter_p.h
+++ b/src/render/backend/platformsurfacefilter_p.h
@@ -108,7 +108,7 @@ private:
void markSurfaceAsValid();
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT SurfaceLocker
+class Q_3DRENDERSHARED_PRIVATE_EXPORT SurfaceLocker
{
public:
explicit SurfaceLocker(QSurface *surface);
diff --git a/src/render/backend/render-backend.pri b/src/render/backend/render-backend.pri
index 352de3be5..6b60dfcda 100644
--- a/src/render/backend/render-backend.pri
+++ b/src/render/backend/render-backend.pri
@@ -11,6 +11,8 @@ HEADERS += \
$$PWD/platformsurfacefilter_p.h \
$$PWD/cameralens_p.h \
$$PWD/entity_p.h \
+ $$PWD/entityvisitor_p.h \
+ $$PWD/entityaccumulator_p.h \
$$PWD/layer_p.h \
$$PWD/levelofdetail_p.h \
$$PWD/nodefunctor_p.h \
@@ -44,6 +46,8 @@ SOURCES += \
$$PWD/platformsurfacefilter.cpp \
$$PWD/cameralens.cpp \
$$PWD/entity.cpp \
+ $$PWD/entityvisitor.cpp \
+ $$PWD/entityaccumulator.cpp \
$$PWD/layer.cpp \
$$PWD/levelofdetail.cpp \
$$PWD/transform.cpp \
diff --git a/src/render/backend/resourceaccessor_p.h b/src/render/backend/resourceaccessor_p.h
index 627efcb0d..ec53a04a2 100644
--- a/src/render/backend/resourceaccessor_p.h
+++ b/src/render/backend/resourceaccessor_p.h
@@ -83,7 +83,7 @@ public:
virtual bool accessResource(ResourceType type, Qt3DCore::QNodeId nodeId, void **handle, QMutex **lock) = 0;
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT ResourceAccessor : public RenderBackendResourceAccessor
+class Q_3DRENDERSHARED_PRIVATE_EXPORT ResourceAccessor : public RenderBackendResourceAccessor
{
public:
ResourceAccessor(NodeManagers *mgr);
diff --git a/src/render/backend/trianglesvisitor_p.h b/src/render/backend/trianglesvisitor_p.h
index ee206f1c9..d05eaef09 100644
--- a/src/render/backend/trianglesvisitor_p.h
+++ b/src/render/backend/trianglesvisitor_p.h
@@ -92,7 +92,7 @@ protected:
Qt3DCore::QNodeId m_nodeId;
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT CoordinateReader
+class Q_3DRENDERSHARED_PRIVATE_EXPORT CoordinateReader
{
public:
explicit CoordinateReader(NodeManagers *manager)
diff --git a/src/render/framegraph/blitframebuffer.cpp b/src/render/framegraph/blitframebuffer.cpp
index b9ff4bea3..342594baf 100644
--- a/src/render/framegraph/blitframebuffer.cpp
+++ b/src/render/framegraph/blitframebuffer.cpp
@@ -66,20 +66,26 @@ void BlitFramebuffer::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("sourceRenderTarget")) {
m_sourceRenderTargetId = propertyChange->value().value<QNodeId>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("destinationRenderTarget")) {
m_destinationRenderTargetId = propertyChange->value().value<QNodeId>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("sourceRect")) {
m_sourceRect = propertyChange->value().toRect();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("destinationRect")) {
m_destinationRect = propertyChange->value().toRect();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("sourceAttachmentPoint")) {
m_sourceAttachmentPoint = propertyChange->value().value<Qt3DRender::QRenderTargetOutput::AttachmentPoint>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("destinationAttachmentPoint")) {
m_destinationAttachmentPoint = propertyChange->value().value<Qt3DRender::QRenderTargetOutput::AttachmentPoint>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("interpolationMethod")) {
m_interpolationMethod = propertyChange->value().value<QBlitFramebuffer::InterpolationMethod>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
- markDirty(AbstractRenderer::AllDirty);
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/cameraselectornode.cpp b/src/render/framegraph/cameraselectornode.cpp
index e21fdf02c..357611c7c 100644
--- a/src/render/framegraph/cameraselectornode.cpp
+++ b/src/render/framegraph/cameraselectornode.cpp
@@ -70,9 +70,10 @@ void CameraSelector::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
qCDebug(Render::Framegraph) << Q_FUNC_INFO;
if (e->type() == PropertyUpdated) {
QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("camera"))
+ if (propertyChange->propertyName() == QByteArrayLiteral("camera")) {
m_cameraUuid = propertyChange->value().value<QNodeId>();
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/clearbuffers.cpp b/src/render/framegraph/clearbuffers.cpp
index d730123c3..ab6225a4b 100644
--- a/src/render/framegraph/clearbuffers.cpp
+++ b/src/render/framegraph/clearbuffers.cpp
@@ -80,17 +80,21 @@ void ClearBuffers::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("buffers")) {
m_type = static_cast<QClearBuffers::BufferType>(propertyChange->value().toInt());
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("clearColor")) {
m_clearColorAsColor = propertyChange->value().value<QColor>();
m_clearColor = vec4dFromColor(m_clearColorAsColor);
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("clearDepthValue")) {
m_clearDepthValue = propertyChange->value().toFloat();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("clearStencilValue")) {
m_clearStencilValue = propertyChange->value().toInt();
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("colorBuffer")) {
m_colorBufferId = propertyChange->value().value<QNodeId>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
- markDirty(AbstractRenderer::AllDirty);
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/dispatchcompute.cpp b/src/render/framegraph/dispatchcompute.cpp
index 6ffb42e71..f7e9dcff4 100644
--- a/src/render/framegraph/dispatchcompute.cpp
+++ b/src/render/framegraph/dispatchcompute.cpp
@@ -80,13 +80,16 @@ void DispatchCompute::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
if (e->type() == Qt3DCore::PropertyUpdated) {
Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("workGroupX"))
+ if (propertyChange->propertyName() == QByteArrayLiteral("workGroupX")) {
m_workGroups[0] = propertyChange->value().toInt();
- else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupY"))
+ markDirty(AbstractRenderer::FrameGraphDirty|AbstractRenderer::ComputeDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupY")) {
m_workGroups[1] = propertyChange->value().toInt();
- else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupZ"))
+ markDirty(AbstractRenderer::FrameGraphDirty|AbstractRenderer::ComputeDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupZ")) {
m_workGroups[2] = propertyChange->value().toInt();
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty|AbstractRenderer::ComputeDirty);
+ }
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/framegraph.pri b/src/render/framegraph/framegraph.pri
index 9784a193c..b969c85e5 100644
--- a/src/render/framegraph/framegraph.pri
+++ b/src/render/framegraph/framegraph.pri
@@ -58,7 +58,13 @@ HEADERS += \
$$PWD/proximityfilter_p.h \
$$PWD/qblitframebuffer.h \
$$PWD/qblitframebuffer_p.h \
- $$PWD/blitframebuffer_p.h
+ $$PWD/blitframebuffer_p.h \
+ $$PWD/qsetfence.h \
+ $$PWD/qwaitfence.h \
+ $$PWD/qwaitfence_p.h \
+ $$PWD/qsetfence_p.h \
+ $$PWD/setfence_p.h \
+ $$PWD/waitfence_p.h
SOURCES += \
$$PWD/cameraselectornode.cpp \
@@ -100,4 +106,8 @@ SOURCES += \
$$PWD/qproximityfilter.cpp \
$$PWD/proximityfilter.cpp \
$$PWD/qblitframebuffer.cpp \
- $$PWD/blitframebuffer.cpp
+ $$PWD/blitframebuffer.cpp \
+ $$PWD/qsetfence.cpp \
+ $$PWD/qwaitfence.cpp \
+ $$PWD/setfence.cpp \
+ $$PWD/waitfence.cpp
diff --git a/src/render/framegraph/framegraphnode.cpp b/src/render/framegraph/framegraphnode.cpp
index 47e8ec91e..16f54df3b 100644
--- a/src/render/framegraph/framegraphnode.cpp
+++ b/src/render/framegraph/framegraphnode.cpp
@@ -133,19 +133,21 @@ void FrameGraphNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
switch (e->type()) {
case Qt3DCore::PropertyUpdated: {
- auto change = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (change->propertyName() == QByteArrayLiteral("parentFrameGraphUpdated")) {
- auto newParent = change->value().value<Qt3DCore::QNodeId>();
+ Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
+ if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) {
+ d_func()->m_enabled = propertyChange->value().toBool();
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("parentFrameGraphUpdated")) {
+ auto newParent = propertyChange->value().value<Qt3DCore::QNodeId>();
setParentId(newParent);
- }
+ markDirty(AbstractRenderer::AllDirty);
+ }
break;
}
default:
+ markDirty(AbstractRenderer::AllDirty);
break;
}
-
- markDirty(AbstractRenderer::AllDirty);
- BackendNode::sceneChangeEvent(e);
}
void FrameGraphNode::cleanup()
diff --git a/src/render/framegraph/framegraphnode_p.h b/src/render/framegraph/framegraphnode_p.h
index 0efd391c7..6aa3b3d6d 100644
--- a/src/render/framegraph/framegraphnode_p.h
+++ b/src/render/framegraph/framegraphnode_p.h
@@ -101,7 +101,9 @@ public:
BufferCapture,
MemoryBarrier,
ProximityFilter,
- BlitFramebuffer
+ BlitFramebuffer,
+ SetFence,
+ WaitFence
};
FrameGraphNodeType nodeType() const { return m_nodeType; }
diff --git a/src/render/framegraph/layerfilternode.cpp b/src/render/framegraph/layerfilternode.cpp
index 4b6842015..f9881be0d 100644
--- a/src/render/framegraph/layerfilternode.cpp
+++ b/src/render/framegraph/layerfilternode.cpp
@@ -73,7 +73,7 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeAddedChange>(e);
if (change->propertyName() == QByteArrayLiteral("layer"))
m_layerIds.append(change->addedNodeId());
- markDirty(AbstractRenderer::LayersDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty);
break;
}
@@ -81,7 +81,7 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeRemovedChange>(e);
if (change->propertyName() == QByteArrayLiteral("layer"))
m_layerIds.removeOne(change->removedNodeId());
- markDirty(AbstractRenderer::LayersDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty);
break;
}
@@ -89,6 +89,7 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyUpdatedChange>(e);
if (change->propertyName() == QByteArrayLiteral("filterMode")) {
m_filterMode = static_cast<QLayerFilter::FilterMode>(change->value().value<int>());
+ markDirty(AbstractRenderer::FrameGraphDirty|AbstractRenderer::LayersDirty);
break;
}
}
diff --git a/src/render/framegraph/memorybarrier.cpp b/src/render/framegraph/memorybarrier.cpp
index ee8f156e3..59b3071ab 100644
--- a/src/render/framegraph/memorybarrier.cpp
+++ b/src/render/framegraph/memorybarrier.cpp
@@ -68,7 +68,7 @@ void MemoryBarrier::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("waitOperations")) {
m_waitOperations = propertyChange->value().value<QMemoryBarrier::Operations>();
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
}
FrameGraphNode::sceneChangeEvent(e);
diff --git a/src/render/framegraph/proximityfilter.cpp b/src/render/framegraph/proximityfilter.cpp
index aed19828b..cdfd7e51e 100644
--- a/src/render/framegraph/proximityfilter.cpp
+++ b/src/render/framegraph/proximityfilter.cpp
@@ -67,11 +67,13 @@ void ProximityFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
qCDebug(Render::Framegraph) << Q_FUNC_INFO;
if (e->type() == Qt3DCore::PropertyUpdated) {
Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("entity"))
+ if (propertyChange->propertyName() == QByteArrayLiteral("entity")) {
m_entityId = propertyChange->value().value<Qt3DCore::QNodeId>();
- else if (propertyChange->propertyName() == QByteArrayLiteral("distanceThreshold"))
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("distanceThreshold")) {
m_distanceThreshold = propertyChange->value().toFloat();
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/qblitframebuffer.cpp b/src/render/framegraph/qblitframebuffer.cpp
index b0a29eab8..d0e1bdbf3 100644
--- a/src/render/framegraph/qblitframebuffer.cpp
+++ b/src/render/framegraph/qblitframebuffer.cpp
@@ -64,8 +64,62 @@ namespace Qt3DRender {
\note In practice the QBlitFramebuffer node will often be used in
combination with QNoDraw since a blit should not involve issuing draw calls
for any entities.
+
+*/
+/*!
+ \enum Qt3DRender::QBlitFramebuffer::InterpolationMethod
+
+ Specifies the interpolation applied if the image is stretched.
+
+*/
+/*!
+ \property Qt3DRender::QBlitFramebuffer::destination
+
+ Specifies the destination render target. When not set, the destination
+ is assumed to be the default framebuffer (i.e. the backbuffer of
+ the current surface), if there is one.
+
+ \note the source and destination must not refer to the same render
+ target.
+*/
+/*!
+
+ \property Qt3DRender::QBlitFramebuffer::destinationAttachmentPoint
+
+ Specifies the target attachment point.
+*/
+
+/*!
+ \property Qt3DRender::QBlitFramebuffer::destinationRect
+
+ Specifies the destination rectangle. The coordinates are assumed to follow
+ the normal Qt coordinate system, meaning Y runs from top to bottom.
+*/
+
+/*!
+ \property Qt3DRender::QBlitFramebuffer::source
+
+ Specifies the source render target. When not set, the source is assumed to
+ be the default framebuffer (i.e. the backbuffer of the current surface), if
+ there is one.
+
+ \note the source and destination must not refer to the same render target.
+
+*/
+/*!
+ \property Qt3DRender::QBlitFramebuffer::sourceAttachmentPoint
+
+ Specifies the source attachment point.
+
+*/
+/*!
+ \property Qt3DRender::QBlitFramebuffer::sourceRect
+
+ Specifies the source rectangle. The coordinates are assumed to follow the
+ normal Qt coordinate system, meaning Y runs from top to bottom.
*/
+
/*!
\qmltype BlitFramebuffer
\inqmlmodule Qt3D.Render
diff --git a/src/render/framegraph/qblitframebuffer.h b/src/render/framegraph/qblitframebuffer.h
index 77b74ab53..79c216d24 100644
--- a/src/render/framegraph/qblitframebuffer.h
+++ b/src/render/framegraph/qblitframebuffer.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QBlitFramebufferPrivate;
class QRenderTarget;
-class QT3DRENDERSHARED_EXPORT QBlitFramebuffer : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QBlitFramebuffer : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QRenderTarget *source READ source WRITE setSource NOTIFY sourceChanged)
diff --git a/src/render/framegraph/qbuffercapture.h b/src/render/framegraph/qbuffercapture.h
index ab8c7d2c2..e5073a308 100644
--- a/src/render/framegraph/qbuffercapture.h
+++ b/src/render/framegraph/qbuffercapture.h
@@ -51,7 +51,7 @@ namespace Qt3DRender
class QBufferCapturePrivate;
-class QT3DRENDERSHARED_EXPORT QBufferCapture : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QBufferCapture : public QFrameGraphNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qcameraselector.h b/src/render/framegraph/qcameraselector.h
index 9aff269ca..861948d94 100644
--- a/src/render/framegraph/qcameraselector.h
+++ b/src/render/framegraph/qcameraselector.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QCameraSelectorPrivate;
-class QT3DRENDERSHARED_EXPORT QCameraSelector : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QCameraSelector : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(Qt3DCore::QEntity *camera READ camera WRITE setCamera NOTIFY cameraChanged)
diff --git a/src/render/framegraph/qclearbuffers.h b/src/render/framegraph/qclearbuffers.h
index 7077b3f24..441a83e78 100644
--- a/src/render/framegraph/qclearbuffers.h
+++ b/src/render/framegraph/qclearbuffers.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QClearBuffersPrivate;
-class QT3DRENDERSHARED_EXPORT QClearBuffers : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QClearBuffers : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(BufferType buffers READ buffers WRITE setBuffers NOTIFY buffersChanged)
diff --git a/src/render/framegraph/qdispatchcompute.h b/src/render/framegraph/qdispatchcompute.h
index 417796b61..dd6efb3ec 100644
--- a/src/render/framegraph/qdispatchcompute.h
+++ b/src/render/framegraph/qdispatchcompute.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QDispatchComputePrivate;
-class QT3DRENDERSHARED_EXPORT QDispatchCompute : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QDispatchCompute : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(int workGroupX READ workGroupX WRITE setWorkGroupX NOTIFY workGroupXChanged)
diff --git a/src/render/framegraph/qframegraphnode.h b/src/render/framegraph/qframegraphnode.h
index 57f4da181..826f01a1e 100644
--- a/src/render/framegraph/qframegraphnode.h
+++ b/src/render/framegraph/qframegraphnode.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QFrameGraphNodePrivate;
-class QT3DRENDERSHARED_EXPORT QFrameGraphNode : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QFrameGraphNode : public Qt3DCore::QNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qframegraphnodecreatedchange.h b/src/render/framegraph/qframegraphnodecreatedchange.h
index f255ff406..96ca0fb38 100644
--- a/src/render/framegraph/qframegraphnodecreatedchange.h
+++ b/src/render/framegraph/qframegraphnodecreatedchange.h
@@ -47,7 +47,7 @@ namespace Qt3DRender {
class QFrameGraphNode;
class QFrameGraphNodeCreatedChangeBasePrivate;
-class QT3DRENDERSHARED_EXPORT QFrameGraphNodeCreatedChangeBase : public Qt3DCore::QNodeCreatedChangeBase
+class Q_3DRENDERSHARED_EXPORT QFrameGraphNodeCreatedChangeBase : public Qt3DCore::QNodeCreatedChangeBase
{
public:
explicit QFrameGraphNodeCreatedChangeBase(const QFrameGraphNode *node);
diff --git a/src/render/framegraph/qfrustumculling.h b/src/render/framegraph/qfrustumculling.h
index f0ed6d032..b715a9a6f 100644
--- a/src/render/framegraph/qfrustumculling.h
+++ b/src/render/framegraph/qfrustumculling.h
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QFrustumCulling : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QFrustumCulling : public QFrameGraphNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qlayerfilter.h b/src/render/framegraph/qlayerfilter.h
index 3ccbdac54..dd628e74e 100644
--- a/src/render/framegraph/qlayerfilter.h
+++ b/src/render/framegraph/qlayerfilter.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QLayer;
class QLayerFilterPrivate;
-class QT3DRENDERSHARED_EXPORT QLayerFilter : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QLayerFilter : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(FilterMode filterMode READ filterMode WRITE setFilterMode NOTIFY filterModeChanged)
diff --git a/src/render/framegraph/qmemorybarrier.h b/src/render/framegraph/qmemorybarrier.h
index 244b7ef53..29b439700 100644
--- a/src/render/framegraph/qmemorybarrier.h
+++ b/src/render/framegraph/qmemorybarrier.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QMemoryBarrierPrivate;
-class QT3DRENDERSHARED_EXPORT QMemoryBarrier : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QMemoryBarrier : public QFrameGraphNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qnodraw.h b/src/render/framegraph/qnodraw.h
index 4547aeeda..3782a88fc 100644
--- a/src/render/framegraph/qnodraw.h
+++ b/src/render/framegraph/qnodraw.h
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QNoDraw : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QNoDraw : public QFrameGraphNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qproximityfilter.h b/src/render/framegraph/qproximityfilter.h
index b101f6c09..56bcd6eaf 100644
--- a/src/render/framegraph/qproximityfilter.h
+++ b/src/render/framegraph/qproximityfilter.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QProximityFilterPrivate;
-class QT3DRENDERSHARED_EXPORT QProximityFilter : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QProximityFilter : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(Qt3DCore::QEntity *entity READ entity WRITE setEntity NOTIFY entityChanged)
diff --git a/src/render/framegraph/qrendercapture.h b/src/render/framegraph/qrendercapture.h
index 119d6a6f3..8fa5d0455 100644
--- a/src/render/framegraph/qrendercapture.h
+++ b/src/render/framegraph/qrendercapture.h
@@ -47,7 +47,7 @@ namespace Qt3DRender {
class QRenderCapturePrivate;
class QRenderCaptureReplyPrivate;
-class QT3DRENDERSHARED_EXPORT QRenderCaptureReply : public QObject
+class Q_3DRENDERSHARED_EXPORT QRenderCaptureReply : public QObject
{
Q_OBJECT
Q_PROPERTY(QImage image READ image CONSTANT)
@@ -78,7 +78,7 @@ private:
friend class QRenderCapturePrivate;
};
-class QT3DRENDERSHARED_EXPORT QRenderCapture : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QRenderCapture : public QFrameGraphNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qrenderpassfilter.h b/src/render/framegraph/qrenderpassfilter.h
index ffb305e14..9fb11757f 100644
--- a/src/render/framegraph/qrenderpassfilter.h
+++ b/src/render/framegraph/qrenderpassfilter.h
@@ -53,7 +53,7 @@ class QRenderPassFilterPrivate;
class QFilterKey;
class QParameter;
-class QT3DRENDERSHARED_EXPORT QRenderPassFilter : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QRenderPassFilter : public QFrameGraphNode
{
Q_OBJECT
diff --git a/src/render/framegraph/qrenderstateset.h b/src/render/framegraph/qrenderstateset.h
index 3df86940b..b08da1ff5 100644
--- a/src/render/framegraph/qrenderstateset.h
+++ b/src/render/framegraph/qrenderstateset.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QRenderStateSetPrivate;
class QRenderState;
-class QT3DRENDERSHARED_EXPORT QRenderStateSet : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QRenderStateSet : public QFrameGraphNode
{
Q_OBJECT
diff --git a/src/render/framegraph/qrendersurfaceselector.h b/src/render/framegraph/qrendersurfaceselector.h
index 5d0273187..73d513311 100644
--- a/src/render/framegraph/qrendersurfaceselector.h
+++ b/src/render/framegraph/qrendersurfaceselector.h
@@ -53,7 +53,7 @@ namespace Qt3DRender {
class QRenderSurfaceSelectorPrivate;
-class QT3DRENDERSHARED_EXPORT QRenderSurfaceSelector : public Qt3DRender::QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QRenderSurfaceSelector : public Qt3DRender::QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(QObject *surface READ surface WRITE setSurface NOTIFY surfaceChanged)
diff --git a/src/render/framegraph/qrendersurfaceselector_p.h b/src/render/framegraph/qrendersurfaceselector_p.h
index 899387b98..70fdc5881 100644
--- a/src/render/framegraph/qrendersurfaceselector_p.h
+++ b/src/render/framegraph/qrendersurfaceselector_p.h
@@ -64,7 +64,7 @@ namespace Qt3DRender {
class QRenderSurfaceSelector;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderSurfaceSelectorPrivate : public Qt3DRender::QFrameGraphNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderSurfaceSelectorPrivate : public Qt3DRender::QFrameGraphNodePrivate
{
public:
QRenderSurfaceSelectorPrivate();
diff --git a/src/render/framegraph/qrendertargetselector.h b/src/render/framegraph/qrendertargetselector.h
index 5e8cd0761..c6b7b641d 100644
--- a/src/render/framegraph/qrendertargetselector.h
+++ b/src/render/framegraph/qrendertargetselector.h
@@ -52,7 +52,7 @@ namespace Qt3DRender {
class QRenderTargetSelectorPrivate;
class QRenderTarget;
-class QT3DRENDERSHARED_EXPORT QRenderTargetSelector : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QRenderTargetSelector : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QRenderTarget *target READ target WRITE setTarget NOTIFY targetChanged)
diff --git a/src/render/framegraph/qsetfence.cpp b/src/render/framegraph/qsetfence.cpp
new file mode 100644
index 000000000..5cb82f3db
--- /dev/null
+++ b/src/render/framegraph/qsetfence.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsetfence.h"
+#include "qsetfence_p.h"
+#include <Qt3DRender/private/qframegraphnodecreatedchange_p.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QSetFencePrivate::QSetFencePrivate()
+ : QFrameGraphNodePrivate()
+ , m_handleType(QSetFence::NoHandle)
+ , m_handle(QVariant())
+{
+}
+
+/*!
+ \class QSetFence
+ \brief FrameGraphNode used to insert a fence in the graphics command stream.
+
+ Fence allow to synchronosize GPU and CPU workloads. GPU commands usually
+ are non-blocking. When issued, commands are inserted in command buffers
+ which will be read at a later time by the GPU. In some cases, you want to
+ continue processing or issue specific command only when you are sure a
+ command has been executed by the hardware. Fences are a way to do so. This
+ is especially important when using 3rd party engines with Qt3D, Qt3D should
+ only access shared resources when we know the other engine command are done
+ modifying the resource.
+
+ QSetFence is a FrameGraph node that inserts a fence into the command
+ stream. It can then be used in conjunction with \l QWaitFence or by
+ extracting the underlying handle.
+
+ The handle property will be updated once the renderer has created the
+ underlying fence resource. The handle will remain valid as long as it
+ remains in the unsignaled state. Once it has reached the signaled state, it
+ will be destroyed and a new handle will be created. That means that
+ depending on how long it takes for the fence to be signaled, the same
+ handle could be used over several frames.
+
+ \since 5.13
+ */
+QSetFence::QSetFence(Qt3DCore::QNode *parent)
+ : QFrameGraphNode(*new QSetFencePrivate(), parent)
+{
+}
+
+QSetFence::~QSetFence()
+{
+}
+
+QSetFence::QSetFence(QSetFencePrivate &dd, Qt3DCore::QNode *parent)
+ : QFrameGraphNode(dd, parent)
+{
+}
+
+/*!
+ \qmlproperty HandleType SetFence::handleType
+
+ Specifies the type of handle being used. Currently only OpenGL Fence ids
+ are supported.
+*/
+/*!
+ \property QSetFence::handleType
+
+ Specifies the type of handle being used. Currently only OpenGL Fence ids
+ are supported.
+*/
+QSetFence::HandleType QSetFence::handleType() const
+{
+ Q_D(const QSetFence);
+ return d->m_handleType;
+}
+
+void QSetFencePrivate::setHandleType(QSetFence::HandleType type)
+{
+ Q_Q(QSetFence);
+ if (m_handleType != type) {
+ const bool blocked = q->blockNotifications(true);
+ m_handleType = type;
+ emit q->handleTypeChanged(type);
+ q->blockNotifications(blocked);
+ }
+}
+
+/*!
+ \qmlproperty variant AbstractFence::handle
+
+ Holds the underlying fence handle wrapped in a variant.
+*/
+/*!
+ \property QAbstractFence::handle
+
+ Holds the underlying fence handle wrapped in a QVariant.
+*/
+QVariant QSetFence::handle() const
+{
+ Q_D(const QSetFence);
+ return d->m_handle;
+}
+
+void QSetFencePrivate::setHandle(QVariant handle)
+{
+ Q_Q(QSetFence);
+ if (m_handle != handle) {
+ const bool blocked = q->blockNotifications(true);
+ m_handle = handle;
+ emit q->handleChanged(handle);
+ q->blockNotifications(blocked);
+ }
+}
+
+void QSetFence::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Qt3DCore::QPropertyUpdatedChangePtr e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
+ if (e->type() == Qt3DCore::PropertyUpdated) {
+ Q_D(QSetFence);
+ if (e->propertyName() == QByteArrayLiteral("handle"))
+ d->setHandle(e->value());
+ else if (e->propertyName() == QByteArrayLiteral("handleType"))
+ d->setHandleType(static_cast<Qt3DRender::QSetFence::HandleType>(e->value().toInt()));
+ }
+}
+
+Qt3DCore::QNodeCreatedChangeBasePtr QSetFence::createNodeCreationChange() const
+{
+ auto creationChange = QFrameGraphNodeCreatedChangePtr<QSetFenceData>::create(this);
+ QSetFenceData &data = creationChange->data;
+ Q_UNUSED(data); // Might be of use later
+ return creationChange;
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/framegraph/qsetfence.h b/src/render/framegraph/qsetfence.h
new file mode 100644
index 000000000..4ad92ae52
--- /dev/null
+++ b/src/render/framegraph/qsetfence.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <Qt3DRender/QFrameGraphNode>
+
+#ifndef QT3DRENDER_QSETFENCE_H
+#define QT3DRENDER_QSETFENCE_H
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QSetFencePrivate;
+
+class Q_3DRENDERSHARED_EXPORT QSetFence : public QFrameGraphNode
+{
+ Q_OBJECT
+ Q_PROPERTY(HandleType handleType READ handleType NOTIFY handleTypeChanged)
+ Q_PROPERTY(QVariant handle READ handle NOTIFY handleChanged)
+public:
+ enum HandleType {
+ NoHandle,
+ OpenGLFenceId
+ };
+ Q_ENUM(HandleType) // LCOV_EXCL_LINE
+
+ explicit QSetFence(Qt3DCore::QNode *parent = nullptr);
+ ~QSetFence();
+
+ HandleType handleType() const;
+ QVariant handle() const;
+
+Q_SIGNALS:
+ void handleTypeChanged(HandleType handleType);
+ void handleChanged(QVariant handle);
+
+protected:
+ explicit QSetFence(QSetFencePrivate &dd, Qt3DCore::QNode *parent = nullptr);
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
+
+private:
+ Q_DECLARE_PRIVATE(QSetFence)
+ Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QSETFENCE_H
diff --git a/src/render/framegraph/qsetfence_p.h b/src/render/framegraph/qsetfence_p.h
new file mode 100644
index 000000000..026afffa5
--- /dev/null
+++ b/src/render/framegraph/qsetfence_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QSETFENCE_P_H
+#define QT3DRENDER_QSETFENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/private/qframegraphnode_p.h>
+#include <Qt3DRender/qsetfence.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QSetFencePrivate : public QFrameGraphNodePrivate
+{
+public:
+ QSetFencePrivate();
+ void setHandleType(QSetFence::HandleType type);
+ void setHandle(QVariant handle);
+
+ QSetFence::HandleType m_handleType;
+ QVariant m_handle;
+
+ Q_DECLARE_PUBLIC(QSetFence)
+};
+
+struct QSetFenceData
+{
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QSETFENCE_P_H
diff --git a/src/render/framegraph/qsortpolicy.h b/src/render/framegraph/qsortpolicy.h
index d94ee3d69..67dfe6ac2 100644
--- a/src/render/framegraph/qsortpolicy.h
+++ b/src/render/framegraph/qsortpolicy.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QSortPolicyPrivate;
-class QT3DRENDERSHARED_EXPORT QSortPolicy : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QSortPolicy : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(QVector<int> sortTypes READ sortTypesInt WRITE setSortTypes NOTIFY sortTypesChanged)
diff --git a/src/render/framegraph/qtechniquefilter.h b/src/render/framegraph/qtechniquefilter.h
index 243b2d6ec..9fe872915 100644
--- a/src/render/framegraph/qtechniquefilter.h
+++ b/src/render/framegraph/qtechniquefilter.h
@@ -51,7 +51,7 @@ class QTechniqueFilterPrivate;
class QFilterKey;
class QParameter;
-class QT3DRENDERSHARED_EXPORT QTechniqueFilter : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QTechniqueFilter : public QFrameGraphNode
{
Q_OBJECT
public:
diff --git a/src/render/framegraph/qtechniquefilter_p.h b/src/render/framegraph/qtechniquefilter_p.h
index d25f10a79..10df8f5bf 100644
--- a/src/render/framegraph/qtechniquefilter_p.h
+++ b/src/render/framegraph/qtechniquefilter_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QTechniqueFilter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QTechniqueFilterPrivate : public QFrameGraphNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QTechniqueFilterPrivate : public QFrameGraphNodePrivate
{
public :
QTechniqueFilterPrivate();
diff --git a/src/render/framegraph/qviewport.h b/src/render/framegraph/qviewport.h
index 1f6ac8310..01830be6a 100644
--- a/src/render/framegraph/qviewport.h
+++ b/src/render/framegraph/qviewport.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QViewportPrivate;
-class QT3DRENDERSHARED_EXPORT QViewport : public QFrameGraphNode
+class Q_3DRENDERSHARED_EXPORT QViewport : public QFrameGraphNode
{
Q_OBJECT
Q_PROPERTY(QRectF normalizedRect READ normalizedRect WRITE setNormalizedRect NOTIFY normalizedRectChanged)
diff --git a/src/render/framegraph/qwaitfence.cpp b/src/render/framegraph/qwaitfence.cpp
new file mode 100644
index 000000000..5195653ce
--- /dev/null
+++ b/src/render/framegraph/qwaitfence.cpp
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwaitfence.h"
+#include "qwaitfence_p.h"
+#include <Qt3DRender/private/qframegraphnode_p.h>
+#include <Qt3DRender/private/qframegraphnodecreatedchange_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+QWaitFencePrivate::QWaitFencePrivate()
+ : QFrameGraphNodePrivate()
+ , m_handleType(QWaitFence::NoHandle)
+ , m_handle(QVariant())
+ , m_waitOnCPU(false)
+ , m_timeout(std::numeric_limits<quint64>::max())
+{
+}
+
+/*!
+ \class QWaitFence
+
+ \brief FrameGraphNode used to wait for a fence in the graphics command
+ stream to become signaled.
+
+ Fence allow to synchronosize GPU and CPU workloads. GPU commands usually
+ are non-blocking. When issued, commands are inserted in command buffers
+ which will be read at a later time by the GPU. In some cases, you want to
+ continue processing or issue specific command only when you are sure a
+ command has been executed by the hardware. Fences are a way to do so. This
+ is especially important when using 3rd party engines with Qt3D, Qt3D should
+ only access shared resources when we know the other engine command are done
+ modifying the resource.
+
+ QWaitFence is a FrameGraph node that will force to wait for it to become
+ signaled before subsequent commands are inserted into the command stream.
+ It can then be used in conjunction with \l QSetFence and contains
+ properties to configure how long it should wait and whether it should block
+ on the CPU side.
+
+ \note Qt 3D uploads GPU resources (Texture, Shaders, Buffers) before
+ issuing draw calls.
+
+ \since 5.13
+ */
+
+QWaitFence::QWaitFence(Qt3DCore::QNode *parent)
+ : QFrameGraphNode(*new QWaitFencePrivate(), parent)
+{
+}
+
+QWaitFence::~QWaitFence()
+{
+}
+
+/*!
+ \qmlproperty bool WaitFence::waitOnCPU
+
+ Specifies whether the CPU should be block while waiting for the fence to
+ become signaled. This is false by default.
+*/
+/*!
+ \property QWaitFence::waitOnCPU
+
+ Specifies whether the CPU should be block while waiting for the fence to
+ become signaled. This is false by default.
+*/
+bool QWaitFence::waitOnCPU() const
+{
+ Q_D(const QWaitFence);
+ return d->m_waitOnCPU;
+}
+
+void QWaitFence::setWaitOnCPU(bool waitOnCPU)
+{
+ Q_D(QWaitFence);
+ if (d->m_waitOnCPU == waitOnCPU)
+ return;
+ d->m_waitOnCPU = waitOnCPU;
+ emit waitOnCPUChanged(waitOnCPU);
+}
+
+/*!
+ \qmlproperty int WaitFence::timeout
+
+ Specifies the maximum amount of time in nanoseconds to wait for the fence
+ to become signaled.
+*/
+/*!
+ \property QWaitFence::timeout
+
+ Specifies the maximum amount of time in nanoseconds to wait for the fence
+ to become signaled.
+*/
+quint64 QWaitFence::timeout() const
+{
+ Q_D(const QWaitFence);
+ return d->m_timeout;
+}
+
+void QWaitFence::setTimeout(quint64 timeout)
+{
+ Q_D(QWaitFence);
+ if (d->m_timeout == timeout)
+ return;
+ d->m_timeout = timeout;
+ emit timeoutChanged(timeout);
+}
+
+QWaitFence::QWaitFence(QWaitFencePrivate &dd, Qt3DCore::QNode *parent)
+ : QFrameGraphNode(dd, parent)
+{
+}
+
+/*!
+ \qmlproperty HandleType WaitFence::handleType
+
+ Specifies the type of handle being used. Currently only OpenGL Fence ids
+ are supported.
+*/
+/*!
+ \property QWaitFence::handleType
+
+ Specifies the type of handle being used. Currently only OpenGL Fence ids
+ are supported.
+*/
+QWaitFence::HandleType QWaitFence::handleType() const
+{
+ Q_D(const QWaitFence);
+ return d->m_handleType;
+}
+
+void QWaitFence::setHandleType(QWaitFence::HandleType type)
+{
+ Q_D(QWaitFence);
+ if (d->m_handleType != type) {
+ d->m_handleType = type;
+ emit handleTypeChanged(type);
+ }
+}
+
+/*!
+ \qmlproperty variant WaitFence::handle
+
+ Holds the underlying fence handle wrapped in a variant.
+*/
+/*!
+ \property QWaitFence::handle
+
+ Holds the underlying fence handle wrapped in a QVariant.
+*/
+QVariant QWaitFence::handle() const
+{
+ Q_D(const QWaitFence);
+ return d->m_handle;
+}
+
+void QWaitFence::setHandle(QVariant handle)
+{
+ Q_D(QWaitFence);
+ if (d->m_handle != handle) {
+ d->m_handle = handle;
+ emit handleChanged(handle);
+ }
+}
+
+Qt3DCore::QNodeCreatedChangeBasePtr QWaitFence::createNodeCreationChange() const
+{
+ auto creationChange = QFrameGraphNodeCreatedChangePtr<QWaitFenceData>::create(this);
+ QWaitFenceData &data = creationChange->data;
+ Q_D(const QWaitFence);
+ data.handleType = d->m_handleType;
+ data.handle = d->m_handle;
+ data.timeout = d->m_timeout;
+ data.waitOnCPU = d->m_waitOnCPU;
+ return creationChange;
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/framegraph/qwaitfence.h b/src/render/framegraph/qwaitfence.h
new file mode 100644
index 000000000..8148fde7d
--- /dev/null
+++ b/src/render/framegraph/qwaitfence.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QWAITFENCE_H
+#define QT3DRENDER_QWAITFENCE_H
+
+#include <Qt3DRender/QFrameGraphNode>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QWaitFencePrivate;
+
+class Q_3DRENDERSHARED_EXPORT QWaitFence : public QFrameGraphNode
+{
+ Q_OBJECT
+ Q_PROPERTY(HandleType handleType READ handleType WRITE setHandleType NOTIFY handleTypeChanged)
+ Q_PROPERTY(QVariant handle READ handle WRITE setHandle NOTIFY handleChanged)
+ Q_PROPERTY(bool waitOnCPU READ waitOnCPU WRITE setWaitOnCPU NOTIFY waitOnCPUChanged)
+ Q_PROPERTY(quint64 timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
+
+public:
+ enum HandleType {
+ NoHandle,
+ OpenGLFenceId
+ };
+ Q_ENUM(HandleType) // LCOV_EXCL_LINE
+ explicit QWaitFence(Qt3DCore::QNode *parent = nullptr);
+ ~QWaitFence();
+
+ void setHandleType(HandleType type);
+ void setHandle(QVariant handle);
+
+ HandleType handleType() const;
+ QVariant handle() const;
+
+ bool waitOnCPU() const;
+ void setWaitOnCPU(bool waitOnCPU);
+
+ quint64 timeout() const;
+ void setTimeout(quint64 timeout);
+
+Q_SIGNALS:
+ void waitOnCPUChanged(bool waitOnCPU);
+ void timeoutChanged(quint64 timeoutChanged);
+ void handleTypeChanged(HandleType handleType);
+ void handleChanged(QVariant handle);
+
+protected:
+ explicit QWaitFence(QWaitFencePrivate &dd, Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QWaitFence)
+ Qt3DCore::QNodeCreatedChangeBasePtr createNodeCreationChange() const override;
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QWAITFENCE_H
diff --git a/src/render/framegraph/qwaitfence_p.h b/src/render/framegraph/qwaitfence_p.h
new file mode 100644
index 000000000..480d69cad
--- /dev/null
+++ b/src/render/framegraph/qwaitfence_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_QWAITFENCE_P_H
+#define QT3DRENDER_QWAITFENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/private/qframegraphnode_p.h>
+#include <Qt3DRender/qwaitfence.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QWaitFencePrivate : public QFrameGraphNodePrivate
+{
+public:
+ QWaitFencePrivate();
+
+ QWaitFence::HandleType m_handleType;
+ QVariant m_handle;
+ bool m_waitOnCPU;
+ quint64 m_timeout;
+};
+
+struct QWaitFenceData
+{
+ QWaitFence::HandleType handleType;
+ QVariant handle;
+ bool waitOnCPU;
+ quint64 timeout;
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+
+#endif // QT3DRENDER_QWAITFENCE_P_H
diff --git a/src/render/framegraph/rendercapture.cpp b/src/render/framegraph/rendercapture.cpp
index d25a01b1f..166294889 100644
--- a/src/render/framegraph/rendercapture.cpp
+++ b/src/render/framegraph/rendercapture.cpp
@@ -76,6 +76,7 @@ void RenderCapture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("renderCaptureRequest")) {
requestCapture(propertyChange->value().value<QRenderCaptureRequest>());
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
}
FrameGraphNode::sceneChangeEvent(e);
diff --git a/src/render/framegraph/renderpassfilternode.cpp b/src/render/framegraph/renderpassfilternode.cpp
index c9277b951..e3da1e36d 100644
--- a/src/render/framegraph/renderpassfilternode.cpp
+++ b/src/render/framegraph/renderpassfilternode.cpp
@@ -97,10 +97,10 @@ void RenderPassFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeAddedChange>(e);
if (change->propertyName() == QByteArrayLiteral("match")) {
appendFilter(change->addedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (change->propertyName() == QByteArrayLiteral("parameter")) {
m_parameterPack.appendParameter(change->addedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
break;
}
@@ -109,10 +109,10 @@ void RenderPassFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeRemovedChange>(e);
if (change->propertyName() == QByteArrayLiteral("match")) {
removeFilter(change->removedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (change->propertyName() == QByteArrayLiteral("parameter")) {
m_parameterPack.removeParameter(change->removedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
break;
}
diff --git a/src/render/framegraph/rendersurfaceselector.cpp b/src/render/framegraph/rendersurfaceselector.cpp
index 7f2fd6170..16a1199b5 100644
--- a/src/render/framegraph/rendersurfaceselector.cpp
+++ b/src/render/framegraph/rendersurfaceselector.cpp
@@ -101,17 +101,22 @@ void RenderSurfaceSelector::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
qCDebug(Render::Framegraph) << Q_FUNC_INFO;
if (e->type() == PropertyUpdated) {
QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("surface"))
+ if (propertyChange->propertyName() == QByteArrayLiteral("surface")) {
m_surface = surfaceFromQObject(propertyChange->value().value<QObject *>());
- else if (propertyChange->propertyName() == QByteArrayLiteral("externalRenderTargetSize"))
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("externalRenderTargetSize")) {
setRenderTargetSize(propertyChange->value().toSize());
- else if (propertyChange->propertyName() == QByteArrayLiteral("width"))
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("width")) {
m_width = propertyChange->value().toInt();
- else if (propertyChange->propertyName() == QByteArrayLiteral("height"))
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("height")) {
m_height = propertyChange->value().toInt();
- else if (propertyChange->propertyName() == QByteArrayLiteral("surfacePixelRatio"))
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("surfacePixelRatio")) {
m_devicePixelRatio = propertyChange->value().toFloat();
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/rendertargetselectornode.cpp b/src/render/framegraph/rendertargetselectornode.cpp
index 4b6e2da84..615608bd2 100644
--- a/src/render/framegraph/rendertargetselectornode.cpp
+++ b/src/render/framegraph/rendertargetselectornode.cpp
@@ -73,11 +73,13 @@ void RenderTargetSelector::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
qCDebug(Render::Framegraph) << Q_FUNC_INFO;
if (e->type() == PropertyUpdated) {
QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e);
- if (propertyChange->propertyName() == QByteArrayLiteral("target"))
+ if (propertyChange->propertyName() == QByteArrayLiteral("target")) {
m_renderTargetUuid = propertyChange->value().value<QNodeId>();
- else if (propertyChange->propertyName() == QByteArrayLiteral("outputs"))
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("outputs")) {
m_outputs = propertyChange->value().value<QVector<Qt3DRender::QRenderTargetOutput::AttachmentPoint> >();
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/setfence.cpp b/src/render/framegraph/setfence.cpp
new file mode 100644
index 000000000..b2e995b25
--- /dev/null
+++ b/src/render/framegraph/setfence.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "setfence_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+SetFence::SetFence()
+ : FrameGraphNode(FrameGraphNode::SetFence, QBackendNode::ReadWrite)
+{
+}
+
+SetFence::~SetFence()
+{
+}
+
+void SetFence::setHandle(const QVariant &handle)
+{
+ auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
+ change->setPropertyName("handle");
+ change->setValue(handle);
+ notifyObservers(change);
+}
+
+void SetFence::setHandleType(QSetFence::HandleType type)
+{
+ auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
+ change->setPropertyName("handleType");
+ change->setValue(QVariant::fromValue(type));
+ notifyObservers(change);
+}
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/framegraph/setfence_p.h b/src/render/framegraph/setfence_p.h
new file mode 100644
index 000000000..31072581c
--- /dev/null
+++ b/src/render/framegraph/setfence_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_SETFENCE_P_H
+#define QT3DRENDER_RENDER_SETFENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/private/framegraphnode_p.h>
+#include <Qt3DRender/qsetfence.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Q_AUTOTEST_EXPORT SetFence : public FrameGraphNode
+{
+public:
+ SetFence();
+ ~SetFence();
+
+ // Called by a job
+ void setHandle(const QVariant &handle);
+ void setHandleType(QSetFence::HandleType type);
+};
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_SETFENCE_P_H
diff --git a/src/render/framegraph/sortpolicy.cpp b/src/render/framegraph/sortpolicy.cpp
index 9631ebeab..b81d1f6cb 100644
--- a/src/render/framegraph/sortpolicy.cpp
+++ b/src/render/framegraph/sortpolicy.cpp
@@ -61,9 +61,9 @@ void SortPolicy::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
auto sortTypesInt = propertyChange->value().value<QVector<int>>();
m_sortTypes.clear();
transformVector(sortTypesInt, m_sortTypes);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
}
- markDirty(AbstractRenderer::AllDirty);
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/statesetnode.cpp b/src/render/framegraph/statesetnode.cpp
index 2ffbb70c7..96551684e 100644
--- a/src/render/framegraph/statesetnode.cpp
+++ b/src/render/framegraph/statesetnode.cpp
@@ -84,7 +84,7 @@ void StateSetNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeAddedChange>(e);
if (change->propertyName() == QByteArrayLiteral("renderState")) {
addRenderState(change->addedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
break;
}
@@ -93,7 +93,7 @@ void StateSetNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto propertyChange = qSharedPointerCast<QPropertyNodeRemovedChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("renderState")) {
removeRenderState(propertyChange->removedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
break;
}
diff --git a/src/render/framegraph/techniquefilternode.cpp b/src/render/framegraph/techniquefilternode.cpp
index 59f49af02..8816984ee 100644
--- a/src/render/framegraph/techniquefilternode.cpp
+++ b/src/render/framegraph/techniquefilternode.cpp
@@ -96,10 +96,10 @@ void TechniqueFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeAddedChange>(e);
if (change->propertyName() == QByteArrayLiteral("matchAll")) {
appendFilter(change->addedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (change->propertyName() == QByteArrayLiteral("parameter")) {
m_parameterPack.appendParameter(change->addedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
break;
}
@@ -108,10 +108,10 @@ void TechniqueFilter::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
const auto change = qSharedPointerCast<QPropertyNodeRemovedChange>(e);
if (change->propertyName() == QByteArrayLiteral("matchAll")) {
removeFilter(change->removedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (change->propertyName() == QByteArrayLiteral("parameter")) {
m_parameterPack.removeParameter(change->removedNodeId());
- markDirty(AbstractRenderer::AllDirty);
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
break;
}
diff --git a/src/render/framegraph/viewportnode.cpp b/src/render/framegraph/viewportnode.cpp
index bed87a13f..b3b53b0f9 100644
--- a/src/render/framegraph/viewportnode.cpp
+++ b/src/render/framegraph/viewportnode.cpp
@@ -128,10 +128,11 @@ void ViewportNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
setYMin(normalizedRect.y());
setXMax(normalizedRect.width());
setYMax(normalizedRect.height());
+ markDirty(AbstractRenderer::FrameGraphDirty);
} else if (propertyChange->propertyName() == QByteArrayLiteral("gamma")) {
setGamma(propertyChange->value().toFloat());
+ markDirty(AbstractRenderer::FrameGraphDirty);
}
- markDirty(AbstractRenderer::AllDirty);
}
FrameGraphNode::sceneChangeEvent(e);
}
diff --git a/src/render/framegraph/waitfence.cpp b/src/render/framegraph/waitfence.cpp
new file mode 100644
index 000000000..9480fb7a0
--- /dev/null
+++ b/src/render/framegraph/waitfence.cpp
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "waitfence_p.h"
+#include <Qt3DRender/private/qwaitfence_p.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+WaitFence::WaitFence()
+ : FrameGraphNode(FrameGraphNode::WaitFence)
+{
+ m_data.handleType = QWaitFence::NoHandle;
+ m_data.waitOnCPU = false;
+ m_data.timeout = std::numeric_limits<quint64>::max();
+}
+
+WaitFence::~WaitFence()
+{
+}
+
+void WaitFence::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+{
+ if (e->type() == Qt3DCore::PropertyUpdated) {
+ Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
+ if (propertyChange->propertyName() == QByteArrayLiteral("handle")) {
+ m_data.handle = propertyChange->value();
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("handleType")) {
+ m_data.handleType = static_cast<QWaitFence::HandleType>(propertyChange->value().toInt());
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("timeout")) {
+ m_data.timeout = propertyChange->value().value<quint64>();
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("waitOnCPU")) {
+ m_data.waitOnCPU = propertyChange->value().toBool();
+ markDirty(AbstractRenderer::FrameGraphDirty);
+ }
+ }
+ FrameGraphNode::sceneChangeEvent(e);
+}
+
+void WaitFence::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+{
+ FrameGraphNode::initializeFromPeer(change);
+ const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QWaitFenceData>>(change);
+ const QWaitFenceData &data = typedChange->data;
+ m_data = data;
+}
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/framegraph/waitfence_p.h b/src/render/framegraph/waitfence_p.h
new file mode 100644
index 000000000..dd48e0efa
--- /dev/null
+++ b/src/render/framegraph/waitfence_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3DRENDER_RENDER_WAITFENCE_P_H
+#define QT3DRENDER_RENDER_WAITFENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/qwaitfence.h>
+#include <Qt3DRender/private/framegraphnode_p.h>
+#include <Qt3DRender/private/qwaitfence_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Q_AUTOTEST_EXPORT WaitFence : public FrameGraphNode
+{
+public:
+ WaitFence();
+ ~WaitFence();
+
+ inline QWaitFenceData data() const { return m_data; }
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+
+private:
+ void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
+
+ QWaitFenceData m_data;
+};
+
+} // namespace Render
+
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_RENDER_WAITFENCE_P_H
diff --git a/src/render/frontend/qabstractfunctor.cpp b/src/render/frontend/qabstractfunctor.cpp
index 4be1da595..698c3a291 100644
--- a/src/render/frontend/qabstractfunctor.cpp
+++ b/src/render/frontend/qabstractfunctor.cpp
@@ -58,8 +58,15 @@ namespace Qt3DRender {
*/
/*!
\fn qintptr Qt3DRender::QAbstractFunctor::id() const
+
+ Returns a pointer to the id of the functor.
*/
/*!
+ \fn qintptr Qt3DRender::functorTypeId()
+
+ Returns a pointer to the type id of the functor.
+*/
+/*!
\macro QT3D_FUNCTOR(Class)
\relates Qt3DRender::QAbstractFunctor
diff --git a/src/render/frontend/qabstractfunctor.h b/src/render/frontend/qabstractfunctor.h
index e28535041..45492e141 100644
--- a/src/render/frontend/qabstractfunctor.h
+++ b/src/render/frontend/qabstractfunctor.h
@@ -73,7 +73,7 @@ qintptr functorTypeId()
}
-class QT3DRENDERSHARED_EXPORT QAbstractFunctor
+class Q_3DRENDERSHARED_EXPORT QAbstractFunctor
{
public:
QAbstractFunctor() = default;
diff --git a/src/render/frontend/qcamera.h b/src/render/frontend/qcamera.h
index e31615741..7d717972e 100644
--- a/src/render/frontend/qcamera.h
+++ b/src/render/frontend/qcamera.h
@@ -58,7 +58,7 @@ namespace Qt3DRender {
class QCameraPrivate;
-class QT3DRENDERSHARED_EXPORT QCamera : public Qt3DCore::QEntity
+class Q_3DRENDERSHARED_EXPORT QCamera : public Qt3DCore::QEntity
{
Q_OBJECT
// CameraLens
diff --git a/src/render/frontend/qcamera_p.h b/src/render/frontend/qcamera_p.h
index 1e8464d05..00d0bfd80 100644
--- a/src/render/frontend/qcamera_p.h
+++ b/src/render/frontend/qcamera_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QCameraPrivate : public Qt3DCore::QEntityPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QCameraPrivate : public Qt3DCore::QEntityPrivate
{
public:
QCameraPrivate();
diff --git a/src/render/frontend/qcameralens.h b/src/render/frontend/qcameralens.h
index d478561ee..da7b426e1 100644
--- a/src/render/frontend/qcameralens.h
+++ b/src/render/frontend/qcameralens.h
@@ -53,7 +53,7 @@ namespace Qt3DRender {
class QCameraLensPrivate;
-class QT3DRENDERSHARED_EXPORT QCameraLens : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QCameraLens : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(ProjectionType projectionType READ projectionType WRITE setProjectionType NOTIFY projectionTypeChanged)
diff --git a/src/render/frontend/qcameralens_p.h b/src/render/frontend/qcameralens_p.h
index 0ec197945..111ab6522 100644
--- a/src/render/frontend/qcameralens_p.h
+++ b/src/render/frontend/qcameralens_p.h
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QCameraLensPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QCameraLensPrivate : public Qt3DCore::QComponentPrivate
{
public:
QCameraLensPrivate();
diff --git a/src/render/frontend/qcomputecommand.cpp b/src/render/frontend/qcomputecommand.cpp
index 5cb72a6ce..8b176cd4f 100644
--- a/src/render/frontend/qcomputecommand.cpp
+++ b/src/render/frontend/qcomputecommand.cpp
@@ -39,6 +39,7 @@
#include "qcomputecommand.h"
#include "qcomputecommand_p.h"
+#include <Qt3DCore/qpropertyupdatedchange.h>
QT_BEGIN_NAMESPACE
@@ -75,12 +76,14 @@ namespace Qt3DRender {
The compute shader is specified in the Material component of the same entity the
ComputeCommand is added to. The workGroupX, workGroupY and workGroupZ properties
specify the work group sizes for the compute shader invocation. DispatchCompute
- node needs to be present in the FrameGraph to actually issue the commands.
+ node needs to be present in the FrameGraph to actually issue the commands. The execution behavior
+ of the compute command can be controlled with the run type property.
- \note If the rendering policy is set to RenderSettings.OnDemand and there are no changes to the
- scene, the ComputeCommand will not be invoked repeatedly.
- The RenderSettings.Always render policy must be set for the ComputeCommand to be
- repeatedly invoked if there are no other changes to the scene that triggers rendering a new
+ \note If the rendering policy is set to RenderSettings.OnDemand, the run
+ type is set to Continuous and there are no changes to the scene, the
+ ComputeCommand will not be invoked repeatedly. The RenderSettings.Always
+ render policy must be set for the ComputeCommand to be repeatedly invoked
+ if there are no other changes to the scene that triggers rendering a new
frame.
*/
@@ -90,6 +93,19 @@ namespace Qt3DRender {
*/
/*!
+ \qmlproperty QComputeCommand::runType
+
+ Specifies whether the compute command should be performed every frame or
+ manually triggered.
+
+ \value Continuous Compute command is executed everyframe. This is the
+ default.
+
+ \value Manual CompouteCommand is executed for a given number of frames and
+ then the component disables itself.
+ */
+
+/*!
\qmlproperty int ComputeCommand::workGroupY
Specifies Y workgroup size.
*/
@@ -114,12 +130,36 @@ namespace Qt3DRender {
Specifies Z workgroup size.
*/
+/*!
+ \property QComputeCommand::runType
+
+ Specifies whether the compute command should be performed every frame or
+ manually triggered.
+
+ If set to Continuous, Compute command is executed everyframe. This is the
+ default.
+
+ If set to Manual CompouteCommand is executed for a given number of frames
+ and then the component disables itself.
+ */
+
QComputeCommandPrivate::QComputeCommandPrivate()
: Qt3DCore::QComponentPrivate()
, m_workGroupX(1)
, m_workGroupY(1)
, m_workGroupZ(1)
+ , m_runType(QComputeCommand::Continuous)
+ , m_frameCount(0)
+{
+}
+
+void QComputeCommandPrivate::setFrameCount(int frameCount)
{
+ m_frameCount = frameCount;
+ const auto propertyChange = Qt3DCore::QPropertyUpdatedChangePtr::create(m_id);
+ propertyChange->setPropertyName("frameCount");
+ propertyChange->setValue(m_frameCount);
+ notifyObservers(propertyChange);
}
/*!
@@ -154,6 +194,12 @@ int QComputeCommand::workGroupZ() const
return d->m_workGroupZ;
}
+QComputeCommand::RunType QComputeCommand::runType() const
+{
+ Q_D(const QComputeCommand);
+ return d->m_runType;
+}
+
/*!
Sets the workgroup for the first dimension to \a workGroupX.
*/
@@ -190,6 +236,50 @@ void QComputeCommand::setWorkGroupZ(int workGroupZ)
}
}
+void QComputeCommand::setRunType(QComputeCommand::RunType runType)
+{
+ Q_D(QComputeCommand);
+ if (d->m_runType != runType) {
+ d->m_runType = runType;
+ emit runTypeChanged();
+ }
+}
+
+/*!
+ When the run type is set to Manual, calling trigger will make the compute
+ command be executed for the next \a frameCount frames. Upon completion of
+ the execution, the enabled property will be set to false.
+ */
+void QComputeCommand::trigger(int frameCount)
+{
+ if (isEnabled())
+ qWarning() << Q_FUNC_INFO << "is triggered while it hasn't finished executing";
+
+ Q_D(QComputeCommand);
+ d->setFrameCount(frameCount);
+ setEnabled(true);
+}
+
+/*!
+ When the run type is set to Manual, calling trigger will make the compute
+ command be executed for the next \a frameCount frames. Upon completion of
+ the execution, the enabled property will be set to false. The size of the
+ workgroup previously set will be overridden with \a workGroupX, \a
+ workGroupY, \a workGroupZ.
+ */
+void QComputeCommand::trigger(int workGroupX, int workGroupY, int workGroupZ, int frameCount)
+{
+ if (isEnabled())
+ qWarning() << Q_FUNC_INFO << "is triggered while it hasn't finished executing";
+
+ setWorkGroupX(workGroupX);
+ setWorkGroupY(workGroupY);
+ setWorkGroupZ(workGroupZ);
+ Q_D(QComputeCommand);
+ d->setFrameCount(frameCount);
+ setEnabled(true);
+}
+
Qt3DCore::QNodeCreatedChangeBasePtr QComputeCommand::createNodeCreationChange() const
{
auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QComputeCommandData>::create(this);
@@ -198,6 +288,8 @@ Qt3DCore::QNodeCreatedChangeBasePtr QComputeCommand::createNodeCreationChange()
data.workGroupX = d->m_workGroupX;
data.workGroupY = d->m_workGroupY;
data.workGroupZ = d->m_workGroupZ;
+ data.runType = d->m_runType;
+ data.frameCount = d->m_frameCount;
return creationChange;
}
diff --git a/src/render/frontend/qcomputecommand.h b/src/render/frontend/qcomputecommand.h
index c31082197..b71007ba0 100644
--- a/src/render/frontend/qcomputecommand.h
+++ b/src/render/frontend/qcomputecommand.h
@@ -49,30 +49,43 @@ namespace Qt3DRender {
class QComputeCommandPrivate;
-class QT3DRENDERSHARED_EXPORT QComputeCommand : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QComputeCommand : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(int workGroupX READ workGroupX WRITE setWorkGroupX NOTIFY workGroupXChanged)
Q_PROPERTY(int workGroupY READ workGroupY WRITE setWorkGroupY NOTIFY workGroupYChanged)
Q_PROPERTY(int workGroupZ READ workGroupZ WRITE setWorkGroupZ NOTIFY workGroupZChanged)
+ Q_PROPERTY(RunType runType READ runType WRITE setRunType NOTIFY runTypeChanged REVISION 13)
public:
+ enum RunType {
+ Continuous = 0,
+ Manual
+ };
+ Q_ENUM(RunType)
+
explicit QComputeCommand(Qt3DCore::QNode *parent = nullptr);
~QComputeCommand();
int workGroupX() const;
int workGroupY() const;
int workGroupZ() const;
+ RunType runType() const;
public Q_SLOTS:
void setWorkGroupX(int workGroupX);
void setWorkGroupY(int workGroupY);
void setWorkGroupZ(int workGroupZ);
+ Q_REVISION(13) void setRunType(RunType runType);
+
+ Q_REVISION(13) void trigger(int frameCount = 1);
+ Q_REVISION(13) void trigger(int workGroupX, int workGroupY, int workGroupZ, int frameCount = 1);
Q_SIGNALS:
void workGroupXChanged();
void workGroupYChanged();
void workGroupZChanged();
+ void runTypeChanged();
private:
Q_DECLARE_PRIVATE(QComputeCommand)
diff --git a/src/render/frontend/qcomputecommand_p.h b/src/render/frontend/qcomputecommand_p.h
index 874edb1fc..0a614325b 100644
--- a/src/render/frontend/qcomputecommand_p.h
+++ b/src/render/frontend/qcomputecommand_p.h
@@ -52,13 +52,14 @@
//
#include <Qt3DCore/private/qcomponent_p.h>
+#include <Qt3DRender/qcomputecommand.h>
#include <Qt3DRender/private/qt3drender_global_p.h>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QComputeCommandPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QComputeCommandPrivate : public Qt3DCore::QComponentPrivate
{
public:
QComputeCommandPrivate();
@@ -66,6 +67,10 @@ public:
int m_workGroupX;
int m_workGroupY;
int m_workGroupZ;
+ QComputeCommand::RunType m_runType;
+ int m_frameCount;
+
+ void setFrameCount(int frameCount);
};
struct QComputeCommandData
@@ -73,6 +78,8 @@ struct QComputeCommandData
int workGroupX;
int workGroupY;
int workGroupZ;
+ QComputeCommand::RunType runType;
+ int frameCount;
};
} // Qt3DRender
diff --git a/src/render/frontend/qlayer.h b/src/render/frontend/qlayer.h
index 27910f190..4900f30e0 100644
--- a/src/render/frontend/qlayer.h
+++ b/src/render/frontend/qlayer.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QLayerPrivate;
-class QT3DRENDERSHARED_EXPORT QLayer : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QLayer : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
diff --git a/src/render/frontend/qlayer_p.h b/src/render/frontend/qlayer_p.h
index 1c01955f7..3a1fd7f61 100644
--- a/src/render/frontend/qlayer_p.h
+++ b/src/render/frontend/qlayer_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QLayerPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QLayerPrivate : public Qt3DCore::QComponentPrivate
{
public:
QLayerPrivate();
diff --git a/src/render/frontend/qlevelofdetail.h b/src/render/frontend/qlevelofdetail.h
index fb74659dd..308a4d3c0 100644
--- a/src/render/frontend/qlevelofdetail.h
+++ b/src/render/frontend/qlevelofdetail.h
@@ -53,7 +53,7 @@ namespace Qt3DRender {
class QCamera;
class QLevelOfDetailPrivate;
-class QT3DRENDERSHARED_EXPORT QLevelOfDetail : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QLevelOfDetail : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged)
diff --git a/src/render/frontend/qlevelofdetail_p.h b/src/render/frontend/qlevelofdetail_p.h
index 136d2ffa3..7b409e4ca 100644
--- a/src/render/frontend/qlevelofdetail_p.h
+++ b/src/render/frontend/qlevelofdetail_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QLevelOfDetailPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QLevelOfDetailPrivate : public Qt3DCore::QComponentPrivate
{
public:
QLevelOfDetailPrivate();
diff --git a/src/render/frontend/qlevelofdetailboundingsphere.h b/src/render/frontend/qlevelofdetailboundingsphere.h
index 43ba422a8..81d49d04e 100644
--- a/src/render/frontend/qlevelofdetailboundingsphere.h
+++ b/src/render/frontend/qlevelofdetailboundingsphere.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QLevelOfDetailBoundingSpherePrivate;
-class QT3DRENDERSHARED_EXPORT QLevelOfDetailBoundingSphere
+class Q_3DRENDERSHARED_EXPORT QLevelOfDetailBoundingSphere
{
Q_GADGET
Q_PROPERTY(QVector3D center READ center CONSTANT)
diff --git a/src/render/frontend/qlevelofdetailswitch.h b/src/render/frontend/qlevelofdetailswitch.h
index 55c7d24c1..1615d16e6 100644
--- a/src/render/frontend/qlevelofdetailswitch.h
+++ b/src/render/frontend/qlevelofdetailswitch.h
@@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QLevelOfDetailSwitch : public QLevelOfDetail
+class Q_3DRENDERSHARED_EXPORT QLevelOfDetailSwitch : public QLevelOfDetail
{
Q_OBJECT
diff --git a/src/render/frontend/qpickingsettings.cpp b/src/render/frontend/qpickingsettings.cpp
index 66d3fc912..84e61e141 100644
--- a/src/render/frontend/qpickingsettings.cpp
+++ b/src/render/frontend/qpickingsettings.cpp
@@ -199,6 +199,9 @@ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod)
* \value NearestPick Only the nearest entity to picking ray origin intersected by the picking ray
* is picked (default).
* \value AllPicks All entities that intersect the picking ray are picked.
+ * \value PriorityPick Selects the entity whose object picker has the highest
+ * value. If several object pickers have the same priority, the closest one on
+ * the ray is selected.
*
* \sa Qt3DRender::QPickEvent
*/
@@ -211,6 +214,7 @@ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod)
\list
\li PickingSettings.NearestPick
\li PickingSettings.AllPicks
+ \li PickingSettings.NearestPriorityPick
\endlist
\sa Qt3DRender::QPickingSettings::PickResultMode
@@ -225,6 +229,10 @@ void QPickingSettings::setPickMethod(QPickingSettings::PickMethod pickMethod)
When setting the pick method to AllPicks, events will be triggered for all the
entities with a QObjectPicker along the ray.
+ When setting the pick method to NearestPriorityPick, events will be
+ triggered for the nearest highest priority picker. This can be used when a
+ given element should always be selected even if others are in front of it.
+
If a QObjectPicker is assigned to an entity with multiple children, an event will
be triggered for each child entity that intersects the ray.
*/
diff --git a/src/render/frontend/qpickingsettings.h b/src/render/frontend/qpickingsettings.h
index 9c8a2c856..11384414b 100644
--- a/src/render/frontend/qpickingsettings.h
+++ b/src/render/frontend/qpickingsettings.h
@@ -51,7 +51,7 @@ class QPickingSettingsPrivate;
// TO DO: Qt 6 -> Make this a QObject
-class QT3DRENDERSHARED_EXPORT QPickingSettings : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QPickingSettings : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(PickMethod pickMethod READ pickMethod WRITE setPickMethod NOTIFY pickMethodChanged)
@@ -73,7 +73,8 @@ public:
enum PickResultMode {
NearestPick,
- AllPicks
+ AllPicks,
+ NearestPriorityPick
};
Q_ENUM(PickResultMode) // LCOV_EXCL_LINE
diff --git a/src/render/frontend/qpickingsettings_p.h b/src/render/frontend/qpickingsettings_p.h
index 780a8b677..73f48c06e 100644
--- a/src/render/frontend/qpickingsettings_p.h
+++ b/src/render/frontend/qpickingsettings_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QPickingSettingsPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QPickingSettingsPrivate : public Qt3DCore::QNodePrivate
{
public:
QPickingSettingsPrivate();
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index ae84599e8..14fbe1754 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -88,6 +88,8 @@
#include <Qt3DRender/qproximityfilter.h>
#include <Qt3DRender/qshaderprogrambuilder.h>
#include <Qt3DRender/qblitframebuffer.h>
+#include <Qt3DRender/qsetfence.h>
+#include <Qt3DRender/qwaitfence.h>
#include <Qt3DCore/qarmature.h>
#include <Qt3DCore/qjoint.h>
#include <Qt3DCore/qskeletonloader.h>
@@ -150,6 +152,8 @@
#include <Qt3DRender/private/joint_p.h>
#include <Qt3DRender/private/loadskeletonjob_p.h>
#include <Qt3DRender/private/proximityfilter_p.h>
+#include <Qt3DRender/private/setfence_p.h>
+#include <Qt3DRender/private/waitfence_p.h>
#include <private/qrenderpluginfactory_p.h>
#include <private/qrenderplugin_p.h>
@@ -298,6 +302,8 @@ void QRenderAspectPrivate::registerBackendTypes()
q->registerBackendType<QMemoryBarrier>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::MemoryBarrier, QMemoryBarrier> >::create(m_renderer));
q->registerBackendType<QProximityFilter>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::ProximityFilter, QProximityFilter> >::create(m_renderer));
q->registerBackendType<QBlitFramebuffer>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::BlitFramebuffer, QBlitFramebuffer> >::create(m_renderer));
+ q->registerBackendType<QSetFence>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::SetFence, QSetFence> >::create(m_renderer));
+ q->registerBackendType<QWaitFence>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::WaitFence, QWaitFence> >::create(m_renderer));
// Picking
q->registerBackendType<QObjectPicker>(QSharedPointer<Render::NodeFunctor<Render::ObjectPicker, Render::ObjectPickerManager> >::create(m_renderer));
@@ -368,6 +374,8 @@ void QRenderAspectPrivate::unregisterBackendTypes()
unregisterBackendType<QRenderCapture>();
unregisterBackendType<QBufferCapture>();
unregisterBackendType<QMemoryBarrier>();
+ unregisterBackendType<QSetFence>();
+ unregisterBackendType<QWaitFence>();
// Picking
unregisterBackendType<QObjectPicker>();
@@ -509,11 +517,8 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
const QVector<QAspectJobPtr> geometryJobs = d->createGeometryRendererJobs();
jobs.append(geometryJobs);
-
- // Add all jobs to queue
- // Note: the getter is also responsible for returning a job ready to run
- jobs.append(d->m_renderer->pickBoundingVolumeJob());
- jobs.append(d->m_renderer->rayCastingJob());
+ const QVector<QAspectJobPtr> preRenderingJobs = d->m_renderer->preRenderingJobs();
+ jobs.append(preRenderingJobs);
// Don't spawn any rendering jobs, if the renderer decides to skip this frame
// Note: this only affects rendering jobs (jobs that load buffers,
diff --git a/src/render/frontend/qrenderaspect.h b/src/render/frontend/qrenderaspect.h
index bde60c9e2..5571988a7 100644
--- a/src/render/frontend/qrenderaspect.h
+++ b/src/render/frontend/qrenderaspect.h
@@ -65,7 +65,7 @@ class QRenderAspectPrivate;
class QRenderAspectTester;
#endif
-class QT3DRENDERSHARED_EXPORT QRenderAspect : public Qt3DCore::QAbstractAspect
+class Q_3DRENDERSHARED_EXPORT QRenderAspect : public Qt3DCore::QAbstractAspect
{
Q_OBJECT
public:
diff --git a/src/render/frontend/qrenderaspect_p.h b/src/render/frontend/qrenderaspect_p.h
index 26ca091f6..4a091e164 100644
--- a/src/render/frontend/qrenderaspect_p.h
+++ b/src/render/frontend/qrenderaspect_p.h
@@ -75,7 +75,7 @@ namespace Render {
class OffscreenSurfaceHelper;
}
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderAspectPrivate : public Qt3DCore::QAbstractAspectPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderAspectPrivate : public Qt3DCore::QAbstractAspectPrivate
{
public:
QRenderAspectPrivate(QRenderAspect::RenderType type);
diff --git a/src/render/frontend/qrenderplugin_p.h b/src/render/frontend/qrenderplugin_p.h
index 5144448c1..c34dabefc 100644
--- a/src/render/frontend/qrenderplugin_p.h
+++ b/src/render/frontend/qrenderplugin_p.h
@@ -64,7 +64,7 @@ namespace Render {
class AbstractRenderer;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPlugin
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderPlugin
{
public:
virtual bool registerBackendTypes(QRenderAspect *aspect, AbstractRenderer *renderer) = 0;
diff --git a/src/render/frontend/qrenderpluginfactory_p.h b/src/render/frontend/qrenderpluginfactory_p.h
index 9cffd500a..26e856613 100644
--- a/src/render/frontend/qrenderpluginfactory_p.h
+++ b/src/render/frontend/qrenderpluginfactory_p.h
@@ -59,7 +59,7 @@ namespace Render {
class QRenderPlugin;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactory
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
diff --git a/src/render/frontend/qrenderpluginfactoryif_p.h b/src/render/frontend/qrenderpluginfactoryif_p.h
index d5f0008d2..249552b32 100644
--- a/src/render/frontend/qrenderpluginfactoryif_p.h
+++ b/src/render/frontend/qrenderpluginfactoryif_p.h
@@ -64,7 +64,7 @@ namespace Render {
class QRenderPlugin;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactoryIf : public QObject
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderPluginFactoryIf : public QObject
{
Q_OBJECT
public:
diff --git a/src/render/frontend/qrendersettings.h b/src/render/frontend/qrendersettings.h
index b759ebd88..9d2baa58b 100644
--- a/src/render/frontend/qrendersettings.h
+++ b/src/render/frontend/qrendersettings.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QFrameGraphNode;
class QRenderSettingsPrivate;
-class QT3DRENDERSHARED_EXPORT QRenderSettings : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QRenderSettings : public Qt3DCore::QComponent
{
Q_OBJECT
diff --git a/src/render/frontend/qrendersettings_p.h b/src/render/frontend/qrendersettings_p.h
index 60ebd0f0d..f91397bd2 100644
--- a/src/render/frontend/qrendersettings_p.h
+++ b/src/render/frontend/qrendersettings_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderSettingsPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderSettingsPrivate : public Qt3DCore::QComponentPrivate
{
public:
QRenderSettingsPrivate();
diff --git a/src/render/frontend/qrendertarget.h b/src/render/frontend/qrendertarget.h
index 69bed5aa5..9faf113da 100644
--- a/src/render/frontend/qrendertarget.h
+++ b/src/render/frontend/qrendertarget.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QRenderTargetPrivate;
class QRenderTargetOutput;
-class QT3DRENDERSHARED_EXPORT QRenderTarget : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QRenderTarget : public Qt3DCore::QComponent
{
Q_OBJECT
public:
diff --git a/src/render/frontend/qrendertarget_p.h b/src/render/frontend/qrendertarget_p.h
index f1035e846..b08477478 100644
--- a/src/render/frontend/qrendertarget_p.h
+++ b/src/render/frontend/qrendertarget_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QRenderTargetOutput;
class QRenderTarget;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderTargetPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderTargetPrivate : public Qt3DCore::QComponentPrivate
{
public:
QRenderTargetPrivate();
diff --git a/src/render/frontend/qrendertargetoutput.h b/src/render/frontend/qrendertargetoutput.h
index 2eb99df3c..a582c26f0 100644
--- a/src/render/frontend/qrendertargetoutput.h
+++ b/src/render/frontend/qrendertargetoutput.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QAbstractTexture;
class QRenderTargetOutputPrivate;
-class QT3DRENDERSHARED_EXPORT QRenderTargetOutput : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QRenderTargetOutput : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(AttachmentPoint attachmentPoint READ attachmentPoint WRITE setAttachmentPoint NOTIFY attachmentPointChanged)
diff --git a/src/render/frontend/qrendertargetoutput_p.h b/src/render/frontend/qrendertargetoutput_p.h
index df855f184..e16a5eeb0 100644
--- a/src/render/frontend/qrendertargetoutput_p.h
+++ b/src/render/frontend/qrendertargetoutput_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QAbstractTexture;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderTargetOutputPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderTargetOutputPrivate : public Qt3DCore::QNodePrivate
{
public:
QRenderTargetOutputPrivate();
diff --git a/src/render/frontend/sphere_p.h b/src/render/frontend/sphere_p.h
index 14b6f1414..10cf92091 100644
--- a/src/render/frontend/sphere_p.h
+++ b/src/render/frontend/sphere_p.h
@@ -64,7 +64,7 @@ namespace Qt3DRender {
namespace Render {
-class QT3DRENDERSHARED_PRIVATE_EXPORT Sphere : public RayCasting::BoundingSphere
+class Q_3DRENDERSHARED_PRIVATE_EXPORT Sphere : public RayCasting::BoundingSphere
{
public:
inline Sphere(Qt3DCore::QNodeId i = Qt3DCore::QNodeId())
@@ -158,7 +158,7 @@ inline bool intersects(const Sphere &a, const Sphere &b)
}
#ifndef QT_NO_DEBUG_STREAM
-QT3DRENDERSHARED_EXPORT QDebug operator<<(QDebug dbg, const Sphere &sphere);
+Q_3DRENDERSHARED_EXPORT QDebug operator<<(QDebug dbg, const Sphere &sphere);
#endif
} // Render
diff --git a/src/render/geometry/attribute.cpp b/src/render/geometry/attribute.cpp
index 6c8c0113a..bc6b27851 100644
--- a/src/render/geometry/attribute.cpp
+++ b/src/render/geometry/attribute.cpp
@@ -100,6 +100,17 @@ void Attribute::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &ch
m_attributeDirty = true;
}
+/*!
+ \fn Qt3DRender::QAttribute::dataSizeChanged(uint vertexSize)
+
+ The signal is emitted with \a vertexSize when the dataSize changes.
+
+*/
+/*!
+ \fn Qt3DRender::QAttribute::dataTypeChanged(Qt3DRender::QAttribute::VertexBaseType vertexBaseType)
+
+ The signal is emitted with \a vertexBaseType when the dataType changed.
+*/
void Attribute::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
switch (e->type()) {
diff --git a/src/render/geometry/geometry.cpp b/src/render/geometry/geometry.cpp
index d87b4d8eb..4ee02a74d 100644
--- a/src/render/geometry/geometry.cpp
+++ b/src/render/geometry/geometry.cpp
@@ -53,8 +53,10 @@ namespace Qt3DRender {
namespace Render {
Geometry::Geometry()
- : BackendNode(ReadOnly)
+ : BackendNode(ReadWrite)
, m_geometryDirty(false)
+ , m_shouldNotifyMinExtentChanged(false)
+ , m_shouldNotifyMaxExtentChanged(false)
{
}
@@ -68,6 +70,10 @@ void Geometry::cleanup()
m_attributes.clear();
m_geometryDirty = false;
m_boundingPositionAttribute = Qt3DCore::QNodeId();
+ m_min = QVector3D();
+ m_max = QVector3D();
+ m_shouldNotifyMinExtentChanged = false;
+ m_shouldNotifyMaxExtentChanged = false;
}
void Geometry::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
@@ -122,6 +128,37 @@ void Geometry::unsetDirty()
m_geometryDirty = false;
}
+// Called from calcboundingvolumejob (in a QtConcurrent thead (can't send
+// update changes from such a thread))
+void Geometry::updateExtent(const QVector3D &min, const QVector3D &max)
+{
+ // Send notification to frontend
+ if (m_min != min) {
+ m_min = min;
+ m_shouldNotifyMinExtentChanged = true;
+ }
+
+ if (m_max != max) {
+ m_max = max;
+ m_shouldNotifyMaxExtentChanged = true;
+ }
+}
+
+// Called from calcboundingvolumejob after all bounding volumes have been
+// updated (in an aspect thread)
+void Geometry::notifyExtentChanged()
+{
+ if (m_shouldNotifyMinExtentChanged || m_shouldNotifyMaxExtentChanged) {
+ auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
+ change->setPropertyName("extent");
+ change->setValue(QVariant::fromValue(QPair<QVector3D, QVector3D>(m_min, m_max)));
+ notifyObservers(change);
+ m_shouldNotifyMinExtentChanged = false;
+ m_shouldNotifyMaxExtentChanged = false;
+ }
+}
+
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/geometry/geometry_p.h b/src/render/geometry/geometry_p.h
index b158648ad..e66524787 100644
--- a/src/render/geometry/geometry_p.h
+++ b/src/render/geometry/geometry_p.h
@@ -75,12 +75,22 @@ public:
inline Qt3DCore::QNodeId boundingPositionAttribute() const { return m_boundingPositionAttribute; }
void unsetDirty();
+ inline QVector3D min() const { return m_min; }
+ inline QVector3D max() const { return m_max; }
+
+ void updateExtent(const QVector3D &min, const QVector3D &max);
+ void notifyExtentChanged();
+
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
QVector<Qt3DCore::QNodeId> m_attributes;
bool m_geometryDirty;
Qt3DCore::QNodeId m_boundingPositionAttribute;
+ QVector3D m_min;
+ QVector3D m_max;
+ bool m_shouldNotifyMinExtentChanged;
+ bool m_shouldNotifyMaxExtentChanged;
};
} // namespace Render
diff --git a/src/render/geometry/qattribute.h b/src/render/geometry/qattribute.h
index 13a0319b5..526a77a59 100644
--- a/src/render/geometry/qattribute.h
+++ b/src/render/geometry/qattribute.h
@@ -53,7 +53,7 @@ class QAttributePrivate;
typedef QSharedPointer<QBuffer> QBufferPtr;
-class QT3DRENDERSHARED_EXPORT QAttribute : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QAttribute : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QBuffer *buffer READ buffer WRITE setBuffer NOTIFY bufferChanged)
diff --git a/src/render/geometry/qattribute_p.h b/src/render/geometry/qattribute_p.h
index d3385345a..8355a042b 100644
--- a/src/render/geometry/qattribute_p.h
+++ b/src/render/geometry/qattribute_p.h
@@ -62,7 +62,7 @@ namespace Qt3DRender {
class QAttribute;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QAttributePrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QAttributePrivate : public Qt3DCore::QNodePrivate
{
public:
Q_DECLARE_PUBLIC(QAttribute)
diff --git a/src/render/geometry/qbuffer.h b/src/render/geometry/qbuffer.h
index f04c98a11..1bd1aa8fd 100644
--- a/src/render/geometry/qbuffer.h
+++ b/src/render/geometry/qbuffer.h
@@ -53,7 +53,7 @@ class QBufferPrivate;
class QBufferDataGenerator;
typedef QSharedPointer<QBufferDataGenerator> QBufferDataGeneratorPtr;
-class QT3DRENDERSHARED_EXPORT QBuffer : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QBuffer : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(BufferType type READ type WRITE setType NOTIFY typeChanged)
diff --git a/src/render/geometry/qbuffer_p.h b/src/render/geometry/qbuffer_p.h
index a342518e0..7a0ffdfb9 100644
--- a/src/render/geometry/qbuffer_p.h
+++ b/src/render/geometry/qbuffer_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QBufferPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_EXPORT QBufferPrivate : public Qt3DCore::QNodePrivate
{
public:
Q_DECLARE_PUBLIC(QBuffer)
diff --git a/src/render/geometry/qbufferdatagenerator.h b/src/render/geometry/qbufferdatagenerator.h
index 004eb26eb..aea6eaef5 100644
--- a/src/render/geometry/qbufferdatagenerator.h
+++ b/src/render/geometry/qbufferdatagenerator.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QBufferDataGenerator : public QAbstractFunctor
+class Q_3DRENDERSHARED_EXPORT QBufferDataGenerator : public QAbstractFunctor
{
public:
virtual ~QBufferDataGenerator() {}
diff --git a/src/render/geometry/qgeometry.cpp b/src/render/geometry/qgeometry.cpp
index c49dde822..ec80e2657 100644
--- a/src/render/geometry/qgeometry.cpp
+++ b/src/render/geometry/qgeometry.cpp
@@ -153,6 +153,28 @@ QGeometry::QGeometry(QGeometryPrivate &dd, QNode *parent)
{
}
+void QGeometry::sceneChangeEvent(const QSceneChangePtr &change)
+{
+ Q_D(QGeometry);
+ QPropertyUpdatedChangePtr e = qSharedPointerCast<QPropertyUpdatedChange>(change);
+ if (e->type() == PropertyUpdated) {
+ const bool blocked = blockNotifications(true);
+ if (e->propertyName() == QByteArrayLiteral("extent")) {
+ const QPair<QVector3D, QVector3D> extent = e->value().value<QPair<QVector3D, QVector3D>>();
+
+ if (extent.first != d->m_minExtent) {
+ d->m_minExtent = extent.first;
+ emit minExtentChanged(extent.first);
+ }
+ if (extent.second != d->m_maxExtent) {
+ d->m_maxExtent = extent.second;
+ emit maxExtentChanged(d->m_maxExtent);
+ }
+ }
+ blockNotifications(blocked);
+ }
+}
+
/*!
\fn void Qt3DRender::QGeometry::addAttribute(Qt3DRender::QAttribute *attribute)
Adds an \a attribute to this geometry.
@@ -216,6 +238,40 @@ QAttribute *QGeometry::boundingVolumePositionAttribute() const
}
/*!
+ \qmlproperty vector3d Geometry::minExtent
+
+ Holds the vertex with the lowest x, y, z position values.
+ */
+
+/*!
+ \property QGeometry::minExtent
+
+ Holds the vertex with the lowest x, y, z position values.
+ */
+QVector3D QGeometry::minExtent() const
+{
+ Q_D(const QGeometry);
+ return d->m_minExtent;
+}
+
+/*!
+ \qmlproperty vector3d Geometry::maxExtent
+
+ Holds the vertex with the highest x, y, z position values.
+ */
+
+/*!
+ \property QGeometry::maxExtent
+
+ Holds the vertex with the highest x, y, z position values.
+ */
+QVector3D QGeometry::maxExtent() const
+{
+ Q_D(const QGeometry);
+ return d->m_maxExtent;
+}
+
+/*!
Returns the list of attributes in this geometry.
*/
QVector<QAttribute *> QGeometry::attributes() const
diff --git a/src/render/geometry/qgeometry.h b/src/render/geometry/qgeometry.h
index 0e6f7d68e..cae637f1f 100644
--- a/src/render/geometry/qgeometry.h
+++ b/src/render/geometry/qgeometry.h
@@ -50,10 +50,12 @@ namespace Qt3DRender {
class QAttribute;
class QGeometryPrivate;
-class QT3DRENDERSHARED_EXPORT QGeometry : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QGeometry : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QAttribute *boundingVolumePositionAttribute READ boundingVolumePositionAttribute WRITE setBoundingVolumePositionAttribute NOTIFY boundingVolumePositionAttributeChanged)
+ Q_PROPERTY(QVector3D minExtent READ minExtent NOTIFY minExtentChanged REVISION 13)
+ Q_PROPERTY(QVector3D maxExtent READ maxExtent NOTIFY maxExtentChanged REVISION 13)
public:
explicit QGeometry(Qt3DCore::QNode *parent = nullptr);
~QGeometry();
@@ -63,15 +65,19 @@ public:
Q_INVOKABLE void removeAttribute(Qt3DRender::QAttribute *attribute);
QAttribute *boundingVolumePositionAttribute() const;
+ QVector3D minExtent() const;
+ QVector3D maxExtent() const;
public Q_SLOTS:
void setBoundingVolumePositionAttribute(QAttribute *boundingVolumePositionAttribute);
Q_SIGNALS:
void boundingVolumePositionAttributeChanged(QAttribute *boundingVolumePositionAttribute);
-
+ Q_REVISION(13) void minExtentChanged(const QVector3D &minExtent);
+ Q_REVISION(13) void maxExtentChanged(const QVector3D &maxExtent);
protected:
explicit QGeometry(QGeometryPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
private:
Q_DECLARE_PRIVATE(QGeometry)
diff --git a/src/render/geometry/qgeometry_p.h b/src/render/geometry/qgeometry_p.h
index e07b9ff0d..94f71d780 100644
--- a/src/render/geometry/qgeometry_p.h
+++ b/src/render/geometry/qgeometry_p.h
@@ -53,12 +53,13 @@
#include <Qt3DRender/private/qt3drender_global_p.h>
#include <Qt3DCore/private/qnode_p.h>
+#include <QVector3D>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QGeometryPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QGeometryPrivate : public Qt3DCore::QNodePrivate
{
public:
Q_DECLARE_PUBLIC(QGeometry)
@@ -68,6 +69,8 @@ public:
QVector<QAttribute *> m_attributes;
QAttribute *m_boundingVolumePositionAttribute;
+ QVector3D m_minExtent;
+ QVector3D m_maxExtent;
};
struct QGeometryData
diff --git a/src/render/geometry/qgeometryfactory.h b/src/render/geometry/qgeometryfactory.h
index 2e4d5c821..92acbc67d 100644
--- a/src/render/geometry/qgeometryfactory.h
+++ b/src/render/geometry/qgeometryfactory.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QGeometry;
-class QT3DRENDERSHARED_EXPORT QGeometryFactory : public QAbstractFunctor
+class Q_3DRENDERSHARED_EXPORT QGeometryFactory : public QAbstractFunctor
{
public:
virtual ~QGeometryFactory();
diff --git a/src/render/geometry/qgeometryrenderer.h b/src/render/geometry/qgeometryrenderer.h
index 85bab9fc6..81bd1ff67 100644
--- a/src/render/geometry/qgeometryrenderer.h
+++ b/src/render/geometry/qgeometryrenderer.h
@@ -53,7 +53,7 @@ class QGeometryFactory;
typedef QSharedPointer<QGeometryFactory> QGeometryFactoryPtr;
-class QT3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QGeometryRenderer : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(int instanceCount READ instanceCount WRITE setInstanceCount NOTIFY instanceCountChanged)
diff --git a/src/render/geometry/qgeometryrenderer_p.h b/src/render/geometry/qgeometryrenderer_p.h
index 8096b4a6b..32ca334e3 100644
--- a/src/render/geometry/qgeometryrenderer_p.h
+++ b/src/render/geometry/qgeometryrenderer_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QGeometryRendererPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QGeometryRendererPrivate : public Qt3DCore::QComponentPrivate
{
public:
QGeometryRendererPrivate();
diff --git a/src/render/geometry/qmesh.h b/src/render/geometry/qmesh.h
index a7b2747f7..458a21fa4 100644
--- a/src/render/geometry/qmesh.h
+++ b/src/render/geometry/qmesh.h
@@ -54,7 +54,7 @@ class QMeshPrivate;
* @brief Simple static mesh
*
*/
-class QT3DRENDERSHARED_EXPORT QMesh : public QGeometryRenderer
+class Q_3DRENDERSHARED_EXPORT QMesh : public QGeometryRenderer
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
diff --git a/src/render/geometry/qmesh_p.h b/src/render/geometry/qmesh_p.h
index 2d03e7862..4a4ff4979 100644
--- a/src/render/geometry/qmesh_p.h
+++ b/src/render/geometry/qmesh_p.h
@@ -69,7 +69,7 @@ namespace Render {
class NodeManagers;
}
-class QT3DRENDERSHARED_PRIVATE_EXPORT QMeshPrivate : public QGeometryRendererPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QMeshPrivate : public QGeometryRendererPrivate
{
public:
QMeshPrivate();
diff --git a/src/render/io/qaxisalignedboundingbox_p.h b/src/render/io/qaxisalignedboundingbox_p.h
index 7a88190b7..c77fa1147 100644
--- a/src/render/io/qaxisalignedboundingbox_p.h
+++ b/src/render/io/qaxisalignedboundingbox_p.h
@@ -86,7 +86,7 @@ public:
bool isNull() const { return m_center.isNull() && m_radii.isNull(); }
- void QT3DRENDERSHARED_PRIVATE_EXPORT update(const QVector<QVector3D> &points);
+ void Q_3DRENDERSHARED_PRIVATE_EXPORT update(const QVector<QVector3D> &points);
inline QVector3D center() const { return m_center; }
inline QVector3D radii() const { return m_radii; }
diff --git a/src/render/io/qgeometryloaderfactory_p.h b/src/render/io/qgeometryloaderfactory_p.h
index 6e0044c4a..b4f2be2b5 100644
--- a/src/render/io/qgeometryloaderfactory_p.h
+++ b/src/render/io/qgeometryloaderfactory_p.h
@@ -65,7 +65,7 @@ namespace Qt3DRender {
class QGeometryLoaderInterface;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QGeometryLoaderFactory : public QObject, public QFactoryInterface
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QGeometryLoaderFactory : public QObject, public QFactoryInterface
{
Q_OBJECT
Q_INTERFACES(QFactoryInterface)
diff --git a/src/render/io/qgeometryloaderinterface_p.h b/src/render/io/qgeometryloaderinterface_p.h
index 22d4f8bea..36928445f 100644
--- a/src/render/io/qgeometryloaderinterface_p.h
+++ b/src/render/io/qgeometryloaderinterface_p.h
@@ -63,7 +63,7 @@ namespace Qt3DRender {
class QGeometry;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QGeometryLoaderInterface : public QObject
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QGeometryLoaderInterface : public QObject
{
public:
virtual QGeometry *geometry() const = 0;
diff --git a/src/render/io/qsceneexporter_p.h b/src/render/io/qsceneexporter_p.h
index 3c8b92c77..7b92a0ff3 100644
--- a/src/render/io/qsceneexporter_p.h
+++ b/src/render/io/qsceneexporter_p.h
@@ -67,7 +67,7 @@ namespace Qt3DRender {
Q_DECLARE_LOGGING_CATEGORY(SceneParsers)
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneExporter : public QObject
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneExporter : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList errors READ errors NOTIFY errorsChanged)
diff --git a/src/render/io/qsceneexportfactory_p.h b/src/render/io/qsceneexportfactory_p.h
index 5ff6149f4..fbb278ebe 100644
--- a/src/render/io/qsceneexportfactory_p.h
+++ b/src/render/io/qsceneexportfactory_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QSceneExporter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneExportFactory
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneExportFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
diff --git a/src/render/io/qsceneexportplugin_p.h b/src/render/io/qsceneexportplugin_p.h
index 3515cd425..dcc1c7769 100644
--- a/src/render/io/qsceneexportplugin_p.h
+++ b/src/render/io/qsceneexportplugin_p.h
@@ -65,7 +65,7 @@ namespace Qt3DRender {
class QSceneExporter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneExportPlugin : public QObject
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneExportPlugin : public QObject
{
Q_OBJECT
public:
diff --git a/src/render/io/qsceneimporter_p.h b/src/render/io/qsceneimporter_p.h
index 8f83231c3..910a7fc66 100644
--- a/src/render/io/qsceneimporter_p.h
+++ b/src/render/io/qsceneimporter_p.h
@@ -67,7 +67,7 @@ namespace Qt3DRender {
Q_DECLARE_LOGGING_CATEGORY(SceneParsers)
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneImporter : public QObject
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneImporter : public QObject
{
Q_OBJECT
Q_PROPERTY(ParserStatus status READ status NOTIFY statusChanged)
diff --git a/src/render/io/qsceneimportfactory_p.h b/src/render/io/qsceneimportfactory_p.h
index c66937fa1..8409ea96d 100644
--- a/src/render/io/qsceneimportfactory_p.h
+++ b/src/render/io/qsceneimportfactory_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QSceneImporter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneImportFactory
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneImportFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
diff --git a/src/render/io/qsceneimportplugin_p.h b/src/render/io/qsceneimportplugin_p.h
index 01ab84060..a24d1fa3e 100644
--- a/src/render/io/qsceneimportplugin_p.h
+++ b/src/render/io/qsceneimportplugin_p.h
@@ -65,7 +65,7 @@ namespace Qt3DRender {
class QSceneImporter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneImportPlugin : public QObject
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneImportPlugin : public QObject
{
Q_OBJECT
public:
diff --git a/src/render/io/qsceneloader.h b/src/render/io/qsceneloader.h
index c69a4ad98..4cb743333 100644
--- a/src/render/io/qsceneloader.h
+++ b/src/render/io/qsceneloader.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QSceneLoaderPrivate;
-class QT3DRENDERSHARED_EXPORT QSceneLoader : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QSceneLoader : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
diff --git a/src/render/io/qsceneloader_p.h b/src/render/io/qsceneloader_p.h
index 45a6a1a4e..50745c66f 100644
--- a/src/render/io/qsceneloader_p.h
+++ b/src/render/io/qsceneloader_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QSceneImporter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSceneLoaderPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSceneLoaderPrivate : public Qt3DCore::QComponentPrivate
{
public:
QSceneLoaderPrivate();
diff --git a/src/render/io/qurlhelper_p.h b/src/render/io/qurlhelper_p.h
index c9c4cfd9b..d816d5d31 100644
--- a/src/render/io/qurlhelper_p.h
+++ b/src/render/io/qurlhelper_p.h
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QUrlHelper
+class Q_3DRENDERSHARED_EXPORT QUrlHelper
{
public:
static QString urlToLocalFileOrQrc(const QUrl &url);
diff --git a/src/render/jobs/calcboundingvolumejob.cpp b/src/render/jobs/calcboundingvolumejob.cpp
index 66d59f812..113dc34ce 100644
--- a/src/render/jobs/calcboundingvolumejob.cpp
+++ b/src/render/jobs/calcboundingvolumejob.cpp
@@ -51,6 +51,7 @@
#include <Qt3DRender/private/buffer_p.h>
#include <Qt3DRender/private/sphere_p.h>
#include <Qt3DRender/private/buffervisitor_p.h>
+#include <Qt3DRender/private/entityaccumulator_p.h>
#include <QtCore/qmath.h>
#if QT_CONFIG(concurrent)
@@ -65,23 +66,14 @@ namespace Render {
namespace {
-void calculateLocalBoundingVolume(NodeManagers *manager, Entity *node);
-
-struct UpdateBoundFunctor {
- NodeManagers *manager;
-
- void operator ()(Qt3DRender::Render::Entity *node)
- {
- calculateLocalBoundingVolume(manager, node);
- }
-};
-
class BoundingVolumeCalculator
{
public:
BoundingVolumeCalculator(NodeManagers *manager) : m_manager(manager) { }
const Sphere& result() { return m_volume; }
+ const QVector3D min() const { return m_min; }
+ const QVector3D max() const { return m_max; }
bool apply(Qt3DRender::Render::Attribute *positionAttribute,
Qt3DRender::Render::Attribute *indexAttribute,
@@ -95,6 +87,9 @@ public:
return false;
}
+ m_min = QVector3D(findExtremePoints.xMin, findExtremePoints.yMin, findExtremePoints.zMin);
+ m_max = QVector3D(findExtremePoints.xMax, findExtremePoints.yMax, findExtremePoints.zMax);
+
// Calculate squared distance for the pairs of points
const float xDist2 = (findExtremePoints.xMaxPt - findExtremePoints.xMinPt).lengthSquared();
const float yDist2 = (findExtremePoints.yMaxPt - findExtremePoints.yMinPt).lengthSquared();
@@ -127,6 +122,8 @@ public:
private:
Sphere m_volume;
NodeManagers *m_manager;
+ QVector3D m_min;
+ QVector3D m_max;
class FindExtremePoints : public Buffer3fVisitor
{
@@ -191,17 +188,20 @@ private:
};
};
-void calculateLocalBoundingVolume(NodeManagers *manager, Entity *node)
+QVector<Geometry *> calculateLocalBoundingVolume(NodeManagers *manager, Entity *node)
{
// The Bounding volume will only be computed if the position Buffer
// isDirty
+ QVector<Geometry *> updatedGeometries;
+
if (!node->isTreeEnabled())
- return;
+ return updatedGeometries;
GeometryRenderer *gRenderer = node->renderComponent<GeometryRenderer>();
+ GeometryManager *geometryManager = manager->geometryManager();
if (gRenderer && gRenderer->primitiveType() != QGeometryRenderer::Patches) {
- Geometry *geom = manager->lookupResource<Geometry, GeometryManager>(gRenderer->geometryId());
+ Geometry *geom = geometryManager->lookupResource(gRenderer->geometryId());
if (geom) {
int drawVertexCount = gRenderer->vertexCount(); // may be 0, gets changed below if so
@@ -224,14 +224,14 @@ void calculateLocalBoundingVolume(NodeManagers *manager, Entity *node)
|| positionAttribute->vertexBaseType() != QAttribute::Float
|| positionAttribute->vertexSize() < 3) {
qWarning("calculateLocalBoundingVolume: Position attribute not suited for bounding volume computation");
- return;
+ return updatedGeometries;
}
Buffer *buf = manager->lookupResource<Buffer, BufferManager>(positionAttribute->bufferId());
// No point in continuing if the positionAttribute doesn't have a suitable buffer
if (!buf) {
qWarning("calculateLocalBoundingVolume: Position attribute not referencing a valid buffer");
- return;
+ return updatedGeometries;
}
// Check if there is an index attribute.
@@ -259,7 +259,7 @@ void calculateLocalBoundingVolume(NodeManagers *manager, Entity *node)
std::end(validIndexTypes),
indexAttribute->vertexBaseType()) == std::end(validIndexTypes)) {
qWarning() << "calculateLocalBoundingVolume: Unsupported index attribute type" << indexAttribute->name() << indexAttribute->vertexBaseType();
- return;
+ return updatedGeometries;
}
break;
@@ -287,25 +287,38 @@ void calculateLocalBoundingVolume(NodeManagers *manager, Entity *node)
node->localBoundingVolume()->setCenter(reader.result().center());
node->localBoundingVolume()->setRadius(reader.result().radius());
node->unsetBoundingVolumeDirty();
+
+ // Record min/max vertex in Geometry
+ geom->updateExtent(reader.min(), reader.max());
+ // Mark geometry as requiring a call to update its frontend
+ updatedGeometries.push_back(geom);
}
}
}
}
-#if QT_CONFIG(concurrent)
- const QVector<Qt3DRender::Render::Entity *> children = node->children();
- if (children.size() > 1) {
- UpdateBoundFunctor functor;
- functor.manager = manager;
- QtConcurrent::blockingMap(children, functor);
- } else
-#endif
+ return updatedGeometries;
+}
+
+struct UpdateBoundFunctor
+{
+ NodeManagers *manager;
+
+ // This define is required to work with QtConcurrent
+ typedef QVector<Geometry *> result_type;
+ QVector<Geometry *> operator ()(Qt3DRender::Render::Entity *node)
{
- const auto children = node->children();
- for (Entity *child : children)
- calculateLocalBoundingVolume(manager, child);
+ return calculateLocalBoundingVolume(manager, node);
}
-}
+};
+
+struct ReduceUpdateBoundFunctor
+{
+ void operator ()(QVector<Geometry *> &result, const QVector<Geometry *> &values)
+ {
+ result += values;
+ }
+};
} // anonymous
@@ -318,7 +331,30 @@ CalculateBoundingVolumeJob::CalculateBoundingVolumeJob()
void CalculateBoundingVolumeJob::run()
{
- calculateLocalBoundingVolume(m_manager, m_node);
+ EntityAccumulator accumulator([](Entity *entity) {
+ return !entity->componentUuid<GeometryRenderer>().isNull();
+ }, m_manager);
+ auto entities = accumulator.apply(m_node);
+
+ QVector<Geometry *> updatedGeometries;
+ updatedGeometries.reserve(entities.size());
+
+#if QT_CONFIG(concurrent)
+ if (entities.size() > 1) {
+ UpdateBoundFunctor functor;
+ functor.manager = m_manager;
+ ReduceUpdateBoundFunctor reduceFunctor;
+ updatedGeometries += QtConcurrent::blockingMappedReduced<decltype(updatedGeometries)>(entities, functor, reduceFunctor);
+ } else
+#endif
+ {
+ for (Entity *child : entities)
+ updatedGeometries += calculateLocalBoundingVolume(m_manager, child);
+ }
+
+ // Send extent updates to frontend
+ for (Geometry *geometry : updatedGeometries)
+ geometry->notifyExtentChanged();
}
void CalculateBoundingVolumeJob::setRoot(Entity *node)
diff --git a/src/render/jobs/calcboundingvolumejob_p.h b/src/render/jobs/calcboundingvolumejob_p.h
index 41a8bd6c1..3b62c83cd 100644
--- a/src/render/jobs/calcboundingvolumejob_p.h
+++ b/src/render/jobs/calcboundingvolumejob_p.h
@@ -65,7 +65,7 @@ namespace Render {
class NodeManagers;
class Entity;
-class QT3DRENDERSHARED_PRIVATE_EXPORT CalculateBoundingVolumeJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT CalculateBoundingVolumeJob : public Qt3DCore::QAspectJob
{
public:
explicit CalculateBoundingVolumeJob();
diff --git a/src/render/jobs/computefilteredboundingvolumejob.cpp b/src/render/jobs/computefilteredboundingvolumejob.cpp
index d8a7b5094..02852685c 100644
--- a/src/render/jobs/computefilteredboundingvolumejob.cpp
+++ b/src/render/jobs/computefilteredboundingvolumejob.cpp
@@ -44,6 +44,8 @@
#include <Qt3DRender/private/renderlogging_p.h>
#include <Qt3DRender/private/sphere_p.h>
#include <Qt3DRender/private/job_common_p.h>
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
#include <QThread>
@@ -54,16 +56,18 @@ namespace Render {
namespace {
-void expandWorldBoundingVolume(Qt3DRender::Render::Sphere *sphere,
+void expandWorldBoundingVolume(NodeManagers *manager,
+ Qt3DRender::Render::Sphere *sphere,
Qt3DRender::Render::Entity *node,
Qt3DRender::Render::Entity *excludeSubTree)
{
Qt3DRender::Render::Sphere childSphere(*node->worldBoundingVolume());
// Go to the nodes that have the most depth
- const auto children = node->children();
- for (Entity *c : children) {
- if (c != excludeSubTree)
- expandWorldBoundingVolume(&childSphere, c, excludeSubTree);
+ const auto childrenHandles = node->childrenHandles();
+ for (const HEntity &handle : childrenHandles) {
+ Entity *c = manager->renderNodesManager()->data(handle);
+ if (c && c != excludeSubTree)
+ expandWorldBoundingVolume(manager, &childSphere, c, excludeSubTree);
}
sphere->expandToContain(childSphere);
}
@@ -73,6 +77,7 @@ void expandWorldBoundingVolume(Qt3DRender::Render::Sphere *sphere,
ComputeFilteredBoundingVolumeJob::ComputeFilteredBoundingVolumeJob()
: m_root(nullptr)
, m_ignoreSubTree(nullptr)
+ , m_manager(nullptr)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::ExpandBoundingVolume, 0);
}
@@ -82,6 +87,11 @@ void ComputeFilteredBoundingVolumeJob::setRoot(Entity *root)
m_root = root;
}
+void ComputeFilteredBoundingVolumeJob::setManagers(NodeManagers *manager)
+{
+ m_manager = manager;
+}
+
void ComputeFilteredBoundingVolumeJob::ignoreSubTree(Entity *node)
{
m_ignoreSubTree = node;
@@ -113,7 +123,7 @@ void ComputeFilteredBoundingVolumeJob::run()
}
Qt3DRender::Render::Sphere sphere;
- expandWorldBoundingVolume(&sphere, m_root, m_ignoreSubTree);
+ expandWorldBoundingVolume(m_manager, &sphere, m_root, m_ignoreSubTree);
finished(sphere);
qCDebug(Jobs) << "Exiting" << Q_FUNC_INFO << QThread::currentThread();
diff --git a/src/render/jobs/computefilteredboundingvolumejob_p.h b/src/render/jobs/computefilteredboundingvolumejob_p.h
index ed336fe08..d2aca575c 100644
--- a/src/render/jobs/computefilteredboundingvolumejob_p.h
+++ b/src/render/jobs/computefilteredboundingvolumejob_p.h
@@ -62,14 +62,16 @@ namespace Qt3DRender {
namespace Render {
class Entity;
+class NodeManagers;
class Sphere;
-class QT3DRENDERSHARED_PRIVATE_EXPORT ComputeFilteredBoundingVolumeJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT ComputeFilteredBoundingVolumeJob : public Qt3DCore::QAspectJob
{
public:
ComputeFilteredBoundingVolumeJob();
void setRoot(Entity *root);
+ void setManagers(NodeManagers *manager);
void ignoreSubTree(Entity *node);
void run() override;
@@ -79,6 +81,7 @@ protected:
private:
Entity *m_root;
Entity *m_ignoreSubTree;
+ NodeManagers *m_manager;
};
typedef QSharedPointer<ComputeFilteredBoundingVolumeJob> ComputeFilteredBoundingVolumeJobPtr;
diff --git a/src/render/jobs/expandboundingvolumejob.cpp b/src/render/jobs/expandboundingvolumejob.cpp
index ec175f312..d63934b54 100644
--- a/src/render/jobs/expandboundingvolumejob.cpp
+++ b/src/render/jobs/expandboundingvolumejob.cpp
@@ -44,6 +44,8 @@
#include <Qt3DRender/private/renderlogging_p.h>
#include <Qt3DRender/private/sphere_p.h>
#include <Qt3DRender/private/job_common_p.h>
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
#include <QThread>
@@ -54,19 +56,25 @@ namespace Render {
namespace {
-void expandWorldBoundingVolume(Qt3DRender::Render::Entity *node)
+void expandWorldBoundingVolume(NodeManagers *manager, Entity *node)
{
// Go to the nodes that have the most depth
- const auto children = node->children();
- for (Entity *c : children)
- expandWorldBoundingVolume(c);
+ const auto childrenHandles = node->childrenHandles();
+ for (const HEntity &handle : childrenHandles) {
+ Entity *c = manager->renderNodesManager()->data(handle);
+ if (c)
+ expandWorldBoundingVolume(manager, c);
+ }
// Then traverse back from leaf to root
// Initialize parent bounding volume to be equal to that of the first child
- if (!children.empty()) {
+ if (!childrenHandles.empty()) {
Qt3DRender::Render::Sphere *parentBoundingVolume = node->worldBoundingVolumeWithChildren();
- for (Entity *c : children)
- parentBoundingVolume->expandToContain(*c->worldBoundingVolumeWithChildren());
+ for (const HEntity &handle : childrenHandles) {
+ Entity *c = manager->renderNodesManager()->data(handle);
+ if (c)
+ parentBoundingVolume->expandToContain(*c->worldBoundingVolumeWithChildren());
+ }
}
}
@@ -74,6 +82,7 @@ void expandWorldBoundingVolume(Qt3DRender::Render::Entity *node)
ExpandBoundingVolumeJob::ExpandBoundingVolumeJob()
: m_node(nullptr)
+ , m_manager(nullptr)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::ExpandBoundingVolume, 0);
}
@@ -83,6 +92,11 @@ void ExpandBoundingVolumeJob::setRoot(Entity *root)
m_node = root;
}
+void ExpandBoundingVolumeJob::setManagers(NodeManagers *manager)
+{
+ m_manager = manager;
+}
+
void ExpandBoundingVolumeJob::run()
{
// Expand worldBoundingVolumeWithChildren of each node that has children by the
@@ -90,7 +104,7 @@ void ExpandBoundingVolumeJob::run()
// TODO: Implement this using a parallel_for
qCDebug(Jobs) << "Entering" << Q_FUNC_INFO << QThread::currentThread();
- expandWorldBoundingVolume(m_node);
+ expandWorldBoundingVolume(m_manager, m_node);
qCDebug(Jobs) << "Exiting" << Q_FUNC_INFO << QThread::currentThread();
}
diff --git a/src/render/jobs/expandboundingvolumejob_p.h b/src/render/jobs/expandboundingvolumejob_p.h
index f468cf816..a2745b456 100644
--- a/src/render/jobs/expandboundingvolumejob_p.h
+++ b/src/render/jobs/expandboundingvolumejob_p.h
@@ -62,17 +62,20 @@ namespace Qt3DRender {
namespace Render {
class Entity;
+class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT ExpandBoundingVolumeJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT ExpandBoundingVolumeJob : public Qt3DCore::QAspectJob
{
public:
ExpandBoundingVolumeJob();
void setRoot(Entity *root);
+ void setManagers(NodeManagers *manager);
void run() override;
private:
Entity *m_node;
+ NodeManagers *m_manager;
};
typedef QSharedPointer<ExpandBoundingVolumeJob> ExpandBoundingVolumeJobPtr;
diff --git a/src/render/jobs/filterlayerentityjob_p.h b/src/render/jobs/filterlayerentityjob_p.h
index 418f3ff3a..33023775f 100644
--- a/src/render/jobs/filterlayerentityjob_p.h
+++ b/src/render/jobs/filterlayerentityjob_p.h
@@ -65,7 +65,7 @@ namespace Render {
class Entity;
class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT FilterLayerEntityJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT FilterLayerEntityJob : public Qt3DCore::QAspectJob
{
public:
FilterLayerEntityJob();
diff --git a/src/render/jobs/framecleanupjob.cpp b/src/render/jobs/framecleanupjob.cpp
index d0496f991..ed01e73b4 100644
--- a/src/render/jobs/framecleanupjob.cpp
+++ b/src/render/jobs/framecleanupjob.cpp
@@ -81,22 +81,20 @@ void FrameCleanupJob::updateBoundingVolumesDebug(Entity *node)
{
Q_UNUSED(node);
#if 0
- BoundingVolumeDebug *debugBV = node->renderComponent<BoundingVolumeDebug>();
- if (debugBV) {
- Qt3DRender::Render::Sphere s;
- if (!debugBV->isRecursive()) {
- s = *node->worldBoundingVolume();
- } else {
- s = *node->worldBoundingVolumeWithChildren();
+ node->traverse([](Entity *node) {
+ BoundingVolumeDebug *debugBV = node->renderComponent<BoundingVolumeDebug>();
+ if (debugBV) {
+ Qt3DRender::Render::Sphere s;
+ if (!debugBV->isRecursive()) {
+ s = *node->worldBoundingVolume();
+ } else {
+ s = *node->worldBoundingVolumeWithChildren();
+ }
+ debugBV->setRadius(s.radius());
+ debugBV->setCenter(s.center());
}
- debugBV->setRadius(s.radius());
- debugBV->setCenter(s.center());
- }
+ });
-
- const auto children = node->children();
- for (Entity *c : children)
- updateBoundingVolumesDebug(c);
#endif
}
diff --git a/src/render/jobs/framecleanupjob_p.h b/src/render/jobs/framecleanupjob_p.h
index e3700fedc..78938a8cf 100644
--- a/src/render/jobs/framecleanupjob_p.h
+++ b/src/render/jobs/framecleanupjob_p.h
@@ -64,7 +64,7 @@ namespace Render {
class NodeManagers;
class Entity;
-class QT3DRENDERSHARED_PRIVATE_EXPORT FrameCleanupJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT FrameCleanupJob : public Qt3DCore::QAspectJob
{
public:
explicit FrameCleanupJob();
diff --git a/src/render/jobs/frustumcullingjob.cpp b/src/render/jobs/frustumcullingjob.cpp
index 1a03b691d..0922fb0cb 100644
--- a/src/render/jobs/frustumcullingjob.cpp
+++ b/src/render/jobs/frustumcullingjob.cpp
@@ -43,6 +43,8 @@
#include <Qt3DRender/private/entity_p.h>
#include <Qt3DRender/private/renderview_p.h>
#include <Qt3DRender/private/sphere_p.h>
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
QT_BEGIN_NAMESPACE
@@ -53,6 +55,7 @@ namespace Render {
FrustumCullingJob::FrustumCullingJob()
: Qt3DCore::QAspectJob()
, m_root(nullptr)
+ , m_manager(nullptr)
, m_active(false)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::FrustumCulling, 0);
@@ -83,27 +86,25 @@ void FrustumCullingJob::run()
void FrustumCullingJob::cullScene(Entity *e, const Plane *planes)
{
- const Sphere *s = e->worldBoundingVolumeWithChildren();
-
- // Unrolled loop
- if (Vector3D::dotProduct(s->center(), planes[0].normal) + planes[0].d < -s->radius())
- return;
- if (Vector3D::dotProduct(s->center(), planes[1].normal) + planes[1].d < -s->radius())
- return;
- if (Vector3D::dotProduct(s->center(), planes[2].normal) + planes[2].d < -s->radius())
- return;
- if (Vector3D::dotProduct(s->center(), planes[3].normal) + planes[3].d < -s->radius())
- return;
- if (Vector3D::dotProduct(s->center(), planes[4].normal) + planes[4].d < -s->radius())
- return;
- if (Vector3D::dotProduct(s->center(), planes[5].normal) + planes[5].d < -s->radius())
- return;
-
- m_visibleEntities.push_back(e);
-
- const QVector<Entity *> children = e->children();
- for (Entity *c : children)
- cullScene(c, planes);
+ e->traverse([planes, this](Entity *e) {
+ const Sphere *s = e->worldBoundingVolumeWithChildren();
+
+ // Unrolled loop
+ if (Vector3D::dotProduct(s->center(), planes[0].normal) + planes[0].d < -s->radius())
+ return;
+ if (Vector3D::dotProduct(s->center(), planes[1].normal) + planes[1].d < -s->radius())
+ return;
+ if (Vector3D::dotProduct(s->center(), planes[2].normal) + planes[2].d < -s->radius())
+ return;
+ if (Vector3D::dotProduct(s->center(), planes[3].normal) + planes[3].d < -s->radius())
+ return;
+ if (Vector3D::dotProduct(s->center(), planes[4].normal) + planes[4].d < -s->radius())
+ return;
+ if (Vector3D::dotProduct(s->center(), planes[5].normal) + planes[5].d < -s->radius())
+ return;
+
+ m_visibleEntities.push_back(e);
+ });
}
} // Render
diff --git a/src/render/jobs/frustumcullingjob_p.h b/src/render/jobs/frustumcullingjob_p.h
index f81e4c5b9..cddbbd409 100644
--- a/src/render/jobs/frustumcullingjob_p.h
+++ b/src/render/jobs/frustumcullingjob_p.h
@@ -63,6 +63,7 @@ namespace Render {
class Entity;
class EntityManager;
+class NodeManagers;
struct Plane;
class FrustumCullingJob : public Qt3DCore::QAspectJob
@@ -73,6 +74,7 @@ public:
QT3D_ALIGNED_MALLOC_AND_FREE()
inline void setRoot(Entity *root) Q_DECL_NOTHROW { m_root = root; }
+ inline void setManagers(NodeManagers *manager) Q_DECL_NOTHROW { m_manager = manager; }
inline void setActive(bool active) Q_DECL_NOTHROW { m_active = active; }
inline bool isActive() const Q_DECL_NOTHROW { return m_active; }
inline void setViewProjection(const Matrix4x4 &viewProjection) Q_DECL_NOTHROW { m_viewProjection = viewProjection; }
@@ -86,6 +88,7 @@ private:
void cullScene(Entity *e, const Plane *planes);
Matrix4x4 m_viewProjection;
Entity *m_root;
+ NodeManagers *m_manager;
QVector<Entity *> m_visibleEntities;
bool m_active;
};
diff --git a/src/render/jobs/job_common_p.h b/src/render/jobs/job_common_p.h
index 8f8242ec8..99bf99195 100644
--- a/src/render/jobs/job_common_p.h
+++ b/src/render/jobs/job_common_p.h
@@ -107,8 +107,9 @@ namespace JobTypes {
SyncFilterEntityByLayer,
SyncMaterialGatherer,
UpdateLayerEntity,
+ SendTextureChangesToFrontend,
+ SendSetFenceHandlesToFrontend,
UpdateEntityHierarchy,
- SendTextureChangesToFrontend
};
} // JobTypes
diff --git a/src/render/jobs/pickboundingvolumejob.cpp b/src/render/jobs/pickboundingvolumejob.cpp
index 2050b8772..96ec11b4e 100644
--- a/src/render/jobs/pickboundingvolumejob.cpp
+++ b/src/render/jobs/pickboundingvolumejob.cpp
@@ -211,7 +211,6 @@ bool PickBoundingVolumeJob::runHelper()
const bool edgePickingRequested = (m_renderSettings->pickMethod() & QPickingSettings::LinePicking);
const bool pointPickingRequested = (m_renderSettings->pickMethod() & QPickingSettings::PointPicking);
const bool primitivePickingRequested = pointPickingRequested | edgePickingRequested | trianglePickingRequested;
- const bool allHitsRequested = (m_renderSettings->pickResultMode() == QPickingSettings::AllPicks);
const bool frontFaceRequested =
m_renderSettings->faceOrientationPickingMode() != QPickingSettings::BackFace;
const bool backFaceRequested =
@@ -237,7 +236,7 @@ bool PickBoundingVolumeJob::runHelper()
// has moved out of the viewport In case of a button released
// outside of the viewport, we still want to notify the
// lastCurrent entity about this.
- dispatchPickEvents(event.second, PickingUtils::HitList(), eventButton, eventButtons, eventModifiers, allHitsRequested);
+ dispatchPickEvents(event.second, PickingUtils::HitList(), eventButton, eventButtons, eventModifiers, m_renderSettings->pickResultMode());
continue;
}
@@ -249,14 +248,16 @@ bool PickBoundingVolumeJob::runHelper()
gathererFunctor.m_backFaceRequested = backFaceRequested;
gathererFunctor.m_manager = m_manager;
gathererFunctor.m_ray = ray;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), allHitsRequested);
+ gathererFunctor.m_entityToPriorityTable = entityPicker.entityToPriorityTable();
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), m_renderSettings->pickResultMode());
}
if (edgePickingRequested) {
PickingUtils::LineCollisionGathererFunctor gathererFunctor;
gathererFunctor.m_manager = m_manager;
gathererFunctor.m_ray = ray;
gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), allHitsRequested);
+ gathererFunctor.m_entityToPriorityTable = entityPicker.entityToPriorityTable();
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), m_renderSettings->pickResultMode());
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
}
if (pointPickingRequested) {
@@ -264,19 +265,20 @@ bool PickBoundingVolumeJob::runHelper()
gathererFunctor.m_manager = m_manager;
gathererFunctor.m_ray = ray;
gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), allHitsRequested);
+ gathererFunctor.m_entityToPriorityTable = entityPicker.entityToPriorityTable();
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), m_renderSettings->pickResultMode());
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
}
if (!primitivePickingRequested) {
sphereHits << entityPicker.hits();
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
- if (!allHitsRequested)
+ if (m_renderSettings->pickResultMode() != QPickingSettings::AllPicks)
sphereHits = { sphereHits.front() };
}
}
// Dispatch events based on hit results
- dispatchPickEvents(event.second, sphereHits, eventButton, eventButtons, eventModifiers, allHitsRequested);
+ dispatchPickEvents(event.second, sphereHits, eventButton, eventButtons, eventModifiers, m_renderSettings->pickResultMode());
}
}
diff --git a/src/render/jobs/pickboundingvolumeutils.cpp b/src/render/jobs/pickboundingvolumeutils.cpp
index 5fed946d6..abc54482a 100644
--- a/src/render/jobs/pickboundingvolumeutils.cpp
+++ b/src/render/jobs/pickboundingvolumeutils.cpp
@@ -55,6 +55,7 @@
#include <vector>
#include <algorithm>
+#include <functional>
QT_BEGIN_NAMESPACE
@@ -134,34 +135,6 @@ bool ViewportCameraAreaGatherer::isUnique(const QVector<ViewportCameraAreaDetail
return true;
}
-QVector<Entity *> gatherEntities(Entity *entity, QVector<Entity *> entities)
-{
- if (entity != nullptr && entity->isEnabled()) {
- entities.push_back(entity);
- // Traverse children
- const auto children = entity->children();
- for (Entity *child : children)
- entities = gatherEntities(child, std::move(entities));
- }
- return entities;
-}
-
-EntityGatherer::EntityGatherer(Entity *root)
- : m_root(root)
- , m_needsRefresh(true)
-{
-}
-
-QVector<Entity *> EntityGatherer::entities() const
-{
- if (m_needsRefresh) {
- m_entities.clear();
- m_entities = gatherEntities(m_root, std::move(m_entities));
- m_needsRefresh = false;
- }
- return m_entities;
-}
-
class TriangleCollisionVisitor : public TrianglesVisitor
{
public:
@@ -418,6 +391,46 @@ HitList reduceToFirstHit(HitList &result, const HitList &intermediate)
return result;
}
+
+struct HighestPriorityHitReducer
+{
+ // No need to protect this from concurrent access as the table
+ // is read only
+ const QHash<Qt3DCore::QNodeId, int> entityToPriorityTable;
+
+ HitList operator()(HitList &result, const HitList &intermediate)
+ {
+ // Sort by priority first
+ // If we have equal priorities, we then sort by distance
+
+ if (!intermediate.empty()) {
+ if (result.empty())
+ result.push_back(intermediate.front());
+ int currentPriority = entityToPriorityTable.value(result.front().m_entityId, 0);
+ float closest = result.front().m_distance;
+
+ for (const auto &v : intermediate) {
+ const int newEntryPriority = entityToPriorityTable.value(v.m_entityId, 0);
+ if (newEntryPriority > currentPriority) {
+ result.push_front(v);
+ currentPriority = newEntryPriority;
+ closest = v.m_distance;
+ } else if (newEntryPriority == currentPriority) {
+ if (v.m_distance < closest) {
+ result.push_front(v);
+ closest = v.m_distance;
+ currentPriority = newEntryPriority;
+ }
+ }
+ }
+
+ while (result.size() > 1)
+ result.pop_back();
+ }
+ return result;
+ }
+};
+
HitList reduceToAllHits(HitList &results, const HitList &intermediate)
{
if (!intermediate.empty())
@@ -492,9 +505,22 @@ struct MapFunctorHolder
} // anonymous
-HitList EntityCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities, bool allHitsRequested)
-{
- const auto reducerOp = allHitsRequested ? PickingUtils::reduceToAllHits : PickingUtils::reduceToFirstHit;
+HitList EntityCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities,
+ Qt3DRender::QPickingSettings::PickResultMode mode)
+{
+ std::function<HitList (HitList &, const HitList &)> reducerOp;
+ switch (mode) {
+ case QPickingSettings::AllPicks:
+ reducerOp = PickingUtils::reduceToAllHits;
+ break;
+ case QPickingSettings::NearestPriorityPick:
+ reducerOp = HighestPriorityHitReducer{ m_entityToPriorityTable };
+ break;
+ case QPickingSettings::NearestPick:
+ reducerOp = PickingUtils::reduceToFirstHit;
+ break;
+ }
+
const MapFunctorHolder holder(this);
#if QT_CONFIG(concurrent)
return QtConcurrent::blockingMappedReduced<HitList>(entities, holder, reducerOp);
@@ -519,9 +545,22 @@ HitList EntityCollisionGathererFunctor::pick(const Entity *entity) const
return result;
}
-HitList TriangleCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities, bool allHitsRequested)
-{
- const auto reducerOp = allHitsRequested ? PickingUtils::reduceToAllHits : PickingUtils::reduceToFirstHit;
+HitList TriangleCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities,
+ Qt3DRender::QPickingSettings::PickResultMode mode)
+{
+ std::function<HitList (HitList &, const HitList &)> reducerOp;
+ switch (mode) {
+ case QPickingSettings::AllPicks:
+ reducerOp = PickingUtils::reduceToAllHits;
+ break;
+ case QPickingSettings::NearestPriorityPick:
+ reducerOp = HighestPriorityHitReducer { m_entityToPriorityTable };
+ break;
+ case QPickingSettings::NearestPick:
+ reducerOp = PickingUtils::reduceToFirstHit;
+ break;
+ }
+
const MapFunctorHolder holder(this);
#if QT_CONFIG(concurrent)
return QtConcurrent::blockingMappedReduced<HitList>(entities, holder, reducerOp);
@@ -553,9 +592,22 @@ HitList TriangleCollisionGathererFunctor::pick(const Entity *entity) const
return result;
}
-HitList LineCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities, bool allHitsRequested)
-{
- const auto reducerOp = allHitsRequested ? PickingUtils::reduceToAllHits : PickingUtils::reduceToFirstHit;
+HitList LineCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities,
+ Qt3DRender::QPickingSettings::PickResultMode mode)
+{
+ std::function<HitList (HitList &, const HitList &)> reducerOp;
+ switch (mode) {
+ case QPickingSettings::AllPicks:
+ reducerOp = PickingUtils::reduceToAllHits;
+ break;
+ case QPickingSettings::NearestPriorityPick:
+ reducerOp = HighestPriorityHitReducer { m_entityToPriorityTable };
+ break;
+ case QPickingSettings::NearestPick:
+ reducerOp = PickingUtils::reduceToFirstHit;
+ break;
+ }
+
const MapFunctorHolder holder(this);
#if QT_CONFIG(concurrent)
return QtConcurrent::blockingMappedReduced<HitList>(entities, holder, reducerOp);
@@ -586,9 +638,22 @@ HitList LineCollisionGathererFunctor::pick(const Entity *entity) const
return result;
}
-HitList PointCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities, bool allHitsRequested)
-{
- const auto reducerOp = allHitsRequested ? PickingUtils::reduceToAllHits : PickingUtils::reduceToFirstHit;
+HitList PointCollisionGathererFunctor::computeHits(const QVector<Entity *> &entities,
+ Qt3DRender::QPickingSettings::PickResultMode mode)
+{
+ std::function<HitList (HitList &, const HitList &)> reducerOp;
+ switch (mode) {
+ case QPickingSettings::AllPicks:
+ reducerOp = PickingUtils::reduceToAllHits;
+ break;
+ case QPickingSettings::NearestPriorityPick:
+ reducerOp = HighestPriorityHitReducer { m_entityToPriorityTable };
+ break;
+ case QPickingSettings::NearestPick:
+ reducerOp = PickingUtils::reduceToFirstHit;
+ break;
+ }
+
const MapFunctorHolder holder(this);
#if QT_CONFIG(concurrent)
return QtConcurrent::blockingMappedReduced<HitList>(entities, holder, reducerOp);
@@ -641,15 +706,17 @@ bool HierarchicalEntityPicker::collectHits(NodeManagers *manager, Entity *root)
{
m_hits.clear();
m_entities.clear();
+ m_entityToPriorityTable.clear();
QRayCastingService rayCasting;
struct EntityData {
Entity* entity;
bool hasObjectPicker;
Qt3DCore::QNodeIdVector recursiveLayers;
+ int priority;
};
std::vector<EntityData> worklist;
- worklist.push_back({root, !root->componentHandle<ObjectPicker>().isNull(), {}});
+ worklist.push_back({root, !root->componentHandle<ObjectPicker>().isNull(), {}, 0});
LayerManager *layerManager = manager->layerManager();
@@ -710,6 +777,8 @@ bool HierarchicalEntityPicker::collectHits(NodeManagers *manager, Entity *root)
if (accepted && queryResult.m_distance >= 0.f && (current.hasObjectPicker || !m_objectPickersRequired)) {
m_entities.push_back(current.entity);
m_hits.push_back(queryResult);
+ // Record entry for entity/priority
+ m_entityToPriorityTable.insert(current.entity->peerId(), current.priority);
}
Qt3DCore::QNodeIdVector recursiveLayers;
@@ -721,10 +790,16 @@ bool HierarchicalEntityPicker::collectHits(NodeManagers *manager, Entity *root)
}
// and pick children
- const auto children = current.entity->children();
- for (auto child: children)
- worklist.push_back({child, current.hasObjectPicker || !child->componentHandle<ObjectPicker>().isNull(),
- current.recursiveLayers + recursiveLayers});
+ const auto childrenHandles = current.entity->childrenHandles();
+ for (const HEntity &handle : childrenHandles) {
+ Entity *child = manager->renderNodesManager()->data(handle);
+ if (child) {
+ ObjectPicker *childPicker = child->renderComponent<ObjectPicker>();
+ worklist.push_back({child, current.hasObjectPicker || childPicker,
+ current.recursiveLayers + recursiveLayers,
+ (childPicker ? childPicker->priority() : current.priority)});
+ }
+ }
}
return !m_hits.empty();
diff --git a/src/render/jobs/pickboundingvolumeutils_p.h b/src/render/jobs/pickboundingvolumeutils_p.h
index 780c16cc8..923a49317 100644
--- a/src/render/jobs/pickboundingvolumeutils_p.h
+++ b/src/render/jobs/pickboundingvolumeutils_p.h
@@ -55,6 +55,7 @@
#include <Qt3DRender/QAbstractRayCaster>
#include <Qt3DRender/private/qray3d_p.h>
#include <Qt3DRender/private/qraycastingservice_p.h>
+#include <Qt3DRender/qpickingsettings.h>
QT_BEGIN_NAMESPACE
@@ -99,19 +100,6 @@ private:
bool isUnique(const QVector<ViewportCameraAreaDetails> &vcaList, const ViewportCameraAreaDetails &vca) const;
};
-class Q_AUTOTEST_EXPORT EntityGatherer
-{
-public:
- explicit EntityGatherer(Entity *root);
-
- QVector<Entity *> entities() const;
-
-private:
- Entity *m_root;
- mutable QVector<Entity *> m_entities;
- mutable bool m_needsRefresh;
-};
-
typedef QVector<RayCasting::QCollisionQueryResult::Hit> HitList;
class Q_AUTOTEST_EXPORT HierarchicalEntityPicker
@@ -124,6 +112,7 @@ public:
bool collectHits(NodeManagers *manager, Entity *root);
inline HitList hits() const { return m_hits; }
inline QVector<Entity *> entities() const { return m_entities; }
+ inline QHash<Qt3DCore::QNodeId, int> entityToPriorityTable() const { return m_entityToPriorityTable; }
private:
RayCasting::QRay3D m_ray;
@@ -132,6 +121,7 @@ private:
bool m_objectPickersRequired;
Qt3DCore::QNodeIdVector m_layerIds;
QAbstractRayCaster::FilterMode m_filterMode;
+ QHash<Qt3DCore::QNodeId, int> m_entityToPriorityTable;
};
struct Q_AUTOTEST_EXPORT AbstractCollisionGathererFunctor
@@ -142,8 +132,9 @@ struct Q_AUTOTEST_EXPORT AbstractCollisionGathererFunctor
bool m_objectPickersRequired = true;
NodeManagers *m_manager = nullptr;
RayCasting::QRay3D m_ray;
+ QHash<Qt3DCore::QNodeId, int> m_entityToPriorityTable;
- virtual HitList computeHits(const QVector<Entity *> &entities, bool allHitsRequested) = 0;
+ virtual HitList computeHits(const QVector<Entity *> &entities, Qt3DRender::QPickingSettings::PickResultMode mode) = 0;
// This define is required to work with QtConcurrent
typedef HitList result_type;
@@ -156,7 +147,7 @@ struct Q_AUTOTEST_EXPORT AbstractCollisionGathererFunctor
struct Q_AUTOTEST_EXPORT EntityCollisionGathererFunctor : public AbstractCollisionGathererFunctor
{
- HitList computeHits(const QVector<Entity *> &entities, bool allHitsRequested) override;
+ HitList computeHits(const QVector<Entity *> &entities, Qt3DRender::QPickingSettings::PickResultMode mode) override;
HitList pick(const Entity *entity) const override;
};
@@ -165,7 +156,7 @@ struct Q_AUTOTEST_EXPORT TriangleCollisionGathererFunctor : public AbstractColli
bool m_frontFaceRequested;
bool m_backFaceRequested;
- HitList computeHits(const QVector<Entity *> &entities, bool allHitsRequested) override;
+ HitList computeHits(const QVector<Entity *> &entities, Qt3DRender::QPickingSettings::PickResultMode mode) override;
HitList pick(const Entity *entity) const override;
};
@@ -173,7 +164,7 @@ struct Q_AUTOTEST_EXPORT LineCollisionGathererFunctor : public AbstractCollision
{
float m_pickWorldSpaceTolerance;
- HitList computeHits(const QVector<Entity *> &entities, bool allHitsRequested) override;
+ HitList computeHits(const QVector<Entity *> &entities, Qt3DRender::QPickingSettings::PickResultMode mode) override;
HitList pick(const Entity *entity) const override;
};
@@ -181,7 +172,7 @@ struct Q_AUTOTEST_EXPORT PointCollisionGathererFunctor : public AbstractCollisio
{
float m_pickWorldSpaceTolerance;
- HitList computeHits(const QVector<Entity *> &entities, bool allHitsRequested) override;
+ HitList computeHits(const QVector<Entity *> &entities, Qt3DRender::QPickingSettings::PickResultMode mode) override;
HitList pick(const Entity *entity) const override;
};
diff --git a/src/render/jobs/raycastingjob.cpp b/src/render/jobs/raycastingjob.cpp
index 7d3af34cc..f3571c210 100644
--- a/src/render/jobs/raycastingjob.cpp
+++ b/src/render/jobs/raycastingjob.cpp
@@ -50,6 +50,7 @@
#include <Qt3DRender/private/renderer_p.h>
#include <Qt3DRender/private/rendersettings_p.h>
#include <Qt3DRender/private/trianglesvisitor_p.h>
+#include <Qt3DRender/private/entityvisitor_p.h>
QT_BEGIN_NAMESPACE
@@ -59,43 +60,23 @@ using namespace Render;
namespace {
-class EntityCasterGatherer
+class EntityCasterGatherer : public EntityVisitor
{
public:
using EntityCasterList = QVector<QPair<Entity *, RayCaster*>>;
+ EntityCasterList m_result;
- explicit EntityCasterGatherer(Entity *root) : m_root(root), m_needsRefresh(true) { }
+ explicit EntityCasterGatherer(NodeManagers *manager) : EntityVisitor(manager) { setPruneDisabled(true); }
- EntityCasterList result() const {
- if (m_needsRefresh) {
- m_result.clear();
- m_result = gatherEntities(m_root, std::move(m_result));
- m_needsRefresh = false;
+ Operation visit(Entity *entity) override {
+ QVector<RayCaster *> components = entity->renderComponents<RayCaster>();
+ for (const auto c: qAsConst(components)) {
+ if (c->isEnabled())
+ m_result.push_back(qMakePair(entity, c));
}
- return m_result;
- }
-
-private:
- EntityCasterList gatherEntities(Entity *entity, EntityCasterList entities) const
- {
- if (entity != nullptr && entity->isEnabled()) {
- QVector<RayCaster *> components = entity->renderComponents<RayCaster>();
- for (const auto c: qAsConst(components)) {
- if (c->isEnabled())
- entities.push_back(qMakePair(entity, c));
- }
- // Traverse children
- const auto children = entity->children();
- for (Entity *child : children)
- entities = gatherEntities(child, std::move(entities));
- }
- return entities;
+ return Continue;
}
-
- Entity *m_root;
- mutable EntityCasterList m_result;
- mutable bool m_needsRefresh;
};
} // anonymous
@@ -145,8 +126,9 @@ bool RayCastingJob::runHelper()
m_renderSettings->faceOrientationPickingMode() != QPickingSettings::FrontFace;
const float pickWorldSpaceTolerance = m_renderSettings->pickWorldSpaceTolerance();
- EntityCasterGatherer gatherer(m_node);
- const EntityCasterGatherer::EntityCasterList &entities = gatherer.result();
+ EntityCasterGatherer gatherer(m_manager);
+ gatherer.apply(m_node);
+ const EntityCasterGatherer::EntityCasterList &entities = gatherer.m_result;
PickingUtils::ViewportCameraAreaGatherer vcaGatherer;
const QVector<PickingUtils::ViewportCameraAreaDetails> vcaDetails = vcaGatherer.gather(m_frameGraphRoot);
@@ -186,7 +168,7 @@ bool RayCastingJob::runHelper()
gathererFunctor.m_manager = m_manager;
gathererFunctor.m_ray = ray;
gathererFunctor.m_objectPickersRequired = false;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
}
if (edgePickingRequested) {
PickingUtils::LineCollisionGathererFunctor gathererFunctor;
@@ -194,7 +176,7 @@ bool RayCastingJob::runHelper()
gathererFunctor.m_ray = ray;
gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
gathererFunctor.m_objectPickersRequired = false;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
}
if (pointPickingRequested) {
@@ -203,7 +185,7 @@ bool RayCastingJob::runHelper()
gathererFunctor.m_ray = ray;
gathererFunctor.m_pickWorldSpaceTolerance = pickWorldSpaceTolerance;
gathererFunctor.m_objectPickersRequired = false;
- sphereHits << gathererFunctor.computeHits(entityPicker.entities(), true);
+ sphereHits << gathererFunctor.computeHits(entityPicker.entities(), QPickingSettings::AllPicks);
PickingUtils::AbstractCollisionGathererFunctor::sortHits(sphereHits);
}
if (!primitivePickingRequested) {
diff --git a/src/render/jobs/sendbuffercapturejob.cpp b/src/render/jobs/sendbuffercapturejob.cpp
index eae26ba6c..8683ea9f2 100644
--- a/src/render/jobs/sendbuffercapturejob.cpp
+++ b/src/render/jobs/sendbuffercapturejob.cpp
@@ -67,6 +67,12 @@ void SendBufferCaptureJob::addRequest(QPair<Buffer *, QByteArray> request)
m_pendingSendBufferCaptures.push_back(request);
}
+// Called by aspect thread jobs to execute (no concurrency at that point)
+bool SendBufferCaptureJob::hasRequests() const
+{
+ return m_pendingSendBufferCaptures.size() > 0;
+}
+
void SendBufferCaptureJob::run()
{
QMutexLocker locker(&m_mutex);
diff --git a/src/render/jobs/sendbuffercapturejob_p.h b/src/render/jobs/sendbuffercapturejob_p.h
index 771497e2f..f47c556df 100644
--- a/src/render/jobs/sendbuffercapturejob_p.h
+++ b/src/render/jobs/sendbuffercapturejob_p.h
@@ -68,13 +68,14 @@ class Entity;
class Renderer;
class Buffer;
-class QT3DRENDERSHARED_PRIVATE_EXPORT SendBufferCaptureJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT SendBufferCaptureJob : public Qt3DCore::QAspectJob
{
public:
explicit SendBufferCaptureJob();
~SendBufferCaptureJob();
void addRequest(QPair<Buffer*, QByteArray> request);
+ bool hasRequests() const;
void run() final;
diff --git a/src/render/jobs/sendrendercapturejob_p.h b/src/render/jobs/sendrendercapturejob_p.h
index 53b111ba6..8bc1e2fb0 100644
--- a/src/render/jobs/sendrendercapturejob_p.h
+++ b/src/render/jobs/sendrendercapturejob_p.h
@@ -63,7 +63,7 @@ namespace Render {
class NodeManagers;
class Entity;
-class QT3DRENDERSHARED_PRIVATE_EXPORT SendRenderCaptureJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT SendRenderCaptureJob : public Qt3DCore::QAspectJob
{
public:
SendRenderCaptureJob();
diff --git a/src/render/jobs/updateentityhierarchyjob_p.h b/src/render/jobs/updateentityhierarchyjob_p.h
index f6ba2d584..fd2b13631 100644
--- a/src/render/jobs/updateentityhierarchyjob_p.h
+++ b/src/render/jobs/updateentityhierarchyjob_p.h
@@ -64,7 +64,7 @@ namespace Render {
class Entity;
class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateEntityHierarchyJob: public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateEntityHierarchyJob: public Qt3DCore::QAspectJob
{
public:
UpdateEntityHierarchyJob();
diff --git a/src/render/jobs/updateentitylayersjob.cpp b/src/render/jobs/updateentitylayersjob.cpp
index 1fa34684f..2c5e38364 100644
--- a/src/render/jobs/updateentitylayersjob.cpp
+++ b/src/render/jobs/updateentitylayersjob.cpp
@@ -49,19 +49,6 @@ namespace Qt3DRender {
namespace Render {
-namespace {
-
-void addLayerIdToEntityChildren(const QVector<Entity *> &children,
- const Qt3DCore::QNodeId layerId)
-{
- for (Entity *child : children) {
- child->addRecursiveLayerId(layerId);
- addLayerIdToEntityChildren(child->children(), layerId);
- }
-}
-
-} // anonymous
-
UpdateEntityLayersJob::UpdateEntityLayersJob()
: m_manager(nullptr)
{
@@ -93,7 +80,9 @@ void UpdateEntityLayersJob::run()
Layer *layer = layerManager->lookupResource(layerId);
if (layer->recursive()) {
// Find all children of the entity and add the layers to them
- addLayerIdToEntityChildren(entity->children(), layerId);
+ entity->traverse([layerId](Entity *e) {
+ e->addRecursiveLayerId(layerId);
+ });
}
}
}
diff --git a/src/render/jobs/updateentitylayersjob_p.h b/src/render/jobs/updateentitylayersjob_p.h
index f2e63e32d..5d36042c4 100644
--- a/src/render/jobs/updateentitylayersjob_p.h
+++ b/src/render/jobs/updateentitylayersjob_p.h
@@ -65,7 +65,7 @@ class Entity;
class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateEntityLayersJob: public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateEntityLayersJob: public Qt3DCore::QAspectJob
{
public:
UpdateEntityLayersJob();
diff --git a/src/render/jobs/updatelevelofdetailjob.cpp b/src/render/jobs/updatelevelofdetailjob.cpp
index e4b651949..b5349a2c1 100644
--- a/src/render/jobs/updatelevelofdetailjob.cpp
+++ b/src/render/jobs/updatelevelofdetailjob.cpp
@@ -39,6 +39,7 @@
#include "updatelevelofdetailjob_p.h"
#include <Qt3DRender/QLevelOfDetail>
+#include <Qt3DRender/private/entityvisitor_p.h>
#include <Qt3DRender/private/job_common_p.h>
#include <Qt3DRender/private/nodemanagers_p.h>
#include <Qt3DRender/private/managers_p.h>
@@ -57,9 +58,145 @@ double approxRollingAverage(double avg, double input) {
return avg;
}
+class LODUpdateVisitor : public Qt3DRender::Render::EntityVisitor
+{
+public:
+ LODUpdateVisitor(double filterValue, Qt3DRender::Render::FrameGraphNode *frameGraphRoot, Qt3DRender::Render::NodeManagers *manager)
+ : Qt3DRender::Render::EntityVisitor(manager)
+ , m_filterValue(filterValue)
+ , m_frameGraphRoot(frameGraphRoot)
+ {
+ }
+
+ double filterValue() const { return m_filterValue; }
+
+ Operation visit(Qt3DRender::Render::Entity *entity = nullptr) override {
+ using namespace Qt3DRender;
+ using namespace Qt3DRender::Render;
+
+ if (!entity->isEnabled())
+ return Prune; // skip disabled sub-trees, since their bounding box is probably not valid anyway
+
+ QVector<LevelOfDetail *> lods = entity->renderComponents<LevelOfDetail>();
+ if (!lods.empty()) {
+ LevelOfDetail* lod = lods.front(); // other lods are ignored
+
+ if (lod->isEnabled() && !lod->thresholds().isEmpty()) {
+ switch (lod->thresholdType()) {
+ case QLevelOfDetail::DistanceToCameraThreshold:
+ updateEntityLodByDistance(entity, lod);
+ break;
+ case QLevelOfDetail::ProjectedScreenPixelSizeThreshold:
+ updateEntityLodByScreenArea(entity, lod);
+ break;
+ default:
+ Q_ASSERT(false);
+ break;
+ }
+ }
+ }
+
+ return Continue;
+ }
+
+private:
+ double m_filterValue = 0.;
+ Qt3DRender::Render::FrameGraphNode *m_frameGraphRoot;
+
+ void updateEntityLodByDistance(Qt3DRender::Render::Entity *entity, Qt3DRender::Render::LevelOfDetail *lod)
+ {
+ using namespace Qt3DRender;
+ using namespace Qt3DRender::Render;
+
+ Matrix4x4 viewMatrix;
+ Matrix4x4 projectionMatrix;
+ if (!Render::CameraLens::viewMatrixForCamera(m_manager->renderNodesManager(), lod->camera(), viewMatrix, projectionMatrix))
+ return;
+
+ const QVector<qreal> thresholds = lod->thresholds();
+ Vector3D center(lod->center());
+ if (lod->hasBoundingVolumeOverride() || entity->worldBoundingVolume() == nullptr) {
+ center = *entity->worldTransform() * center;
+ } else {
+ center = entity->worldBoundingVolume()->center();
+ }
+
+ const Vector3D tcenter = viewMatrix * center;
+ const float dist = tcenter.length();
+ const int n = thresholds.size();
+ for (int i=0; i<n; ++i) {
+ if (dist <= thresholds[i] || i == n -1) {
+ m_filterValue = approxRollingAverage<30>(m_filterValue, i);
+ i = qBound(0, static_cast<int>(qRound(m_filterValue)), n - 1);
+ if (lod->currentIndex() != i)
+ lod->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
+
+ void updateEntityLodByScreenArea(Qt3DRender::Render::Entity *entity, Qt3DRender::Render::LevelOfDetail *lod)
+ {
+ using namespace Qt3DRender;
+ using namespace Qt3DRender::Render;
+
+ Matrix4x4 viewMatrix;
+ Matrix4x4 projectionMatrix;
+ if (!Render::CameraLens::viewMatrixForCamera(m_manager->renderNodesManager(), lod->camera(), viewMatrix, projectionMatrix))
+ return;
+
+ PickingUtils::ViewportCameraAreaGatherer vcaGatherer(lod->camera());
+ const QVector<PickingUtils::ViewportCameraAreaDetails> vcaTriplets = vcaGatherer.gather(m_frameGraphRoot);
+ if (vcaTriplets.isEmpty())
+ return;
+
+ const PickingUtils::ViewportCameraAreaDetails &vca = vcaTriplets.front();
+
+ const QVector<qreal> thresholds = lod->thresholds();
+ Sphere bv(Vector3D(lod->center()), lod->radius());
+ if (!lod->hasBoundingVolumeOverride() && entity->worldBoundingVolume() != nullptr) {
+ bv = *(entity->worldBoundingVolume());
+ } else {
+ bv.transform(*entity->worldTransform());
+ }
+
+ bv.transform(projectionMatrix * viewMatrix);
+ const float sideLength = bv.radius() * 2.f;
+ float area = vca.viewport.width() * sideLength * vca.viewport.height() * sideLength;
+
+ const QRect r = windowViewport(vca.area, vca.viewport);
+ area = std::sqrt(area * r.width() * r.height());
+
+ const int n = thresholds.size();
+ for (int i = 0; i < n; ++i) {
+ if (thresholds[i] < area || i == n -1) {
+ m_filterValue = approxRollingAverage<30>(m_filterValue, i);
+ i = qBound(0, static_cast<int>(qRound(m_filterValue)), n - 1);
+ if (lod->currentIndex() != i)
+ lod->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
+
+ QRect windowViewport(const QSize &area, const QRectF &relativeViewport) const
+ {
+ if (area.isValid()) {
+ const int areaWidth = area.width();
+ const int areaHeight = area.height();
+ return QRect(relativeViewport.x() * areaWidth,
+ (1.0 - relativeViewport.y() - relativeViewport.height()) * areaHeight,
+ relativeViewport.width() * areaWidth,
+ relativeViewport.height() * areaHeight);
+ }
+ return relativeViewport.toRect();
+ }
+};
+
}
-namespace Qt3DRender {
+
+namespace Qt3DRender {
namespace Render {
UpdateLevelOfDetailJob::UpdateLevelOfDetailJob()
@@ -98,119 +235,13 @@ void UpdateLevelOfDetailJob::run()
if (m_manager->levelOfDetailManager()->count() == 0)
return;
- updateEntityLod(m_root);
-}
-
-QRect UpdateLevelOfDetailJob::windowViewport(const QSize &area, const QRectF &relativeViewport) const
-{
- if (area.isValid()) {
- const int areaWidth = area.width();
- const int areaHeight = area.height();
- return QRect(relativeViewport.x() * areaWidth,
- (1.0 - relativeViewport.y() - relativeViewport.height()) * areaHeight,
- relativeViewport.width() * areaWidth,
- relativeViewport.height() * areaHeight);
- }
- return relativeViewport.toRect();
-}
-
-void UpdateLevelOfDetailJob::updateEntityLod(Entity *entity)
-{
- if (!entity->isEnabled())
- return; // skip disabled sub-trees, since their bounding box is probably not valid anyway
-
- QVector<LevelOfDetail *> lods = entity->renderComponents<LevelOfDetail>();
- if (!lods.empty()) {
- LevelOfDetail* lod = lods.front(); // other lods are ignored
-
- if (lod->isEnabled() && !lod->thresholds().isEmpty()) {
- switch (lod->thresholdType()) {
- case QLevelOfDetail::DistanceToCameraThreshold:
- updateEntityLodByDistance(entity, lod);
- break;
- case QLevelOfDetail::ProjectedScreenPixelSizeThreshold:
- updateEntityLodByScreenArea(entity, lod);
- break;
- default:
- Q_ASSERT(false);
- break;
- }
- }
- }
-
- const auto children = entity->children();
- for (Qt3DRender::Render::Entity *child : children)
- updateEntityLod(child);
-}
-
-void UpdateLevelOfDetailJob::updateEntityLodByDistance(Entity *entity, LevelOfDetail *lod)
-{
- Matrix4x4 viewMatrix;
- Matrix4x4 projectionMatrix;
- if (!Render::CameraLens::viewMatrixForCamera(m_manager->renderNodesManager(), lod->camera(), viewMatrix, projectionMatrix))
- return;
-
- const QVector<qreal> thresholds = lod->thresholds();
- Vector3D center(lod->center());
- if (lod->hasBoundingVolumeOverride() || entity->worldBoundingVolume() == nullptr) {
- center = *entity->worldTransform() * center;
- } else {
- center = entity->worldBoundingVolume()->center();
- }
-
- const Vector3D tcenter = viewMatrix * center;
- const float dist = tcenter.length();
- const int n = thresholds.size();
- for (int i=0; i<n; ++i) {
- if (dist <= thresholds[i] || i == n -1) {
- m_filterValue = approxRollingAverage<30>(m_filterValue, i);
- i = qBound(0, static_cast<int>(qRound(m_filterValue)), n - 1);
- if (lod->currentIndex() != i)
- lod->setCurrentIndex(i);
- break;
- }
- }
-}
-
-void UpdateLevelOfDetailJob::updateEntityLodByScreenArea(Entity *entity, LevelOfDetail *lod)
-{
- Matrix4x4 viewMatrix;
- Matrix4x4 projectionMatrix;
- if (!Render::CameraLens::viewMatrixForCamera(m_manager->renderNodesManager(), lod->camera(), viewMatrix, projectionMatrix))
- return;
-
- PickingUtils::ViewportCameraAreaGatherer vcaGatherer(lod->camera());
- const QVector<PickingUtils::ViewportCameraAreaDetails> vcaTriplets = vcaGatherer.gather(m_frameGraphRoot);
- if (vcaTriplets.isEmpty())
- return;
-
- const PickingUtils::ViewportCameraAreaDetails &vca = vcaTriplets.front();
- const QVector<qreal> thresholds = lod->thresholds();
- Sphere bv(Vector3D(lod->center()), lod->radius());
- if (!lod->hasBoundingVolumeOverride() && entity->worldBoundingVolume() != nullptr) {
- bv = *(entity->worldBoundingVolume());
- } else {
- bv.transform(*entity->worldTransform());
- }
+ if (m_manager->levelOfDetailManager()->count() == 0)
+ return; // no LODs, lets bail out early
- bv.transform(projectionMatrix * viewMatrix);
- const float sideLength = bv.radius() * 2.f;
- float area = vca.viewport.width() * sideLength * vca.viewport.height() * sideLength;
-
- const QRect r = windowViewport(vca.area, vca.viewport);
- area = std::sqrt(area * r.width() * r.height());
-
- const int n = thresholds.size();
- for (int i = 0; i < n; ++i) {
- if (thresholds[i] < area || i == n -1) {
- m_filterValue = approxRollingAverage<30>(m_filterValue, i);
- i = qBound(0, static_cast<int>(qRound(m_filterValue)), n - 1);
- if (lod->currentIndex() != i)
- lod->setCurrentIndex(i);
- break;
- }
- }
+ LODUpdateVisitor visitor(m_filterValue, m_frameGraphRoot, m_manager);
+ visitor.apply(m_root);
+ m_filterValue = visitor.filterValue();
}
} // Render
diff --git a/src/render/jobs/updatelevelofdetailjob_p.h b/src/render/jobs/updatelevelofdetailjob_p.h
index 4c80a3205..3c7d00d2c 100644
--- a/src/render/jobs/updatelevelofdetailjob_p.h
+++ b/src/render/jobs/updatelevelofdetailjob_p.h
@@ -66,7 +66,7 @@ class NodeManagers;
class LevelOfDetail;
class FrameGraphNode;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateLevelOfDetailJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateLevelOfDetailJob : public Qt3DCore::QAspectJob
{
public:
UpdateLevelOfDetailJob();
@@ -81,12 +81,6 @@ public:
Entity *root() const { return m_root; }
private:
- void updateEntityLod(Entity *entity);
- void updateEntityLodByDistance(Entity *entity, LevelOfDetail *lod);
- void updateEntityLodByScreenArea(Entity *entity, LevelOfDetail *lod);
-
- QRect windowViewport(const QSize &area, const QRectF &relativeViewport) const;
-
NodeManagers *m_manager;
FrameGraphNode *m_frameGraphRoot;
Entity *m_root;
diff --git a/src/render/jobs/updatemeshtrianglelistjob_p.h b/src/render/jobs/updatemeshtrianglelistjob_p.h
index 9b67b9f49..048f8f01a 100644
--- a/src/render/jobs/updatemeshtrianglelistjob_p.h
+++ b/src/render/jobs/updatemeshtrianglelistjob_p.h
@@ -62,7 +62,7 @@ namespace Render {
class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateMeshTriangleListJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateMeshTriangleListJob : public Qt3DCore::QAspectJob
{
public:
UpdateMeshTriangleListJob();
diff --git a/src/render/jobs/updateshaderdatatransformjob_p.h b/src/render/jobs/updateshaderdatatransformjob_p.h
index 2fc06b8f7..bcf4eb6af 100644
--- a/src/render/jobs/updateshaderdatatransformjob_p.h
+++ b/src/render/jobs/updateshaderdatatransformjob_p.h
@@ -62,7 +62,7 @@ namespace Render {
class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateShaderDataTransformJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateShaderDataTransformJob : public Qt3DCore::QAspectJob
{
public:
UpdateShaderDataTransformJob();
diff --git a/src/render/jobs/updateskinningpalettejob.cpp b/src/render/jobs/updateskinningpalettejob.cpp
index 1ee9101f9..0f5d3d6d6 100644
--- a/src/render/jobs/updateskinningpalettejob.cpp
+++ b/src/render/jobs/updateskinningpalettejob.cpp
@@ -79,7 +79,11 @@ void UpdateSkinningPaletteJob::run()
// Find all the armature components and update their skinning palettes
QVector<HArmature> dirtyArmatures;
- findDirtyArmatures(m_root, dirtyArmatures);
+ m_root->traverse([&dirtyArmatures](Entity *entity) {
+ const auto armatureHandle = entity->componentHandle<Armature>();
+ if (!armatureHandle.isNull() && !dirtyArmatures.contains(armatureHandle))
+ dirtyArmatures.push_back(armatureHandle);
+ });
// Update the skeleton for each dirty armature
auto skeletonManager = m_nodeManagers->skeletonManager();
@@ -96,22 +100,6 @@ void UpdateSkinningPaletteJob::run()
}
}
-void UpdateSkinningPaletteJob::findDirtyArmatures(Entity *entity,
- QVector<HArmature> &armatures) const
-{
- // Just return all enabled armatures found on entities for now
- // TODO: Be smarter about limiting which armatures we update. For e.g. only
- // those with skeletons that have changed and only those that are within view
- // of one or more renderviews.
- const auto armatureHandle = entity->componentHandle<Armature>();
- if (!armatureHandle.isNull() && !armatures.contains(armatureHandle))
- armatures.push_back(armatureHandle);
-
- const auto children = entity->children();
- for (const auto child : children)
- findDirtyArmatures(child, armatures);
-}
-
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/jobs/updateskinningpalettejob_p.h b/src/render/jobs/updateskinningpalettejob_p.h
index 9e230f143..c52e0841c 100644
--- a/src/render/jobs/updateskinningpalettejob_p.h
+++ b/src/render/jobs/updateskinningpalettejob_p.h
@@ -75,7 +75,6 @@ public:
protected:
void run() override;
- void findDirtyArmatures(Entity *entity, QVector<HArmature> &armatures) const;
NodeManagers *m_nodeManagers;
Entity *m_root;
QVector<HJoint> m_dirtyJoints;
diff --git a/src/render/jobs/updatetreeenabledjob.cpp b/src/render/jobs/updatetreeenabledjob.cpp
index 6475ea78c..e97fc6414 100644
--- a/src/render/jobs/updatetreeenabledjob.cpp
+++ b/src/render/jobs/updatetreeenabledjob.cpp
@@ -41,6 +41,8 @@
#include <Qt3DRender/private/entity_p.h>
#include <Qt3DRender/private/job_common_p.h>
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
#include <QThread>
@@ -51,14 +53,17 @@ namespace Render {
namespace {
-void updateTreeEnabled(Entity *node, bool parentEnabled)
+void updateTreeEnabled(NodeManagers *manager, Entity *node, bool parentEnabled)
{
const bool treeEnabled = node->isEnabled() && parentEnabled;
node->setTreeEnabled(treeEnabled);
- const QVector<Entity*> children = node->children();
- for (Entity *child : children)
- updateTreeEnabled(child, treeEnabled);
+ const auto childrenHandles = node->childrenHandles();
+ for (const HEntity &handle : childrenHandles) {
+ Entity *child = manager->renderNodesManager()->data(handle);
+ if (child)
+ updateTreeEnabled(manager, child, treeEnabled);
+ }
}
}
@@ -75,10 +80,15 @@ void UpdateTreeEnabledJob::setRoot(Entity *root)
m_node = root;
}
+void UpdateTreeEnabledJob::setManagers(NodeManagers *manager)
+{
+ m_manager = manager;
+}
+
void UpdateTreeEnabledJob::run()
{
- if (m_node)
- updateTreeEnabled(m_node, true);
+ if (m_node && m_manager)
+ updateTreeEnabled(m_manager, m_node, true);
}
} // namespace Render
diff --git a/src/render/jobs/updatetreeenabledjob_p.h b/src/render/jobs/updatetreeenabledjob_p.h
index 132271eaa..ba28998bc 100644
--- a/src/render/jobs/updatetreeenabledjob_p.h
+++ b/src/render/jobs/updatetreeenabledjob_p.h
@@ -62,17 +62,20 @@ namespace Qt3DRender {
namespace Render {
class Entity;
+class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateTreeEnabledJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateTreeEnabledJob : public Qt3DCore::QAspectJob
{
public:
UpdateTreeEnabledJob();
void setRoot(Entity *root);
+ void setManagers(NodeManagers *manager);
void run() override;
private:
Entity *m_node;
+ NodeManagers *m_manager;
};
typedef QSharedPointer<UpdateTreeEnabledJob> UpdateTreeEnabledJobPtr;
diff --git a/src/render/jobs/updateworldboundingvolumejob_p.h b/src/render/jobs/updateworldboundingvolumejob_p.h
index affe78045..afb8cc6e1 100644
--- a/src/render/jobs/updateworldboundingvolumejob_p.h
+++ b/src/render/jobs/updateworldboundingvolumejob_p.h
@@ -62,7 +62,7 @@ namespace Render {
class EntityManager;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateWorldBoundingVolumeJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateWorldBoundingVolumeJob : public Qt3DCore::QAspectJob
{
public:
UpdateWorldBoundingVolumeJob();
diff --git a/src/render/jobs/updateworldtransformjob.cpp b/src/render/jobs/updateworldtransformjob.cpp
index c56ed8507..1a9697843 100644
--- a/src/render/jobs/updateworldtransformjob.cpp
+++ b/src/render/jobs/updateworldtransformjob.cpp
@@ -44,6 +44,8 @@
#include <Qt3DRender/private/transform_p.h>
#include <Qt3DRender/private/renderlogging_p.h>
#include <Qt3DRender/private/job_common_p.h>
+#include <Qt3DRender/private/managers_p.h>
+#include <Qt3DRender/private/nodemanagers_p.h>
#include <QThread>
@@ -54,7 +56,7 @@ namespace Render {
namespace {
-void updateWorldTransformAndBounds(Qt3DRender::Render::Entity *node, const Matrix4x4 &parentTransform)
+void updateWorldTransformAndBounds(NodeManagers *manager, Entity *node, const Matrix4x4 &parentTransform)
{
Matrix4x4 worldTransform(parentTransform);
Transform *nodeTransform = node->renderComponent<Transform>();
@@ -64,9 +66,12 @@ void updateWorldTransformAndBounds(Qt3DRender::Render::Entity *node, const Matri
*(node->worldTransform()) = worldTransform;
- const auto children = node->children();
- for (Qt3DRender::Render::Entity *child : children)
- updateWorldTransformAndBounds(child, worldTransform);
+ const auto childrenHandles = node->childrenHandles();
+ for (const HEntity &handle : childrenHandles) {
+ Entity *child = manager->renderNodesManager()->data(handle);
+ if (child)
+ updateWorldTransformAndBounds(manager, child, worldTransform);
+ }
}
}
@@ -74,6 +79,7 @@ void updateWorldTransformAndBounds(Qt3DRender::Render::Entity *node, const Matri
UpdateWorldTransformJob::UpdateWorldTransformJob()
: Qt3DCore::QAspectJob()
, m_node(nullptr)
+ , m_manager(nullptr)
{
SET_JOB_RUN_STAT_TYPE(this, JobTypes::UpdateTransform, 0);
}
@@ -83,6 +89,11 @@ void UpdateWorldTransformJob::setRoot(Entity *root)
m_node = root;
}
+void UpdateWorldTransformJob::setManagers(NodeManagers *manager)
+{
+ m_manager = manager;
+}
+
void UpdateWorldTransformJob::run()
{
// Iterate over each level of hierarchy in our scene
@@ -98,7 +109,7 @@ void UpdateWorldTransformJob::run()
Entity *parent = m_node->parent();
if (parent != nullptr)
parentTransform = *(parent->worldTransform());
- updateWorldTransformAndBounds(m_node, parentTransform);
+ updateWorldTransformAndBounds(m_manager, m_node, parentTransform);
qCDebug(Jobs) << "Exiting" << Q_FUNC_INFO << QThread::currentThread();
}
diff --git a/src/render/jobs/updateworldtransformjob_p.h b/src/render/jobs/updateworldtransformjob_p.h
index a85310e5c..2689fe45a 100644
--- a/src/render/jobs/updateworldtransformjob_p.h
+++ b/src/render/jobs/updateworldtransformjob_p.h
@@ -62,17 +62,21 @@ namespace Qt3DRender {
namespace Render {
class Entity;
+class NodeManagers;
-class QT3DRENDERSHARED_PRIVATE_EXPORT UpdateWorldTransformJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT UpdateWorldTransformJob : public Qt3DCore::QAspectJob
{
public:
UpdateWorldTransformJob();
void setRoot(Entity *root);
+ void setManagers(NodeManagers *manager);
+
void run() override;
private:
Entity *m_node;
+ NodeManagers *m_manager;
};
typedef QSharedPointer<UpdateWorldTransformJob> UpdateWorldTransformJobPtr;
diff --git a/src/render/lights/qabstractlight.h b/src/render/lights/qabstractlight.h
index b5dd89222..e92a5ee1d 100644
--- a/src/render/lights/qabstractlight.h
+++ b/src/render/lights/qabstractlight.h
@@ -52,7 +52,7 @@ namespace Qt3DRender {
class QAbstractLightPrivate;
-class QT3DRENDERSHARED_EXPORT QAbstractLight : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QAbstractLight : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(Type type READ type)
diff --git a/src/render/lights/qabstractlight_p.h b/src/render/lights/qabstractlight_p.h
index f7831dce2..ebb8092b4 100644
--- a/src/render/lights/qabstractlight_p.h
+++ b/src/render/lights/qabstractlight_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QAbstractLight;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QAbstractLightPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QAbstractLightPrivate : public Qt3DCore::QComponentPrivate
{
public:
explicit QAbstractLightPrivate(QAbstractLight::Type type);
diff --git a/src/render/lights/qdirectionallight.h b/src/render/lights/qdirectionallight.h
index 6be1585db..5d572b9ea 100644
--- a/src/render/lights/qdirectionallight.h
+++ b/src/render/lights/qdirectionallight.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QDirectionalLightPrivate;
-class QT3DRENDERSHARED_EXPORT QDirectionalLight : public QAbstractLight
+class Q_3DRENDERSHARED_EXPORT QDirectionalLight : public QAbstractLight
{
Q_OBJECT
Q_PROPERTY(QVector3D worldDirection READ worldDirection WRITE setWorldDirection NOTIFY worldDirectionChanged)
diff --git a/src/render/lights/qdirectionallight_p.h b/src/render/lights/qdirectionallight_p.h
index ea80913eb..d57a95604 100644
--- a/src/render/lights/qdirectionallight_p.h
+++ b/src/render/lights/qdirectionallight_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QDirectionalLight;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QDirectionalLightPrivate : QAbstractLightPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QDirectionalLightPrivate : QAbstractLightPrivate
{
public:
QDirectionalLightPrivate();
diff --git a/src/render/lights/qenvironmentlight.h b/src/render/lights/qenvironmentlight.h
index 995768d3c..3afc44f28 100644
--- a/src/render/lights/qenvironmentlight.h
+++ b/src/render/lights/qenvironmentlight.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QAbstractTexture;
class QEnvironmentLightPrivate;
-class QT3DRENDERSHARED_EXPORT QEnvironmentLight : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QEnvironmentLight : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QAbstractTexture *irradiance READ irradiance WRITE setIrradiance NOTIFY irradianceChanged)
diff --git a/src/render/lights/qenvironmentlight_p.h b/src/render/lights/qenvironmentlight_p.h
index f4fa97b5a..a512f8f5b 100644
--- a/src/render/lights/qenvironmentlight_p.h
+++ b/src/render/lights/qenvironmentlight_p.h
@@ -62,7 +62,7 @@ namespace Qt3DRender {
class QAbstractTexture;
class QEnvironmentLight;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QEnvironmentLightPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QEnvironmentLightPrivate : public Qt3DCore::QComponentPrivate
{
public:
explicit QEnvironmentLightPrivate();
diff --git a/src/render/lights/qpointlight.h b/src/render/lights/qpointlight.h
index 16e048560..1efe1679a 100644
--- a/src/render/lights/qpointlight.h
+++ b/src/render/lights/qpointlight.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QPointLightPrivate;
-class QT3DRENDERSHARED_EXPORT QPointLight : public QAbstractLight
+class Q_3DRENDERSHARED_EXPORT QPointLight : public QAbstractLight
{
Q_OBJECT
Q_PROPERTY(float constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged)
diff --git a/src/render/lights/qpointlight_p.h b/src/render/lights/qpointlight_p.h
index 147867667..64c971291 100644
--- a/src/render/lights/qpointlight_p.h
+++ b/src/render/lights/qpointlight_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QPointLight;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QPointLightPrivate : public QAbstractLightPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QPointLightPrivate : public QAbstractLightPrivate
{
public:
QPointLightPrivate();
diff --git a/src/render/lights/qspotlight.h b/src/render/lights/qspotlight.h
index 8902708a3..760508b79 100644
--- a/src/render/lights/qspotlight.h
+++ b/src/render/lights/qspotlight.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QSpotLightPrivate;
-class QT3DRENDERSHARED_EXPORT QSpotLight : public QAbstractLight
+class Q_3DRENDERSHARED_EXPORT QSpotLight : public QAbstractLight
{
Q_OBJECT
Q_PROPERTY(float constantAttenuation READ constantAttenuation WRITE setConstantAttenuation NOTIFY constantAttenuationChanged)
diff --git a/src/render/lights/qspotlight_p.h b/src/render/lights/qspotlight_p.h
index eabc00353..2646a72cd 100644
--- a/src/render/lights/qspotlight_p.h
+++ b/src/render/lights/qspotlight_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QSpotLight;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QSpotLightPrivate : public QAbstractLightPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QSpotLightPrivate : public QAbstractLightPrivate
{
public:
QSpotLightPrivate();
diff --git a/src/render/materialsystem/qeffect.h b/src/render/materialsystem/qeffect.h
index 0a65311ba..decae6f39 100644
--- a/src/render/materialsystem/qeffect.h
+++ b/src/render/materialsystem/qeffect.h
@@ -51,7 +51,7 @@ class QParameter;
class QTechnique;
class QEffectPrivate;
-class QT3DRENDERSHARED_EXPORT QEffect : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QEffect : public Qt3DCore::QNode
{
Q_OBJECT
public:
diff --git a/src/render/materialsystem/qeffect_p.h b/src/render/materialsystem/qeffect_p.h
index 39c7d1ecc..c1fe22ec0 100644
--- a/src/render/materialsystem/qeffect_p.h
+++ b/src/render/materialsystem/qeffect_p.h
@@ -63,7 +63,7 @@ class QEffect;
class QParameter;
class QTechnique;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QEffectPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QEffectPrivate : public Qt3DCore::QNodePrivate
{
public :
QEffectPrivate();
diff --git a/src/render/materialsystem/qfilterkey.h b/src/render/materialsystem/qfilterkey.h
index 23c2dd342..d7dd470db 100644
--- a/src/render/materialsystem/qfilterkey.h
+++ b/src/render/materialsystem/qfilterkey.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QFilterKeyPrivate;
-class QT3DRENDERSHARED_EXPORT QFilterKey : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QFilterKey : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
diff --git a/src/render/materialsystem/qfilterkey_p.h b/src/render/materialsystem/qfilterkey_p.h
index 4050bc295..2174841a3 100644
--- a/src/render/materialsystem/qfilterkey_p.h
+++ b/src/render/materialsystem/qfilterkey_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QFilterKeyPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QFilterKeyPrivate : public Qt3DCore::QNodePrivate
{
public:
QFilterKeyPrivate();
diff --git a/src/render/materialsystem/qgraphicsapifilter.h b/src/render/materialsystem/qgraphicsapifilter.h
index 08b30b1f7..337193673 100644
--- a/src/render/materialsystem/qgraphicsapifilter.h
+++ b/src/render/materialsystem/qgraphicsapifilter.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QGraphicsApiFilterPrivate;
-class QT3DRENDERSHARED_EXPORT QGraphicsApiFilter : public QObject
+class Q_3DRENDERSHARED_EXPORT QGraphicsApiFilter : public QObject
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QGraphicsApiFilter::Api api READ api WRITE setApi NOTIFY apiChanged)
diff --git a/src/render/materialsystem/qgraphicsapifilter_p.h b/src/render/materialsystem/qgraphicsapifilter_p.h
index f4581ac05..3961d4f93 100644
--- a/src/render/materialsystem/qgraphicsapifilter_p.h
+++ b/src/render/materialsystem/qgraphicsapifilter_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-struct QT3DRENDERSHARED_PRIVATE_EXPORT GraphicsApiFilterData
+struct Q_3DRENDERSHARED_PRIVATE_EXPORT GraphicsApiFilterData
{
GraphicsApiFilterData();
@@ -75,7 +75,7 @@ struct QT3DRENDERSHARED_PRIVATE_EXPORT GraphicsApiFilterData
bool operator <(const GraphicsApiFilterData &other) const;
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT QGraphicsApiFilterPrivate : public QObjectPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QGraphicsApiFilterPrivate : public QObjectPrivate
{
public:
QGraphicsApiFilterPrivate()
diff --git a/src/render/materialsystem/qmaterial.h b/src/render/materialsystem/qmaterial.h
index 9d1895294..d7d40f138 100644
--- a/src/render/materialsystem/qmaterial.h
+++ b/src/render/materialsystem/qmaterial.h
@@ -54,7 +54,7 @@ class QParameter;
class QMaterialPrivate;
class QEffect;
-class QT3DRENDERSHARED_EXPORT QMaterial : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QMaterial : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QEffect *effect READ effect WRITE setEffect NOTIFY effectChanged)
diff --git a/src/render/materialsystem/qmaterial_p.h b/src/render/materialsystem/qmaterial_p.h
index 9fb8d5de9..273e044e2 100644
--- a/src/render/materialsystem/qmaterial_p.h
+++ b/src/render/materialsystem/qmaterial_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QParameter;
class QEffect;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QMaterialPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QMaterialPrivate : public Qt3DCore::QComponentPrivate
{
public:
QMaterialPrivate();
diff --git a/src/render/materialsystem/qparameter.h b/src/render/materialsystem/qparameter.h
index 169543e24..8d56bcbe7 100644
--- a/src/render/materialsystem/qparameter.h
+++ b/src/render/materialsystem/qparameter.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QParameterPrivate;
class QAbstractTexture;
-class QT3DRENDERSHARED_EXPORT QParameter : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QParameter : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
diff --git a/src/render/materialsystem/qparameter_p.h b/src/render/materialsystem/qparameter_p.h
index a56a63af4..e8d74ac91 100644
--- a/src/render/materialsystem/qparameter_p.h
+++ b/src/render/materialsystem/qparameter_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QParameter;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QParameterPrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QParameterPrivate : public Qt3DCore::QNodePrivate
{
public:
QParameterPrivate();
diff --git a/src/render/materialsystem/qrenderpass.h b/src/render/materialsystem/qrenderpass.h
index 14bd34b37..b82a0d973 100644
--- a/src/render/materialsystem/qrenderpass.h
+++ b/src/render/materialsystem/qrenderpass.h
@@ -59,7 +59,7 @@ typedef QVector<QParameter*> ParameterList;
class QRenderPassPrivate;
-class QT3DRENDERSHARED_EXPORT QRenderPass : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QRenderPass : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QShaderProgram *shaderProgram READ shaderProgram WRITE setShaderProgram NOTIFY shaderProgramChanged)
diff --git a/src/render/materialsystem/qshaderdata.h b/src/render/materialsystem/qshaderdata.h
index 5e57d11a4..eda009c6a 100644
--- a/src/render/materialsystem/qshaderdata.h
+++ b/src/render/materialsystem/qshaderdata.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QShaderDataPrivate;
-class QT3DRENDERSHARED_EXPORT PropertyReaderInterface
+class Q_3DRENDERSHARED_EXPORT PropertyReaderInterface
{
public:
virtual ~PropertyReaderInterface();
@@ -59,7 +59,7 @@ public:
typedef QSharedPointer<PropertyReaderInterface> PropertyReaderInterfacePtr;
-class QT3DRENDERSHARED_EXPORT QShaderData : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QShaderData : public Qt3DCore::QComponent
{
Q_OBJECT
public:
diff --git a/src/render/materialsystem/qshaderdata_p.h b/src/render/materialsystem/qshaderdata_p.h
index 258c962ee..18890aec9 100644
--- a/src/render/materialsystem/qshaderdata_p.h
+++ b/src/render/materialsystem/qshaderdata_p.h
@@ -86,7 +86,7 @@ class QShaderDataPropertyReader: public PropertyReaderInterface
}
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT QShaderDataPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QShaderDataPrivate : public Qt3DCore::QComponentPrivate
{
public:
QShaderDataPrivate();
diff --git a/src/render/materialsystem/qshaderprogram.h b/src/render/materialsystem/qshaderprogram.h
index efcfa792e..49c1076e5 100644
--- a/src/render/materialsystem/qshaderprogram.h
+++ b/src/render/materialsystem/qshaderprogram.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QShaderProgramPrivate;
-class QT3DRENDERSHARED_EXPORT QShaderProgram : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QShaderProgram : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(QByteArray vertexShaderCode READ vertexShaderCode WRITE setVertexShaderCode NOTIFY vertexShaderCodeChanged)
diff --git a/src/render/materialsystem/qshaderprogrambuilder.cpp b/src/render/materialsystem/qshaderprogrambuilder.cpp
index 9318f96af..84dd33372 100644
--- a/src/render/materialsystem/qshaderprogrambuilder.cpp
+++ b/src/render/materialsystem/qshaderprogrambuilder.cpp
@@ -94,6 +94,53 @@ QShaderProgramBuilder::QShaderProgramBuilder(QShaderProgramBuilderPrivate &dd, Q
{
}
+void QShaderProgramBuilder::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
+{
+ Q_D(QShaderProgramBuilder);
+ if (change->type() == Qt3DCore::PropertyUpdated) {
+ const Qt3DCore::QPropertyUpdatedChangePtr e = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(change);
+ if (e->propertyName() == QByteArrayLiteral("generatedShaderCode")) {
+ const bool blocked = blockNotifications(true);
+ const QPair<int, QByteArray> data = e->value().value<QPair<int, QByteArray>>();
+
+ switch (data.first) {
+ case QShaderProgram::Vertex: {
+ d->m_vertexShaderCode = data.second;
+ emit vertexShaderCodeChanged(d->m_vertexShaderCode);
+ break;
+ }
+ case QShaderProgram::Fragment:{
+ d->m_fragmentShaderCode = data.second;
+ emit fragmentShaderCodeChanged(d->m_fragmentShaderCode);
+ break;
+ }
+ case QShaderProgram::Geometry: {
+ d->m_geometryShaderCode = data.second;
+ emit geometryShaderCodeChanged(d->m_geometryShaderCode);
+ break;
+ }
+ case QShaderProgram::Compute: {
+ d->m_computeShaderCode = data.second;
+ emit computeShaderCodeChanged(d->m_computeShaderCode);
+ break;
+ }
+ case QShaderProgram::TessellationControl: {
+ d->m_tessControlShaderCode = data.second;
+ emit tessellationControlShaderCodeChanged(d->m_tessControlShaderCode);
+ break;
+ }
+ case QShaderProgram::TessellationEvaluation: {
+ d->m_tessEvalShaderCode = data.second;
+ emit tessellationEvaluationShaderCodeChanged(d->m_tessEvalShaderCode);
+ break;
+ }
+ }
+
+ blockNotifications(blocked);
+ }
+ }
+}
+
/*!
\qmlproperty string ShaderProgramBuilder::shaderProgram
@@ -311,6 +358,114 @@ QUrl QShaderProgramBuilder::computeShaderGraph() const
return d->m_computeShaderGraph;
}
+/*!
+ \qmlproperty string ShaderProgramBuilder:vertexShaderCode
+
+ Holds the generated vertex shader code
+ \since 2.13
+*/
+/*!
+ \property QShaderProgram:Builder:vertexShaderCode
+
+ Holds the generate vertex shader code.
+ \since 5.13
+*/
+QByteArray QShaderProgramBuilder::vertexShaderCode() const
+{
+ Q_D(const QShaderProgramBuilder);
+ return d->m_vertexShaderCode;
+}
+
+/*!
+ \qmlproperty string ShaderProgramBuilder:tessellationControlShaderCode
+
+ Holds the generated tessellation control shader code
+ \since 2.13
+*/
+/*!
+ \property QShaderProgram:Builder:tessellationControlShaderCode
+
+ Holds the generate tessellation control shader code.
+ \since 5.13
+*/
+QByteArray QShaderProgramBuilder::tessellationControlShaderCode() const
+{
+ Q_D(const QShaderProgramBuilder);
+ return d->m_tessControlShaderCode;
+}
+
+/*!
+ \qmlproperty string ShaderProgramBuilder:tessellationEvaluationShaderCode
+
+ Holds the generated tessellation evaluation shader code
+ \since 2.13
+*/
+/*!
+ \property QShaderProgram:Builder:tessellationEvaluationShaderCode
+
+ Holds the generate tessellation evaluation shader code.
+ \since 5.13
+*/
+QByteArray QShaderProgramBuilder::tessellationEvaluationShaderCode() const
+{
+ Q_D(const QShaderProgramBuilder);
+ return d->m_tessEvalShaderCode;
+}
+
+/*!
+ \qmlproperty string ShaderProgramBuilder:geometryShaderCode
+
+ Holds the generated geometry shader code
+ \since 2.13
+*/
+/*!
+ \property QShaderProgram:Builder:geometryShaderCode
+
+ Holds the generate geometry shader code.
+ \since 5.13
+*/
+QByteArray QShaderProgramBuilder::geometryShaderCode() const
+{
+ Q_D(const QShaderProgramBuilder);
+ return d->m_geometryShaderCode;
+}
+
+/*!
+ \qmlproperty string ShaderProgramBuilder::fragmentShaderCode
+
+ Holds the generated fragment shader code
+ \since 2.13
+*/
+/*!
+ \property QShaderProgram:Builder:fragmentShaderCode
+
+ Holds the generate fragment shader code.
+ \since 5.13
+*/
+QByteArray QShaderProgramBuilder::fragmentShaderCode() const
+{
+ Q_D(const QShaderProgramBuilder);
+ return d->m_fragmentShaderCode;
+}
+
+/*!
+ \qmlproperty string ShaderProgramBuilder::computeShaderCode
+
+ Holds the generated compute shader code
+ \since 2.13
+*/
+/*!
+ \property QShaderProgram:Builder:computeShaderCode
+
+ Holds the generate compute shader code.
+ \since 5.13
+*/
+QByteArray QShaderProgramBuilder::computeShaderCode() const
+{
+ Q_D(const QShaderProgramBuilder);
+ return d->m_computeShaderCode;
+}
+
Qt3DCore::QNodeCreatedChangeBasePtr QShaderProgramBuilder::createNodeCreationChange() const
{
auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QShaderProgramBuilderData>::create(this);
diff --git a/src/render/materialsystem/qshaderprogrambuilder.h b/src/render/materialsystem/qshaderprogrambuilder.h
index fbbf7c752..184093730 100644
--- a/src/render/materialsystem/qshaderprogrambuilder.h
+++ b/src/render/materialsystem/qshaderprogrambuilder.h
@@ -52,7 +52,7 @@ namespace Qt3DRender {
class QShaderProgram;
class QShaderProgramBuilderPrivate;
-class QT3DRENDERSHARED_EXPORT QShaderProgramBuilder : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QShaderProgramBuilder : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QShaderProgram* shaderProgram READ shaderProgram WRITE setShaderProgram NOTIFY shaderProgramChanged)
@@ -63,6 +63,12 @@ class QT3DRENDERSHARED_EXPORT QShaderProgramBuilder : public Qt3DCore::QNode
Q_PROPERTY(QUrl geometryShaderGraph READ geometryShaderGraph WRITE setGeometryShaderGraph NOTIFY geometryShaderGraphChanged)
Q_PROPERTY(QUrl fragmentShaderGraph READ fragmentShaderGraph WRITE setFragmentShaderGraph NOTIFY fragmentShaderGraphChanged)
Q_PROPERTY(QUrl computeShaderGraph READ computeShaderGraph WRITE setComputeShaderGraph NOTIFY computeShaderGraphChanged)
+ Q_PROPERTY(QByteArray vertexShaderCode READ vertexShaderCode NOTIFY vertexShaderCodeChanged REVISION 13)
+ Q_PROPERTY(QByteArray tessellationControlShaderCode READ tessellationControlShaderCode NOTIFY tessellationControlShaderCodeChanged REVISION 13)
+ Q_PROPERTY(QByteArray tessellationEvaluationShaderCode READ tessellationEvaluationShaderCode NOTIFY tessellationEvaluationShaderCodeChanged REVISION 13)
+ Q_PROPERTY(QByteArray geometryShaderCode READ geometryShaderCode NOTIFY geometryShaderCodeChanged REVISION 13)
+ Q_PROPERTY(QByteArray fragmentShaderCode READ fragmentShaderCode NOTIFY fragmentShaderCodeChanged REVISION 13)
+ Q_PROPERTY(QByteArray computeShaderCode READ computeShaderCode NOTIFY computeShaderCodeChanged REVISION 13)
public:
explicit QShaderProgramBuilder(Qt3DCore::QNode *parent = nullptr);
@@ -76,6 +82,12 @@ public:
QUrl geometryShaderGraph() const;
QUrl fragmentShaderGraph() const;
QUrl computeShaderGraph() const;
+ QByteArray vertexShaderCode() const;
+ QByteArray tessellationControlShaderCode() const;
+ QByteArray tessellationEvaluationShaderCode() const;
+ QByteArray geometryShaderCode() const;
+ QByteArray fragmentShaderCode() const;
+ QByteArray computeShaderCode() const;
public Q_SLOTS:
void setShaderProgram(Qt3DRender::QShaderProgram *program);
@@ -96,9 +108,16 @@ Q_SIGNALS:
void geometryShaderGraphChanged(const QUrl &geometryShaderGraph);
void fragmentShaderGraphChanged(const QUrl &fragmentShaderGraph);
void computeShaderGraphChanged(const QUrl &computeShaderGraph);
+ Q_REVISION(13) void vertexShaderCodeChanged(const QByteArray &vertexShaderCode);
+ Q_REVISION(13) void tessellationControlShaderCodeChanged(const QByteArray &tessellationControlShaderCode);
+ Q_REVISION(13) void tessellationEvaluationShaderCodeChanged(const QByteArray &tessellationEvaluationShaderCode);
+ Q_REVISION(13) void geometryShaderCodeChanged(const QByteArray &geometryShaderCode);
+ Q_REVISION(13) void fragmentShaderCodeChanged(const QByteArray &fragmentShaderCode);
+ Q_REVISION(13) void computeShaderCodeChanged(const QByteArray &computeShaderCode);
protected:
explicit QShaderProgramBuilder(QShaderProgramBuilderPrivate &dd, Qt3DCore::QNode *parent = nullptr);
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
private:
Q_DECLARE_PRIVATE(QShaderProgramBuilder)
diff --git a/src/render/materialsystem/qshaderprogrambuilder_p.h b/src/render/materialsystem/qshaderprogrambuilder_p.h
index e1b470229..2ac765a1d 100644
--- a/src/render/materialsystem/qshaderprogrambuilder_p.h
+++ b/src/render/materialsystem/qshaderprogrambuilder_p.h
@@ -74,6 +74,12 @@ public:
QUrl m_geometryShaderGraph;
QUrl m_fragmentShaderGraph;
QUrl m_computeShaderGraph;
+ QByteArray m_vertexShaderCode;
+ QByteArray m_tessControlShaderCode;
+ QByteArray m_tessEvalShaderCode;
+ QByteArray m_geometryShaderCode;
+ QByteArray m_fragmentShaderCode;
+ QByteArray m_computeShaderCode;
};
struct QShaderProgramBuilderData
diff --git a/src/render/materialsystem/qtechnique.h b/src/render/materialsystem/qtechnique.h
index c0c0d0ade..7711cd67f 100644
--- a/src/render/materialsystem/qtechnique.h
+++ b/src/render/materialsystem/qtechnique.h
@@ -55,7 +55,7 @@ class QParameter;
class QTechniquePrivate;
class QGraphicsApiFilter;
-class QT3DRENDERSHARED_EXPORT QTechnique : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QTechnique : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QGraphicsApiFilter *graphicsApiFilter READ graphicsApiFilter CONSTANT)
diff --git a/src/render/materialsystem/shaderbuilder.cpp b/src/render/materialsystem/shaderbuilder.cpp
index 9c7cb0938..c1ec7f75a 100644
--- a/src/render/materialsystem/shaderbuilder.cpp
+++ b/src/render/materialsystem/shaderbuilder.cpp
@@ -40,6 +40,7 @@
#include "shaderbuilder_p.h"
#include <Qt3DRender/private/qshaderprogrambuilder_p.h>
+#include <Qt3DRender/qshaderprogram.h>
#include <Qt3DRender/private/qshaderprogram_p.h>
#include <Qt3DRender/private/qurlhelper_p.h>
@@ -112,6 +113,31 @@ using namespace Qt3DCore;
namespace Qt3DRender {
namespace Render {
+
+namespace {
+
+QShaderProgram::ShaderType toQShaderProgramType(ShaderBuilder::ShaderType type)
+{
+ switch (type) {
+ case ShaderBuilder::ShaderType::Vertex:
+ return QShaderProgram::Vertex;
+ case ShaderBuilder::ShaderType::TessellationControl:
+ return QShaderProgram::TessellationControl;
+ case ShaderBuilder::ShaderType::TessellationEvaluation:
+ return QShaderProgram::TessellationEvaluation;
+ case ShaderBuilder::ShaderType::Geometry:
+ return QShaderProgram::Geometry;
+ case ShaderBuilder::ShaderType::Fragment:
+ return QShaderProgram::Fragment;
+ case ShaderBuilder::ShaderType::Compute:
+ return QShaderProgram::Compute;
+ default:
+ Q_UNREACHABLE();
+ }
+}
+
+} // anonymous
+
QString ShaderBuilder::getPrototypesFile()
{
return qt3dGlobalShaderPrototypes->prototypesFile();
@@ -244,6 +270,13 @@ void ShaderBuilder::generateCode(ShaderBuilder::ShaderType type)
const auto code = generator.createShaderCode(m_enabledLayers);
m_codes.insert(type, QShaderProgramPrivate::deincludify(code, graphPath + QStringLiteral(".glsl")));
m_dirtyTypes.remove(type);
+
+ // Send notification to the frontend
+ Qt3DCore::QPropertyUpdatedChangePtr propertyChange = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ propertyChange->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
+ propertyChange->setPropertyName("generatedShaderCode");
+ propertyChange->setValue(QVariant::fromValue(qMakePair(int(toQShaderProgramType(type)), m_codes.value(type))));
+ notifyObservers(propertyChange);
}
void ShaderBuilder::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
diff --git a/src/render/materialsystem/shaderbuilder_p.h b/src/render/materialsystem/shaderbuilder_p.h
index e9378e3c5..00c4e1c28 100644
--- a/src/render/materialsystem/shaderbuilder_p.h
+++ b/src/render/materialsystem/shaderbuilder_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
namespace Render {
-class QT3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilder : public BackendNode
+class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilder : public BackendNode
{
public:
enum ShaderType {
diff --git a/src/render/materialsystem/shadercache_p.h b/src/render/materialsystem/shadercache_p.h
index bda629ee5..40b88b53e 100644
--- a/src/render/materialsystem/shadercache_p.h
+++ b/src/render/materialsystem/shadercache_p.h
@@ -66,7 +66,7 @@ namespace Render {
class tst_ShaderCache;
#endif
-class QT3DRENDERSHARED_PRIVATE_EXPORT ShaderCache
+class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderCache
{
public:
~ShaderCache();
diff --git a/src/render/materialsystem/technique_p.h b/src/render/materialsystem/technique_p.h
index 0ca9d3ae9..d885c1b87 100644
--- a/src/render/materialsystem/technique_p.h
+++ b/src/render/materialsystem/technique_p.h
@@ -73,7 +73,7 @@ namespace Render {
class TechniqueManager;
-class QT3DRENDERSHARED_PRIVATE_EXPORT Technique : public BackendNode
+class Q_3DRENDERSHARED_PRIVATE_EXPORT Technique : public BackendNode
{
public:
Technique();
diff --git a/src/render/picking/objectpicker.cpp b/src/render/picking/objectpicker.cpp
index 76f00993c..43e308d20 100644
--- a/src/render/picking/objectpicker.cpp
+++ b/src/render/picking/objectpicker.cpp
@@ -53,6 +53,7 @@ namespace Render {
ObjectPicker::ObjectPicker()
: BackendNode(QBackendNode::ReadWrite)
+ , m_priority(0)
, m_isPressed(false)
, m_hoverEnabled(false)
, m_dragEnabled(false)
@@ -70,6 +71,7 @@ void ObjectPicker::cleanup()
m_isPressed = false;
m_hoverEnabled = false;
m_dragEnabled = false;
+ m_priority = 0;
notifyJob();
}
@@ -79,6 +81,7 @@ void ObjectPicker::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr
const auto &data = typedChange->data;
m_hoverEnabled = data.hoverEnabled;
m_dragEnabled = data.dragEnabled;
+ m_priority = data.priority;
notifyJob();
}
@@ -97,6 +100,8 @@ void ObjectPicker::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
m_hoverEnabled = propertyChange->value().toBool();
} else if (propertyChange->propertyName() == QByteArrayLiteral("dragEnabled")) {
m_dragEnabled = propertyChange->value().toBool();
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("priority")) {
+ m_priority = propertyChange->value().toInt();
}
markDirty(AbstractRenderer::AllDirty);
@@ -175,6 +180,16 @@ void ObjectPicker::onExited()
notifyObservers(e);
}
+void ObjectPicker::setPriority(int priority)
+{
+ m_priority = priority;
+}
+
+int ObjectPicker::priority() const
+{
+ return m_priority;
+}
+
} // Render
} // Qt3DRender
diff --git a/src/render/picking/objectpicker_p.h b/src/render/picking/objectpicker_p.h
index b9c308afb..7389a4b53 100644
--- a/src/render/picking/objectpicker_p.h
+++ b/src/render/picking/objectpicker_p.h
@@ -81,10 +81,15 @@ public:
void onEntered();
void onExited();
+ // Needed for unit tests
+ void setPriority(int priority);
+ int priority() const;
+
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void notifyJob();
+ int m_priority;
bool m_isPressed;
bool m_hoverEnabled;
bool m_dragEnabled;
diff --git a/src/render/picking/qabstractraycaster.cpp b/src/render/picking/qabstractraycaster.cpp
index fa48cf0b0..ecec7a628 100644
--- a/src/render/picking/qabstractraycaster.cpp
+++ b/src/render/picking/qabstractraycaster.cpp
@@ -58,6 +58,10 @@ QAbstractRayCasterPrivate::QAbstractRayCasterPrivate()
m_shareable = false;
}
+/*!
+ \property Qt3DRender::QAbstractRayCaster::Hits
+*/
+
QAbstractRayCasterPrivate *QAbstractRayCasterPrivate::get(QAbstractRayCaster *obj)
{
return obj->d_func();
diff --git a/src/render/picking/qabstractraycaster.h b/src/render/picking/qabstractraycaster.h
index c706a7bd2..592511786 100644
--- a/src/render/picking/qabstractraycaster.h
+++ b/src/render/picking/qabstractraycaster.h
@@ -53,7 +53,7 @@ namespace Qt3DRender {
class QAbstractRayCasterPrivate;
class QLayer;
-class QT3DRENDERSHARED_EXPORT QAbstractRayCaster : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QAbstractRayCaster : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(RunMode runMode READ runMode WRITE setRunMode NOTIFY runModeChanged)
diff --git a/src/render/picking/qabstractraycaster_p.h b/src/render/picking/qabstractraycaster_p.h
index 2c4006e70..2dcddbd6a 100644
--- a/src/render/picking/qabstractraycaster_p.h
+++ b/src/render/picking/qabstractraycaster_p.h
@@ -64,7 +64,7 @@ class QLayer;
/*!
\internal
*/
-class QT3DRENDERSHARED_PRIVATE_EXPORT QAbstractRayCasterPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QAbstractRayCasterPrivate : public Qt3DCore::QComponentPrivate
{
public:
QAbstractRayCasterPrivate();
diff --git a/src/render/picking/qobjectpicker.cpp b/src/render/picking/qobjectpicker.cpp
index e15a7cdfc..f41ea06a6 100644
--- a/src/render/picking/qobjectpicker.cpp
+++ b/src/render/picking/qobjectpicker.cpp
@@ -268,6 +268,23 @@ void QObjectPicker::setDragEnabled(bool dragEnabled)
}
/*!
+ * Sets the picker's priority to \a priority. This is used when the pick result
+ * mode on QPickingSettings is set to QPickingSettings::NearestPriorityPick.
+ * Picking results are sorted by highest priority and shortest picking
+ * distance.
+ *
+ * \since 5.13
+ */
+void QObjectPicker::setPriority(int priority)
+{
+ Q_D(QObjectPicker);
+ if (priority != d->m_priority) {
+ d->m_priority = priority;
+ emit priorityChanged(priority);
+ }
+}
+
+/*!
\qmlproperty bool Qt3D.Render::ObjectPicker::dragEnabled
*/
/*!
@@ -314,6 +331,25 @@ bool QObjectPicker::isPressed() const
return d->m_pressed;
}
+/*!
+ \qmlproperty int Qt3D.Render::ObjectPicker::priority
+
+ The priority to be used when filtering pick results by priority when
+ PickingSettings.pickResultMode is set to PickingSettings.PriorityPick.
+*/
+/*!
+ \property Qt3DRender::QObjectPicker::priority
+
+ The priority to be used when filtering pick results by priority when
+ QPickingSettings::pickResultMode is set to
+ QPickingSettings::NearestPriorityPick.
+*/
+int QObjectPicker::priority() const
+{
+ Q_D(const QObjectPicker);
+ return d->m_priority;
+}
+
/*! \internal */
void QObjectPicker::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
{
@@ -467,6 +503,7 @@ Qt3DCore::QNodeCreatedChangeBasePtr QObjectPicker::createNodeCreationChange() co
Q_D(const QObjectPicker);
data.hoverEnabled = d->m_hoverEnabled;
data.dragEnabled = d->m_dragEnabled;
+ data.priority = d->m_priority;
return creationChange;
}
diff --git a/src/render/picking/qobjectpicker.h b/src/render/picking/qobjectpicker.h
index 9f3b138c3..8866c99a9 100644
--- a/src/render/picking/qobjectpicker.h
+++ b/src/render/picking/qobjectpicker.h
@@ -51,13 +51,14 @@ class QAttribute;
class QObjectPickerPrivate;
class QPickEvent;
-class QT3DRENDERSHARED_EXPORT QObjectPicker : public Qt3DCore::QComponent
+class Q_3DRENDERSHARED_EXPORT QObjectPicker : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged)
Q_PROPERTY(bool dragEnabled READ isDragEnabled WRITE setDragEnabled NOTIFY dragEnabledChanged)
Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged)
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
+ Q_PROPERTY(int priority READ priority WRITE setPriority NOTIFY priorityChanged REVISION 13)
public:
explicit QObjectPicker(QNode *parent = nullptr);
@@ -69,9 +70,12 @@ public:
bool containsMouse() const;
bool isPressed() const;
+ int priority() const;
+
public Q_SLOTS:
void setHoverEnabled(bool hoverEnabled);
void setDragEnabled(bool dragEnabled);
+ Q_REVISION(13) void setPriority(int priority);
Q_SIGNALS:
void pressed(Qt3DRender::QPickEvent *pick);
@@ -84,6 +88,7 @@ Q_SIGNALS:
void dragEnabledChanged(bool dragEnabled);
void pressedChanged(bool pressed);
void containsMouseChanged(bool containsMouse);
+ Q_REVISION(13) void priorityChanged(int priority);
protected:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
diff --git a/src/render/picking/qobjectpicker_p.h b/src/render/picking/qobjectpicker_p.h
index 3c48b9419..b95183ab5 100644
--- a/src/render/picking/qobjectpicker_p.h
+++ b/src/render/picking/qobjectpicker_p.h
@@ -59,7 +59,7 @@ namespace Qt3DRender {
/*!
\internal
*/
-class QT3DRENDERSHARED_PRIVATE_EXPORT QObjectPickerPrivate : public Qt3DCore::QComponentPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QObjectPickerPrivate : public Qt3DCore::QComponentPrivate
{
public:
QObjectPickerPrivate()
@@ -69,6 +69,7 @@ public:
, m_pressed(false)
, m_containsMouse(false)
, m_acceptedLastPressedEvent(true)
+ , m_priority(0)
{
m_shareable = false;
}
@@ -79,6 +80,7 @@ public:
bool m_pressed;
bool m_containsMouse;
bool m_acceptedLastPressedEvent;
+ int m_priority;
enum EventType {
Pressed,
@@ -102,6 +104,7 @@ struct QObjectPickerData
{
bool hoverEnabled;
bool dragEnabled;
+ int priority;
};
} // namespace Qt3DRender
diff --git a/src/render/picking/qpickevent.h b/src/render/picking/qpickevent.h
index 7d854043e..5b354efb7 100644
--- a/src/render/picking/qpickevent.h
+++ b/src/render/picking/qpickevent.h
@@ -54,7 +54,7 @@ class QPickEventPrivate;
class QPickEvent;
typedef QSharedPointer<QPickEvent> QPickEventPtr;
-class QT3DRENDERSHARED_EXPORT QPickEvent : public QObject
+class Q_3DRENDERSHARED_EXPORT QPickEvent : public QObject
{
Q_OBJECT
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted NOTIFY acceptedChanged)
diff --git a/src/render/picking/qpickevent_p.h b/src/render/picking/qpickevent_p.h
index ced36c9bb..e27ee51e2 100644
--- a/src/render/picking/qpickevent_p.h
+++ b/src/render/picking/qpickevent_p.h
@@ -60,7 +60,7 @@ namespace Qt3DRender {
class QPickEvent;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QPickEventPrivate : public QObjectPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QPickEventPrivate : public QObjectPrivate
{
public:
QPickEventPrivate()
diff --git a/src/render/picking/qpicklineevent.h b/src/render/picking/qpicklineevent.h
index 09697ad22..5941d38d4 100644
--- a/src/render/picking/qpicklineevent.h
+++ b/src/render/picking/qpicklineevent.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QPickLineEventPrivate;
-class QT3DRENDERSHARED_EXPORT QPickLineEvent : public QPickEvent
+class Q_3DRENDERSHARED_EXPORT QPickLineEvent : public QPickEvent
{
Q_OBJECT
Q_PROPERTY(uint edgeIndex READ edgeIndex CONSTANT)
diff --git a/src/render/picking/qpickpointevent.h b/src/render/picking/qpickpointevent.h
index f298f64b9..78ab23d9e 100644
--- a/src/render/picking/qpickpointevent.h
+++ b/src/render/picking/qpickpointevent.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QPickPointEventPrivate;
-class QT3DRENDERSHARED_EXPORT QPickPointEvent : public QPickEvent
+class Q_3DRENDERSHARED_EXPORT QPickPointEvent : public QPickEvent
{
Q_OBJECT
Q_PROPERTY(uint pointIndex READ pointIndex CONSTANT)
diff --git a/src/render/picking/qpicktriangleevent.h b/src/render/picking/qpicktriangleevent.h
index f116af288..48a1da762 100644
--- a/src/render/picking/qpicktriangleevent.h
+++ b/src/render/picking/qpicktriangleevent.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QPickTriangleEventPrivate;
-class QT3DRENDERSHARED_EXPORT QPickTriangleEvent : public QPickEvent
+class Q_3DRENDERSHARED_EXPORT QPickTriangleEvent : public QPickEvent
{
Q_OBJECT
Q_PROPERTY(uint triangleIndex READ triangleIndex CONSTANT)
diff --git a/src/render/picking/qraycaster.h b/src/render/picking/qraycaster.h
index 088c46607..b565c2c25 100644
--- a/src/render/picking/qraycaster.h
+++ b/src/render/picking/qraycaster.h
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QRayCaster : public QAbstractRayCaster
+class Q_3DRENDERSHARED_EXPORT QRayCaster : public QAbstractRayCaster
{
Q_OBJECT
Q_PROPERTY(QVector3D origin READ origin WRITE setOrigin NOTIFY originChanged)
diff --git a/src/render/picking/qraycasterhit.h b/src/render/picking/qraycasterhit.h
index 4764994df..9f62889fd 100644
--- a/src/render/picking/qraycasterhit.h
+++ b/src/render/picking/qraycasterhit.h
@@ -53,7 +53,7 @@ namespace Qt3DRender {
class QRayCasterHitData;
class QAbstractRayCasterPrivate;
-class QT3DRENDERSHARED_EXPORT QRayCasterHit
+class Q_3DRENDERSHARED_EXPORT QRayCasterHit
{
Q_GADGET
public:
diff --git a/src/render/picking/qscreenraycaster.h b/src/render/picking/qscreenraycaster.h
index 09ad94374..216ed47f5 100644
--- a/src/render/picking/qscreenraycaster.h
+++ b/src/render/picking/qscreenraycaster.h
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QScreenRayCaster : public QAbstractRayCaster
+class Q_3DRENDERSHARED_EXPORT QScreenRayCaster : public QAbstractRayCaster
{
Q_OBJECT
diff --git a/src/render/qt3drender_global.h b/src/render/qt3drender_global.h
index 68e1cb639..0bd34ac8b 100644
--- a/src/render/qt3drender_global.h
+++ b/src/render/qt3drender_global.h
@@ -46,12 +46,12 @@ QT_BEGIN_NAMESPACE
#if defined(QT_SHARED) || !defined(QT_STATIC)
# if defined(QT_BUILD_3DRENDER_LIB)
-# define QT3DRENDERSHARED_EXPORT Q_DECL_EXPORT
+# define Q_3DRENDERSHARED_EXPORT Q_DECL_EXPORT
# else
-# define QT3DRENDERSHARED_EXPORT Q_DECL_IMPORT
+# define Q_3DRENDERSHARED_EXPORT Q_DECL_IMPORT
# endif
#else
-# define QT3DRENDERSHARED_EXPORT
+# define Q_3DRENDERSHARED_EXPORT
#endif
QT_END_NAMESPACE
diff --git a/src/render/qt3drender_global_p.h b/src/render/qt3drender_global_p.h
index bdc35fd86..5caa8d895 100644
--- a/src/render/qt3drender_global_p.h
+++ b/src/render/qt3drender_global_p.h
@@ -54,6 +54,6 @@
#include "qt3drender_global.h"
#include <Qt3DRender/private/qt3drender-config_p.h>
-#define QT3DRENDERSHARED_PRIVATE_EXPORT QT3DRENDERSHARED_EXPORT
+#define Q_3DRENDERSHARED_PRIVATE_EXPORT Q_3DRENDERSHARED_EXPORT
#endif // QT3DRENDER_GLOBAL_P_H
diff --git a/src/render/raycasting/boundingsphere_p.h b/src/render/raycasting/boundingsphere_p.h
index bcffbaa19..fb76a8496 100644
--- a/src/render/raycasting/boundingsphere_p.h
+++ b/src/render/raycasting/boundingsphere_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
namespace RayCasting {
-class QT3DRENDERSHARED_EXPORT BoundingSphere : public QBoundingVolume
+class Q_3DRENDERSHARED_EXPORT BoundingSphere : public QBoundingVolume
{
public:
BoundingSphere();
diff --git a/src/render/raycasting/qabstractcollisionqueryservice_p.h b/src/render/raycasting/qabstractcollisionqueryservice_p.h
index fa35792d0..40137d239 100644
--- a/src/render/raycasting/qabstractcollisionqueryservice_p.h
+++ b/src/render/raycasting/qabstractcollisionqueryservice_p.h
@@ -77,7 +77,7 @@ public:
{}
};
-class QT3DRENDERSHARED_EXPORT QAbstractCollisionQueryService : public Qt3DCore::QAbstractServiceProvider
+class Q_3DRENDERSHARED_EXPORT QAbstractCollisionQueryService : public Qt3DCore::QAbstractServiceProvider
{
Q_OBJECT
public:
diff --git a/src/render/raycasting/qboundingvolume_p.h b/src/render/raycasting/qboundingvolume_p.h
index b63463f23..796085b25 100644
--- a/src/render/raycasting/qboundingvolume_p.h
+++ b/src/render/raycasting/qboundingvolume_p.h
@@ -61,7 +61,7 @@ namespace RayCasting {
class QRay3D;
-class QT3DRENDERSHARED_EXPORT QBoundingVolume
+class Q_3DRENDERSHARED_EXPORT QBoundingVolume
{
public:
QBoundingVolume();
diff --git a/src/render/raycasting/qboundingvolumeprovider_p.h b/src/render/raycasting/qboundingvolumeprovider_p.h
index ae9fd65e3..42b95dd30 100644
--- a/src/render/raycasting/qboundingvolumeprovider_p.h
+++ b/src/render/raycasting/qboundingvolumeprovider_p.h
@@ -60,7 +60,7 @@ namespace RayCasting {
class QBoundingVolume;
-class QT3DRENDERSHARED_EXPORT QBoundingVolumeProvider
+class Q_3DRENDERSHARED_EXPORT QBoundingVolumeProvider
{
public:
virtual ~QBoundingVolumeProvider();
diff --git a/src/render/raycasting/qcollisionqueryresult_p.h b/src/render/raycasting/qcollisionqueryresult_p.h
index 24371d30e..67f6a34d0 100644
--- a/src/render/raycasting/qcollisionqueryresult_p.h
+++ b/src/render/raycasting/qcollisionqueryresult_p.h
@@ -65,7 +65,7 @@ namespace RayCasting {
typedef int QQueryHandle;
class QCollisionQueryResultPrivate;
-class QT3DRENDERSHARED_EXPORT QCollisionQueryResult
+class Q_3DRENDERSHARED_EXPORT QCollisionQueryResult
{
public:
struct Hit {
diff --git a/src/render/raycasting/qray3d_p.h b/src/render/raycasting/qray3d_p.h
index 8b7852cc3..7d1ac874e 100644
--- a/src/render/raycasting/qray3d_p.h
+++ b/src/render/raycasting/qray3d_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
namespace RayCasting {
-class QT3DRENDERSHARED_EXPORT QRay3D
+class Q_3DRENDERSHARED_EXPORT QRay3D
{
public:
QRay3D();
@@ -104,12 +104,12 @@ QT3D_DECLARE_TYPEINFO_2(Qt3DRender, RayCasting, QRay3D, Q_MOVABLE_TYPE)
#ifndef QT_NO_DEBUG_STREAM
-QT3DRENDERSHARED_EXPORT QDebug operator<<(QDebug dbg, const QRay3D &ray);
+Q_3DRENDERSHARED_EXPORT QDebug operator<<(QDebug dbg, const QRay3D &ray);
#endif
#ifndef QT_NO_DATASTREAM
-QT3DRENDERSHARED_EXPORT QDataStream &operator<<(QDataStream &stream, const QRay3D &ray);
-QT3DRENDERSHARED_EXPORT QDataStream &operator>>(QDataStream &stream, QRay3D &ray);
+Q_3DRENDERSHARED_EXPORT QDataStream &operator<<(QDataStream &stream, const QRay3D &ray);
+Q_3DRENDERSHARED_EXPORT QDataStream &operator>>(QDataStream &stream, QRay3D &ray);
#endif
} // namespace RayCasting
diff --git a/src/render/raycasting/qraycastingservice_p.h b/src/render/raycasting/qraycastingservice_p.h
index b77c8af9f..792ba2626 100644
--- a/src/render/raycasting/qraycastingservice_p.h
+++ b/src/render/raycasting/qraycastingservice_p.h
@@ -69,7 +69,7 @@ class QRayCastingServicePrivate;
typedef QFuture<QCollisionQueryResult> FutureQueryResult;
-class QT3DRENDERSHARED_EXPORT QRayCastingService : public QAbstractCollisionQueryService
+class Q_3DRENDERSHARED_EXPORT QRayCastingService : public QAbstractCollisionQueryService
{
public:
QRayCastingService();
diff --git a/src/render/renderers/opengl/graphicshelpers/glfence_p.h b/src/render/renderers/opengl/graphicshelpers/glfence_p.h
new file mode 100644
index 000000000..366065048
--- /dev/null
+++ b/src/render/renderers/opengl/graphicshelpers/glfence_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GLFENCE_P_H
+#define GLFENCE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+// GLsync is a pointer to a struct (unlike the rest of GL which used int ids)
+// We cannot reference GLsync as it's only available since 3.2 We use FenceId
+// to wrap that around and trust the GLHelpers will convert them accordingly.
+using GLFence = void *;
+
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+
+#endif // GLFENCE_P_H
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelperes2.cpp b/src/render/renderers/opengl/graphicshelpers/graphicshelperes2.cpp
index c5753195b..71540b1ad 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelperes2.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelperes2.cpp
@@ -318,6 +318,33 @@ void GraphicsHelperES2::drawBuffer(GLenum mode)
qWarning() << "glDrawBuffer is not supported with OpenGL ES 2";
}
+void *GraphicsHelperES2::fenceSync()
+{
+ qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
+ return nullptr;
+}
+
+void GraphicsHelperES2::clientWaitSync(void *, GLuint64 )
+{
+ qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
+}
+
+void GraphicsHelperES2::waitSync(void *)
+{
+ qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
+}
+
+bool GraphicsHelperES2::wasSyncSignaled(void *)
+{
+ qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
+ return false;
+}
+
+void GraphicsHelperES2::deleteSync(void *)
+{
+ qWarning() << "Fences are not supported by OpenGL ES 2.0 (since OpenGL ES 3.0)";
+}
+
void GraphicsHelperES2::blendEquation(GLenum mode)
{
m_funcs->glBlendEquation(mode);
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelperes2_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelperes2_p.h
index 1c6df41b6..8c8dd34e9 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelperes2_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelperes2_p.h
@@ -132,6 +132,12 @@ public:
void readBuffer(GLenum mode) override;
void drawBuffer(GLenum mode) override;
+ void *fenceSync() override;
+ void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
+ void waitSync(void *sync) override;
+ bool wasSyncSignaled(void *sync) override;
+ void deleteSync(void *sync) override;
+
void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelperes3.cpp b/src/render/renderers/opengl/graphicshelpers/graphicshelperes3.cpp
index 34c1e7448..5e5d2e001 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelperes3.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelperes3.cpp
@@ -147,6 +147,26 @@ QT_BEGIN_NAMESPACE
#define GL_READ_FRAMEBUFFER 0x8CA8
#endif
+#ifndef GL_SIGNALED
+#define GL_SIGNALED 0x9119
+#endif
+
+#ifndef GL_SYNC_STATUS
+#define GL_SYNC_STATUS 0x9114
+#endif
+
+#ifndef GL_TIMEOUT_IGNORED
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
+#endif
+
+#ifndef GL_SYNC_GPU_COMMANDS_COMPLETE
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#endif
+
+#ifndef GL_SYNC_FLUSH_COMMANDS_BIT
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#endif
+
namespace Qt3DRender {
namespace Render {
@@ -307,6 +327,7 @@ bool GraphicsHelperES3::supportsFeature(GraphicsHelperInterface::Feature feature
case BlitFramebuffer:
case UniformBufferObject:
case MapBuffer:
+ case Fences:
return true;
default:
return false;
@@ -439,6 +460,37 @@ uint GraphicsHelperES3::uniformByteSize(const ShaderUniform &description)
return arrayStride ? rawByteSize * arrayStride : rawByteSize;
}
+void *GraphicsHelperES3::fenceSync()
+{
+ return m_extraFuncs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+}
+
+void GraphicsHelperES3::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
+{
+ m_extraFuncs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
+}
+
+void GraphicsHelperES3::waitSync(void *sync)
+{
+ m_extraFuncs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
+}
+
+bool GraphicsHelperES3::wasSyncSignaled(void *sync)
+{
+ GLint v;
+ m_extraFuncs->glGetSynciv(static_cast<GLsync>(sync),
+ GL_SYNC_STATUS,
+ sizeof(v),
+ nullptr,
+ &v);
+ return v == GL_SIGNALED;
+}
+
+void GraphicsHelperES3::deleteSync(void *sync)
+{
+ m_extraFuncs->glDeleteSync(static_cast<GLsync>(sync));
+}
+
void GraphicsHelperES3::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
{
m_extraFuncs->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelperes3_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelperes3_p.h
index d4467cf7f..dc5cef10c 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelperes3_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelperes3_p.h
@@ -90,6 +90,12 @@ public:
UniformType uniformTypeFromGLType(GLenum glType) override;
uint uniformByteSize(const ShaderUniform &description) override;
+ void *fenceSync() override;
+ void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
+ void waitSync(void *sync) override;
+ bool wasSyncSignaled(void *sync) override;
+ void deleteSync(void *sync) override;
+
protected:
QOpenGLExtraFunctions *m_extraFuncs = nullptr;
};
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2.cpp b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2.cpp
index 6da8a9b6f..b6f3412b2 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2.cpp
@@ -272,6 +272,33 @@ void GraphicsHelperGL2::drawBuffer(GLenum mode)
m_funcs->glDrawBuffer(mode);
}
+void *GraphicsHelperGL2::fenceSync()
+{
+ qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
+ return nullptr;
+}
+
+void GraphicsHelperGL2::clientWaitSync(void *, GLuint64 )
+{
+ qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
+}
+
+void GraphicsHelperGL2::waitSync(void *)
+{
+ qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
+}
+
+bool GraphicsHelperGL2::wasSyncSignaled(void *)
+{
+ qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
+ return false;
+}
+
+void GraphicsHelperGL2::deleteSync(void *)
+{
+ qWarning() << "Fences are not supported by OpenGL 2.0 (since OpenGL 3.2)";
+}
+
void GraphicsHelperGL2::blendEquation(GLenum mode)
{
m_funcs->glBlendEquation(mode);
@@ -412,6 +439,7 @@ bool GraphicsHelperGL2::supportsFeature(GraphicsHelperInterface::Feature feature
case MRT:
return (m_fboFuncs != nullptr);
case TextureDimensionRetrieval:
+ case MapBuffer:
return true;
default:
return false;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2_p.h
index 2db75004f..b142b2623 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl2_p.h
@@ -132,6 +132,12 @@ public:
void readBuffer(GLenum mode) override;
void drawBuffer(GLenum mode) override;
+ void *fenceSync() override;
+ void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
+ void waitSync(void *sync) override;
+ bool wasSyncSignaled(void *sync) override;
+ void deleteSync(void *sync) override;
+
void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp
index a35c4e37f..5ff1a2ba5 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp
@@ -334,6 +334,37 @@ void GraphicsHelperGL3_2::drawBuffer(GLenum mode)
m_funcs->glDrawBuffer(mode);
}
+void *GraphicsHelperGL3_2::fenceSync()
+{
+ return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+}
+
+void GraphicsHelperGL3_2::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
+{
+ m_funcs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
+}
+
+void GraphicsHelperGL3_2::waitSync(void *sync)
+{
+ m_funcs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
+}
+
+bool GraphicsHelperGL3_2::wasSyncSignaled(void *sync)
+{
+ GLint v;
+ m_funcs->glGetSynciv(static_cast<GLsync>(sync),
+ GL_SYNC_STATUS,
+ sizeof(v),
+ nullptr,
+ &v);
+ return v == GL_SIGNALED;
+}
+
+void GraphicsHelperGL3_2::deleteSync(void *sync)
+{
+ m_funcs->glDeleteSync(static_cast<GLsync>(sync));
+}
+
void GraphicsHelperGL3_2::blendEquation(GLenum mode)
{
m_funcs->glBlendEquation(mode);
@@ -481,6 +512,7 @@ bool GraphicsHelperGL3_2::supportsFeature(GraphicsHelperInterface::Feature featu
case TextureDimensionRetrieval:
case BindableFragmentOutputs:
case BlitFramebuffer:
+ case Fences:
return true;
case Tessellation:
return !m_tessFuncs.isNull();
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2_p.h
index 133295fd7..9e81345ad 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_2_p.h
@@ -134,6 +134,12 @@ public:
void readBuffer(GLenum mode) override;
void drawBuffer(GLenum mode) override;
+ void *fenceSync() override;
+ void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
+ void waitSync(void *sync) override;
+ bool wasSyncSignaled(void *sync) override;
+ void deleteSync(void *sync) override;
+
void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp
index b2512d84a..81081943d 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp
@@ -330,6 +330,37 @@ void GraphicsHelperGL3_3::drawBuffer(GLenum mode)
m_funcs->glDrawBuffer(mode);
}
+void *GraphicsHelperGL3_3::fenceSync()
+{
+ return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+}
+
+void GraphicsHelperGL3_3::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
+{
+ m_funcs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
+}
+
+void GraphicsHelperGL3_3::waitSync(void *sync)
+{
+ m_funcs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
+}
+
+bool GraphicsHelperGL3_3::wasSyncSignaled(void *sync)
+{
+ GLint v;
+ m_funcs->glGetSynciv(static_cast<GLsync>(sync),
+ GL_SYNC_STATUS,
+ sizeof(v),
+ nullptr,
+ &v);
+ return v == GL_SIGNALED;
+}
+
+void GraphicsHelperGL3_3::deleteSync(void *sync)
+{
+ m_funcs->glDeleteSync(static_cast<GLsync>(sync));
+}
+
void GraphicsHelperGL3_3::blendEquation(GLenum mode)
{
m_funcs->glBlendEquation(mode);
@@ -477,6 +508,7 @@ bool GraphicsHelperGL3_3::supportsFeature(GraphicsHelperInterface::Feature featu
case TextureDimensionRetrieval:
case BindableFragmentOutputs:
case BlitFramebuffer:
+ case Fences:
return true;
case Tessellation:
return !m_tessFuncs.isNull();
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3_p.h
index 0ecdd3620..c480e5258 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl3_3_p.h
@@ -134,6 +134,12 @@ public:
void readBuffer(GLenum mode) override;
void drawBuffer(GLenum mode) override;
+ void *fenceSync() override;
+ void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
+ void waitSync(void *sync) override;
+ bool wasSyncSignaled(void *sync) override;
+ void deleteSync(void *sync) override;
+
void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp
index ce1b8ac2b..22cbf7428 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp
@@ -400,6 +400,39 @@ void GraphicsHelperGL4::drawBuffer(GLenum mode)
m_funcs->glDrawBuffer(mode);
}
+void *GraphicsHelperGL4::fenceSync()
+{
+ return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+}
+
+void GraphicsHelperGL4::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
+{
+ qDebug() << Q_FUNC_INFO << sync << static_cast<GLsync>(sync);
+ GLenum e = m_funcs->glClientWaitSync(static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, nanoSecTimeout);
+ qDebug() << e;
+}
+
+void GraphicsHelperGL4::waitSync(void *sync)
+{
+ m_funcs->glWaitSync(static_cast<GLsync>(sync), 0, GL_TIMEOUT_IGNORED);
+}
+
+bool GraphicsHelperGL4::wasSyncSignaled(void *sync)
+{
+ GLint v = 0;
+ m_funcs->glGetSynciv(static_cast<GLsync>(sync),
+ GL_SYNC_STATUS,
+ sizeof(v),
+ nullptr,
+ &v);
+ return v == GL_SIGNALED;
+}
+
+void GraphicsHelperGL4::deleteSync(void *sync)
+{
+ m_funcs->glDeleteSync(static_cast<GLsync>(sync));
+}
+
void GraphicsHelperGL4::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
{
m_funcs->glUniform1fv(location, count, values);
@@ -746,6 +779,8 @@ bool GraphicsHelperGL4::supportsFeature(GraphicsHelperInterface::Feature feature
case DrawBuffersBlend:
case BlitFramebuffer:
case IndirectDrawing:
+ case MapBuffer:
+ case Fences:
return true;
default:
return false;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4_p.h
index 3020b16d8..da62f4212 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpergl4_p.h
@@ -132,6 +132,12 @@ public:
void readBuffer(GLenum mode) override;
void drawBuffer(GLenum mode) override;
+ void *fenceSync() override;
+ void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) override;
+ void waitSync(void *sync) override;
+ bool wasSyncSignaled(void *sync) override;
+ void deleteSync(void *sync) override;
+
void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) override;
void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) override;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelperinterface_p.h b/src/render/renderers/opengl/graphicshelpers/graphicshelperinterface_p.h
index e41325cb7..2a1688b7f 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelperinterface_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelperinterface_p.h
@@ -82,7 +82,8 @@ public:
DrawBuffersBlend,
BlitFramebuffer,
IndirectDrawing,
- MapBuffer
+ MapBuffer,
+ Fences
};
enum FBOBindMode {
@@ -155,6 +156,12 @@ public:
virtual void readBuffer(GLenum mode) = 0;
virtual void drawBuffer(GLenum mode) = 0;
+ virtual void *fenceSync() = 0;
+ virtual void clientWaitSync(void *sync, GLuint64 nanoSecTimeout) = 0;
+ virtual void waitSync(void *sync) = 0;
+ virtual bool wasSyncSignaled(void *sync) = 0;
+ virtual void deleteSync(void *sync) = 0;
+
virtual void glUniform1fv(GLint location, GLsizei count, const GLfloat *value) = 0;
virtual void glUniform2fv(GLint location, GLsizei count, const GLfloat *value) = 0;
virtual void glUniform3fv(GLint location, GLsizei count, const GLfloat *value) = 0;
diff --git a/src/render/renderers/opengl/graphicshelpers/graphicshelpers.pri b/src/render/renderers/opengl/graphicshelpers/graphicshelpers.pri
index c40f52374..ad08038c9 100644
--- a/src/render/renderers/opengl/graphicshelpers/graphicshelpers.pri
+++ b/src/render/renderers/opengl/graphicshelpers/graphicshelpers.pri
@@ -3,6 +3,7 @@
INCLUDEPATH += $$PWD
HEADERS += \
+ $$PWD/glfence_p.h \
$$PWD/graphicscontext_p.h \
$$PWD/graphicshelperinterface_p.h \
$$PWD/graphicshelperes2_p.h \
diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp
index daf6db717..1a2971a3f 100644
--- a/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext.cpp
@@ -1088,6 +1088,33 @@ void SubmissionContext::clearStencilValue(int stencil)
}
}
+GLFence SubmissionContext::fenceSync()
+{
+ return m_glHelper->fenceSync();
+}
+
+void SubmissionContext::clientWaitSync(GLFence sync, GLuint64 nanoSecTimeout)
+{
+ qDebug() << Q_FUNC_INFO << sync;
+ m_glHelper->clientWaitSync(sync, nanoSecTimeout);
+}
+
+void SubmissionContext::waitSync(GLFence sync)
+{
+ qDebug() << Q_FUNC_INFO << sync;
+ m_glHelper->waitSync(sync);
+}
+
+bool SubmissionContext::wasSyncSignaled(GLFence sync)
+{
+ return m_glHelper->wasSyncSignaled(sync);
+}
+
+void SubmissionContext::deleteSync(GLFence sync)
+{
+ m_glHelper->deleteSync(sync);
+}
+
// It will be easier if the QGraphicContext applies the QUniformPack
// than the other way around
bool SubmissionContext::setParameters(ShaderParameterPack &parameterPack)
@@ -1113,7 +1140,7 @@ bool SubmissionContext::setParameters(ShaderParameterPack &parameterPack)
if (t != nullptr) {
UniformValue &texUniform = uniformValues[namedTex.glslNameId];
if (texUniform.valueType() == UniformValue::TextureValue) {
- const int texUnit = m_textureContext.activateTexture(TextureSubmissionContext::TextureScopeMaterial, t);
+ const int texUnit = m_textureContext.activateTexture(TextureSubmissionContext::TextureScopeMaterial, m_gl, t);
texUniform.data<int>()[namedTex.uniformArrayIndex] = texUnit;
if (texUnit == -1) {
if (namedTex.glslNameId != irradianceId &&
diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h b/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h
index 9b9bd7fa8..844e62f15 100644
--- a/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h
@@ -60,6 +60,7 @@
#include <Qt3DRender/qattribute.h>
#include <Qt3DRender/private/handle_types_p.h>
#include <Qt3DRender/private/shadercache_p.h>
+#include <Qt3DRender/private/glfence_p.h>
QT_BEGIN_NAMESPACE
@@ -147,6 +148,14 @@ public:
void clearDepthValue(float depth);
void clearStencilValue(int stencil);
+
+ // Fences
+ GLFence fenceSync();
+ void clientWaitSync(GLFence sync, GLuint64 nanoSecTimeout);
+ void waitSync(GLFence sync);
+ bool wasSyncSignaled(GLFence sync);
+ void deleteSync(GLFence sync);
+
private:
void initialize();
diff --git a/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext.cpp b/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext.cpp
index 35fc1dc7c..67d0f9976 100644
--- a/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext.cpp
+++ b/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext.cpp
@@ -104,7 +104,9 @@ void TextureSubmissionContext::endDrawing()
TextureExtRendererLocker::unlock(m_activeTextures[i].texture);
}
-int TextureSubmissionContext::activateTexture(TextureSubmissionContext::TextureScope scope, GLTexture *tex)
+int TextureSubmissionContext::activateTexture(TextureSubmissionContext::TextureScope scope,
+ QOpenGLContext *m_gl,
+ GLTexture *tex)
{
// Returns the texture unit to use for the texture
// This always return a valid unit, unless there are more textures than
@@ -115,11 +117,20 @@ int TextureSubmissionContext::activateTexture(TextureSubmissionContext::TextureS
if (onUnit == -1)
return -1;
- // Texture must have been created and updated at this point
- QOpenGLTexture *glTex = tex->getGLTexture();
- if (glTex == nullptr)
- return -1;
- glTex->bind(uint(onUnit));
+ const int sharedTextureId = tex->sharedTextureId();
+ // We have a valid texture id provided by a shared context
+ if (sharedTextureId > 0) {
+ m_gl->functions()->glActiveTexture(GL_TEXTURE0 + onUnit);
+ const QAbstractTexture::Target target = tex->properties().target;
+ // For now we know that target values correspond to the GL values
+ m_gl->functions()->glBindTexture(target, tex->sharedTextureId());
+ } else {
+ // Texture must have been created and updated at this point
+ QOpenGLTexture *glTex = tex->getGLTexture();
+ if (glTex == nullptr)
+ return -1;
+ glTex->bind(uint(onUnit));
+ }
if (m_activeTextures[onUnit].texture != tex) {
if (m_activeTextures[onUnit].texture)
TextureExtRendererLocker::unlock(m_activeTextures[onUnit].texture);
diff --git a/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext_p.h b/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext_p.h
index d0c1565b2..3c84fe558 100644
--- a/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext_p.h
+++ b/src/render/renderers/opengl/graphicshelpers/texturesubmissioncontext_p.h
@@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE
+class QOpenGLContext;
+
namespace Qt3DRender {
namespace Render {
@@ -78,7 +80,7 @@ public:
void initialize(GraphicsContext *context);
void endDrawing();
- int activateTexture(TextureScope scope, GLTexture* tex);
+ int activateTexture(TextureScope scope, QOpenGLContext *gl, GLTexture* tex);
void deactivateTexture(GLTexture *tex);
void deactivateTexturesWithScope(TextureScope ts);
diff --git a/src/render/renderers/opengl/jobs/filtercompatibletechniquejob_p.h b/src/render/renderers/opengl/jobs/filtercompatibletechniquejob_p.h
index 4f7a7146c..27b3d4ed2 100644
--- a/src/render/renderers/opengl/jobs/filtercompatibletechniquejob_p.h
+++ b/src/render/renderers/opengl/jobs/filtercompatibletechniquejob_p.h
@@ -64,7 +64,7 @@ namespace Render {
class TechniqueManager;
class Renderer;
-class QT3DRENDERSHARED_PRIVATE_EXPORT FilterCompatibleTechniqueJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT FilterCompatibleTechniqueJob : public Qt3DCore::QAspectJob
{
public:
FilterCompatibleTechniqueJob();
diff --git a/src/render/renderers/opengl/jobs/materialparametergathererjob_p.h b/src/render/renderers/opengl/jobs/materialparametergathererjob_p.h
index fbfac3364..6ba060841 100644
--- a/src/render/renderers/opengl/jobs/materialparametergathererjob_p.h
+++ b/src/render/renderers/opengl/jobs/materialparametergathererjob_p.h
@@ -70,7 +70,7 @@ class Renderer;
// TO be executed for each FrameGraph branch with a given RenderPassFilter/TechniqueFilter
-class QT3DRENDERSHARED_PRIVATE_EXPORT MaterialParameterGathererJob : public Qt3DCore::QAspectJob
+class Q_3DRENDERSHARED_PRIVATE_EXPORT MaterialParameterGathererJob : public Qt3DCore::QAspectJob
{
public:
MaterialParameterGathererJob();
diff --git a/src/render/renderers/opengl/jobs/renderviewjobutils.cpp b/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
index 49e85e1d3..c2d75b499 100644
--- a/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
+++ b/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
@@ -68,6 +68,7 @@
#include <Qt3DRender/private/techniquemanager_p.h>
#include <Qt3DRender/private/memorybarrier_p.h>
#include <Qt3DRender/private/blitframebuffer_p.h>
+#include <Qt3DRender/private/waitfence_p.h>
QT_BEGIN_NAMESPACE
@@ -274,6 +275,17 @@ void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, const FrameGraphN
break;
}
+ case FrameGraphNode::WaitFence: {
+ const Render::WaitFence *waitFence = static_cast<const Render::WaitFence *>(node);
+ rv->appendWaitFence(waitFence->data());
+ break;
+ }
+
+ case FrameGraphNode::SetFence: {
+ rv->appendInsertFenceId(node->peerId());
+ break;
+ }
+
default:
// Should never get here
qCWarning(Backend) << "Unhandled FrameGraphNode type";
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index aeb3e513d..b4a19c641 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -91,6 +91,7 @@
#include <Qt3DRender/private/renderviewbuilder_p.h>
#include <Qt3DRender/private/commandthread_p.h>
#include <Qt3DRender/private/glcommands_p.h>
+#include <Qt3DRender/private/setfence_p.h>
#include <Qt3DRender/qcameralens.h>
#include <Qt3DCore/private/qeventfilterservice_p.h>
@@ -197,6 +198,7 @@ Renderer::Renderer(QRenderAspect::RenderType type)
, m_vaoGathererJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { lookForAbandonedVaos(); }, JobTypes::DirtyVaoGathering))
, m_textureGathererJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { lookForDirtyTextures(); }, JobTypes::DirtyTextureGathering))
, m_sendTextureChangesToFrontendJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { sendTextureChangesToFrontend(); }, JobTypes::SendTextureChangesToFrontend))
+ , m_sendSetFenceHandlesToFrontendJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { sendSetFenceHandlesToFrontend(); }, JobTypes::SendSetFenceHandlesToFrontend))
, m_introspectShaderJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([this] { reloadDirtyShaders(); }, JobTypes::DirtyShaderGathering))
, m_syncTextureLoadingJob(Render::GenericLambdaJobPtr<std::function<void ()>>::create([] {}, JobTypes::SyncTextureLoading))
, m_ownedContext(false)
@@ -294,6 +296,8 @@ void Renderer::setNodeManagers(NodeManagers *managers)
m_updateShaderDataTransformJob->setManagers(m_nodesManager);
m_cleanupJob->setManagers(m_nodesManager);
m_calculateBoundingVolumeJob->setManagers(m_nodesManager);
+ m_expandBoundingVolumeJob->setManagers(m_nodesManager);
+ m_worldTransformJob->setManagers(m_nodesManager);
m_pickBoundingVolumeJob->setManagers(m_nodesManager);
m_rayCastingJob->setManagers(m_nodesManager);
m_updateWorldBoundingVolumeJob->setManager(m_nodesManager->renderNodesManager());
@@ -303,6 +307,7 @@ void Renderer::setNodeManagers(NodeManagers *managers)
m_updateMeshTriangleListJob->setManagers(m_nodesManager);
m_filterCompatibleTechniqueJob->setManager(m_nodesManager->techniqueManager());
m_updateEntityLayersJob->setManager(m_nodesManager);
+ m_updateTreeEnabledJob->setManagers(m_nodesManager);
m_updateEntityHierarchyJob->setManager(m_nodesManager);
}
@@ -393,6 +398,9 @@ void Renderer::initialize()
[this] { releaseGraphicsResources(); });
}
+ qCDebug(Backend) << "Qt3D shared context:" << ctx->shareContext();
+ qCDebug(Backend) << "Qt global shared context:" << qt_gl_global_share_context();
+
if (!ctx->shareContext()) {
m_shareContext = new QOpenGLContext;
m_shareContext->setFormat(ctx->format());
@@ -1097,7 +1105,7 @@ void Renderer::lookForDirtyTextures()
}
// Dirty meaning that something has changed on the texture
- // either properties, parameters, generator or a texture image
+ // either properties, parameters, shared texture id, generator or a texture image
if (texture->dirtyFlags() != Texture::NotDirty)
m_dirtyTextures.push_back(handle);
// Note: texture dirty flags are reset when actually updating the
@@ -1183,7 +1191,7 @@ void Renderer::reloadDirtyShaders()
// Executed in a job
void Renderer::sendTextureChangesToFrontend()
{
- const QVector<QPair<TextureProperties, Qt3DCore::QNodeIdVector>> updateTextureProperties = std::move(m_updatedTextureProperties);
+ const QVector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>> updateTextureProperties = std::move(m_updatedTextureProperties);
for (const auto &pair : updateTextureProperties) {
// Prepare change notification
@@ -1202,6 +1210,22 @@ void Renderer::sendTextureChangesToFrontend()
}
}
+// Executed in a job
+void Renderer::sendSetFenceHandlesToFrontend()
+{
+ const QVector<QPair<Qt3DCore::QNodeId, GLFence>> updatedSetFence = std::move(m_updatedSetFences);
+ FrameGraphManager *fgManager = m_nodesManager->frameGraphManager();
+ for (const auto &pair : updatedSetFence) {
+ FrameGraphNode *fgNode = fgManager->lookupNode(pair.first);
+ if (fgNode != nullptr) { // Node could have been deleted before we got a chance to notify it
+ Q_ASSERT(fgNode->nodeType() == FrameGraphNode::SetFence);
+ SetFence *setFenceNode = static_cast<SetFence *>(fgNode);
+ setFenceNode->setHandleType(QSetFence::OpenGLFenceId);
+ setFenceNode->setHandle(QVariant::fromValue(pair.second));
+ }
+ }
+}
+
// Render Thread (or QtQuick RenderThread when using Scene3D)
// Scene3D: When using Scene3D rendering, we can't assume that when
// updateGLResources is called, the resource handles points to still existing
@@ -1215,6 +1239,25 @@ void Renderer::sendTextureChangesToFrontend()
void Renderer::updateGLResources()
{
{
+ // Update active fence objects:
+ // - Destroy fences that have reached their signaled state
+ GLFenceManager *fenceManager = m_nodesManager->glFenceManager();
+ const auto end = fenceManager->end();
+ auto it = fenceManager->begin();
+ while (it != end) {
+ const GLFence fence = it.value();
+ if (m_submissionContext->wasSyncSignaled(fence)) {
+ // Fence was signaled, we delete it
+ // before removing the entry from the manager
+ m_submissionContext->deleteSync(fence);
+ it = fenceManager->erase(it);
+ } else {
+ ++it;
+ }
+ }
+ }
+
+ {
Profiling::GLTimeRecorder recorder(Profiling::BufferUpload);
const QVector<HBuffer> dirtyBufferHandles = std::move(m_dirtyBuffers);
for (const HBuffer &handle: dirtyBufferHandles) {
@@ -1280,8 +1323,13 @@ void Renderer::updateGLResources()
// Gather these information and store them to be distributed by a change next frame
const QNodeIdVector referenceTextureIds = glTextureManager->referencedTextureIds(glTexture);
// Store properties and referenceTextureIds
- if (info.wasUpdated)
- m_updatedTextureProperties.push_back({info.properties, referenceTextureIds});
+ if (info.wasUpdated) {
+ Texture::TextureUpdateInfo updateInfo;
+ updateInfo.properties = info.properties;
+ updateInfo.handleType = QAbstractTexture::OpenGLTextureId;
+ updateInfo.handle = info.texture ? QVariant(info.texture->textureId()) : QVariant();
+ m_updatedTextureProperties.push_back({updateInfo, referenceTextureIds});
+ }
}
}
}
@@ -1303,18 +1351,21 @@ void Renderer::updateTexture(Texture *texture)
return;
// For implementing unique, non-shared, non-cached textures.
- // for now, every texture is shared by default
+ // for now, every texture is shared by default except if:
+ // - texture is reference by a render attachment
+ // - texture is referencing a shared texture id
+ bool isUnique = texture->sharedTextureId() > 0;
- bool isUnique = false;
-
- // TO DO: Update the vector once per frame (or in a job)
- const QVector<HAttachment> activeRenderTargetOutputs = m_nodesManager->attachmentManager()->activeHandles();
- // A texture is unique if it's being reference by a render target output
- for (const HAttachment &attachmentHandle : activeRenderTargetOutputs) {
- RenderTargetOutput *attachment = m_nodesManager->attachmentManager()->data(attachmentHandle);
- if (attachment->textureUuid() == texture->peerId()) {
- isUnique = true;
- break;
+ if (!isUnique) {
+ // TO DO: Update the vector once per frame (or in a job)
+ const QVector<HAttachment> activeRenderTargetOutputs = m_nodesManager->attachmentManager()->activeHandles();
+ // A texture is unique if it's being reference by a render target output
+ for (const HAttachment &attachmentHandle : activeRenderTargetOutputs) {
+ RenderTargetOutput *attachment = m_nodesManager->attachmentManager()->data(attachmentHandle);
+ if (attachment->textureUuid() == texture->peerId()) {
+ isUnique = true;
+ break;
+ }
}
}
@@ -1361,6 +1412,9 @@ void Renderer::updateTexture(Texture *texture)
// we hold a reference to a unique or exclusive access to a shared texture
// we can thus modify the texture directly.
const Texture::DirtyFlags dirtyFlags = texture->dirtyFlags();
+ if (dirtyFlags.testFlag(Texture::DirtySharedTextureId) &&
+ !glTextureManager->setSharedTextureId(glTexture, texture->sharedTextureId()))
+ qWarning() << "[Qt3DRender::TextureNode] updateTexture: TextureImpl.setSharedTextureId failed, should be non-shared";
if (dirtyFlags.testFlag(Texture::DirtyProperties) &&
!glTextureManager->setProperties(glTexture, texture->properties()))
@@ -1394,6 +1448,7 @@ void Renderer::cleanupTexture(Qt3DCore::QNodeId cleanedUpTextureId)
glTextureManager->abandon(glTexture, cleanedUpTextureId);
}
+// Called by SubmitRenderView
void Renderer::downloadGLBuffers()
{
lookForDownloadableBuffers();
@@ -1478,6 +1533,45 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
if (renderView->memoryBarrier() != QMemoryBarrier::None)
m_submissionContext->memoryBarrier(renderView->memoryBarrier());
+
+ // Insert Fence into command stream if needed
+ const Qt3DCore::QNodeIdVector insertFenceIds = renderView->insertFenceIds();
+ GLFenceManager *fenceManager = m_nodesManager->glFenceManager();
+ for (const Qt3DCore::QNodeId insertFenceId : insertFenceIds) {
+ // If the fence is not in the manager, then it hasn't been inserted
+ // into the command stream yet.
+ if (fenceManager->find(insertFenceId) == fenceManager->end()) {
+ // Insert fence into command stream
+ GLFence glFence = m_submissionContext->fenceSync();
+ // Record glFence
+ fenceManager->insert(insertFenceId, glFence);
+ // Add entry for notification changes to be sent
+ m_updatedSetFences.push_back({insertFenceId, glFence});
+ }
+ // If it is in the manager, then it hasn't been signaled yet,
+ // nothing we can do but try at the next frame
+ }
+
+ // Wait for fences if needed
+ const QVector<QWaitFenceData> waitFences = renderView->waitFences();
+ for (const QWaitFenceData &waitFence : waitFences) {
+ // TO DO
+ if (waitFence.handleType != QWaitFence::OpenGLFenceId) {
+ qWarning() << "WaitFence handleType should be OpenGLFenceId when using the Qt 3D OpenGL renderer";
+ continue;
+ }
+ GLFence fence = reinterpret_cast<GLFence>(waitFence.handle.value<qintptr>());
+ if (fence == nullptr)
+ continue;
+
+ if (waitFence.waitOnCPU) {
+ m_submissionContext->clientWaitSync(fence,
+ waitFence.timeout);
+ } else {
+ m_submissionContext->waitSync(fence);
+ }
+ }
+
// Note: the RenderStateSet is allocated once per RV if needed
// and it contains a list of StateVariant value types
RenderStateSet *renderViewStateSet = renderView->stateSet();
@@ -1642,6 +1736,33 @@ void Renderer::skipNextFrame()
m_submitRenderViewsSemaphore.release(1);
}
+// Jobs we may have to run even if no rendering will happen
+QVector<QAspectJobPtr> Renderer::preRenderingJobs()
+{
+ QVector<QAspectJobPtr> jobs;
+
+ // Do we need to notify any texture about property changes?
+ if (m_updatedTextureProperties.size() > 0)
+ jobs.push_back(m_sendTextureChangesToFrontendJob);
+
+ // Do we need to notify frontend about fence change?
+ if (m_updatedSetFences.size() > 0)
+ jobs.push_back(m_sendSetFenceHandlesToFrontendJob);
+
+ const QVector<Qt3DCore::QNodeId> pendingCaptureIds = takePendingRenderCaptureSendRequests();
+ if (pendingCaptureIds.size() > 0) {
+ m_sendRenderCaptureJob->setPendingCaptureRequests(pendingCaptureIds);
+ jobs.push_back(m_sendRenderCaptureJob);
+ }
+ if (m_sendBufferCaptureJob->hasRequests())
+ jobs.push_back(m_sendBufferCaptureJob);
+
+ jobs.append(pickBoundingVolumeJob());
+ jobs.append(rayCastingJob());
+
+ return jobs;
+}
+
// Waits to be told to create jobs for the next frame
// Called by QRenderAspect jobsToExecute context of QAspectThread
// Returns all the jobs (and with proper dependency chain) required
@@ -1703,17 +1824,6 @@ QVector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
renderBinJobs.push_back(m_updateLevelOfDetailJob);
renderBinJobs.push_back(m_cleanupJob);
- const QVector<Qt3DCore::QNodeId> pendingCaptureIds = takePendingRenderCaptureSendRequests();
- if (pendingCaptureIds.size() > 0) {
- m_sendRenderCaptureJob->setPendingCaptureRequests(pendingCaptureIds);
- renderBinJobs.push_back(m_sendRenderCaptureJob);
- }
-
- // Do we need to notify any texture about property changes?
- if (m_updatedTextureProperties.size() > 0)
- renderBinJobs.push_back(m_sendTextureChangesToFrontendJob);
-
- renderBinJobs.push_back(m_sendBufferCaptureJob);
renderBinJobs.append(bufferJobs);
// Jobs to prepare GL Resource upload
diff --git a/src/render/renderers/opengl/renderer/renderer_p.h b/src/render/renderers/opengl/renderer/renderer_p.h
index 6443215a4..5b5f5c4f4 100644
--- a/src/render/renderers/opengl/renderer/renderer_p.h
+++ b/src/render/renderers/opengl/renderer/renderer_p.h
@@ -81,6 +81,7 @@
#include <Qt3DRender/private/updateentityhierarchyjob_p.h>
#include <Qt3DRender/private/renderercache_p.h>
#include <Qt3DRender/private/texture_p.h>
+#include <Qt3DRender/private/glfence_p.h>
#include <QHash>
#include <QMatrix4x4>
@@ -97,6 +98,10 @@
#include <functional>
+#if defined(QT_BUILD_INTERNAL)
+class tst_Renderer;
+#endif
+
QT_BEGIN_NAMESPACE
class QSurface;
@@ -153,7 +158,7 @@ typedef QSharedPointer<UpdateLevelOfDetailJob> UpdateLevelOfDetailJobPtr;
using SynchronizerJobPtr = GenericLambdaJobPtr<std::function<void()>>;
using IntrospectShadersJobPtr = GenericLambdaJobPtr<std::function<void()>>;
-class QT3DRENDERSHARED_PRIVATE_EXPORT Renderer : public AbstractRenderer
+class Q_3DRENDERSHARED_PRIVATE_EXPORT Renderer : public AbstractRenderer
{
public:
explicit Renderer(QRenderAspect::RenderType type);
@@ -197,6 +202,7 @@ public:
bool shouldRender() override;
void skipNextFrame() override;
+ QVector<Qt3DCore::QAspectJobPtr> preRenderingJobs() override;
QVector<Qt3DCore::QAspectJobPtr> renderBinJobs() override;
Qt3DCore::QAspectJobPtr pickBoundingVolumeJob() override;
Qt3DCore::QAspectJobPtr rayCastingJob() override;
@@ -376,6 +382,7 @@ private:
GenericLambdaJobPtr<std::function<void ()>> m_vaoGathererJob;
GenericLambdaJobPtr<std::function<void ()>> m_textureGathererJob;
GenericLambdaJobPtr<std::function<void ()>> m_sendTextureChangesToFrontendJob;
+ GenericLambdaJobPtr<std::function<void ()>> m_sendSetFenceHandlesToFrontendJob;
IntrospectShadersJobPtr m_introspectShaderJob;
SynchronizerJobPtr m_syncTextureLoadingJob;
@@ -386,6 +393,7 @@ private:
void lookForDirtyTextures();
void reloadDirtyShaders();
void sendTextureChangesToFrontend();
+ void sendSetFenceHandlesToFrontend();
QMutex m_abandonedVaosMutex;
QVector<HVao> m_abandonedVaos;
@@ -394,7 +402,8 @@ private:
QVector<HBuffer> m_downloadableBuffers;
QVector<HShader> m_dirtyShaders;
QVector<HTexture> m_dirtyTextures;
- QVector<QPair<TextureProperties, Qt3DCore::QNodeIdVector>> m_updatedTextureProperties;
+ QVector<QPair<Texture::TextureUpdateInfo, Qt3DCore::QNodeIdVector>> m_updatedTextureProperties;
+ QVector<QPair<Qt3DCore::QNodeId, GLFence>> m_updatedSetFences;
bool m_ownedContext;
@@ -406,6 +415,10 @@ private:
friend class Qt3DRender::Debug::CommandExecuter;
#endif
+#ifdef QT_BUILD_INTERNAL
+ friend class ::tst_Renderer;
+#endif
+
QMetaObject::Connection m_contextConnection;
RendererCache m_cache;
};
diff --git a/src/render/renderers/opengl/renderer/renderview.cpp b/src/render/renderers/opengl/renderer/renderview.cpp
index 62758bb53..9bbf966c8 100644
--- a/src/render/renderers/opengl/renderer/renderview.cpp
+++ b/src/render/renderers/opengl/renderer/renderview.cpp
@@ -712,6 +712,11 @@ QVector<RenderCommand *> RenderView::buildComputeRenderCommands(const QVector<En
if ((computeJob = entity->renderComponent<ComputeCommand>()) != nullptr
&& computeJob->isEnabled()) {
+ // Note: if frameCount has reached 0 in the previous frame, isEnabled
+ // would be false
+ if (computeJob->runType() == QComputeCommand::Manual)
+ computeJob->updateFrameCount();
+
const Qt3DCore::QNodeId materialComponentId = entity->componentUuid<Material>();
const QVector<RenderPassParameterData> renderPassData = m_parameters.value(materialComponentId);
diff --git a/src/render/renderers/opengl/renderer/renderview_p.h b/src/render/renderers/opengl/renderer/renderview_p.h
index cb3c74917..7ebcdb6bd 100644
--- a/src/render/renderers/opengl/renderer/renderview_p.h
+++ b/src/render/renderers/opengl/renderer/renderview_p.h
@@ -65,6 +65,7 @@
#include <Qt3DRender/private/qmemorybarrier_p.h>
#include <Qt3DRender/private/qrendercapture_p.h>
#include <Qt3DRender/private/qblitframebuffer_p.h>
+#include <Qt3DRender/private/qwaitfence_p.h>
#include <Qt3DCore/private/qframeallocator_p.h>
#include <Qt3DRender/private/aligned_malloc_p.h>
@@ -174,6 +175,13 @@ public:
inline void appendProximityFilterId(const Qt3DCore::QNodeId proximityFilterId) { m_data.m_proximityFilterIds.push_back(proximityFilterId); }
inline Qt3DCore::QNodeIdVector proximityFilterIds() const { return m_data.m_proximityFilterIds; }
+ inline void appendInsertFenceId(const Qt3DCore::QNodeId setFenceId) { m_insertFenceIds.push_back(setFenceId); }
+ // We prefix with get to avoid confusion when it is called
+ inline Qt3DCore::QNodeIdVector insertFenceIds() const { return m_insertFenceIds; }
+
+ inline void appendWaitFence(const QWaitFenceData &data) { m_waitFences.push_back(data); }
+ inline QVector<QWaitFenceData> waitFences() const { return m_waitFences; }
+
inline void setRenderPassFilter(const RenderPassFilter *rpFilter) Q_DECL_NOTHROW { m_data.m_passFilter = rpFilter; }
inline const RenderPassFilter *renderPassFilter() const Q_DECL_NOTHROW { return m_data.m_passFilter; }
@@ -320,6 +328,8 @@ private:
bool m_frustumCulling:1;
int m_workGroups[3];
QMemoryBarrier::Operations m_memoryBarrier;
+ QVector<Qt3DCore::QNodeId> m_insertFenceIds;
+ QVector<QWaitFenceData> m_waitFences;
// We do not use pointers to RenderNodes or Drawable's here so that the
// render aspect is free to change the drawables on the next frame whilst
diff --git a/src/render/renderers/opengl/textures/gltexture.cpp b/src/render/renderers/opengl/textures/gltexture.cpp
index 27b94882a..4fd8a8a86 100644
--- a/src/render/renderers/opengl/textures/gltexture.cpp
+++ b/src/render/renderers/opengl/textures/gltexture.cpp
@@ -57,6 +57,11 @@
#include <Qt3DCore/qpropertynodeaddedchange.h>
#include <Qt3DCore/qpropertynoderemovedchange.h>
+#if !defined(QT_OPENGL_ES_2)
+#include <QOpenGLFunctions_3_1>
+#include <QOpenGLFunctions_4_5_Core>
+#endif
+
QT_BEGIN_NAMESPACE
using namespace Qt3DCore;
@@ -75,6 +80,7 @@ GLTexture::GLTexture(TextureDataManager *texDataMgr,
, m_textureImageDataManager(texImgDataMgr)
, m_dataFunctor(texGen)
, m_pendingDataFunctor(nullptr)
+ , m_sharedTextureId(-1)
, m_externalRendering(false)
{
// make sure texture generator is executed
@@ -181,39 +187,44 @@ GLTexture::TextureUpdateInfo GLTexture::createOrUpdateGLTexture()
m_properties.status = QAbstractTexture::Error;
- // on the first invocation in the render thread, make sure to
- // evaluate the texture data generator output
- // (this might change some property values)
- if (m_dataFunctor && !m_textureData) {
- const bool successfullyLoadedTextureData = loadTextureDataFromGenerator();
- if (successfullyLoadedTextureData) {
- setDirtyFlag(Properties, true);
- needUpload = true;
- } else {
- if (m_pendingDataFunctor != m_dataFunctor.get()) {
- qWarning() << "[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame";
- m_pendingDataFunctor = m_dataFunctor.get();
+ const bool hasSharedTextureId = m_sharedTextureId > 0;
+
+ // Only load texture data if we are not using a sharedTextureId
+ if (!hasSharedTextureId) {
+ // on the first invocation in the render thread, make sure to
+ // evaluate the texture data generator output
+ // (this might change some property values)
+ if (m_dataFunctor && !m_textureData) {
+ const bool successfullyLoadedTextureData = loadTextureDataFromGenerator();
+ if (successfullyLoadedTextureData) {
+ setDirtyFlag(Properties, true);
+ needUpload = true;
+ } else {
+ if (m_pendingDataFunctor != m_dataFunctor.get()) {
+ qWarning() << "[Qt3DRender::GLTexture] No QTextureData generated from Texture Generator yet. Texture will be invalid for this frame";
+ m_pendingDataFunctor = m_dataFunctor.get();
+ }
+ textureInfo.properties.status = QAbstractTexture::Loading;
+ return textureInfo;
}
- textureInfo.properties.status = QAbstractTexture::Loading;
- return textureInfo;
}
- }
- // additional texture images may be defined through image data generators
- if (testDirtyFlag(TextureData)) {
- m_imageData.clear();
- loadTextureDataFromImages();
- needUpload = true;
- }
+ // additional texture images may be defined through image data generators
+ if (testDirtyFlag(TextureData)) {
+ m_imageData.clear();
+ loadTextureDataFromImages();
+ needUpload = true;
+ }
- // don't try to create the texture if the format was not set
- if (m_properties.format == QAbstractTexture::Automatic) {
- textureInfo.properties.status = QAbstractTexture::Error;
- return textureInfo;
+ // don't try to create the texture if the format was not set
+ if (m_properties.format == QAbstractTexture::Automatic) {
+ textureInfo.properties.status = QAbstractTexture::Error;
+ return textureInfo;
+ }
}
// if the properties changed, we need to re-allocate the texture
- if (testDirtyFlag(Properties)) {
+ if (testDirtyFlag(Properties) || testDirtyFlag(SharedTextureId)) {
delete m_gl;
m_gl = nullptr;
textureInfo.wasUpdated = true;
@@ -223,40 +234,48 @@ GLTexture::TextureUpdateInfo GLTexture::createOrUpdateGLTexture()
needUpload = true;
}
+ m_properties.status = QAbstractTexture::Ready;
- if (!m_gl) {
- m_gl = buildGLTexture();
+ if (hasSharedTextureId && testDirtyFlag(SharedTextureId)) {
+ // Update m_properties by doing introspection on the texture
+ introspectPropertiesFromSharedTextureId();
+ } else {
+ // We only build a QOpenGLTexture if we have no shared textureId set
if (!m_gl) {
- textureInfo.properties.status = QAbstractTexture::Error;
- return textureInfo;
- }
+ m_gl = buildGLTexture();
+ if (!m_gl) {
+ textureInfo.properties.status = QAbstractTexture::Error;
+ return textureInfo;
+ }
- m_gl->allocateStorage();
- if (!m_gl->isStorageAllocated()) {
- textureInfo.properties.status = QAbstractTexture::Error;
- return textureInfo;
+ m_gl->allocateStorage();
+ if (!m_gl->isStorageAllocated()) {
+ textureInfo.properties.status = QAbstractTexture::Error;
+ return textureInfo;
+ }
}
- }
- m_properties.status = QAbstractTexture::Ready;
- textureInfo.properties = m_properties;
- textureInfo.texture = m_gl;
+ textureInfo.texture = m_gl;
- // need to (re-)upload texture data?
- if (needUpload) {
- uploadGLTextureData();
- setDirtyFlag(TextureData, false);
- }
+ // need to (re-)upload texture data?
+ if (needUpload) {
+ uploadGLTextureData();
+ setDirtyFlag(TextureData, false);
+ }
- // need to set texture parameters?
- if (testDirtyFlag(Properties) || testDirtyFlag(Parameters)) {
- updateGLTextureParameters();
+ // need to set texture parameters?
+ if (testDirtyFlag(Properties) || testDirtyFlag(Parameters)) {
+ updateGLTextureParameters();
+ }
}
+ textureInfo.properties = m_properties;
+
// un-set properties and parameters. The TextureData flag might have been set by another thread
// in the meantime, so don't clear that.
setDirtyFlag(Properties, false);
setDirtyFlag(Parameters, false);
+ setDirtyFlag(SharedTextureId, false);
return textureInfo;
}
@@ -355,6 +374,14 @@ void GLTexture::setGenerator(const QTextureGeneratorPtr &generator)
}
}
+void GLTexture::setSharedTextureId(int textureId)
+{
+ if (m_sharedTextureId != textureId) {
+ m_sharedTextureId = textureId;
+ setDirtyFlag(SharedTextureId);
+ }
+}
+
// Return nullptr if
// - context cannot be obtained
// - texture hasn't yet been loaded
@@ -403,8 +430,8 @@ QOpenGLTexture *GLTexture::buildGLTexture()
// is written against GLES 1.0.
if (m_properties.format == QAbstractTexture::RGB8_ETC1) {
if ((ctx->isOpenGLES() && ctx->format().majorVersion() >= 3)
- || ctx->hasExtension(QByteArrayLiteral("GL_OES_compressed_ETC2_RGB8_texture"))
- || ctx->hasExtension(QByteArrayLiteral("GL_ARB_ES3_compatibility")))
+ || ctx->hasExtension(QByteArrayLiteral("GL_OES_compressed_ETC2_RGB8_texture"))
+ || ctx->hasExtension(QByteArrayLiteral("GL_ARB_ES3_compatibility")))
format = m_properties.format = QAbstractTexture::RGB8_ETC2;
}
@@ -414,14 +441,14 @@ QOpenGLTexture *GLTexture::buildGLTexture()
glTex->setSize(m_properties.width, m_properties.height, m_properties.depth);
// Set layers count if texture array
if (m_actualTarget == QAbstractTexture::Target1DArray ||
- m_actualTarget == QAbstractTexture::Target2DArray ||
- m_actualTarget == QAbstractTexture::Target2DMultisampleArray ||
- m_actualTarget == QAbstractTexture::TargetCubeMapArray) {
+ m_actualTarget == QAbstractTexture::Target2DArray ||
+ m_actualTarget == QAbstractTexture::Target2DMultisampleArray ||
+ m_actualTarget == QAbstractTexture::TargetCubeMapArray) {
glTex->setLayers(m_properties.layers);
}
if (m_actualTarget == QAbstractTexture::Target2DMultisample ||
- m_actualTarget == QAbstractTexture::Target2DMultisampleArray) {
+ m_actualTarget == QAbstractTexture::Target2DMultisampleArray) {
// Set samples count if multisampled texture
// (multisampled textures don't have mipmaps)
glTex->setSamples(m_properties.samples);
@@ -504,8 +531,8 @@ void GLTexture::updateGLTextureParameters()
m_gl->setWrapMode(QOpenGLTexture::DirectionS, static_cast<QOpenGLTexture::WrapMode>(m_parameters.wrapModeX));
if (m_actualTarget != QAbstractTexture::Target1D &&
- m_actualTarget != QAbstractTexture::Target1DArray &&
- m_actualTarget != QAbstractTexture::TargetBuffer)
+ m_actualTarget != QAbstractTexture::Target1DArray &&
+ m_actualTarget != QAbstractTexture::TargetBuffer)
m_gl->setWrapMode(QOpenGLTexture::DirectionT, static_cast<QOpenGLTexture::WrapMode>(m_parameters.wrapModeY));
if (m_actualTarget == QAbstractTexture::Target3D)
m_gl->setWrapMode(QOpenGLTexture::DirectionR, static_cast<QOpenGLTexture::WrapMode>(m_parameters.wrapModeZ));
@@ -519,6 +546,129 @@ void GLTexture::updateGLTextureParameters()
}
}
+void GLTexture::introspectPropertiesFromSharedTextureId()
+{
+ // We know that the context is active when this function is called
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ if (!ctx) {
+ qWarning() << Q_FUNC_INFO << "requires an OpenGL context";
+ return;
+ }
+ QOpenGLFunctions *gl = ctx->functions();
+
+ // If the user has set the target format himself, we won't try to deduce it
+ if (m_properties.target != QAbstractTexture::TargetAutomatic)
+ return;
+
+ const QAbstractTexture::Target targets[] = {
+ QAbstractTexture::Target2D,
+ QAbstractTexture::TargetCubeMap,
+#ifndef QT_OPENGL_ES_2
+ QAbstractTexture::Target1D,
+ QAbstractTexture::Target1DArray,
+ QAbstractTexture::Target3D,
+ QAbstractTexture::Target2DArray,
+ QAbstractTexture::TargetCubeMapArray,
+ QAbstractTexture::Target2DMultisample,
+ QAbstractTexture::Target2DMultisampleArray,
+ QAbstractTexture::TargetRectangle,
+ QAbstractTexture::TargetBuffer,
+#endif
+ };
+
+#ifndef QT_OPENGL_ES_2
+ // Try to find texture target with GL 4.5 functions
+ const QPair<int, int> ctxGLVersion = ctx->format().version();
+ if (ctxGLVersion.first > 4 || (ctxGLVersion.first == 4 && ctxGLVersion.second >= 5)) {
+ // Only for GL 4.5+
+ QOpenGLFunctions_4_5_Core *gl5 = ctx->versionFunctions<QOpenGLFunctions_4_5_Core>();
+#ifdef GL_TEXTURE_TARGET
+ if (gl5 != nullptr)
+ gl5->glGetTextureParameteriv(m_sharedTextureId, GL_TEXTURE_TARGET, reinterpret_cast<int *>(&m_properties.target));
+#endif
+ }
+#endif
+
+ // If GL 4.5 function unavailable or not working, try a slower way
+ if (m_properties.target == QAbstractTexture::TargetAutomatic) {
+ // // OpenGL offers no proper way of querying for the target of a texture given its id
+ gl->glActiveTexture(GL_TEXTURE0);
+
+ const GLenum targetBindings[] = {
+ GL_TEXTURE_BINDING_2D,
+ GL_TEXTURE_BINDING_CUBE_MAP,
+#ifndef QT_OPENGL_ES_2
+ GL_TEXTURE_BINDING_1D,
+ GL_TEXTURE_BINDING_1D_ARRAY,
+ GL_TEXTURE_BINDING_3D,
+ GL_TEXTURE_BINDING_2D_ARRAY,
+ GL_TEXTURE_BINDING_CUBE_MAP_ARRAY,
+ GL_TEXTURE_BINDING_2D_MULTISAMPLE,
+ GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY,
+ GL_TEXTURE_BINDING_RECTANGLE,
+ GL_TEXTURE_BINDING_BUFFER
+#endif
+ };
+
+ Q_ASSERT(sizeof(targetBindings) / sizeof(targetBindings[0] == sizeof(targets) / sizeof(targets[0])));
+
+ for (uint i = 0; i < sizeof(targetBindings) / sizeof(targetBindings[0]); ++i) {
+ const int target = targets[i];
+ gl->glBindTexture(target, m_sharedTextureId);
+ int boundId = 0;
+ gl->glGetIntegerv(targetBindings[i], &boundId);
+ gl->glBindTexture(target, 0);
+ if (boundId == m_sharedTextureId) {
+ m_properties.target = static_cast<QAbstractTexture::Target>(target);
+ break;
+ }
+ }
+ }
+
+ // Return early if we weren't able to find texture target
+ if (std::find(std::begin(targets), std::end(targets), m_properties.target) == std::end(targets)) {
+ qWarning() << "Unable to determine texture target for shared GL texture";
+ return;
+ }
+
+ // Bind texture once we know its target
+ gl->glBindTexture(m_properties.target, m_sharedTextureId);
+
+ // TO DO: Improve by using glGetTextureParameters when available which
+ // support direct state access
+#ifndef GL_TEXTURE_MAX_LEVEL
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#endif
+
+#ifndef GL_TEXTURE_WRAP_R
+#define GL_TEXTURE_WRAP_R 0x8072
+#endif
+
+ gl->glGetTexParameteriv(int(m_properties.target), GL_TEXTURE_MAX_LEVEL, reinterpret_cast<int *>(&m_properties.mipLevels));
+ gl->glGetTexParameteriv(int(m_properties.target), GL_TEXTURE_MIN_FILTER, reinterpret_cast<int *>(&m_parameters.minificationFilter));
+ gl->glGetTexParameteriv(int(m_properties.target), GL_TEXTURE_MAG_FILTER, reinterpret_cast<int *>(&m_parameters.magnificationFilter));
+ gl->glGetTexParameteriv(int(m_properties.target), GL_TEXTURE_WRAP_R, reinterpret_cast<int *>(&m_parameters.wrapModeX));
+ gl->glGetTexParameteriv(int(m_properties.target), GL_TEXTURE_WRAP_S, reinterpret_cast<int *>(&m_parameters.wrapModeY));
+ gl->glGetTexParameteriv(int(m_properties.target), GL_TEXTURE_WRAP_T, reinterpret_cast<int *>(&m_parameters.wrapModeZ));
+
+#ifndef QT_OPENGL_ES_2
+ // Try to retrieve dimensions (not available on ES 2.0)
+ if (!ctx->isOpenGLES()) {
+ QOpenGLFunctions_3_1 *gl3 = ctx->versionFunctions<QOpenGLFunctions_3_1>();
+ if (!gl3) {
+ qWarning() << "Failed to retrieve shared texture dimensions";
+ return;
+ }
+
+ gl3->glGetTexLevelParameteriv(int(m_properties.target), 0, GL_TEXTURE_WIDTH, reinterpret_cast<int *>(&m_properties.width));
+ gl3->glGetTexLevelParameteriv(int(m_properties.target), 0, GL_TEXTURE_HEIGHT, reinterpret_cast<int *>(&m_properties.height));
+ gl3->glGetTexLevelParameteriv(int(m_properties.target), 0, GL_TEXTURE_DEPTH, reinterpret_cast<int *>(&m_properties.depth));
+ gl3->glGetTexLevelParameteriv(int(m_properties.target), 0, GL_TEXTURE_INTERNAL_FORMAT, reinterpret_cast<int *>(&m_properties.format));
+ }
+#endif
+
+ gl->glBindTexture(m_properties.target, 0);
+}
} // namespace Render
} // namespace Qt3DRender
diff --git a/src/render/renderers/opengl/textures/gltexture_p.h b/src/render/renderers/opengl/textures/gltexture_p.h
index ca9c0d5db..66f66926c 100644
--- a/src/render/renderers/opengl/textures/gltexture_p.h
+++ b/src/render/renderers/opengl/textures/gltexture_p.h
@@ -125,6 +125,7 @@ public:
inline TextureProperties properties() const { return m_properties; }
inline TextureParameters parameters() const { return m_parameters; }
inline QTextureGeneratorPtr textureGenerator() const { return m_dataFunctor; }
+ inline int sharedTextureId() const { return m_sharedTextureId; }
inline QVector<Image> images() const { return m_images; }
inline QSize size() const { return QSize(m_properties.width, m_properties.height); }
@@ -204,14 +205,15 @@ protected:
void setProperties(const TextureProperties &props);
void setImages(const QVector<Image> &images);
void setGenerator(const QTextureGeneratorPtr &generator);
+ void setSharedTextureId(int textureId);
private:
enum DirtyFlag {
TextureData = 0x01, // one or more image generators have been executed, data needs uploading to GPU
Properties = 0x02, // texture needs to be (re-)created
- Parameters = 0x04 // texture parameters need to be (re-)set
-
+ Parameters = 0x04, // texture parameters need to be (re-)set
+ SharedTextureId = 0x08 // texture id from shared context
};
bool testDirtyFlag(DirtyFlag flag)
@@ -232,6 +234,7 @@ private:
void loadTextureDataFromImages();
void uploadGLTextureData();
void updateGLTextureParameters();
+ void introspectPropertiesFromSharedTextureId();
void destroyResources();
bool m_unique;
@@ -257,6 +260,7 @@ private:
QTextureDataPtr m_textureData;
QVector<QTextureImageDataPtr> m_imageData;
+ int m_sharedTextureId;
bool m_externalRendering;
};
diff --git a/src/render/renderstates/qalphacoverage.h b/src/render/renderstates/qalphacoverage.h
index 53636d300..7c4e1c2c8 100644
--- a/src/render/renderstates/qalphacoverage.h
+++ b/src/render/renderstates/qalphacoverage.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QAlphaCoveragePrivate;
-class QT3DRENDERSHARED_EXPORT QAlphaCoverage : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QAlphaCoverage : public QRenderState
{
Q_OBJECT
public:
diff --git a/src/render/renderstates/qalphatest.h b/src/render/renderstates/qalphatest.h
index 8545d2043..7ec14eaee 100644
--- a/src/render/renderstates/qalphatest.h
+++ b/src/render/renderstates/qalphatest.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QAlphaTestPrivate;
-class QT3DRENDERSHARED_EXPORT QAlphaTest : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QAlphaTest : public QRenderState
{
Q_OBJECT
Q_PROPERTY(AlphaFunction alphaFunction READ alphaFunction WRITE setAlphaFunction NOTIFY alphaFunctionChanged)
diff --git a/src/render/renderstates/qblendequation.h b/src/render/renderstates/qblendequation.h
index d084113d7..69a06768d 100644
--- a/src/render/renderstates/qblendequation.h
+++ b/src/render/renderstates/qblendequation.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QBlendEquationPrivate;
-class QT3DRENDERSHARED_EXPORT QBlendEquation : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QBlendEquation : public QRenderState
{
Q_OBJECT
Q_PROPERTY(BlendFunction blendFunction READ blendFunction WRITE setBlendFunction NOTIFY blendFunctionChanged)
diff --git a/src/render/renderstates/qblendequation_p.h b/src/render/renderstates/qblendequation_p.h
index 228e61f15..c8a65de11 100644
--- a/src/render/renderstates/qblendequation_p.h
+++ b/src/render/renderstates/qblendequation_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QBlendEquationPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QBlendEquationPrivate : public QRenderStatePrivate
{
public:
QBlendEquationPrivate()
diff --git a/src/render/renderstates/qblendequationarguments.h b/src/render/renderstates/qblendequationarguments.h
index 1b2e039f7..e454dbae5 100644
--- a/src/render/renderstates/qblendequationarguments.h
+++ b/src/render/renderstates/qblendequationarguments.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QBlendEquationArgumentsPrivate;
-class QT3DRENDERSHARED_EXPORT QBlendEquationArguments : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QBlendEquationArguments : public QRenderState
{
Q_OBJECT
Q_PROPERTY(Blending sourceRgb READ sourceRgb WRITE setSourceRgb NOTIFY sourceRgbChanged)
diff --git a/src/render/renderstates/qblendequationarguments_p.h b/src/render/renderstates/qblendequationarguments_p.h
index 110039295..d2aae69c7 100644
--- a/src/render/renderstates/qblendequationarguments_p.h
+++ b/src/render/renderstates/qblendequationarguments_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QBlendEquationArgumentsPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QBlendEquationArgumentsPrivate : public QRenderStatePrivate
{
public:
QBlendEquationArgumentsPrivate(Render::StateMask type = Render::BlendEquationArgumentsMask)
diff --git a/src/render/renderstates/qclipplane.h b/src/render/renderstates/qclipplane.h
index fa210d668..94bfaa57d 100644
--- a/src/render/renderstates/qclipplane.h
+++ b/src/render/renderstates/qclipplane.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QClipPlanePrivate;
-class QT3DRENDERSHARED_EXPORT QClipPlane : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QClipPlane : public QRenderState
{
Q_OBJECT
Q_PROPERTY(int planeIndex READ planeIndex WRITE setPlaneIndex NOTIFY planeIndexChanged)
diff --git a/src/render/renderstates/qclipplane_p.h b/src/render/renderstates/qclipplane_p.h
index 517831e10..9c59675c6 100644
--- a/src/render/renderstates/qclipplane_p.h
+++ b/src/render/renderstates/qclipplane_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QClipPlanePrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QClipPlanePrivate : public QRenderStatePrivate
{
public:
QClipPlanePrivate()
diff --git a/src/render/renderstates/qcolormask.h b/src/render/renderstates/qcolormask.h
index 7d28e80c6..980cde5ac 100644
--- a/src/render/renderstates/qcolormask.h
+++ b/src/render/renderstates/qcolormask.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QColorMaskPrivate;
-class QT3DRENDERSHARED_EXPORT QColorMask : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QColorMask : public QRenderState
{
Q_OBJECT
Q_PROPERTY(bool redMasked READ isRedMasked WRITE setRedMasked NOTIFY redMaskedChanged)
diff --git a/src/render/renderstates/qcolormask_p.h b/src/render/renderstates/qcolormask_p.h
index 1e2386eb9..bd041de3b 100644
--- a/src/render/renderstates/qcolormask_p.h
+++ b/src/render/renderstates/qcolormask_p.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QColorMaskPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QColorMaskPrivate : public QRenderStatePrivate
{
public:
QColorMaskPrivate()
diff --git a/src/render/renderstates/qcullface.h b/src/render/renderstates/qcullface.h
index ab60d342e..053e86215 100644
--- a/src/render/renderstates/qcullface.h
+++ b/src/render/renderstates/qcullface.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QCullFacePrivate;
-class QT3DRENDERSHARED_EXPORT QCullFace : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QCullFace : public QRenderState
{
Q_OBJECT
Q_PROPERTY(CullingMode mode READ mode WRITE setMode NOTIFY modeChanged)
diff --git a/src/render/renderstates/qcullface_p.h b/src/render/renderstates/qcullface_p.h
index 98cf99454..fd85b27a7 100644
--- a/src/render/renderstates/qcullface_p.h
+++ b/src/render/renderstates/qcullface_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QCullFacePrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QCullFacePrivate : public QRenderStatePrivate
{
public:
QCullFacePrivate()
diff --git a/src/render/renderstates/qdepthtest.h b/src/render/renderstates/qdepthtest.h
index 91c06c649..419c36b57 100644
--- a/src/render/renderstates/qdepthtest.h
+++ b/src/render/renderstates/qdepthtest.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QDepthTestPrivate;
-class QT3DRENDERSHARED_EXPORT QDepthTest : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QDepthTest : public QRenderState
{
Q_OBJECT
Q_PROPERTY(DepthFunction depthFunction READ depthFunction WRITE setDepthFunction NOTIFY depthFunctionChanged)
diff --git a/src/render/renderstates/qdepthtest_p.h b/src/render/renderstates/qdepthtest_p.h
index 555be2d4a..82689a50f 100644
--- a/src/render/renderstates/qdepthtest_p.h
+++ b/src/render/renderstates/qdepthtest_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QDepthTestPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QDepthTestPrivate : public QRenderStatePrivate
{
public :
QDepthTestPrivate()
diff --git a/src/render/renderstates/qdithering.h b/src/render/renderstates/qdithering.h
index db6667f8a..4f118977d 100644
--- a/src/render/renderstates/qdithering.h
+++ b/src/render/renderstates/qdithering.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QDitheringPrivate;
-class QT3DRENDERSHARED_EXPORT QDithering : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QDithering : public QRenderState
{
Q_OBJECT
public:
diff --git a/src/render/renderstates/qfrontface.h b/src/render/renderstates/qfrontface.h
index 9ef32d8ed..10cc9b422 100644
--- a/src/render/renderstates/qfrontface.h
+++ b/src/render/renderstates/qfrontface.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QFrontFacePrivate;
-class QT3DRENDERSHARED_EXPORT QFrontFace : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QFrontFace : public QRenderState
{
Q_OBJECT
Q_PROPERTY(WindingDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
diff --git a/src/render/renderstates/qfrontface_p.h b/src/render/renderstates/qfrontface_p.h
index 3849714fd..605e78196 100644
--- a/src/render/renderstates/qfrontface_p.h
+++ b/src/render/renderstates/qfrontface_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QFrontFacePrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QFrontFacePrivate : public QRenderStatePrivate
{
public:
QFrontFacePrivate()
diff --git a/src/render/renderstates/qlinewidth.h b/src/render/renderstates/qlinewidth.h
index 764ebc82a..3e53a5f29 100644
--- a/src/render/renderstates/qlinewidth.h
+++ b/src/render/renderstates/qlinewidth.h
@@ -47,7 +47,7 @@ namespace Qt3DRender {
class QLineWidthPrivate;
-class QT3DRENDERSHARED_EXPORT QLineWidth : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QLineWidth : public QRenderState
{
Q_OBJECT
Q_PROPERTY(float value READ value WRITE setValue NOTIFY valueChanged)
diff --git a/src/render/renderstates/qmultisampleantialiasing.h b/src/render/renderstates/qmultisampleantialiasing.h
index 087f32ce2..5ac0dfdb5 100644
--- a/src/render/renderstates/qmultisampleantialiasing.h
+++ b/src/render/renderstates/qmultisampleantialiasing.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QMultiSampleAntiAliasingPrivate;
-class QT3DRENDERSHARED_EXPORT QMultiSampleAntiAliasing : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QMultiSampleAntiAliasing : public QRenderState
{
Q_OBJECT
diff --git a/src/render/renderstates/qnodepthmask.h b/src/render/renderstates/qnodepthmask.h
index 20171595e..221052699 100644
--- a/src/render/renderstates/qnodepthmask.h
+++ b/src/render/renderstates/qnodepthmask.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QNoDepthMaskPrivate;
-class QT3DRENDERSHARED_EXPORT QNoDepthMask : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QNoDepthMask : public QRenderState
{
Q_OBJECT
public:
diff --git a/src/render/renderstates/qpointsize.h b/src/render/renderstates/qpointsize.h
index 7e50a7953..49fdd5c9c 100644
--- a/src/render/renderstates/qpointsize.h
+++ b/src/render/renderstates/qpointsize.h
@@ -47,7 +47,7 @@ namespace Qt3DRender {
class QPointSizePrivate;
-class QT3DRENDERSHARED_EXPORT QPointSize : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QPointSize : public QRenderState
{
Q_OBJECT
Q_PROPERTY(SizeMode sizeMode READ sizeMode WRITE setSizeMode NOTIFY sizeModeChanged)
diff --git a/src/render/renderstates/qpointsize_p.h b/src/render/renderstates/qpointsize_p.h
index eb669b131..fab7baf30 100644
--- a/src/render/renderstates/qpointsize_p.h
+++ b/src/render/renderstates/qpointsize_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QPointSizePrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QPointSizePrivate : public QRenderStatePrivate
{
public:
QPointSizePrivate(QPointSize::SizeMode sizeMode, float value)
diff --git a/src/render/renderstates/qpolygonoffset.h b/src/render/renderstates/qpolygonoffset.h
index f89203c6b..9ba18f2e4 100644
--- a/src/render/renderstates/qpolygonoffset.h
+++ b/src/render/renderstates/qpolygonoffset.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QPolygonOffsetPrivate;
-class QT3DRENDERSHARED_EXPORT QPolygonOffset : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QPolygonOffset : public QRenderState
{
Q_OBJECT
diff --git a/src/render/renderstates/qpolygonoffset_p.h b/src/render/renderstates/qpolygonoffset_p.h
index 66a62674e..11edaf445 100644
--- a/src/render/renderstates/qpolygonoffset_p.h
+++ b/src/render/renderstates/qpolygonoffset_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QPolygonOffsetPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QPolygonOffsetPrivate : public QRenderStatePrivate
{
public:
QPolygonOffsetPrivate()
diff --git a/src/render/renderstates/qrenderstate.h b/src/render/renderstates/qrenderstate.h
index 6892432be..3b7ff03bc 100644
--- a/src/render/renderstates/qrenderstate.h
+++ b/src/render/renderstates/qrenderstate.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QRenderStatePrivate;
-class QT3DRENDERSHARED_EXPORT QRenderState : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QRenderState : public Qt3DCore::QNode
{
Q_OBJECT
public:
diff --git a/src/render/renderstates/qrenderstate_p.h b/src/render/renderstates/qrenderstate_p.h
index c3457afd7..e43097020 100644
--- a/src/render/renderstates/qrenderstate_p.h
+++ b/src/render/renderstates/qrenderstate_p.h
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QRenderStatePrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderStatePrivate : public Qt3DCore::QNodePrivate
{
public:
explicit QRenderStatePrivate(Render::StateMask type);
diff --git a/src/render/renderstates/qscissortest.h b/src/render/renderstates/qscissortest.h
index f94e997f8..c808dc1c6 100644
--- a/src/render/renderstates/qscissortest.h
+++ b/src/render/renderstates/qscissortest.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QScissorTestPrivate;
-class QT3DRENDERSHARED_EXPORT QScissorTest : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QScissorTest : public QRenderState
{
Q_OBJECT
Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged)
diff --git a/src/render/renderstates/qscissortest_p.h b/src/render/renderstates/qscissortest_p.h
index 7c7bfdfe0..eebf3c326 100644
--- a/src/render/renderstates/qscissortest_p.h
+++ b/src/render/renderstates/qscissortest_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QScissorTestPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QScissorTestPrivate : public QRenderStatePrivate
{
public:
QScissorTestPrivate()
diff --git a/src/render/renderstates/qseamlesscubemap.h b/src/render/renderstates/qseamlesscubemap.h
index 40ae0a955..d2f63a8df 100644
--- a/src/render/renderstates/qseamlesscubemap.h
+++ b/src/render/renderstates/qseamlesscubemap.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QSeamlessCubemapPrivate;
-class QT3DRENDERSHARED_EXPORT QSeamlessCubemap : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QSeamlessCubemap : public QRenderState
{
Q_OBJECT
diff --git a/src/render/renderstates/qstencilmask.h b/src/render/renderstates/qstencilmask.h
index 5f6e3b686..08396a86f 100644
--- a/src/render/renderstates/qstencilmask.h
+++ b/src/render/renderstates/qstencilmask.h
@@ -48,7 +48,7 @@ namespace Qt3DRender {
class QStencilMaskPrivate;
-class QT3DRENDERSHARED_EXPORT QStencilMask : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QStencilMask : public QRenderState
{
Q_OBJECT
Q_PROPERTY(uint frontOutputMask READ frontOutputMask WRITE setFrontOutputMask NOTIFY frontOutputMaskChanged)
diff --git a/src/render/renderstates/qstencilmask_p.h b/src/render/renderstates/qstencilmask_p.h
index 762b249f8..c9af3d7f1 100644
--- a/src/render/renderstates/qstencilmask_p.h
+++ b/src/render/renderstates/qstencilmask_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilMaskPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QStencilMaskPrivate : public QRenderStatePrivate
{
public:
QStencilMaskPrivate()
diff --git a/src/render/renderstates/qstenciloperation.h b/src/render/renderstates/qstenciloperation.h
index 889bb73dc..90c7da7ba 100644
--- a/src/render/renderstates/qstenciloperation.h
+++ b/src/render/renderstates/qstenciloperation.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QStencilOperationPrivate;
class QStencilOperationArguments;
-class QT3DRENDERSHARED_EXPORT QStencilOperation : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QStencilOperation : public QRenderState
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QStencilOperationArguments *front READ front CONSTANT)
diff --git a/src/render/renderstates/qstenciloperation_p.h b/src/render/renderstates/qstenciloperation_p.h
index dbce734b1..a1c0cda4a 100644
--- a/src/render/renderstates/qstenciloperation_p.h
+++ b/src/render/renderstates/qstenciloperation_p.h
@@ -64,7 +64,7 @@ struct QStencilOperationData
QStencilOperationArgumentsData back;
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilOperationPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QStencilOperationPrivate : public QRenderStatePrivate
{
public:
QStencilOperationPrivate()
diff --git a/src/render/renderstates/qstenciloperationarguments.h b/src/render/renderstates/qstenciloperationarguments.h
index 9705c9822..e8e23c6fe 100644
--- a/src/render/renderstates/qstenciloperationarguments.h
+++ b/src/render/renderstates/qstenciloperationarguments.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QStencilOperationPrivate;
class QStencilOperationArgumentsPrivate;
-class QT3DRENDERSHARED_EXPORT QStencilOperationArguments : public QObject
+class Q_3DRENDERSHARED_EXPORT QStencilOperationArguments : public QObject
{
Q_OBJECT
Q_PROPERTY(FaceMode faceMode READ faceMode NOTIFY faceModeChanged)
diff --git a/src/render/renderstates/qstenciloperationarguments_p.h b/src/render/renderstates/qstenciloperationarguments_p.h
index 3babd3373..b24ddf09d 100644
--- a/src/render/renderstates/qstenciloperationarguments_p.h
+++ b/src/render/renderstates/qstenciloperationarguments_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilOperationArgumentsPrivate : public QObjectPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QStencilOperationArgumentsPrivate : public QObjectPrivate
{
public:
QStencilOperationArgumentsPrivate(QStencilOperationArguments::FaceMode mode)
diff --git a/src/render/renderstates/qstenciltest.h b/src/render/renderstates/qstenciltest.h
index 0178ef968..f17baa23f 100644
--- a/src/render/renderstates/qstenciltest.h
+++ b/src/render/renderstates/qstenciltest.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QStencilTestPrivate;
class QStencilTestArguments;
-class QT3DRENDERSHARED_EXPORT QStencilTest : public QRenderState
+class Q_3DRENDERSHARED_EXPORT QStencilTest : public QRenderState
{
Q_OBJECT
Q_PROPERTY(Qt3DRender::QStencilTestArguments *front READ front CONSTANT)
diff --git a/src/render/renderstates/qstenciltest_p.h b/src/render/renderstates/qstenciltest_p.h
index 838ba5bc0..328e34878 100644
--- a/src/render/renderstates/qstenciltest_p.h
+++ b/src/render/renderstates/qstenciltest_p.h
@@ -64,7 +64,7 @@ struct QStencilTestData
QStencilTestArgumentsData back;
};
-class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilTestPrivate : public QRenderStatePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QStencilTestPrivate : public QRenderStatePrivate
{
public:
QStencilTestPrivate()
diff --git a/src/render/renderstates/qstenciltestarguments.h b/src/render/renderstates/qstenciltestarguments.h
index 35447d477..92696806d 100644
--- a/src/render/renderstates/qstenciltestarguments.h
+++ b/src/render/renderstates/qstenciltestarguments.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QStencilTestPrivate;
class QStencilTestArgumentsPrivate;
-class QT3DRENDERSHARED_EXPORT QStencilTestArguments : public QObject
+class Q_3DRENDERSHARED_EXPORT QStencilTestArguments : public QObject
{
Q_OBJECT
Q_PROPERTY(StencilFaceMode faceMode READ faceMode NOTIFY faceModeChanged)
diff --git a/src/render/renderstates/qstenciltestarguments_p.h b/src/render/renderstates/qstenciltestarguments_p.h
index 662301843..9a85c93a6 100644
--- a/src/render/renderstates/qstenciltestarguments_p.h
+++ b/src/render/renderstates/qstenciltestarguments_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QStencilTestArgumentsPrivate : public QObjectPrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QStencilTestArgumentsPrivate : public QObjectPrivate
{
public:
QStencilTestArgumentsPrivate(QStencilTestArguments::StencilFaceMode face)
diff --git a/src/render/texture/apitexturemanager_p.h b/src/render/texture/apitexturemanager_p.h
index 58e6e6420..79dc9af94 100644
--- a/src/render/texture/apitexturemanager_p.h
+++ b/src/render/texture/apitexturemanager_p.h
@@ -257,6 +257,19 @@ public:
return true;
}
+ // Change the texture's referenced texture Id from a shared context
+ bool setSharedTextureId(APITexture *tex, int textureId)
+ {
+ Q_ASSERT(tex);
+
+ if (isShared(tex))
+ return false;
+
+ tex->setSharedTextureId(textureId);
+ m_updatedTextures.push_back(tex);
+ return true;
+ }
+
// Retrieves abandoned textures. This should be regularly called from the OpenGL thread
// to make sure needed GL resources are de-allocated.
QVector<APITexture*> takeAbandonedTextures()
@@ -344,6 +357,7 @@ private:
newTex->setProperties(node->properties());
newTex->setParameters(node->parameters());
newTex->setImages(texImgs);
+ newTex->setSharedTextureId(node->sharedTextureId());
m_updatedTextures.push_back(newTex);
diff --git a/src/render/texture/qabstracttexture.cpp b/src/render/texture/qabstracttexture.cpp
index 03746620e..751b6691f 100644
--- a/src/render/texture/qabstracttexture.cpp
+++ b/src/render/texture/qabstracttexture.cpp
@@ -66,6 +66,9 @@ QAbstractTexturePrivate::QAbstractTexturePrivate()
, m_comparisonMode(QAbstractTexture::CompareNone)
, m_layers(1)
, m_samples(1)
+ , m_sharedTextureId(-1)
+ , m_handleType(QAbstractTexture::NoHandle)
+ , m_handle(QVariant())
{
}
@@ -414,7 +417,7 @@ void QAbstractTexture::setDepth(int depth)
}
/*!
- * \return the width of the texture
+ * Returns the width of the texture
*/
int QAbstractTexture::width() const
{
@@ -423,7 +426,7 @@ int QAbstractTexture::width() const
}
/*!
- * \return the height of the texture
+ * Returns the height of the texture
*/
int QAbstractTexture::height() const
{
@@ -432,7 +435,7 @@ int QAbstractTexture::height() const
}
/*!
- * \return the depth of the texture
+ * Returns the depth of the texture
*/
int QAbstractTexture::depth() const
{
@@ -462,7 +465,7 @@ void QAbstractTexture::setLayers(int layers)
}
/*!
- \return the maximum number of layers for the texture provider.
+ Returns the maximum number of layers for the texture provider.
\note this has a meaning only for texture providers that have 3D or
array target formats.
@@ -495,7 +498,7 @@ void QAbstractTexture::setSamples(int samples)
}
/*!
- \return the number of samples per texel for the texture provider.
+ Returns the number of samples per texel for the texture provider.
\note this has a meaning only for texture providers that have multisample
formats.
@@ -561,7 +564,35 @@ void QAbstractTexture::setStatus(Status status)
}
/*!
- * \return the current status of the texture provider.
+ * \internal
+ */
+void QAbstractTexture::setHandle(const QVariant &handle)
+{
+ Q_D(QAbstractTexture);
+ if (d->m_handle != handle) {
+ d->m_handle = handle;
+ const bool blocked = blockNotifications(true);
+ emit handleChanged(handle);
+ blockNotifications(blocked);
+ }
+}
+
+/*!
+ * \internal
+ */
+void QAbstractTexture::setHandleType(QAbstractTexture::HandleType type)
+{
+ Q_D(QAbstractTexture);
+ if (d->m_handleType != type) {
+ d->m_handleType = type;
+ const bool blocked = blockNotifications(true);
+ emit handleTypeChanged(type);
+ blockNotifications(blocked);
+ }
+}
+
+/*!
+ * Returns the current status of the texture provider.
*/
QAbstractTexture::Status QAbstractTexture::status() const
{
@@ -663,7 +694,7 @@ void QAbstractTexture::removeTextureImage(QAbstractTextureImage *textureImage)
}
/*!
- \return a list of pointers to QAbstractTextureImage objects contained in
+ Returns a list of pointers to QAbstractTextureImage objects contained in
the texture provider.
*/
QVector<QAbstractTextureImage *> QAbstractTexture::textureImages() const
@@ -817,7 +848,7 @@ void QAbstractTexture::setMaximumAnisotropy(float anisotropy)
}
/*!
- * \return the current maximum anisotropy
+ * Returns the current maximum anisotropy
*/
float QAbstractTexture::maximumAnisotropy() const
{
@@ -826,7 +857,7 @@ float QAbstractTexture::maximumAnisotropy() const
}
/*!
- \property Qt3DRender::QAbstractTexture::comparisonFunction
+ \property Qt3DRender::QAbstractTexture::ComparisonFunction
Holds the comparison function of the texture provider.
*/
@@ -843,7 +874,7 @@ void QAbstractTexture::setComparisonFunction(QAbstractTexture::ComparisonFunctio
}
/*!
- * \return the current comparison function.
+ * Returns the current comparison function.
*/
QAbstractTexture::ComparisonFunction QAbstractTexture::comparisonFunction() const
{
@@ -852,7 +883,7 @@ QAbstractTexture::ComparisonFunction QAbstractTexture::comparisonFunction() cons
}
/*!
- \property Qt3DRender::QAbstractTexture::comparisonMode
+ \property Qt3DRender::QAbstractTexture::ComparisonMode
Holds the comparison mode of the texture provider.
*/
@@ -869,7 +900,7 @@ void QAbstractTexture::setComparisonMode(QAbstractTexture::ComparisonMode mode)
}
/*!
- * \return the current comparison mode.
+ * Returns the current comparison mode.
*/
QAbstractTexture::ComparisonMode QAbstractTexture::comparisonMode() const
{
@@ -878,7 +909,7 @@ QAbstractTexture::ComparisonMode QAbstractTexture::comparisonMode() const
}
/*!
- * \return the current data generator.
+ * Returns the current data generator.
*/
QTextureGeneratorPtr QAbstractTexture::dataGenerator() const
{
@@ -886,6 +917,55 @@ QTextureGeneratorPtr QAbstractTexture::dataGenerator() const
return d->m_dataFunctor;
}
+/*!
+ * \property Qt3DRender::QAbstractTexture::handleType
+ *
+ * Holds the current texture handle type.
+ */
+
+/*!
+ * \qmlproperty handleType
+ *
+ * Holds the current texture handle type.
+ */
+
+/*!
+ * \return the current texture handle type.
+ * \since 5.13
+ */
+QAbstractTexture::HandleType QAbstractTexture::handleType() const
+{
+ Q_D(const QAbstractTexture);
+ return d->m_handleType;
+}
+
+
+/*!
+ * \property Qt3DRender::QAbstractTexture::handle
+ *
+ * Holds the current texture handle, if Qt 3D is using the OpenGL renderer,
+ * handle is a texture id integer.
+ */
+
+/*!
+ * \qmlproperty handle
+ *
+ * Holds the current texture handle, if Qt 3D is using the OpenGL renderer,
+ * handle is a texture id integer.
+ */
+
+/*!
+ * \return the current texture handle, if Qt 3D is using the OpenGL renderer,
+ * handle is a texture id integer.
+ *
+ * \since 5.13
+ */
+QVariant QAbstractTexture::handle() const
+{
+ Q_D(const QAbstractTexture);
+ return d->m_handle;
+}
+
Qt3DCore::QNodeCreatedChangeBasePtr QAbstractTexture::createNodeCreationChange() const
{
auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QAbstractTextureData>::create(this);
@@ -909,9 +989,13 @@ Qt3DCore::QNodeCreatedChangeBasePtr QAbstractTexture::createNodeCreationChange()
data.layers = d->m_layers;
data.samples = d->m_samples;
data.dataFunctor = d->m_dataFunctor;
+ data.sharedTextureId = d->m_sharedTextureId;
return creationChange;
}
+/*!
+ A function for receiving and processing a \a change.
+*/
void QAbstractTexture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
{
switch (change->type()) {
@@ -941,6 +1025,10 @@ void QAbstractTexture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
bool blocked = blockNotifications(true);
setStatus(static_cast<QAbstractTexture::Status>(propertyChange->value().toInt()));
blockNotifications(blocked);
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("handleType")) {
+ setHandleType(static_cast<QAbstractTexture::HandleType>(propertyChange->value().toInt()));
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("handle")) {
+ setHandle(propertyChange->value());
}
// TODO handle target changes, it's a CONSTANT property but can be affected by loader
break;
diff --git a/src/render/texture/qabstracttexture.h b/src/render/texture/qabstracttexture.h
index f17633710..6097e4449 100644
--- a/src/render/texture/qabstracttexture.h
+++ b/src/render/texture/qabstracttexture.h
@@ -55,7 +55,7 @@ class QTextureGenerator;
typedef QSharedPointer<QTextureGenerator> QTextureGeneratorPtr;
-class QT3DRENDERSHARED_EXPORT QAbstractTexture : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QAbstractTexture : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(Target target READ target CONSTANT)
@@ -73,6 +73,8 @@ class QT3DRENDERSHARED_EXPORT QAbstractTexture : public Qt3DCore::QNode
Q_PROPERTY(ComparisonMode comparisonMode READ comparisonMode WRITE setComparisonMode NOTIFY comparisonModeChanged)
Q_PROPERTY(int layers READ layers WRITE setLayers NOTIFY layersChanged)
Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged)
+ Q_PROPERTY(HandleType handleType READ handleType NOTIFY handleTypeChanged REVISION 13)
+ Q_PROPERTY(QVariant handle READ handle NOTIFY handleChanged REVISION 13)
public:
@@ -268,6 +270,12 @@ public:
};
Q_ENUM(ComparisonMode) // LCOV_EXCL_LINE
+ enum HandleType {
+ NoHandle,
+ OpenGLTextureId
+ };
+ Q_ENUM(HandleType) // LCOV_EXCL_LINE
+
~QAbstractTexture();
Target target() const;
@@ -298,6 +306,8 @@ public:
int layers() const;
int samples() const;
QTextureGeneratorPtr dataGenerator() const;
+ HandleType handleType() const;
+ QVariant handle() const;
public Q_SLOTS:
void setFormat(TextureFormat format);
@@ -327,6 +337,8 @@ Q_SIGNALS:
void comparisonModeChanged(ComparisonMode comparisonMode);
void layersChanged(int layers);
void samplesChanged(int samples);
+ Q_REVISION(13) void handleTypeChanged(HandleType handleType);
+ Q_REVISION(13) void handleChanged(QVariant handle);
protected:
explicit QAbstractTexture(Qt3DCore::QNode *parent = nullptr);
@@ -335,6 +347,8 @@ protected:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) override;
void setStatus(Status status);
+ void setHandle(const QVariant &handle);
+ void setHandleType(HandleType type);
private:
Q_DECLARE_PRIVATE(QAbstractTexture)
diff --git a/src/render/texture/qabstracttexture_p.h b/src/render/texture/qabstracttexture_p.h
index a27ae3729..f4bdecacc 100644
--- a/src/render/texture/qabstracttexture_p.h
+++ b/src/render/texture/qabstracttexture_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QAbstractTexturePrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QAbstractTexturePrivate : public Qt3DCore::QNodePrivate
{
public :
QAbstractTexturePrivate();
@@ -87,6 +87,11 @@ public :
int m_layers;
int m_samples;
+ int m_sharedTextureId;
+
+ QAbstractTexture::HandleType m_handleType;
+ QVariant m_handle;
+
QTextureGeneratorPtr dataFunctor() const;
void setDataFunctor(const QTextureGeneratorPtr &generator);
@@ -113,6 +118,7 @@ struct QAbstractTextureData
Qt3DCore::QNodeIdVector textureImageIds;
int layers;
int samples;
+ int sharedTextureId;
QTextureGeneratorPtr dataFunctor;
};
diff --git a/src/render/texture/qabstracttextureimage.h b/src/render/texture/qabstracttextureimage.h
index 7e840fdd4..e072a26dc 100644
--- a/src/render/texture/qabstracttextureimage.h
+++ b/src/render/texture/qabstracttextureimage.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QAbstractTextureImagePrivate;
-class QT3DRENDERSHARED_EXPORT QAbstractTextureImage : public Qt3DCore::QNode
+class Q_3DRENDERSHARED_EXPORT QAbstractTextureImage : public Qt3DCore::QNode
{
Q_OBJECT
Q_PROPERTY(int mipLevel READ mipLevel WRITE setMipLevel NOTIFY mipLevelChanged)
diff --git a/src/render/texture/qabstracttextureimage_p.h b/src/render/texture/qabstracttextureimage_p.h
index f0d836055..a5299acd7 100644
--- a/src/render/texture/qabstracttextureimage_p.h
+++ b/src/render/texture/qabstracttextureimage_p.h
@@ -61,7 +61,7 @@ namespace Qt3DRender {
class QAbstractTextureImage;
-class QT3DRENDERSHARED_PRIVATE_EXPORT QAbstractTextureImagePrivate : public Qt3DCore::QNodePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QAbstractTextureImagePrivate : public Qt3DCore::QNodePrivate
{
public:
QAbstractTextureImagePrivate();
diff --git a/src/render/texture/qpaintedtextureimage.h b/src/render/texture/qpaintedtextureimage.h
index 5b884a42e..1e8cf90ae 100644
--- a/src/render/texture/qpaintedtextureimage.h
+++ b/src/render/texture/qpaintedtextureimage.h
@@ -50,7 +50,7 @@ namespace Qt3DRender {
class QPaintedTextureImagePrivate;
-class QT3DRENDERSHARED_EXPORT QPaintedTextureImage : public QAbstractTextureImage
+class Q_3DRENDERSHARED_EXPORT QPaintedTextureImage : public QAbstractTextureImage
{
Q_OBJECT
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
diff --git a/src/render/texture/qpaintedtextureimage_p.h b/src/render/texture/qpaintedtextureimage_p.h
index 4e554f1c1..48553323d 100644
--- a/src/render/texture/qpaintedtextureimage_p.h
+++ b/src/render/texture/qpaintedtextureimage_p.h
@@ -63,7 +63,7 @@ class QPainter;
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QPaintedTextureImagePrivate : public QAbstractTextureImagePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QPaintedTextureImagePrivate : public QAbstractTextureImagePrivate
{
public:
QPaintedTextureImagePrivate();
diff --git a/src/render/texture/qtexture.cpp b/src/render/texture/qtexture.cpp
index f8b34451f..0e652c6ff 100644
--- a/src/render/texture/qtexture.cpp
+++ b/src/render/texture/qtexture.cpp
@@ -1487,6 +1487,69 @@ bool QTextureFromSourceGenerator::isMirrored() const
return m_mirrored;
}
+/*!
+ * \class QSharedGLTexture
+ * \brief Allows to use a textureId from a separate OpenGL context in a Qt 3D scene.
+ *
+ * Depending on the rendering mode used by Qt 3D, the shared context will either be:
+ * \list
+ * \li qt_gl_global_share_context when letting Qt 3D drive the rendering. When
+ * setting the attribute Qt::AA_ShareOpenGLContexts on the QApplication class,
+ * this will automatically make QOpenGLWidget instances have their context shared
+ * with qt_gl_global_share_context.
+ * \li the shared context from the QtQuick scene. You might have to subclass
+ * QWindow or use QtQuickRenderControl to have control over what that shared
+ * context is though as of 5.13 it is qt_gl_global_share_context.
+ * \endlist
+ *
+ * \since 5.13
+ *
+ * Any 3rd party engine that shares its context with the Qt 3D renderer can now
+ * provide texture ids that will be referenced by the Qt 3D texture.
+ *
+ * You can omit specifying the texture properties, Qt 3D will try at runtime to
+ * determine what they are. If you know them, you can of course provide them,
+ * avoid additional work for Qt 3D.
+ *
+ * Keep in mind that if you are using custom materials and shaders, you need to
+ * specify the correct sampler type to be used.
+ */
+
+QSharedGLTexture::QSharedGLTexture(Qt3DCore::QNode *parent)
+ : QAbstractTexture(parent)
+{
+ QAbstractTexturePrivate *d = static_cast<QAbstractTexturePrivate *>(Qt3DCore::QNodePrivate::get(this));
+ d->m_target = TargetAutomatic;
+}
+
+QSharedGLTexture::~QSharedGLTexture()
+{
+}
+
+/*!
+ * \qmlproperty textureId
+ *
+ * The OpenGL texture id value that you want Qt3D to gain access to.
+ */
+/*!
+ *\property Qt3DRender::QSharedGLTexture::textureId
+ *
+ * The OpenGL texture id value that you want Qt3D to gain access to.
+ */
+int QSharedGLTexture::textureId() const
+{
+ return static_cast<QAbstractTexturePrivate *>(d_ptr.get())->m_sharedTextureId;
+}
+
+void QSharedGLTexture::setTextureId(int id)
+{
+ QAbstractTexturePrivate *d = static_cast<QAbstractTexturePrivate *>(Qt3DCore::QNodePrivate::get(this));
+ if (d->m_sharedTextureId != id) {
+ d->m_sharedTextureId = id;
+ emit textureIdChanged(id);
+ }
+}
+
} // namespace Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/texture/qtexture.h b/src/render/texture/qtexture.h
index 24d19fbcf..7556c6fc4 100644
--- a/src/render/texture/qtexture.h
+++ b/src/render/texture/qtexture.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_EXPORT QTexture1D : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture1D : public QAbstractTexture
{
Q_OBJECT
public:
@@ -63,7 +63,7 @@ public:
~QTexture1D();
};
-class QT3DRENDERSHARED_EXPORT QTexture1DArray : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture1DArray : public QAbstractTexture
{
Q_OBJECT
public:
@@ -71,7 +71,7 @@ public:
~QTexture1DArray();
};
-class QT3DRENDERSHARED_EXPORT QTexture2D : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture2D : public QAbstractTexture
{
Q_OBJECT
public:
@@ -79,7 +79,7 @@ public:
~QTexture2D();
};
-class QT3DRENDERSHARED_EXPORT QTexture2DArray : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture2DArray : public QAbstractTexture
{
Q_OBJECT
public:
@@ -87,7 +87,7 @@ public:
~QTexture2DArray();
};
-class QT3DRENDERSHARED_EXPORT QTexture3D : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture3D : public QAbstractTexture
{
Q_OBJECT
public:
@@ -95,7 +95,7 @@ public:
~QTexture3D();
};
-class QT3DRENDERSHARED_EXPORT QTextureCubeMap : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTextureCubeMap : public QAbstractTexture
{
Q_OBJECT
public:
@@ -103,7 +103,7 @@ public:
~QTextureCubeMap();
};
-class QT3DRENDERSHARED_EXPORT QTextureCubeMapArray : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTextureCubeMapArray : public QAbstractTexture
{
Q_OBJECT
public:
@@ -111,7 +111,7 @@ public:
~QTextureCubeMapArray();
};
-class QT3DRENDERSHARED_EXPORT QTexture2DMultisample : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture2DMultisample : public QAbstractTexture
{
Q_OBJECT
public:
@@ -119,7 +119,7 @@ public:
~QTexture2DMultisample();
};
-class QT3DRENDERSHARED_EXPORT QTexture2DMultisampleArray : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTexture2DMultisampleArray : public QAbstractTexture
{
Q_OBJECT
public:
@@ -127,7 +127,7 @@ public:
~QTexture2DMultisampleArray();
};
-class QT3DRENDERSHARED_EXPORT QTextureRectangle : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTextureRectangle : public QAbstractTexture
{
Q_OBJECT
public:
@@ -135,7 +135,7 @@ public:
~QTextureRectangle();
};
-class QT3DRENDERSHARED_EXPORT QTextureBuffer : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTextureBuffer : public QAbstractTexture
{
Q_OBJECT
public:
@@ -145,7 +145,7 @@ public:
class QTextureLoaderPrivate;
-class QT3DRENDERSHARED_EXPORT QTextureLoader : public QAbstractTexture
+class Q_3DRENDERSHARED_EXPORT QTextureLoader : public QAbstractTexture
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
@@ -169,6 +169,23 @@ private:
Q_DECLARE_PRIVATE(QTextureLoader)
};
+class Q_3DRENDERSHARED_EXPORT QSharedGLTexture : public QAbstractTexture
+{
+ Q_OBJECT
+ Q_PROPERTY(int textureId READ textureId WRITE setTextureId NOTIFY textureIdChanged)
+public:
+ explicit QSharedGLTexture(Qt3DCore::QNode *parent = nullptr);
+ ~QSharedGLTexture();
+
+ int textureId() const;
+
+public Q_SLOTS:
+ void setTextureId(int id);
+
+Q_SIGNALS:
+ void textureIdChanged(int textureId);
+};
+
} // namespace Qt3DRender
QT_END_NAMESPACE
diff --git a/src/render/texture/qtexture_p.h b/src/render/texture/qtexture_p.h
index 087480340..012b719ff 100644
--- a/src/render/texture/qtexture_p.h
+++ b/src/render/texture/qtexture_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QTextureLoaderPrivate : public QAbstractTexturePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QTextureLoaderPrivate : public QAbstractTexturePrivate
{
public:
QTextureLoaderPrivate();
diff --git a/src/render/texture/qtexturedata.h b/src/render/texture/qtexturedata.h
index a86a3ec45..04324ca14 100644
--- a/src/render/texture/qtexturedata.h
+++ b/src/render/texture/qtexturedata.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QTextureDataPrivate;
-class QT3DRENDERSHARED_EXPORT QTextureData
+class Q_3DRENDERSHARED_EXPORT QTextureData
{
public:
QTextureData();
diff --git a/src/render/texture/qtexturegenerator.h b/src/render/texture/qtexturegenerator.h
index 10f0cde57..7ae3d3a84 100644
--- a/src/render/texture/qtexturegenerator.h
+++ b/src/render/texture/qtexturegenerator.h
@@ -52,7 +52,7 @@ namespace Qt3DRender {
class QTextureData;
typedef QSharedPointer<QTextureData> QTextureDataPtr;
-class QT3DRENDERSHARED_EXPORT QTextureGenerator : public QAbstractFunctor
+class Q_3DRENDERSHARED_EXPORT QTextureGenerator : public QAbstractFunctor
{
public:
virtual ~QTextureGenerator();
diff --git a/src/render/texture/qtextureimage.h b/src/render/texture/qtextureimage.h
index d3fccde70..7d08c8e6e 100644
--- a/src/render/texture/qtextureimage.h
+++ b/src/render/texture/qtextureimage.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QTextureImagePrivate;
-class QT3DRENDERSHARED_EXPORT QTextureImage : public QAbstractTextureImage
+class Q_3DRENDERSHARED_EXPORT QTextureImage : public QAbstractTextureImage
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
diff --git a/src/render/texture/qtextureimage_p.h b/src/render/texture/qtextureimage_p.h
index 5a4ea8f5a..3cb704cf8 100644
--- a/src/render/texture/qtextureimage_p.h
+++ b/src/render/texture/qtextureimage_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-class QT3DRENDERSHARED_PRIVATE_EXPORT QTextureImagePrivate : public QAbstractTextureImagePrivate
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QTextureImagePrivate : public QAbstractTextureImagePrivate
{
public:
QTextureImagePrivate()
diff --git a/src/render/texture/qtextureimagedata.h b/src/render/texture/qtextureimagedata.h
index 6d66f2390..68ceebabc 100644
--- a/src/render/texture/qtextureimagedata.h
+++ b/src/render/texture/qtextureimagedata.h
@@ -51,7 +51,7 @@ namespace Qt3DRender {
class QTextureImageDataPrivate;
-class QT3DRENDERSHARED_EXPORT QTextureImageData
+class Q_3DRENDERSHARED_EXPORT QTextureImageData
{
public:
QTextureImageData();
diff --git a/src/render/texture/qtextureimagedatagenerator.h b/src/render/texture/qtextureimagedatagenerator.h
index 0e7e6c782..7c58b3878 100644
--- a/src/render/texture/qtextureimagedatagenerator.h
+++ b/src/render/texture/qtextureimagedatagenerator.h
@@ -55,7 +55,7 @@ namespace Qt3DRender {
class QTextureImageData;
typedef QSharedPointer<QTextureImageData> QTextureImageDataPtr;
-class QT3DRENDERSHARED_EXPORT QTextureImageDataGenerator : public QAbstractFunctor
+class Q_3DRENDERSHARED_EXPORT QTextureImageDataGenerator : public QAbstractFunctor
{
public:
virtual ~QTextureImageDataGenerator() {}
diff --git a/src/render/texture/qtexturewrapmode.h b/src/render/texture/qtexturewrapmode.h
index 36af013a8..b31ccc17b 100644
--- a/src/render/texture/qtexturewrapmode.h
+++ b/src/render/texture/qtexturewrapmode.h
@@ -49,7 +49,7 @@ namespace Qt3DRender {
class QTextureWrapModePrivate;
-class QT3DRENDERSHARED_EXPORT QTextureWrapMode : public QObject
+class Q_3DRENDERSHARED_EXPORT QTextureWrapMode : public QObject
{
Q_OBJECT
Q_PROPERTY(WrapMode x READ x WRITE setX NOTIFY xChanged)
diff --git a/src/render/texture/texture.cpp b/src/render/texture/texture.cpp
index 749b85802..17fd47be3 100644
--- a/src/render/texture/texture.cpp
+++ b/src/render/texture/texture.cpp
@@ -115,6 +115,7 @@ void Texture::cleanup()
// texture is being referenced by a shared API specific texture (GLTexture)
m_dataFunctor.reset();
m_textureImageIds.clear();
+ m_sharedTextureId = -1;
// set default values
m_properties = {};
@@ -181,6 +182,9 @@ void Texture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
dirty = DirtyProperties;
} else if (propertyChange->propertyName() == QByteArrayLiteral("generator")) {
setDataGenerator(propertyChange->value().value<QTextureGeneratorPtr>());
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("textureId")) {
+ m_sharedTextureId = propertyChange->value().toInt();
+ dirty = DirtySharedTextureId;
}
}
break;
@@ -219,7 +223,7 @@ void Texture::setDataGenerator(const QTextureGeneratorPtr &generator)
// Called by sendTextureChangesToFrontendJob once GLTexture and sharing
// has been performed
-void Texture::updatePropertiesAndNotify(const TextureProperties &properties)
+void Texture::updatePropertiesAndNotify(const TextureUpdateInfo &updateInfo)
{
// If we are Dirty, some property has changed and the properties we have
// received are potentially already outdated
@@ -228,57 +232,73 @@ void Texture::updatePropertiesAndNotify(const TextureProperties &properties)
// Note we don't update target has it is constant for frontend nodes
- if (properties.width != m_properties.width) {
- m_properties.width = properties.width;
+ if (updateInfo.properties.width != m_properties.width) {
+ m_properties.width = updateInfo.properties.width;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("width");
- change->setValue(properties.width);
+ change->setValue(updateInfo.properties.width);
notifyObservers(change);
}
- if (properties.height != m_properties.height) {
- m_properties.height = properties.height;
+ if (updateInfo.properties.height != m_properties.height) {
+ m_properties.height = updateInfo.properties.height;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("height");
- change->setValue(properties.height);
+ change->setValue(updateInfo.properties.height);
notifyObservers(change);
}
- if (properties.depth != m_properties.depth) {
- m_properties.depth = properties.depth;
+ if (updateInfo.properties.depth != m_properties.depth) {
+ m_properties.depth = updateInfo.properties.depth;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("depth");
- change->setValue(properties.depth);
+ change->setValue(updateInfo.properties.depth);
notifyObservers(change);
}
- if (properties.layers != m_properties.layers) {
- m_properties.layers = properties.layers;
+ if (updateInfo.properties.layers != m_properties.layers) {
+ m_properties.layers = updateInfo.properties.layers;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("layers");
- change->setValue(properties.layers);
+ change->setValue(updateInfo.properties.layers);
notifyObservers(change);
}
- if (properties.format != m_properties.format) {
- m_properties.format = properties.format;
+ if (updateInfo.properties.format != m_properties.format) {
+ m_properties.format = updateInfo.properties.format;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("format");
- change->setValue(properties.format);
+ change->setValue(updateInfo.properties.format);
notifyObservers(change);
}
- if (properties.status != m_properties.status) {
- m_properties.status = properties.status;
+ if (updateInfo.properties.status != m_properties.status) {
+ m_properties.status = updateInfo.properties.status;
auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
change->setPropertyName("status");
- change->setValue(properties.status);
+ change->setValue(updateInfo.properties.status);
+ notifyObservers(change);
+ }
+
+ {
+ auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
+ change->setPropertyName("handleType");
+ change->setValue(updateInfo.handleType);
+ notifyObservers(change);
+ }
+
+ {
+ auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(peerId());
+ change->setDeliveryFlags(Qt3DCore::QSceneChange::Nodes);
+ change->setPropertyName("handle");
+ change->setValue(updateInfo.handle);
notifyObservers(change);
}
}
@@ -315,11 +335,14 @@ void Texture::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &chan
m_parameters.comparisonFunction = data.comparisonFunction;
m_parameters.comparisonMode = data.comparisonMode;
m_dataFunctor = data.dataFunctor;
+ m_sharedTextureId = data.sharedTextureId;
for (const QNodeId imgId : data.textureImageIds)
addTextureImage(imgId);
addDirtyFlag(DirtyFlags(DirtyImageGenerators|DirtyProperties|DirtyParameters));
+ if (m_sharedTextureId > 0)
+ addDirtyFlag(DirtySharedTextureId);
}
diff --git a/src/render/texture/texture_p.h b/src/render/texture/texture_p.h
index 86c49f695..c60e90181 100644
--- a/src/render/texture/texture_p.h
+++ b/src/render/texture/texture_p.h
@@ -137,10 +137,18 @@ public:
DirtyProperties = 0x1,
DirtyParameters = 0x2,
DirtyImageGenerators = 0x4,
- DirtyDataGenerator = 0x8
+ DirtyDataGenerator = 0x8,
+ DirtySharedTextureId = 0x16
};
Q_DECLARE_FLAGS(DirtyFlags, DirtyFlag)
+ struct TextureUpdateInfo
+ {
+ TextureProperties properties;
+ QVariant handle;
+ QAbstractTexture::HandleType handleType;
+ };
+
void addDirtyFlag(DirtyFlags flags);
DirtyFlags dirtyFlags();
void unsetDirty();
@@ -155,9 +163,10 @@ public:
inline const TextureParameters& parameters() const { return m_parameters; }
inline const Qt3DCore::QNodeIdVector textureImageIds() const { return m_textureImageIds; }
inline const QTextureGeneratorPtr& dataGenerator() const { return m_dataFunctor; }
+ inline int sharedTextureId() const { return m_sharedTextureId; }
void setDataGenerator(const QTextureGeneratorPtr &generator);
- void updatePropertiesAndNotify(const TextureProperties &propreties);
+ void updatePropertiesAndNotify(const TextureUpdateInfo &updateInfo);
bool isValid(TextureImageManager *manager) const;
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
@@ -165,6 +174,7 @@ private:
DirtyFlags m_dirty;
TextureProperties m_properties;
TextureParameters m_parameters;
+ int m_sharedTextureId;
QTextureGeneratorPtr m_dataFunctor;
Qt3DCore::QNodeIdVector m_textureImageIds;