summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-11 15:13:04 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-11 15:15:41 +0200
commit22203c3521bc0213226c0c01d8782f0d0656da1e (patch)
tree21bca67c41b377a7b1def53bab719b1a3c517eb1
parentccb1e22b6279858094615ed01d211b3e2a5d81a8 (diff)
parent7bc264b20fe1e707ab5b1ce248463a6365db0d06 (diff)
Merge branch '2.3' into master
-rw-r--r--examples/3dstudioruntime2/cppdatainput/main.cpp17
-rw-r--r--examples/3dstudioruntime2/cppdatainput/presentation/datainput.uia2
-rw-r--r--examples/3dstudioruntime2/qmldatainput/presentation/datainput.uia2
-rw-r--r--examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml12
-rw-r--r--res/DataModelMetadata/en-us/MetaData.xml172
-rw-r--r--src/runtime/animator/q3dsanimator.cpp8
-rw-r--r--src/runtime/api/q3dsdatainput.cpp75
-rw-r--r--src/runtime/api/q3dsdatainput.h7
-rw-r--r--src/runtime/api/q3dsdatainput_p.h2
-rw-r--r--src/runtime/api/q3dspresentation.cpp39
-rw-r--r--src/runtime/api/q3dspresentation.h3
-rw-r--r--src/runtime/api/q3dspresentation_p.h5
-rw-r--r--src/runtime/api/q3dspresentationcontroller.cpp12
-rw-r--r--src/runtime/dragon/dragon.pri12
-rw-r--r--src/runtime/dragon/dragonactivatedsurface.cpp252
-rw-r--r--src/runtime/dragon/dragonactivatedsurface_p.h76
-rw-r--r--src/runtime/dragon/dragonattachment.cpp (renamed from src/runtime/dragon/dragonattachmentpack.cpp)2
-rw-r--r--src/runtime/dragon/dragonattachment_p.h (renamed from src/runtime/dragon/jobs/dragonshaderjobs_p.h)29
-rw-r--r--src/runtime/dragon/dragonattachmentpack_p.h99
-rw-r--r--src/runtime/dragon/dragonentity.cpp39
-rw-r--r--src/runtime/dragon/dragonentity_p.h20
-rw-r--r--src/runtime/dragon/dragonglbuffer.cpp32
-rw-r--r--src/runtime/dragon/dragonglbuffer_p.h10
-rw-r--r--src/runtime/dragon/dragonglshader.cpp13
-rw-r--r--src/runtime/dragon/dragonglshader_p.h2
-rw-r--r--src/runtime/dragon/dragongltexture_p.h5
-rw-r--r--src/runtime/dragon/dragonmanager_p.h411
-rw-r--r--src/runtime/dragon/dragonmapper_p.h2
-rw-r--r--src/runtime/dragon/dragonoffscreensurfacehelper.cpp10
-rw-r--r--src/runtime/dragon/dragonrenderbuffer.cpp2
-rw-r--r--src/runtime/dragon/dragonrendercommand_p.h35
-rw-r--r--src/runtime/dragon/dragonrenderer.cpp240
-rw-r--r--src/runtime/dragon/dragonrenderer_p.h45
-rw-r--r--src/runtime/dragon/dragonrendertarget.cpp1
-rw-r--r--src/runtime/dragon/dragonrendertarget_p.h2
-rw-r--r--src/runtime/dragon/dragonrendertargetoutput_p.h28
-rw-r--r--src/runtime/dragon/dragonrenderview_p.h15
-rw-r--r--src/runtime/dragon/dragonscene2d.cpp416
-rw-r--r--src/runtime/dragon/dragonscene2d_p.h159
-rw-r--r--src/runtime/dragon/dragontask_p.h8
-rw-r--r--src/runtime/dragon/dragontexture.cpp2
-rw-r--r--src/runtime/dragon/dragontexture_p.h2
-rw-r--r--src/runtime/dragon/dragontrackingchangescontainer_p.h5
-rw-r--r--src/runtime/dragon/framegraph/dragonblitframebuffer_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragoncameraselectornode_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonclearbuffers.cpp65
-rw-r--r--src/runtime/dragon/framegraph/dragonclearbuffers_p.h29
-rw-r--r--src/runtime/dragon/framegraph/dragondispatchcompute_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonframegraph.pri103
-rw-r--r--src/runtime/dragon/framegraph/dragonframegraphnode_p.h7
-rw-r--r--src/runtime/dragon/framegraph/dragonlayerfilternode.cpp27
-rw-r--r--src/runtime/dragon/framegraph/dragonlayerfilternode_p.h10
-rw-r--r--src/runtime/dragon/framegraph/dragonmemorybarrier_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonproximityfilter_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonrendercapture_p.h4
-rw-r--r--src/runtime/dragon/framegraph/dragonrenderpassfilternode_p.h5
-rw-r--r--src/runtime/dragon/framegraph/dragonrendersurfaceselector_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonrendertargetselectornode_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonsortcriterion.cpp82
-rw-r--r--src/runtime/dragon/framegraph/dragonsortpolicy_p.h2
-rw-r--r--src/runtime/dragon/framegraph/dragonstatesetnode_p.h3
-rw-r--r--src/runtime/dragon/framegraph/dragontechniquefilternode_p.h3
-rw-r--r--src/runtime/dragon/framegraph/dragonviewportnode_p.h2
-rw-r--r--src/runtime/dragon/framegraph/framegraph.pri1
-rw-r--r--src/runtime/dragon/geometry/dragonbuffer.cpp2
-rw-r--r--src/runtime/dragon/geometry/dragonbuffer_p.h1
-rw-r--r--src/runtime/dragon/geometry/dragongeometryrenderer.cpp41
-rw-r--r--src/runtime/dragon/geometry/dragongeometryrenderer_p.h18
-rw-r--r--src/runtime/dragon/geometry/dragonsphere_p.h2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelperes2.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelperes3.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelperes3_2.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelpergl2.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_2.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_3.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelpergl4.cpp2
-rw-r--r--src/runtime/dragon/graphicshelpers/dragongraphicshelperinterface_p.h2
-rw-r--r--src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp7
-rw-r--r--src/runtime/dragon/jobs/dragonrenderviewjobs.cpp67
-rw-r--r--src/runtime/dragon/jobs/dragonrenderviewjobs_p.h20
-rw-r--r--src/runtime/dragon/jobs/dragonshaderjobs.cpp145
-rw-r--r--src/runtime/dragon/jobs/dragontransformjobs.cpp23
-rw-r--r--src/runtime/dragon/jobs/dragontreejobs_p.h7
-rw-r--r--src/runtime/dragon/jobs/jobs.pri2
-rw-r--r--src/runtime/dragon/materialsystem/dragonfilterkey.cpp6
-rw-r--r--src/runtime/dragon/materialsystem/dragonparameter_p.h4
-rw-r--r--src/runtime/dragon/materialsystem/dragonrenderpass.cpp3
-rw-r--r--src/runtime/dragon/materialsystem/dragonrenderpass_p.h4
-rw-r--r--src/runtime/dragon/materialsystem/dragonshader.cpp4
-rw-r--r--src/runtime/dragon/materialsystem/dragonshader_p.h10
-rw-r--r--src/runtime/dragon/materialsystem/dragonshaderbuilder.cpp308
-rw-r--r--src/runtime/dragon/materialsystem/dragonshaderbuilder_p.h105
-rw-r--r--src/runtime/dragon/materialsystem/dragonshaderdata.cpp27
-rw-r--r--src/runtime/dragon/materialsystem/dragonshaderdata_p.h22
-rw-r--r--src/runtime/dragon/materialsystem/dragontechnique.cpp79
-rw-r--r--src/runtime/dragon/materialsystem/dragontechnique_p.h18
-rw-r--r--src/runtime/dragon/materialsystem/materialsystem.pri2
-rw-r--r--src/runtime/dragon/qdragonrenderaspect.cpp18
-rw-r--r--src/runtime/dragon/qdragonrenderaspect_p.h10
-rw-r--r--src/runtime/dragon/renderer/dragondraw.cpp2
-rw-r--r--src/runtime/dragon/renderer/dragonopenglvertexarrayobject_p.h2
-rw-r--r--src/runtime/dragon/renderer/dragonshaderparameterpack_p.h2
-rw-r--r--src/runtime/dragon/renderstates/dragonrenderstates.cpp2
-rw-r--r--src/runtime/q3dsdatainputentry_p.h30
-rw-r--r--src/runtime/q3dsdistancefieldglyphcache.cpp240
-rw-r--r--src/runtime/q3dsdistancefieldglyphcache_p.h2
-rw-r--r--src/runtime/q3dsdistancefieldmaterialgenerator.cpp14
-rw-r--r--src/runtime/q3dsdistancefieldmaterialgenerator_p.h3
-rw-r--r--src/runtime/q3dsengine.cpp72
-rw-r--r--src/runtime/q3dsengine_p.h15
-rw-r--r--src/runtime/q3dsinputmanager.cpp30
-rw-r--r--src/runtime/q3dsmaterial_p.h1
-rw-r--r--src/runtime/q3dsres.qrc4
-rw-r--r--src/runtime/q3dsscenemanager.cpp288
-rw-r--r--src/runtime/q3dsscenemanager_p.h6
-rw-r--r--src/runtime/q3dstextmesh.cpp36
-rw-r--r--src/runtime/q3dstextmesh_p.h3
-rw-r--r--src/runtime/q3dsuiadocument.cpp11
-rw-r--r--src/runtime/q3dsuiaparser.cpp24
-rw-r--r--src/runtime/q3dsuippresentation.cpp26
-rw-r--r--src/runtime/runtime.pro3
-rw-r--r--src/runtime/shaders/distancefieldtext.frag6
-rw-r--r--src/runtime/shaders/distancefieldtext.vert52
-rw-r--r--src/runtime/shaders/distancefieldtext_dropshadow.frag29
-rw-r--r--src/runtime/shaders/distancefieldtext_dropshadow.vert75
-rw-r--r--src/runtime/shaders/distancefieldtext_dropshadow_core.frag34
-rw-r--r--src/runtime/shaders/distancefieldtext_dropshadow_core.vert55
-rw-r--r--src/runtime/slideplayerng/q3dsanimationmanagerng.cpp4
-rw-r--r--tests/auto/uipparser/tst_q3dsuipparser.cpp2
129 files changed, 2036 insertions, 2695 deletions
diff --git a/examples/3dstudioruntime2/cppdatainput/main.cpp b/examples/3dstudioruntime2/cppdatainput/main.cpp
index 92f1018..639111e 100644
--- a/examples/3dstudioruntime2/cppdatainput/main.cpp
+++ b/examples/3dstudioruntime2/cppdatainput/main.cpp
@@ -84,15 +84,14 @@ int main(int argc, char *argv[])
Q3DSSurfaceViewer viewer;
QObject::connect(&viewer, &Q3DSSurfaceViewer::presentationLoaded, &viewer, [&] {
- const QVariantList diList = viewer.presentation()->getDataInputs();
+ const auto diList = viewer.presentation()->dataInputs();
for (const auto &it : diList) {
- Q3DSDataInput *dynDi = qvariant_cast<Q3DSDataInput *>(it);
+ Q3DSDataInput *dynDi = it;
if (dynDi->name().contains(QLatin1String("color"))) {
if (dynDi->isValid()) {
// Access and modify metadata.
dynDi->setMetadata("metadata1", "gauge color");
- qDebug() << "Metadata key for" << dynDi->name() << ":" << dynDi->metadataKey();
- qDebug() << "Metadata: " << dynDi->metadata();
+ qDebug() << "Metadata: " << dynDi->metadata("metadata1");
QObject::connect(&viewer, &Q3DSSurfaceViewer::frameUpdate,
[&colorRed, dynDi] {
@@ -109,12 +108,9 @@ int main(int argc, char *argv[])
dynDi->setMax(270.0f);
// Access and modify metadata.
- qDebug() << "Metadata key for" << dynDi->name() << ":" << dynDi->metadataKey();
- qDebug() << "Metadata: " << dynDi->metadata();
dynDi->setMetadata("metadata2", "Secondary rotation control");
- qDebug() << "New metadata key for" << dynDi->name() << ":"
- << dynDi->metadataKey();
- qDebug() << "New metadata for " << dynDi->name() << ":" << dynDi->metadata();
+ qDebug() << "New metadata for" << dynDi->name() << ":"
+ << dynDi->metadata(dynDi->metadataKeys().last());
QObject::connect(&viewer, &Q3DSSurfaceViewer::frameUpdate, [&range, dynDi] {
dynDi->setValue((float)range);
@@ -123,8 +119,7 @@ int main(int argc, char *argv[])
}
}
}
- const auto diWithMetadata = viewer.presentation()
- ->getDataInputs(QVariant("metadata1"));
+ auto diWithMetadata = viewer.presentation()->dataInputs(QVariant("metadata1"));
qDebug() << "Datainputs with metadatakey metadata1: ";
for (auto &it : diWithMetadata)
qDebug() << it->name();
diff --git a/examples/3dstudioruntime2/cppdatainput/presentation/datainput.uia b/examples/3dstudioruntime2/cppdatainput/presentation/datainput.uia
index 5676aec..0c89121 100644
--- a/examples/3dstudioruntime2/cppdatainput/presentation/datainput.uia
+++ b/examples/3dstudioruntime2/cppdatainput/presentation/datainput.uia
@@ -3,7 +3,7 @@
<assets initial="datainput">
<presentation id="datainput" src="datainput.uip"/>
<dataInput name="colorInput" type="Vector3"/>
- <dataInput metadatakey="metadata1" metadata="Controls rotation" max="360" name="rangeInput" min="0" type="Ranged Number"/>
+ <dataInput metadata="metadata1$Controls rotation" max="360" name="rangeInput" min="0" type="Ranged Number"/>
</assets>
<statemachine ref="#logic">
<visual-states>
diff --git a/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uia b/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uia
index 67014ae..30d0084 100644
--- a/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uia
+++ b/examples/3dstudioruntime2/qmldatainput/presentation/datainput.uia
@@ -8,7 +8,7 @@
<dataInput name="rangeInput" type="Ranged Number" min="0" max="360"/>
<dataInput name="scaleInput" type="Vector3"/>
<dataInput name="stringInput" type="String"/>
- <dataInput name="variantInput" type="Variant"/>
+ <dataInput name="variantInput" type="Variant" metadata="usage$opacity$datasource$speedgauge_visibility"/>
</assets>
<statemachine ref="#logic">
<visual-states>
diff --git a/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml b/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml
index 12d635c..8e23fff 100644
--- a/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml
+++ b/examples/3dstudioruntime2/qmldatainput/qml/qmldatainput/main.qml
@@ -93,10 +93,14 @@ Item {
Text {
id: diItem
color: "red"
- // Show the min-max range for datainput type Ranged Number
- text: modelData.name + (modelData.max !== 0 ? " range min: " + modelData.min
- + " range max: " + modelData.max
- : "")
+ // Show the metadata keys available for this datainput and
+ // min-max range for datainput type Ranged Number
+ text: "name: " + modelData.name + " \n metadata keys: ["
+ + modelData.metadataKeys() + "]"
+ + (modelData.max !== 0 ? "\n range min: " + modelData.min
+ + " range max: " + modelData.max
+ : "")
+ font.pointSize: 6
}
}
}
diff --git a/res/DataModelMetadata/en-us/MetaData.xml b/res/DataModelMetadata/en-us/MetaData.xml
index aba9772..534b4c1 100644
--- a/res/DataModelMetadata/en-us/MetaData.xml
+++ b/res/DataModelMetadata/en-us/MetaData.xml
@@ -39,10 +39,10 @@
<Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="False" controllable="True" />
<Property name="opacity" formalName="Opacity" min="0" max="100" default="100" hidden="True" />
<Property name="orthographic" formalName="Orthographic" description="Remove all perspective from the camera?" type="Boolean" animatable="False" />
- <Property name="position" formalName="Position" description="Location in local space" type="Vector" default="0 0 -600" controllable="True" />
- <Property name="rotation" formalName="Rotation" description="Rotation around local axes" type="Rotation" controllable="True" />
- <Property name="scale" formalName="Scale" description="Size adjustments along local axes" type="Vector" default="1 1 1" controllable="True" />
- <Property name="pivot" formalName="Pivot" description="Offset of the contents away from the local center" type="Vector" controllable="True" />
+ <Property name="position" formalName="Position" description="Location in local space" type="Vector" default="0 0 -600" />
+ <Property name="rotation" formalName="Rotation" description="Rotation around local axes" type="Rotation" />
+ <Property name="scale" formalName="Scale" description="Size adjustments along local axes" type="Vector" default="1 1 1" />
+ <Property name="pivot" formalName="Pivot" description="Offset of the contents away from the local center" type="Vector" />
<Property name="fov" formalName="Field of View" description="Viewing angle of the camera\n(how much it can see)" min="1" max="180" default="60">
<ShowIfEqual property="orthographic" value="False"/>
</Property>
@@ -80,121 +80,128 @@
<Property name="positionv" formalName="V Position" description="Offset of the image along the V\ndirection of the material" />
<Property name="pivotu" formalName="U Pivot" description="Offset the image in the U direction\nwithout affecting rotation center" />
<Property name="pivotv" formalName="V Pivot" description="Offset the image in the V direction\nwithout affecting rotation center" />
+ <!-- Texture subpresentation is not set to controllable as it does not currently work in runtime -->
<Property name="subpresentation" formalName="Sub-Presentation" description="Presentation or QML stream\nto use instead of the image" type="Renderable" />
</Image>
<Layer>
- <Property name="name" formalName="Name" description="Object name" type="String" default="Layer" hidden="False" />
- <Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="False" controllable="True" />
- <Property name="disabledepthtest" formalName="Disable Depth Test" description="Optimize render speed for layers with\nmostly transparent objects?" type="Boolean" animatable="False"/>
- <Property name="disabledepthprepass" formalName="Disable Depth Prepass" description="Optimize render speed for layers\nwith low depth complexity" type="Boolean" animatable="False"/>
- <Property name="progressiveaa" formalName="Progressive AA" description="Improves the visual quality when no\nitems are moving" list="None:2x:4x:8x" default="None" />
- <Property name="multisampleaa" formalName="Multisample AA" description="Improves geometry quality, e.g.\nsilhouettes." list="None:2x:4x:SSAA" default="None" />
- <Property name="temporalaa" formalName="Temporal AA" description="Improve overall quality using camera\njittering and frame blending?" type="Boolean" default="False"/>
- <Property name="background" formalName="Layer Background" description="The color to use for the layer\neach frame" list="Transparent:SolidColor:Unspecified" default="Transparent" />
- <Property name="backgroundcolor" formalName="Background Color" description="The background color for the layer" type="Color" animatable="False">
+ <!-- Basic Properties -->
+ <Property name="name" formalName="Name" description="Object name" type="String" default="Layer" hidden="False" category="Basic Properties" />
+ <Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="False" controllable="True" category="Basic Properties" />
+ <Property name="background" formalName="Layer Background" description="The color to use for the layer\neach frame" list="Transparent:SolidColor:Unspecified" default="Transparent" category="Basic Properties" />
+ <Property name="backgroundcolor" formalName="Background Color" description="The background color for the layer" type="Color" animatable="False" category="Basic Properties">
<ShowIfEqual property="background" value="SolidColor"/>
</Property>
- <Property name="blendtype" formalName="Blend Mode" list="Normal:Screen:Multiply:Add:Subtract:*Overlay:*ColorBurn:*ColorDodge" default="Normal" description="Mode of blending between this layer\nand layers below. Modes marked with\n* are available only with HW supporting\nadvanced blending modes." />
- <Property name="horzfields" formalName="Horizontal Fields" description="Properties to use to control the\nhorizontal size and placement" list="Left/Width:Left/Right:Width/Right" default="Left/Width" />
- <Property name="left" formalName="Left" description="Distance between presentation and\nlayer left edges">
+ <Property name="blendtype" formalName="Blend Mode" list="Normal:Screen:Multiply:Add:Subtract:*Overlay:*ColorBurn:*ColorDodge" default="Normal" description="Mode of blending between this layer\nand layers below. Modes marked with\n* are available only with HW supporting\nadvanced blending modes." category="Basic Properties" />
+ <Property name="sourcepath" formalName="Sub-Presentation" description="Presentation or QML stream to\nrender for this layer" type="Renderable" controllable="True" category="Basic Properties" />
+
+ <!-- Variant Tags -->
+ <Property name="variants" type="String" category="Variant Tags" />
+
+ <!-- Antialiasing -->
+ <Property name="progressiveaa" formalName="Progressive AA" description="Improves the visual quality when no\nitems are moving" list="None:2x:4x:8x" default="None" category="Antialiasing" />
+ <Property name="multisampleaa" formalName="Multisample AA" description="Improves geometry quality, e.g.\nsilhouettes." list="None:2x:4x:SSAA" default="None" category="Antialiasing" />
+ <Property name="temporalaa" formalName="Temporal AA" description="Improve overall quality using camera\njittering and frame blending?" type="Boolean" default="False" category="Antialiasing" />
+
+ <!-- Size -->
+ <Property name="horzfields" formalName="Horizontal Fields" description="Properties to use to control the\nhorizontal size and placement" list="Left/Width:Left/Right:Width/Right" default="Left/Width" category="Size" />
+ <Property name="left" formalName="Left" description="Distance between presentation and\nlayer left edges" category="Size">
<ShowIfEqual property="horzfields" value="Left/Width"/>
<ShowIfEqual property="horzfields" value="Left/Right"/>
</Property>
- <Property name="leftunits" formalName="Left Units" description="Left distance is percent of overall\nwidth or absolute pixels" list="percent:pixels" default="percent">
+ <Property name="leftunits" formalName="Left Units" description="Left distance is percent of overall\nwidth or absolute pixels" list="percent:pixels" default="percent" category="Size">
<ShowIfEqual property="horzfields" value="Left/Width"/>
<ShowIfEqual property="horzfields" value="Left/Right"/>
</Property>
- <Property name="width" formalName="Width" description="Overall layer width" default="100">
+ <Property name="width" formalName="Width" description="Overall layer width" default="100" category="Size">
<ShowIfEqual property="horzfields" value="Left/Width"/>
<ShowIfEqual property="horzfields" value="Width/Right"/>
</Property>
- <Property name="widthunits" formalName="Width Units" description="Width is percent of overall width\nor absolute pixels" list="percent:pixels" default="percent">
+ <Property name="widthunits" formalName="Width Units" description="Width is percent of overall width\nor absolute pixels" list="percent:pixels" default="percent" category="Size">
<ShowIfEqual property="horzfields" value="Left/Width"/>
<ShowIfEqual property="horzfields" value="Width/Right"/>
</Property>
- <Property name="right" formalName="Right" description="Distance between presentation and layer\nright edges">
+ <Property name="right" formalName="Right" description="Distance between presentation and layer\nright edges" category="Size">
<ShowIfEqual property="horzfields" value="Left/Right"/>
<ShowIfEqual property="horzfields" value="Width/Right"/>
</Property>
- <Property name="rightunits" formalName="Right Units" description="Right distance is percent of overall\nwidth or absolute pixels" list="percent:pixels" default="percent">
+ <Property name="rightunits" formalName="Right Units" description="Right distance is percent of overall\nwidth or absolute pixels" list="percent:pixels" default="percent" category="Size">
<ShowIfEqual property="horzfields" value="Left/Right"/>
<ShowIfEqual property="horzfields" value="Width/Right"/>
</Property>
- <Property name="vertfields" formalName="Vertical Fields" description="Properties to use to control the\nvertical size and placement" list="Top/Height:Top/Bottom:Height/Bottom" default="Top/Height" />
- <Property name="top" formalName="Top" description="Distance between presentation and layer\ntop edges.">
+ <Property name="vertfields" formalName="Vertical Fields" description="Properties to use to control the\nvertical size and placement" list="Top/Height:Top/Bottom:Height/Bottom" default="Top/Height" category="Size" />
+ <Property name="top" formalName="Top" description="Distance between presentation and layer\ntop edges." category="Size">
<ShowIfEqual property="vertfields" value="Top/Height"/>
<ShowIfEqual property="vertfields" value="Top/Bottom"/>
</Property>
- <Property name="topunits" formalName="Top Units" description="Top distance is percent of overall\nheight or absolute pixels" list="percent:pixels" default="percent">
+ <Property name="topunits" formalName="Top Units" description="Top distance is percent of overall\nheight or absolute pixels" list="percent:pixels" default="percent" category="Size">
<ShowIfEqual property="vertfields" value="Top/Height"/>
<ShowIfEqual property="vertfields" value="Top/Bottom"/>
</Property>
- <Property name="height" formalName="Height" description="Overall layer height." default="100">
+ <Property name="height" formalName="Height" description="Overall layer height." default="100" category="Size">
<ShowIfEqual property="vertfields" value="Top/Height"/>
<ShowIfEqual property="vertfields" value="Height/Bottom"/>
</Property>
- <Property name="heightunits" formalName="Height Units" description="Height is percent of overall height\nor absolute pixels" list="percent:pixels" default="percent">
+ <Property name="heightunits" formalName="Height Units" description="Height is percent of overall height\nor absolute pixels" list="percent:pixels" default="percent" category="Size">
<ShowIfEqual property="vertfields" value="Top/Height"/>
<ShowIfEqual property="vertfields" value="Height/Bottom"/>
</Property>
- <Property name="bottom" formalName="Bottom" description="Distance between presentation and layer\nbottom edges">
+ <Property name="bottom" formalName="Bottom" description="Distance between presentation and layer\nbottom edges" category="Size">
<ShowIfEqual property="vertfields" value="Top/Bottom"/>
<ShowIfEqual property="vertfields" value="Height/Bottom"/>
</Property>
- <Property name="bottomunits" formalName="Bottom Units" description="Bottom distance is percent of overall\nheight or absolute pixels" list="percent:pixels" default="percent">
+ <Property name="bottomunits" formalName="Bottom Units" description="Bottom distance is percent of overall\nheight or absolute pixels" list="percent:pixels" default="percent" category="Size">
<ShowIfEqual property="vertfields" value="Top/Bottom"/>
<ShowIfEqual property="vertfields" value="Height/Bottom"/>
</Property>
- <Property name="sourcepath" formalName="Sub-Presentation" description="Presentation or QML stream to\nrender for this layer" type="Renderable" />
- <!-- Restating the node properties so they appear at the bottom of the list because they won't be used quite as much -->
- <!--CN - removing properties that may force the layer to render offscreen. We aren't ready to support this feature-->
- <Property name="position" formalName="Position" description="Position" type="Vector" hidden="True"/>
- <Property name="rotation" formalName="Rotation" description="Rotation" type="Rotation" hidden="True" />
- <Property name="scale" formalName="Scale" description="Scale" type="Vector" default="1 1 1" hidden="True" />
- <Property name="pivot" formalName="Pivot" description="Pivot" type="Vector" hidden="True" />
- <Property name="opacity" formalName="Opacity" min="0" max="100" default="100" hidden="True" />
- <Property name="aostrength" formalName="Ambient Occlusion" description="Amount of ambient occlusion shading\nto apply" min="0" max="100" default="0">
+ <!-- Ambient Occlusion -->
+ <Property name="aostrength" formalName="Ambient Occlusion" description="Amount of ambient occlusion shading\nto apply" min="0" max="100" default="0" category="Ambient Occlusion" >
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="aodistance" formalName="AO Distance" description="Size of the ambient occlusion shading" default="5">
+ <Property name="aodistance" formalName="AO Distance" description="Size of the ambient occlusion shading" default="5" category="Ambient Occlusion">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="aosoftness" formalName="AO Softness" description="Magnitude of the blurring used to\nsoften shading" min="0" max="50" default="50">
+ <Property name="aosoftness" formalName="AO Softness" description="Magnitude of the blurring used to\nsoften shading" min="0" max="50" default="50" category="Ambient Occlusion">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="aobias" formalName="AO Threshold" description="Remove AO from flat surfaces to\nprevent artifacts" default="0">
+ <Property name="aobias" formalName="AO Threshold" description="Remove AO from flat surfaces to\nprevent artifacts" default="0" category="Ambient Occlusion">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="aosamplerate" formalName="AO Sampling Rate" description="Quality of AO sampling" type="Long" default="2" min="2" max="4">
+ <Property name="aosamplerate" formalName="AO Sampling Rate" description="Quality of AO sampling" type="Long" default="2" min="2" max="4" category="Ambient Occlusion">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="aodither" formalName="AO Detail" description="Use close-range detail AO" type="Boolean" default="True">
+ <Property name="aodither" formalName="AO Detail" description="Use close-range detail AO" type="Boolean" default="True" category="Ambient Occlusion">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="shadowstrength" formalName="Shadow Strength" description="Amount of shadowing to apply" min="0" max="100" default="0" hidden="True">
+ <!-- Shadow -->
+ <Property name="shadowstrength" formalName="Shadow Strength" description="Amount of shadowing to apply" min="0" max="100" default="0" hidden="True" category="Shadow">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="shadowdist" formalName="Shadow Distance" description="Maximum distance to ray march for\nshadows test" default="10" hidden="True">
+ <Property name="shadowdist" formalName="Shadow Distance" description="Maximum distance to ray march for\nshadows test" default="10" hidden="True" category="Shadow">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="shadowsoftness" formalName="Shadow Softness" description="Amount of softening of the shadow\nedges" min="0" max="100" default="100" hidden="True">
+ <Property name="shadowsoftness" formalName="Shadow Softness" description="Amount of softening of the shadow\nedges" min="0" max="100" default="100" hidden="True" category="Shadow">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="shadowbias" formalName="Shadow Threshold" description="Remove self-shadowing from flat\nsurfaces" default="0" hidden="True">
+ <Property name="shadowbias" formalName="Shadow Threshold" description="Remove self-shadowing from flat\nsurfaces" default="0" hidden="True" category="Shadow">
<ShowIfEqual property="sourcepath" value=""/>
</Property>
- <Property name="lightprobe" formalName="Light Probe" description="Image used for image-based lighting\nand reflections" type="Image" />
- <Property name="probebright" formalName="IBL Brightness" description="Amount of light emitted by the light\nprobe." default="100" />
- <Property name="fastibl" formalName="Fast IBL" description="Use a faster approximation to\nimage-based lighting" type="Boolean" default="True" hidden="True" />
- <Property name="probehorizon" formalName="IBL Horizon Cutoff" description="Upper limit for horizon darkening\nof the light probe" min="-1" max="-0.001" default="-1" />
- <Property name="probefov" formalName="IBL FOV Angle" description="Image source FOV for the case of using\na camera-source as the IBL probe" min="1.0" max="180" default="180" />
- <Property name="lightprobe2" formalName="Secondary Light Probe" description="Image to blend over the primary light\nprobe" type="Image" />
- <Property name="probe2fade" formalName="Probe Crossfade" description="Blend amount between the primary and\nseconary probes" min="0.0" max="1.0" default="1.0" />
- <Property name="probe2window" formalName="Secondary Probe Window" description="Texture-U window size used for the\nmoving window (for scrolling textures)" min="0.01" max="1.0" default="1.0" hidden="True" />
- <Property name="probe2pos" formalName="Secondary Probe Offset" description="Texture-U window offset used for the\nmoving window" default="0.5" hidden="True" />
+ <!-- Light Probe -->
+ <Property name="lightprobe" formalName="Light Probe" description="Image used for image-based lighting\nand reflections" type="Image" category="Light Probe" />
+ <Property name="probebright" formalName="IBL Brightness" description="Amount of light emitted by the light\nprobe." default="100" category="Light Probe" />
+ <Property name="fastibl" formalName="Fast IBL" description="Use a faster approximation to\nimage-based lighting" type="Boolean" default="True" hidden="True" category="Light Probe" />
+ <Property name="probehorizon" formalName="IBL Horizon Cutoff" description="Upper limit for horizon darkening\nof the light probe" min="-1" max="-0.001" default="-1" category="Light Probe" />
+ <Property name="probefov" formalName="IBL FOV Angle" description="Image source FOV for the case of using\na camera-source as the IBL probe" min="1.0" max="180" default="180" category="Light Probe" />
+ <Property name="lightprobe2" formalName="Secondary Light Probe" description="Image to blend over the primary light\nprobe" type="Image" category="Light Probe" />
+ <Property name="probe2fade" formalName="Probe Crossfade" description="Blend amount between the primary and\nseconary probes" min="0.0" max="1.0" default="1.0" category="Light Probe" />
+ <Property name="probe2window" formalName="Secondary Probe Window" description="Texture-U window size used for the\nmoving window (for scrolling textures)" min="0.01" max="1.0" default="1.0" hidden="True" category="Light Probe" />
+ <Property name="probe2pos" formalName="Secondary Probe Offset" description="Texture-U window offset used for the\nmoving window" default="0.5" hidden="True" category="Light Probe" />
+
+ <!-- Advanced -->
+ <Property name="disabledepthtest" formalName="Disable Depth Test" description="Optimize render speed for layers with\nmostly transparent objects?" type="Boolean" animatable="False" category="Advanced" />
+ <Property name="disabledepthprepass" formalName="Disable Depth Prepass" description="Optimize render speed for layers\nwith low depth complexity" type="Boolean" animatable="False" category="Advanced" />
</Layer>
<Light>
<Property name="name" formalName="Name" description="Object name" type="String" default="Light" hidden="False" />
@@ -202,11 +209,11 @@
<Property name="opacity" formalName="Opacity" min="0" max="100" default="100" hidden="True" />
<Property name='scope' formalName="Scope" description="Portion of the scene graph lit by this\nlight; no value results in entire layer\nbeing affected." type='ObjectRef' />
<Property name="lighttype" formalName="Light Type" description="Type of illumination to use" list="Directional:Point:Area" default="Directional" />
- <Property name="position" formalName="Position" description="Location in local space" type="Vector" controllable="True"/>
- <Property name="rotation" formalName="Rotation" description="Rotation around local axes" type="Rotation" controllable="True" />
- <Property name="scale" formalName="Scale" description="Size adjustments along local axes" type="Vector" default="1 1 1" controllable="True" />
- <Property name="pivot" formalName="Pivot" description="Offset of the contents away from the local center" type="Vector" controllable="True" />
- <Property name="lightdiffuse" formalName="Light Color" description="Color of diffuse lighting effect" type="Color" default="1 1 1" controllable="True" />
+ <Property name="position" formalName="Position" description="Location in local space" type="Vector"/>
+ <Property name="rotation" formalName="Rotation" description="Rotation around local axes" type="Rotation" />
+ <Property name="scale" formalName="Scale" description="Size adjustments along local axes" type="Vector" default="1 1 1" />
+ <Property name="pivot" formalName="Pivot" description="Offset of the contents away from the local center" type="Vector" />
+ <Property name="lightdiffuse" formalName="Light Color" description="Color of diffuse lighting effect" type="Color" default="1 1 1" />
<Property name="lightspecular" formalName="Specular Color" description="Color of specular lighting highlights" type="Color" default="1 1 1"/>
<Property name="lightambient" formalName="Ambient Color" description="Color of unlit areas (black for none)" type="Color"/>
<Property name="brightness" formalName="Brightness" description="Strength of the light" default="100"/>
@@ -222,7 +229,7 @@
<Property name="areaheight" formalName="Height" description="Height of the surface of the area light" min="0" default="100" hidden="True">
<ShowIfEqual property="lighttype" value="Area"/>
</Property>
- <Property name="castshadow" formalName="Cast Shadows?" description="Enable shadow casting for this light" type="Boolean" default="False"/>
+ <Property name="castshadow" formalName="Cast Shadows" description="Enable shadow casting for this light" type="Boolean" default="False"/>
<Property name="shdwfactor" formalName="Shadow Darkness" description="Factor used to darken shadows" default="10.0" min="1.0" max="100.0" />
<Property name="shdwfilter" formalName="Shadow Softness" description="Width of the blur filter on the shadow map" min="1" max="100" default="35" />
<Property name="shdwmapres" formalName="Shadow Resolution" description="Resolution of shadow map\n(powers of two)" type="ShadowMapResolution" default="9" animatable="False" />
@@ -230,22 +237,20 @@
<Property name="shdwmapfar" formalName="Shadow Far Clip" description="Affects the maximum distance for the shadow\ndepth map" default="5000" />
<Property name="shdwmapfov" formalName="Shadow Field of View" description="Affects the field of view of the shadow\ncamera" default="90" min="1" max="179" hidden="True" />
</Light>
+ <MaterialBase>
+ <Property name="name" formalName="Name" description="Object name" type="String" default="Material" hidden="False" category="Basic Properties" />
+ <Property name="iblprobe" formalName="IBL Override" description="IBL probe to use in place of the\nlayer probe for this material" type="Image" category="Basic Properties" />
+ </MaterialBase>
<Lightmaps>
- <Property name="name" formalName="Name" description="Object name" type="String" default="Lightmaps" hidden="False" category="Lighting" />
<Property name="lightmapindirect" formalName="Indirect Lightmap" description="Image providing indirect light values\nfor GI" type="Image" category="Lighting" />
<Property name="lightmapradiosity" formalName="Radiosity Lightmap" description="Image providing directional light values" type="Image" category="Lighting" />
<Property name="lightmapshadow" formalName="Shadow Lightmap" description="Baked Shadow map" type="Image" category="Lighting" />
</Lightmaps>
- <MaterialBase>
- <Property name="name" formalName="Name" description="Object name" type="String" default="MaterialBase" hidden="False" category="Material" />
- <Property name="iblprobe" formalName="IBL Override" description="IBL probe to use in place of the\nlayer probe for this material" type="Image" category="Material" />
- </MaterialBase>
<Material>
- <Property name="name" formalName="Name" description="Object name" type="String" default="Material" hidden="False" category="Material" />
<Property name="shaderlighting" formalName="Lighting" description="Light model" list="Pixel:None" default="Pixel" category="Material" />
<Property name="blendmode" formalName="Blending Mode" description="How this material blends with content\nbehind it. Modes marked with * are\navailable only with HW supporting\nadvanced blending modes." list="Normal:Screen:Multiply:*Overlay:*ColorBurn:*ColorDodge" default="Normal" category="Material" />
<Property name="vertexcolors" formalName="Enable Vertex Colors" description="Use vertex colors from the mesh" type="Boolean" default="False" animatable="False" category="Material" />
- <Property name="diffuse" formalName="Diffuse Color" description="Color when lit from any direction" type="Color" default="1 1 1" category="Material" controllable="True" />
+ <Property name="diffuse" formalName="Diffuse Color" description="Color when lit from any direction" type="Color" default="1 1 1" category="Material" />
<Property name="diffusemap" formalName="Diffuse Map" description="Image to multiply with diffuse color" type="Image" category="Material" />
<Property name="diffusemap2" formalName="Diffuse Map 2" description="Image to multiply with diffuse color" type="Image" category="Material" />
<Property name="diffusemap3" formalName="Diffuse Map 3" description="Image to multiply with diffuse color" type="Image" category="Material" />
@@ -274,17 +279,16 @@
<Property name="diffuselightwrap" formalName="Diffuse Light Wrap" description="Diffuse Light Wrap" type="float" min='0.0' max='1.0' category="Material" />
</Material>
<ReferencedMaterial>
- <Property name="name" formalName="Name" description="Object name" type="String" default="Material" hidden="True" category="Material" />
<Property name="referencedmaterial" formalName="Referenced Material" description="Material to use all settings from" type="ObjectRef" category="Material" />
</ReferencedMaterial>
<Model>
<!--<Property name="name" formalName="Name" description="Object name" type="String" default="Model" hidden="False" />
- <Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="False" controllable="True" />-->
+ <Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="False" />-->
<Property name="sourcepath" formalName="Mesh" description="Geometry to use for this model" type="Mesh" />
<Property name="poseroot" hidden="True" type="Long" default="-1" />
- <Property name="tessellation" formalName="Tessellation Mode" description="Type of tessellation to subdivide\nthe geometry" list="None:Linear:Phong:NPatch" default="None" />
+ <!--<Property name="tessellation" formalName="Tessellation Mode" description="Type of tessellation to subdivide\nthe geometry" list="None:Linear:Phong:NPatch" default="None" />
<Property name="edgetess" formalName="Edge Tessellation" description="Max Tessellation amount" min="1" max="64" default="4" />
- <Property name="innertess" formalName="Inner Tessellation" description="Min Tessellation amount" min="1" max="64" default="4" />
+ <Property name="innertess" formalName="Inner Tessellation" description="Min Tessellation amount" min="1" max="64" default="4" />-->
</Model>
<Node>
<Event name="onPressureDown" category="Gesture" />
@@ -309,11 +313,11 @@
<Event name="onTwoPointSwipeDown" category="Gesture" />
-->
- <Property name="position" formalName="Position" description="Location in local space" type="Vector" controllable="True" />
- <Property name="rotation" formalName="Rotation" description="Rotation around local axes" type="Rotation" controllable="True" />
- <Property name="scale" formalName="Scale" description="Size adjustments along local axes" type="Vector" default="1 1 1" controllable="True" />
- <Property name="pivot" formalName="Pivot" description="Offset of the contents away from the\nlocal center" type="Vector" controllable="True" />
- <Property name="opacity" formalName="Opacity" description="How much the element (and its children)\nocclude items behind them" min="0" max="100" default="100" controllable="True" />
+ <Property name="position" formalName="Position" description="Location in local space" type="Vector" />
+ <Property name="rotation" formalName="Rotation" description="Rotation around local axes" type="Rotation" />
+ <Property name="scale" formalName="Scale" description="Size adjustments along local axes" type="Vector" default="1 1 1" />
+ <Property name="pivot" formalName="Pivot" description="Offset of the contents away from the\nlocal center" type="Vector" />
+ <Property name="opacity" formalName="Opacity" description="How much the element (and its children)\nocclude items behind them" min="0" max="100" default="100" />
<Property name="rotationorder" formalName="Rotation Order" description="Rotation Order" list="XYZ:YZX:ZXY:XZY:YXZ:ZYX:XYZr:YZXr:ZXYr:XZYr:YXZr:ZYXr" default="YXZ" hidden="True"/>
<Property name="orientation" formalName="Orientation" description="Orientation" list="Left Handed:Right Handed" default="Left Handed" hidden="True"/>
<Property name="boneid" type="Long" hidden="True" default="-1" />
@@ -395,6 +399,7 @@
</RenderPlugin>
<Scene>
<Property name="name" formalName="Name" type="String" default="Scene" hidden="True" />
+ <Property name="eyeball" formalName="Visible" description="Item visibility" type="Boolean" default="True" hidden="True" />
<Property name="bgcolorenable" formalName="Use Background" description="Clear the contents to a solid color\nbefore each frame?" type="Boolean" default="True" />
<Property name="backgroundcolor" formalName="Background Color" description="Color to use for the background" type="Color" animatable="False" />
<Event name="onPressureDown" category="Gesture" />
@@ -449,10 +454,21 @@
<!-- HW accelerated fonts not supported
<Property name="enableacceleratedfont" formalName="Hardware accelerated font" description="Enabled hardware acclerated font" type="Boolean" default="false" />
-->
- <Property name="size" formalName="Font Size" description="Font Size" type="FontSize" default="36" animatable="False" controllable="True" />
+ <Property name="size" formalName="Font Size" description="Font Size" type="FontSize" default="36" animatable="False" />
<Property name="horzalign" formalName="Horizontal Alignment" description="Horizontal Alignment" list="Left:Center:Right" default="Center" />
<Property name="vertalign" formalName="Vertical Alignment" description="Vertical Alignment" list="Top:Middle:Bottom" default="Middle" />
<Property name="leading" formalName="Leading" description="Leading" />
<Property name="tracking" formalName="Tracking" description="Tracking" />
+ <Property name="boundingbox" formalName="Text Area" description="Fixed size text area. If not set,\ntext area grows with text." type="Float2" default="0 0" />
+ <Property name="wordwrap" formalName="Word Wrapping" description="Word wrapping. Has effect only if fixed size\ntext area is used.\nClip: Cut text if it does not fit.\nWrapWord: Wrap between words, if possible.\nWrapAnywhere: Wrap even in the middle\nof words." list="Clip:WrapWord:WrapAnywhere" default="WrapWord" />
+ <Property name="elide" formalName="Eliding" description="Elide text that does not fit the\ntext area. Has effect only if\nfixed text area is defined." list="ElideNone:ElideLeft:ElideMiddle:ElideRight" default="ElideNone" />
+ <Property name="dropshadow" formalName="Drop-Shadow" description="Add a drop-shadow to the text.\nThe shadow is a darker shade of the given color." type="Boolean" default="False" />
+ <Property name="dropshadowstrength" formalName="Shadow Darkness" description="Darkness of the shadow in percents.\n100 is black, 0 is the same color as the text." min="0" max="100" type="Float" default="80" />
+ <Property name="dropshadowoffsetx" formalName="Horizontal Offset" description="Horizontal offset of the shadow.\nIt is relative to the font size." min="-100" max="100" type="Float" default="0"/>
+ <Property name="dropshadowoffsety" formalName="Vertical Offset" description="Vertical offset of the shadow.\nIt is relative to the font size." min="-100" max="100" type="Float" default="0" />
+ <!--To be removed in 2.x (when UIP version is next updated)
+ <Property name="dropshadowoffset" formalName="Shadow Offset" description="Offset of the shadow. It\nis relative to the font size." min="1" max="100" type="Float" default="10" />
+ <Property name="dropshadowhorzalign" formalName="Horizontal Position" description="Horizontal position of the shadow" list="Left:Center:Right" default="Right" />
+ <Property name="dropshadowvertalign" formalName="Vertical Position" description="Vertical position of the shadow" list="Top:Middle:Bottom" default="Bottom" />-->
</Text>
</MetaData>
diff --git a/src/runtime/animator/q3dsanimator.cpp b/src/runtime/animator/q3dsanimator.cpp
index f666df2..3f0265e 100644
--- a/src/runtime/animator/q3dsanimator.cpp
+++ b/src/runtime/animator/q3dsanimator.cpp
@@ -91,7 +91,13 @@ void syncDirtyProperties(const Q3DSAnimator::DirtyPropertyList &dirtyProperties)
case QVariant::Vector3D:
return QVariant::fromValue(v);
case QVariant::Color:
- return QVariant::fromValue(QColor::fromRgbF(qreal(v.x()), qreal(v.y()), qreal(v.z())));
+ {
+ // stabilize values
+ const float r = qBound(0.0f, v.x(), 1.0f);
+ const float g = qBound(0.0f, v.y(), 1.0f);
+ const float b = qBound(0.0f, v.z(), 1.0f);
+ return QVariant::fromValue(QColor::fromRgbF(qreal(r), qreal(g), qreal(b)));
+ }
default:
return QVariant();
}
diff --git a/src/runtime/api/q3dsdatainput.cpp b/src/runtime/api/q3dsdatainput.cpp
index 96799f9..0abeba4 100644
--- a/src/runtime/api/q3dsdatainput.cpp
+++ b/src/runtime/api/q3dsdatainput.cpp
@@ -142,41 +142,48 @@ bool Q3DSDataInput::isValid() const
}
/*!
- \property Q3DSDataInput::metadata
-
- Returns the metadata for this datainput. Metadata is convenience data
- that can be used by API clients to better identify datainput purpose, and facilitate
+ Returns the metadata for this datainput for the specified \a key. Metadata is convenience
+ data that can be used by API clients to better identify datainput purpose, and facilitate
binding the appropriate external data source to this datainput. Metadata does not have
any impact to rendering.
- Datainput only has a single key-value pair at any given time.
+ \sa Q3DSDataInput::metadataKeys()
*/
-QVariant Q3DSDataInput::metadata() const
+QVariant Q3DSDataInput::metadata(const QVariant &key) const
{
Q_D(const Q3DSDataInput);
if (!d->presentation)
return {};
return Q3DSPresentationPrivate::get(d->presentation)
- ->controller->handleDataInputMetaData(this);
+ ->controller->handleDataInputMetaData(this, key);
}
/*!
- \property Q3DSDataInput::metadataKey
-
- Returns the metadata key for this datainput.
+ Returns the metadata keys for this datainput.
\sa Q3DSDataInput::metadata()
*/
-QVariant Q3DSDataInput::metadataKey() const
+QVariantList Q3DSDataInput::metadataKeys() const
{
Q_D(const Q3DSDataInput);
if (!d->presentation)
return {};
- return Q3DSPresentationPrivate::get(d->presentation)
- ->controller->handleDataInputMetaDataKey(this);
+ return QVariantList(Q3DSPresentationPrivate::get(d->presentation)
+ ->controller->handleDataInputMetaDataKeys(this));
+}
+
+/*!
+ Removes the metadata for this datainput for the specified \a key.
+
+ \sa Q3DSDataInput::metadata()
+ */
+void Q3DSDataInput::removeMetadata(const QVariant &key)
+{
+ Q_D(Q3DSDataInput);
+ d->sendMetadataRemove(key);
}
/*!
@@ -270,12 +277,26 @@ void Q3DSDataInputPrivate::sendValue()
void Q3DSDataInputPrivate::sendMin(float min)
{
- Q3DSPresentationPrivate::get(presentation)->setDataInputMin(name, min);
+ if (!presentation)
+ return;
+
+ Q3DSPresentationPrivate::get(presentation)->setDataInputMin(name, min);
}
void Q3DSDataInputPrivate::sendMax(float max)
{
- Q3DSPresentationPrivate::get(presentation)->setDataInputMax(name, max);
+ if (!presentation)
+ return;
+
+ Q3DSPresentationPrivate::get(presentation)->setDataInputMax(name, max);
+}
+
+void Q3DSDataInputPrivate::sendMetadataRemove(const QVariant &key)
+{
+ if (!presentation)
+ return;
+
+ Q3DSPresentationPrivate::get(presentation)->removeDatainputMetadata(name, key);
}
/*!
@@ -389,4 +410,28 @@ void Q3DSDataInputPrivate::sendMax(float max)
previous value.
*/
+/*!
+ \qmlmethod void DataInput::setMetadata(QVariant key, QVariant metadata)
+
+ Sets the datainput \a metadata for \a key.
+*/
+
+/*!
+ \qmlmethod QVariant DataInput::getMetadata(QVariant key)
+
+ Gets the datainput metadata for \a key.
+*/
+
+/*!
+ \qmlmethod QVariantList DataInput::getMetadataKeys()
+
+ Gets all metadata keys for this datainput.
+*/
+
+/*!
+ \qmlmethod void DataInput::removeMetadata(QVariant key)
+
+ Removes datainput metadata for /a key.
+*/
+
QT_END_NAMESPACE
diff --git a/src/runtime/api/q3dsdatainput.h b/src/runtime/api/q3dsdatainput.h
index 2ba6d35..377773a 100644
--- a/src/runtime/api/q3dsdatainput.h
+++ b/src/runtime/api/q3dsdatainput.h
@@ -62,9 +62,10 @@ public:
float min() const;
float max() const;
bool isValid() const;
- QVariant metadata() const;
- QVariant metadataKey() const;
- void setMetadata(const QVariant &key, const QVariant &metadata);
+ Q_INVOKABLE QVariant metadata(const QVariant &key) const;
+ Q_INVOKABLE QVariantList metadataKeys() const;
+ Q_INVOKABLE void setMetadata(const QVariant &key, const QVariant &metadata);
+ Q_INVOKABLE void removeMetadata(const QVariant &key);
public Q_SLOTS:
void setName(const QString &name);
void setValue(const QVariant &value);
diff --git a/src/runtime/api/q3dsdatainput_p.h b/src/runtime/api/q3dsdatainput_p.h
index 7dcca9e..9c8a2a9 100644
--- a/src/runtime/api/q3dsdatainput_p.h
+++ b/src/runtime/api/q3dsdatainput_p.h
@@ -59,7 +59,7 @@ public:
void sendMin(float min);
void sendMax(float min);
void sendMetaData(const QVariant &key, const QVariant &metadata);
-
+ void sendMetadataRemove(const QVariant &key);
QString name;
QVariant value;
Q3DSPresentation *presentation = nullptr;
diff --git a/src/runtime/api/q3dspresentation.cpp b/src/runtime/api/q3dspresentation.cpp
index 2a1d9eb..2233790 100644
--- a/src/runtime/api/q3dspresentation.cpp
+++ b/src/runtime/api/q3dspresentation.cpp
@@ -517,6 +517,16 @@ void Q3DSPresentation::setAttribute(const QString &elementPath, const QString &a
d->controller->handleSetAttribute(elementPath, attributeName, value);
}
+QVariantList Q3DSPresentation::getDataInputs()
+{
+ QVariantList ret;
+ const auto diList = dataInputs();
+ for (auto &it : diList)
+ ret.append(QVariant::fromValue(it));
+
+ return ret;
+}
+
/*!
Returns a list of datainputs defined for this presentation. Use setDataInputValue()
interface to set a datainput value using datainput name, or call Q3DSDataInput::setValue
@@ -525,45 +535,43 @@ void Q3DSPresentation::setAttribute(const QString &elementPath, const QString &a
\sa setDataInputValue
\sa Q3DSDataInput
*/
-QVariantList Q3DSPresentation::getDataInputs()
+QVector<Q3DSDataInput *> Q3DSPresentation::dataInputs()
{
Q_D(Q3DSPresentation);
- QVariantList ret;
+ QVector<Q3DSDataInput *> ret;
if (d->controller) {
const auto diList = d->controller->handleGetDataInputs();
for (auto &it : diList) {
// Assign "this" as presentation associated with this datainput,
// as the query from Q3DSUipPresentation does not return
// actual datainput object references with presentation associations.
- // Instead we get datainput metadata stored in DataInput entry map.
- // Actual datainput object is therefore created on the fly based on this metadata and
- // handed out to API client.
- // Here we associate DI with the presentation object that is now available
- // in order for setValue calls to be correctly routed.
+ // (Instead we get datainput information stored in DataInput entry map.)
+ // Actual datainput object are therefore created in Q3DSEngine if needed;
+ // here we associate DI with the presentation object that is now available,
+ // in order for setValue calls to be correctly routed, and get the latest
+ // min/max values.
auto privDi = Q3DSDataInputPrivate::get(it);
privDi->presentation = this;
- QVariant var(QVariant::fromValue(it));
- ret.append(var);
+ ret.append(it);
}
return ret;
} else {
- return QVariantList();
+ return {};
}
}
-
/*!
Returns a list of datainputs defined for this presentation which have metadata key
\a metadataKey.
\sa Q3DSDataInput
*/
-QVector<Q3DSDataInput *> Q3DSPresentation::getDataInputs(const QVariant &metadataKey)
+QVector<Q3DSDataInput *> Q3DSPresentation::dataInputs(const QVariant &metadataKey)
{
Q_D(Q3DSPresentation);
QVector<Q3DSDataInput *> ret;
if (d->controller) {
const auto diList = d->controller->handleGetDataInputs(metadataKey);
- for (auto &it : diList) {
+ for (const auto &it : diList) {
auto privDi = Q3DSDataInputPrivate::get(it);
privDi->presentation = this;
ret.append(it);
@@ -832,6 +840,11 @@ float Q3DSPresentationPrivate::dataInputMax(const QString &name) const
return controller->pcEngine()->dataInputMax(name);
}
+void Q3DSPresentationPrivate::removeDatainputMetadata(const QString &name, const QVariant &key)
+{
+ controller->pcEngine()->removeDatainputMetadata(name, key);
+}
+
/*!
\qmltype Presentation
\instantiates Q3DSPresentation
diff --git a/src/runtime/api/q3dspresentation.h b/src/runtime/api/q3dspresentation.h
index 54816ed..9aaffa5 100644
--- a/src/runtime/api/q3dspresentation.h
+++ b/src/runtime/api/q3dspresentation.h
@@ -101,7 +101,8 @@ public:
Q_INVOKABLE void setAttribute(const QString &elementPath, const QString &attributeName, const QVariant &value);
Q_INVOKABLE QVariantList getDataInputs();
- QVector<Q3DSDataInput *> getDataInputs(const QVariant &metadataKey);
+ QVector<Q3DSDataInput *> dataInputs();
+ QVector<Q3DSDataInput *> dataInputs(const QVariant &metadataKey);
void keyPressEvent(QKeyEvent *e);
void keyReleaseEvent(QKeyEvent *e);
diff --git a/src/runtime/api/q3dspresentation_p.h b/src/runtime/api/q3dspresentation_p.h
index 2f0129d..b72132a 100644
--- a/src/runtime/api/q3dspresentation_p.h
+++ b/src/runtime/api/q3dspresentation_p.h
@@ -88,8 +88,8 @@ public:
virtual QVector<Q3DSDataInput *> handleGetDataInputs() const;
virtual QVector<Q3DSDataInput *> handleGetDataInputs(const QVariant &metadataKey) const;
virtual bool handleIsValidDataInput(const Q3DSDataInput *di) const;
- virtual QVariant handleDataInputMetaData(const Q3DSDataInput *di) const;
- virtual QVariant handleDataInputMetaDataKey(const Q3DSDataInput *di) const;
+ virtual QVariant handleDataInputMetaData(const Q3DSDataInput *di, const QVariant &key) const;
+ virtual QList<QVariant> handleDataInputMetaDataKeys(const Q3DSDataInput *di) const;
virtual void handleFireEvent(const QString &elementPath, const QString &eventName);
virtual void handleGoToTime(const QString &elementPath, float timeSeconds);
virtual void handleGoToSlideByName(const QString &elementPath, const QString &name);
@@ -127,6 +127,7 @@ public:
void setDataInputMetaData(const QString &diName, const QVariant &key, const QVariant &metaData);
void setDataInputMin(const QString &name, float min);
void setDataInputMax(const QString &name, float max);
+ void removeDatainputMetadata(const QString &name, const QVariant &key);
float dataInputMin(const QString &name) const;
float dataInputMax(const QString &name) const;
diff --git a/src/runtime/api/q3dspresentationcontroller.cpp b/src/runtime/api/q3dspresentationcontroller.cpp
index b8fdf1e..5e1debb 100644
--- a/src/runtime/api/q3dspresentationcontroller.cpp
+++ b/src/runtime/api/q3dspresentationcontroller.cpp
@@ -133,7 +133,7 @@ QVector<Q3DSDataInput *> Q3DSPresentationController::handleGetDataInputs() const
if (m_pcEngine)
return m_pcEngine->dataInputs();
else
- return QVector<Q3DSDataInput *>();
+ return {};
}
QVector<Q3DSDataInput *> Q3DSPresentationController::handleGetDataInputs(
@@ -142,7 +142,7 @@ QVector<Q3DSDataInput *> Q3DSPresentationController::handleGetDataInputs(
if (m_pcEngine)
return m_pcEngine->dataInputs(metadataKey);
else
- return QVector<Q3DSDataInput *>();
+ return {};
}
bool Q3DSPresentationController::handleIsValidDataInput(const Q3DSDataInput *di) const
@@ -154,19 +154,19 @@ bool Q3DSPresentationController::handleIsValidDataInput(const Q3DSDataInput *di)
}
QVariant Q3DSPresentationController::handleDataInputMetaData(
- const Q3DSDataInput *di) const
+ const Q3DSDataInput *di, const QVariant &key) const
{
if (m_pcEngine)
- return m_pcEngine->dataInputMetaData(di);
+ return m_pcEngine->dataInputMetaData(di, key);
else
return {};
}
-QVariant Q3DSPresentationController::handleDataInputMetaDataKey(
+QList<QVariant> Q3DSPresentationController::handleDataInputMetaDataKeys(
const Q3DSDataInput *di) const
{
if (m_pcEngine)
- return m_pcEngine->dataInputMetaDataKey(di);
+ return m_pcEngine->dataInputMetaDataKeys(di);
else
return {};
}
diff --git a/src/runtime/dragon/dragon.pri b/src/runtime/dragon/dragon.pri
index 3df6856..a32fbec 100644
--- a/src/runtime/dragon/dragon.pri
+++ b/src/runtime/dragon/dragon.pri
@@ -13,7 +13,7 @@ QT_PRIVATE += openglextensions
#*-msvc*:QMAKE_CXXFLAGS += /showIncludes
HEADERS += \
- $$PWD/dragonattachmentpack_p.h \
+ $$PWD/dragonattachment_p.h \
$$PWD/dragonbackendnode_p.h \
$$PWD/dragontexture_p.h \
$$PWD/dragontrackingchangescontainer_p.h \
@@ -34,7 +34,6 @@ HEADERS += \
$$PWD/dragongltexture_p.h \
$$PWD/dragongltypehelpers_p.h \
$$PWD/dragonoffscreensurfacehelper_p.h \
- $$PWD/dragonmanager_p.h \
$$PWD/dragontask_p.h \
$$PWD/qdragonrenderaspect_p.h \
$$PWD/dragonparameterpack_p.h \
@@ -46,10 +45,11 @@ HEADERS += \
$$PWD/dragonimmutable_p.h \
$$PWD/dragonmutable_p.h \
$$PWD/dragoncomparegenerators_p.h \
- $$PWD/dragontextureproperties_p.h
+ $$PWD/dragontextureproperties_p.h \
+ $$PWD/dragonscene2d_p.h
SOURCES += \
- $$PWD/dragonattachmentpack.cpp \
+ $$PWD/dragonattachment.cpp \
$$PWD/dragonbackendnode.cpp \
$$PWD/dragontexture.cpp \
$$PWD/dragontrackingchangescontainer.cpp \
@@ -74,5 +74,5 @@ SOURCES += \
$$PWD/dragonrenderbuffer.cpp \
$$PWD/dragonactivatedsurface.cpp \
$$PWD/dragonoptional.cpp \
- $$PWD/dragonstringtoint.cpp
-
+ $$PWD/dragonstringtoint.cpp \
+ $$PWD/dragonscene2d.cpp
diff --git a/src/runtime/dragon/dragonactivatedsurface.cpp b/src/runtime/dragon/dragonactivatedsurface.cpp
index 2d79a94..9699c5c 100644
--- a/src/runtime/dragon/dragonactivatedsurface.cpp
+++ b/src/runtime/dragon/dragonactivatedsurface.cpp
@@ -65,9 +65,6 @@
// Qt3DRender::Render
#include <Qt3DRender/private/platformsurfacefilter_p.h>
-#include <Qt3DCore/QNodeId>
-
-#include <QOpenGLContext>
#include <QSurface>
#include <QWindow>
#include <qcullface.h>
@@ -237,41 +234,29 @@ ActivatedSurface::~ActivatedSurface()
m_glContext->doneCurrent();
}
-bool ActivatedSurface::isValid()
+bool ActivatedSurface::isValid() const
{
return m_valid;
}
-void ActivatedSurface::setGlHelper(QSharedPointer<Dragon::GraphicsHelperInterface> helper)
-{
- m_glHelper = helper;
-}
-
void ActivatedSurface::clearBackBuffer(const ClearBackBufferInfo &info)
{
auto clearBufferTypes = info.buffers;
if (clearBufferTypes & QClearBuffers::ColorBuffer) {
const QVector4D vCol = info.color;
const QColor color = QColor::fromRgbF(vCol.x(), vCol.y(), vCol.z(), vCol.w());
- if (m_clearColor != color) {
- m_clearColor = color;
- m_glContext->functions()->glClearColor(color.redF(),
- color.greenF(),
- color.blueF(),
- color.alphaF());
- }
+ m_glContext->functions()->glClearColor(color.redF(),
+ color.greenF(),
+ color.blueF(),
+ color.alphaF());
}
if (clearBufferTypes & QClearBuffers::DepthBuffer) {
const float depth = info.depth;
- if (m_clearDepth != depth) {
- m_glContext->functions()->glClearDepthf(depth);
- }
+ m_glContext->functions()->glClearDepthf(depth);
}
if (clearBufferTypes & QClearBuffers::StencilBuffer) {
const int stencil = info.stencil;
- if (m_clearStencil != stencil) {
- m_glContext->functions()->glClearStencil(stencil);
- }
+ m_glContext->functions()->glClearStencil(stencil);
}
if (clearBufferTypes != QClearBuffers::None) {
@@ -288,24 +273,6 @@ void ActivatedSurface::clearBackBuffer(const ClearBackBufferInfo &info)
}
}
-bool ActivatedSurface::activateShader(const Immutable<GLShader> &shader)
-{
- if (shader->dna == m_activeShaderDNA) {
- return true;
- }
-
- // TODO consider m_material
- // // Ensure material uniforms are re-applied
- // m_material = nullptr;
-
- // TODO do we need to store the active shader?
- // m_activeShader = shader;
-
- shader->shaderProgram->bind();
- m_activeShaderDNA = shader->dna;
- return true;
-}
-
void ActivatedSurface::applyUniform(const ShaderUniform &description, const UniformValue &v)
{
const UniformType type = m_glHelper->uniformTypeFromGLType(description.m_type);
@@ -472,13 +439,13 @@ UniformValue standardUniformValue(StandardUniform standardUniformType,
return UniformValue(convertToQMatrix4x4(cameraMatrices->viewMatrix * model).normalMatrix());
case ViewportMatrix: {
QMatrix4x4 viewportMatrix;
- // TO DO: Implement on Matrix4x4
+ // TODO: Implement on Matrix4x4
viewportMatrix.viewport(resolveViewport(renderView->viewport, renderView->surfaceSize));
return UniformValue(Matrix4x4(viewportMatrix));
}
case InverseViewportMatrix: {
QMatrix4x4 viewportMatrix;
- // TO DO: Implement on Matrix4x4
+ // TODO: Implement on Matrix4x4
viewportMatrix.viewport(resolveViewport(renderView->viewport, renderView->surfaceSize));
return UniformValue(Matrix4x4(viewportMatrix.inverted()));
}
@@ -506,143 +473,8 @@ UniformValue standardUniformValue(StandardUniform standardUniformType,
}
default:
Q_UNREACHABLE();
- return UniformValue();
- }
-}
-
-bool ActivatedSurface::bindParameters(const Immutable<RenderView> &renderView,
- const Immutable<CameraMatrices> &cameraMatrices,
- const MutableContainer<GLBuffer> &glBuffers,
- const MutableContainer<GLTexture> &glTextures,
- int maxTextureImageUnits,
- const Immutable<GLShader> &glShader,
- const Immutable<Matrix4x4> &worldTransform,
- const ParameterNameToParameterMap &parameterMap)
-{
- // ParameterMap = nameId -> parameter for current command
-
- // Set standard uniforms
- // TODO Once we have shader graphs, we should put standard uniforms in a uniform buffer object
- // and emulate UBOs on hardware that doesn't support it, including unrolling them in the
- // shaders
- for (const auto &standardShaderUniform : glShader->standardUniforms) {
- const auto &shaderUniform = standardShaderUniform.shaderUniform;
- const auto &setter = standardShaderUniform.standardUniform;
- UniformValue uniformValue = standardUniformValue(setter, renderView, cameraMatrices, *worldTransform);
- applyUniform(shaderUniform, uniformValue);
- }
-
- // Keep track of the currently bound texture unit
- int unit = 0;
- // TODO: In OpenGL 4.4+, there is bindTextures(), which we could add to our graphics helpers:
- // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindTextures.xhtml
- for (const auto &shaderUniform : glShader->uniforms) { // scalars and textures
- // TODO consider returning the result of this in cases where the parameters have not changed,
- // so that we can reuse the same parameter and avoid looking it up every frame. The returned
- // result can be stored in a map in the Frame
- const auto &parameterIt = parameterMap.constFind(shaderUniform.m_nameId);
- if (parameterIt == parameterMap.cend())
- continue;
-
- const auto &parameter = parameterIt.value();
- const auto &uniformValue = parameter->uniformValue();
-
- if (uniformValue.valueType() != UniformValue::NodeId) {
- applyUniform(shaderUniform, uniformValue);
- continue;
- }
-
- // At this point a uniform value can only be a scalar type
- // or a Qt3DCore::QNodeId corresponding to a Texture
- // ShaderData/Buffers would be handled as UBO/SSBO and would therefore
- // not be in the default uniform block
-
- const QNodeId *nodeIds = uniformValue.constData<QNodeId>();
- const int uniformArraySize = uint(uniformValue.byteSize()) / sizeof(QNodeId);
- for (int i = 0; i < uniformArraySize; ++i) {
- const QNodeId texId = nodeIds[i];
- if (texId.isNull()) {
- qDebug() << "Got null texId, skipping";
- // TODO this entire implementation is a bit fragile. Consider making UniformValue
- // store data in a more type-safe way for QNodeIds
- continue;
- }
-
- Q_ASSERT(glTextures.contains(texId));
- const auto &texture = glTextures[texId];
- // Q_ASSERT(texture->openGLTexture != nullptr);
-
- if (texture->openGLTexture == nullptr) {
- // TODO current valid case for this is when the format is automatic, however,
- // we need to investigate where this is used and why we should skip at this point
- continue;
- }
-
- ShaderParameterPack::NamedTexture namedTex(shaderUniform.m_nameId, texId, i);
-
- UniformValue textureValue(uniformArraySize * sizeof(int), UniformValue::TextureValue);
- std::fill(textureValue.data<int>(), textureValue.data<int>() + uniformArraySize, -1);
-
- if (unit >= maxTextureImageUnits) {
- // TODO: Check this earlier and skip rendering completely if this is the case.
- qWarning() << "WARNING: Max number of texture units exhausted,"
- << "GL_MAX_TEXTURE_IMAGE_UNITS:" << maxTextureImageUnits
- << "Texture cannot be bound.";
- continue;
- }
- // NOTE: Qt3D used to have some logic to keep track of bound textures to avoid
- // re-binding. However, this introduced additional complexity and caused performance
- // problems on the CPU side. We should consider adding back some of this logic
- // if it turns out to be beneficial for performance. However, considering that
- // glBindTextures no longer uses glActiveTexture, it seems likely that there is
- // no need for this.
- texture->openGLTexture->bind(GLuint(unit));
-
- textureValue.data<int>()[namedTex.uniformArrayIndex] = unit;
- applyUniform(shaderUniform, textureValue);
-
- unit += 1;
- }
- }
-
- GLuint uboIndex = 0;
- for (const auto &shaderUniformBlock : glShader->uniformBlocks) {
- const auto &parameterIt = parameterMap.constFind(shaderUniformBlock.m_nameId);
- if (parameterIt == parameterMap.cend())
- continue;
-
- const auto &parameter = parameterIt.value();
- const auto &uniformValue = parameter->uniformValue();
- if (uniformValue.valueType() != UniformValue::NodeId) {
- // TODO might be a bit spammy to send this to the output
- qWarning()
- << "WARNING: Found UniformBlock with corresponding parameter that was not of UniformValue::NodeId type. This is not supported";
- }
-
- const auto &bufferId = *uniformValue.constData<QNodeId>();
- Q_ASSERT(glBuffers.contains(bufferId));
- const auto &glBuffer = glBuffers[bufferId];
-
- // TODO always zero, consider using other locations...
- // TODO Make sure that there's enough binding points
- const GLuint blockIndex = GLuint(shaderUniformBlock.m_index);
- const GLuint programId = glShader->shaderProgram->programId();
- m_glHelper->bindUniformBlock(programId, blockIndex, uboIndex);
- // Needed to avoid conflict where the buffer would already be bound as a VertexArray
- const auto glType = glBufferTypes[GLBuffer::UniformBuffer];
- m_glContext->functions()->glBindBuffer(glType, glBuffer->bufferId());
- m_glHelper->bindBufferBase(glType, uboIndex++, glBuffer->bufferId());
- // Buffer update to GL buffer will be done at render time
- }
-
- for (const auto &shaderStorageBlock : glShader->storageBlocks) {
- // TODO add support for shader storage blocks
- Q_UNUSED(shaderStorageBlock)
- qWarning() << "WARNING: Shader storage blocks are not yet supported";
}
-
- // if not all data is valid, the next frame will be rendered immediately
- return true;
+ return UniformValue();
}
bool ActivatedSurface::bindVertexArrayObject(const Immutable<GLVertexArrayObject> &vao)
@@ -684,11 +516,6 @@ Immutable<GLVertexArrayObject> ActivatedSurface::createVertexArrayObject(
}
vao.m_owners = key;
- // TODO actually check if geometry is dirty
-
- // TODO verify that the shader does not need to be bound to create a vertex array object
-// activateShader(uploadedShader);
-
// TODO return bound vao for other commands to use or just move internals here
const auto attributeIds = geometry->attributes();
@@ -698,8 +525,6 @@ Immutable<GLVertexArrayObject> ActivatedSurface::createVertexArrayObject(
const auto &glBuffer = uploadedBuffers[attribute->bufferId()];
const auto attributeType = attributeTypeToGLBufferType(attribute->attributeType());
- // TODO get GlBuffer
-
// Index Attribute
bool attributeWasDirty = attributes.dirtyOrNew().contains(attributeId);
@@ -759,7 +584,6 @@ Immutable<GLVertexArrayObject> ActivatedSurface::createVertexArrayObject(
}
GLVertexArrayObject::VAOVertexAttribute attr;
-// attr.bufferHandle = glBuffer;
attr.attributeType = attributeType;
attr.dataType = attributeDataType;
attr.divisor = attribute->divisor();
@@ -812,21 +636,6 @@ void ActivatedSurface::memoryBarrier(const QMemoryBarrier::Operations &operation
// TODO Review (make more functional?)
void ActivatedSurface::activateRenderTarget(GLuint fboId, const AttachmentPack &attachments)
{
- // GLuint fboId = lastBoundFBOId; // we will revert to this if we did not get an FBO id
- // if (renderTargetNodeId) {
- // // New RenderTarget
- // if (!m_renderTargets.contains(renderTargetNodeId)) {
- // if (m_defaultFBO != 0 && fboId == m_defaultFBO) {
- // // this is the default fbo that some platforms create (iOS), we just register it
- // // Insert FBO into hash
- // m_renderTargets.insert(renderTargetNodeId, fboId);
- // } else {
- // fboId = createRenderTarget(renderTargetNodeId, attachments, glTextures);
- // }
- // } else {
- // fboId = updateRenderTarget(renderTargetNodeId, attachments, true, glTextures);
- // }
- // }
m_activeFBO = fboId;
m_glHelper->bindFrameBufferObject(m_activeFBO, GraphicsHelperInterface::FBODraw);
// Set active drawBuffers
@@ -836,12 +645,13 @@ void ActivatedSurface::activateRenderTarget(GLuint fboId, const AttachmentPack &
// TODO Review (make more functional?)
void ActivatedSurface::activateDrawBuffers(const AttachmentPack &attachments)
{
- const QVector<int> activeDrawBuffers = attachments.drawBuffers;
-
if (!m_glHelper->checkFrameBufferComplete()) {
qWarning() << "WARNING: FBO incomplete";
return;
}
+
+ const QVector<int> activeDrawBuffers = attachments.drawBuffers;
+
if (activeDrawBuffers.size() <= 1)
return;
// We need MRT if the number is more than 1
@@ -854,15 +664,6 @@ void ActivatedSurface::activateDrawBuffers(const AttachmentPack &attachments)
m_glHelper->drawBuffers(activeDrawBuffers.size(), activeDrawBuffers.data());
}
-bool ActivatedSurface::bindGLBuffer(const Mutable<GLBuffer> &buffer, GLBuffer::Type type)
-{
- // TODO DO NOT USE
- // TODO only bind in functions that need it, and immediately release when finished calling
- Q_UNUSED(buffer)
- Q_UNUSED(type)
- return true;
-}
-
// TODO Review (make more functional?)
GLuint ActivatedSurface::createRenderTarget(Qt3DCore::QNodeId renderTargetNodeId,
const AttachmentPack &attachments,
@@ -885,7 +686,6 @@ GLuint ActivatedSurface::createRenderTarget(Qt3DCore::QNodeId renderTargetNodeId
// TODO Review (make more functional?)
GLuint ActivatedSurface::updateRenderTarget(Qt3DCore::QNodeId renderTargetNodeId,
const AttachmentPack &attachments,
- bool isActiveRenderTarget,
const MutableContainer<GLTexture> &glTextures)
{
Q_ASSERT(m_renderTargets.contains(renderTargetNodeId));
@@ -907,10 +707,6 @@ GLuint ActivatedSurface::updateRenderTarget(Qt3DCore::QNodeId renderTargetNodeId
}
const auto &glTexture = glTextures[attachment->textureUuid];
needsResize |= (glTexture->size() != s);
- if (isActiveRenderTarget) {
- if (attachment->point == QRenderTargetOutput::Color0)
- m_renderTargetFormat = glTexture->properties.format;
- }
}
}
@@ -922,7 +718,7 @@ GLuint ActivatedSurface::updateRenderTarget(Qt3DCore::QNodeId renderTargetNodeId
return fboId;
}
-void ActivatedSurface::viewport(const QRectF &viewport, const QSize &surfaceSize)
+void ActivatedSurface::setViewport(const QRectF &viewport, const QSize &surfaceSize)
{
// save for later use; this has nothing to do with the viewport but it is
// here that we get to know the surfaceSize from the RenderView.
@@ -1061,7 +857,7 @@ QSize ActivatedSurface::renderTargetSize(const QSize &surfaceSize) const
return renderTargetSize;
}
-GraphicsApiFilterData ActivatedSurface::contextInfo()
+GraphicsApiFilterData ActivatedSurface::contextInfo() const
{
GraphicsApiFilterData result;
QStringList extensions;
@@ -1103,11 +899,12 @@ QSharedPointer<Dragon::GraphicsHelperInterface> ActivatedSurface::resolveHighest
#ifndef QT_OPENGL_ES_2
else {
QAbstractOpenGLFunctions *glFunctions = nullptr;
- // TODO clean up
-/* if ((glFunctions = m_glContext->versionFunctions<QOpenGLFunctions_4_3_Core>()) != nullptr) {
- qCDebug(Render::Backend) << Q_FUNC_INFO << " Building OpenGL 4.3";
+ // TODO: Note that max OpenGL backend is currently GL3_3, check 4.3 behavior
+ /*if ((glFunctions = m_glContext->versionFunctions<QOpenGLFunctions_4_3_Core>())
+ != nullptr) {
+ //qCDebug(Render::Backend) << Q_FUNC_INFO << " Building OpenGL 4.3";
glHelper.reset(new Dragon::GraphicsHelperGL4());
- } else*/ if ((glFunctions = m_glContext->versionFunctions<QOpenGLFunctions_3_3_Core>())
+ } else */ if ((glFunctions = m_glContext->versionFunctions<QOpenGLFunctions_3_3_Core>())
!= nullptr) {
//qCDebug(Render::Backend) << Q_FUNC_INFO << " Building OpenGL 3.3";
glHelper.reset(new Dragon::GraphicsHelperGL3_3());
@@ -1127,9 +924,6 @@ QSharedPointer<Dragon::GraphicsHelperInterface> ActivatedSurface::resolveHighest
}
#endif
- // Set Vendor and Extensions of reference GraphicsApiFilter
- // TO DO: would that vary like the glHelper ?
-
return glHelper;
}
@@ -1473,7 +1267,7 @@ void ActivatedSurface::applyState(const StateVariant &stateVariant)
void ActivatedSurface::resetMasked(qint64 maskOfStatesToReset)
{
- // TO DO -> Call gcHelper methods instead of raw GL
+ // TODO -> Call gcHelper methods instead of raw GL
// QOpenGLFunctions shouldn't be used here directly
QOpenGLFunctions *funcs = m_glContext->functions();
@@ -1576,7 +1370,7 @@ void ActivatedSurface::blitFramebuffer(const BlitFramebufferInfo &blitFramebuffe
if (inputTarget.has_value()) {
const auto &inputRenderTarget = inputTarget.get();
if (m_renderTargets.contains(inputRenderTarget->peerId()))
- inputFboId = updateRenderTarget(inputRenderTarget->peerId(), inputAttachments.get(), false, glTextures);
+ inputFboId = updateRenderTarget(inputRenderTarget->peerId(), inputAttachments.get(), glTextures);
else
inputFboId = createRenderTarget(inputRenderTarget->peerId(), inputAttachments.get(), glTextures);
inputBufferIsDefault = false;
@@ -1587,7 +1381,7 @@ void ActivatedSurface::blitFramebuffer(const BlitFramebufferInfo &blitFramebuffe
if (outputTarget.has_value()) {
const auto &outputRenderTarget = outputTarget.get();
if (m_renderTargets.contains(outputRenderTarget->peerId()))
- outputFboId = updateRenderTarget(outputRenderTarget->peerId(), outputAttachments.get(), false, glTextures);
+ outputFboId = updateRenderTarget(outputRenderTarget->peerId(), outputAttachments.get(), glTextures);
else
outputFboId = createRenderTarget(outputRenderTarget->peerId(), outputAttachments.get(), glTextures);
outputBufferIsDefault = false;
diff --git a/src/runtime/dragon/dragonactivatedsurface_p.h b/src/runtime/dragon/dragonactivatedsurface_p.h
index 20cd3b3..1afaa39 100644
--- a/src/runtime/dragon/dragonactivatedsurface_p.h
+++ b/src/runtime/dragon/dragonactivatedsurface_p.h
@@ -30,8 +30,6 @@
#ifndef ACTIVATEDSURFACE_P_H
#define ACTIVATEDSURFACE_P_H
-#include <private/dragonoptional_p.h>
-
#include <Qt3DRender/qabstracttexture.h>
#include <Qt3DRender/qmemorybarrier.h>
@@ -108,69 +106,59 @@ public:
~ActivatedSurface();
- bool isValid();
- void setGlHelper(QSharedPointer<Dragon::GraphicsHelperInterface> helper);
+ bool isValid() const;
+
// TODO this is not really const and needs a better solution
Dragon::GraphicsHelperInterface *glHelper() const { return m_glHelper.data(); }
- QSharedPointer<Dragon::GraphicsHelperInterface> resolveHighestOpenGLFunctions() const;
// commands
void clearBackBuffer(const ClearBackBufferInfo &info);
void memoryBarrier(const QMemoryBarrier::Operations &operations);
void activateRenderTarget(GLuint fboId,
const AttachmentPack &attachments);
- void viewport(const QRectF &viewport, const QSize &surfaceSize);
+ void setViewport(const QRectF &viewport, const QSize &surfaceSize);
Immutable<GLVertexArrayObject> createVertexArrayObject(VAOIdentifier key,
const Mutable<GLShader> &uploadedShader,
const Immutable<Geometry> &geometry,
const ValueContainer<Attribute> &attributes,
const MutableContainer<GLBuffer> &uploadedBuffers);
- GraphicsApiFilterData contextInfo();
+ GraphicsApiFilterData contextInfo() const;
- bool activateShader(const Immutable<GLShader> &shader);
- bool bindVertexArrayObject(const Immutable<GLVertexArrayObject> &vao);
+ QOpenGLContext *openGLContext() const;
- GLBuffer createGLBuffer(const Immutable<LoadedBuffer> &buffer);
- bool bindGLBuffer(const Mutable<GLBuffer> &buffer, GLBuffer::Type type);
- bool bindParameters(const Immutable<RenderView> &renderView, const Immutable<CameraMatrices> &cameraMatrices, const MutableContainer<GLBuffer> &glBuffers,
- const MutableContainer<GLTexture> &glTextures, int maxTextureImageUnits,
- const Immutable<GLShader> &glShader, const Immutable<Matrix4x4> &worldTransform,
- const ParameterNameToParameterMap &parameterMap);
+ QSize bindFrameBufferAttachmentHelper(GLuint fboId,
+ const AttachmentPack &attachments,
+ const MutableContainer<GLTexture> &glTextures);
-// bool performDraw(const RenderCommand &command,
-// const Value<GLShader> &glShader,
-// const ValueContainer<Attribute> &attributes, const Value<GLVertexArrayObject> &vao);
- QOpenGLContext *openGLContext() const;
- // TODO make private
- void applyState(const StateVariant &stateVariant);
+ DrawContext beginDrawing(bool autoSwapBuffers);
- // TODO consider moving where they are used
+ void blitFramebuffer(const BlitFramebufferInfo &blitFramebufferInfo, uint defaultFboId, const MutableContainer<GLTexture> &glTextures);
+ RenderStateSet applyStateSet(const RenderStateSet &previous, const RenderStateSet &next);
+
+private:
+
+ void applyState(const StateVariant &stateVariant);
+ QSharedPointer<Dragon::GraphicsHelperInterface> resolveHighestOpenGLFunctions() const;
+ bool bindVertexArrayObject(const Immutable<GLVertexArrayObject> &vao);
GLuint createRenderTarget(Qt3DCore::QNodeId renderTargetNodeId,
const AttachmentPack &attachments,
const MutableContainer<GLTexture> &glTextures);
GLuint updateRenderTarget(Qt3DCore::QNodeId renderTargetNodeId,
const AttachmentPack &attachments,
- bool isActiveRenderTarget,
const MutableContainer<GLTexture> &glTextures);
- QSize bindFrameBufferAttachmentHelper(GLuint fboId,
- const AttachmentPack &attachments,
- const MutableContainer<GLTexture> &glTextures);
void activateDrawBuffers(const AttachmentPack &attachments);
// Parameter/uniform functions
void applyUniform(const ShaderUniform &description, const UniformValue &v);
- DrawContext beginDrawing(bool autoSwapBuffers);
+ QSize renderTargetSize(const QSize &surfaceSize) const;
+
+ template<UniformType>
+ void applyUniformHelper(const ShaderUniform &, const UniformValue &) const
+ {
+ Q_ASSERT_X(false, Q_FUNC_INFO, "Uniform: Didn't provide specialized apply() implementation");
+ }
+ void resetMasked(qint64 maskOfStatesToReset);
- void blitFramebuffer(const BlitFramebufferInfo &blitFramebufferInfo, uint defaultFboId, const MutableContainer<GLTexture> &glTextures);
- RenderStateSet applyStateSet(const RenderStateSet &previous, const RenderStateSet &next);
-private:
- // Cached clear data
- Optional<QColor> m_clearColor;
- Optional<float> m_clearDepth;
- Optional<int> m_clearStencil;
- // Cached shader data
- ProgramDNA m_activeShaderDNA = 0;
- // TODO difference between currentSurface and surface is what?
QSurface *m_surface = nullptr;
bool m_valid = false;
QSharedPointer<Dragon::GraphicsHelperInterface> m_glHelper;
@@ -179,35 +167,21 @@ private:
GLuint m_activeFBO = 0;
// Render targets
- // QHash<Qt3DCore::QNodeId, HGLBuffer> m_renderBufferHash;
QHash<Qt3DCore::QNodeId, GLuint> m_renderTargets;
QHash<GLuint, QSize> m_renderTargetsSize;
- QAbstractTexture::TextureFormat m_renderTargetFormat;
// Context
bool m_supportsVAO = false;
GLuint m_defaultFBO = 0;
-
- // TODO consider removing
QSize m_surfaceSize;
QRectF m_viewport;
- // TODO reconsider active textures strategy
- Immutable<RenderStateSet> m_currentStateSet;
-
// Set to be mutable because some functions don't change the state, but still
// need to access the context. Note that mutable is strictly not necessary
// because it's a pointer.
mutable QOpenGLContext *m_glContext = nullptr;
- QSize renderTargetSize(const QSize &surfaceSize) const;
- template<UniformType>
- void applyUniformHelper(const ShaderUniform &, const UniformValue &) const
- {
- Q_ASSERT_X(false, Q_FUNC_INFO, "Uniform: Didn't provide specialized apply() implementation");
- }
- void resetMasked(qint64 maskOfStatesToReset);
};
// TODO consider a template-only (macro-free) implementation
diff --git a/src/runtime/dragon/dragonattachmentpack.cpp b/src/runtime/dragon/dragonattachment.cpp
index 83ae952..e950022 100644
--- a/src/runtime/dragon/dragonattachmentpack.cpp
+++ b/src/runtime/dragon/dragonattachment.cpp
@@ -28,7 +28,7 @@
**
****************************************************************************/
-#include "dragonattachmentpack_p.h"
+#include "dragonattachment_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/runtime/dragon/jobs/dragonshaderjobs_p.h b/src/runtime/dragon/dragonattachment_p.h
index e7aa448..ce86d45 100644
--- a/src/runtime/dragon/jobs/dragonshaderjobs_p.h
+++ b/src/runtime/dragon/dragonattachment_p.h
@@ -28,8 +28,8 @@
**
****************************************************************************/
-#ifndef SHADERJOBS_P_H
-#define SHADERJOBS_P_H
+#ifndef QT3DRENDER_RENDER_ATTACHMENT_P_H
+#define QT3DRENDER_RENDER_ATTACHMENT_P_H
//
// W A R N I N G
@@ -42,21 +42,34 @@
// We mean it.
//
-#include <private/dragonvaluecontainer_p.h>
+#include <Qt3DRender/qrendertargetoutput.h>
+#include <QVector>
QT_BEGIN_NAMESPACE
namespace Qt3DRender {
namespace Dragon {
-class Shader;
-struct GLShader;
+struct Attachment
+{
+ Attachment()
+ : m_mipLevel(0)
+ , m_layer(0)
+ , m_point(QRenderTargetOutput::Color0)
+ , m_face(QAbstractTexture::CubeMapNegativeX)
+ {}
+
+ QString m_name;
+ int m_mipLevel;
+ int m_layer;
+ Qt3DCore::QNodeId m_textureUuid;
+ QRenderTargetOutput::AttachmentPoint m_point;
+ QAbstractTexture::CubeMapFace m_face;
+};
-ValueContainer<GLShader> uploadShaders(ValueContainer<GLShader> uploadedShaders,
- const ValueContainer<Shader> &shader);
} // namespace Dragon
} // namespace Qt3DRender
QT_END_NAMESPACE
-#endif // SHADERJOBS_P_H
+#endif // QT3DRENDER_RENDER_ATTACHMENT_P_H
diff --git a/src/runtime/dragon/dragonattachmentpack_p.h b/src/runtime/dragon/dragonattachmentpack_p.h
deleted file mode 100644
index f0cd7e4..0000000
--- a/src/runtime/dragon/dragonattachmentpack_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_RENDER_ATTACHMENTPACK_P_H
-#define QT3DRENDER_RENDER_ATTACHMENTPACK_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/qrendertargetoutput.h>
-#include <QVector>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-namespace Dragon {
-
-struct Attachment
-{
- Attachment()
- : m_mipLevel(0)
- , m_layer(0)
- , m_point(QRenderTargetOutput::Color0)
- , m_face(QAbstractTexture::CubeMapNegativeX)
- {}
-
- QString m_name;
- int m_mipLevel;
- int m_layer;
- Qt3DCore::QNodeId m_textureUuid;
- QRenderTargetOutput::AttachmentPoint m_point;
- QAbstractTexture::CubeMapFace m_face;
-};
-
-class RenderTarget;
-class RenderTargetSelector;
-class AttachmentManager;
-
-
-//class AttachmentPack
-//{
-//public:
-// AttachmentPack();
-// AttachmentPack(const RenderTarget *target,
-// AttachmentManager *attachmentManager,
-// const QVector<QRenderTargetOutput::AttachmentPoint> &drawBuffers = QVector<QRenderTargetOutput::AttachmentPoint>());
-
-// QVector<Attachment> attachments() const { return m_attachments; }
-// QVector<int> getGlDrawBuffers() const { return m_drawBuffers; }
-
-// // return index of given attachment within actual draw buffers list
-// int getDrawBufferIndex(QRenderTargetOutput::AttachmentPoint attachmentPoint) const;
-
-//private:
-// QVector<Attachment> m_attachments;
-// QVector<int> m_drawBuffers;
-//};
-
-} // namespace Dragon
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // QT3DRENDER_RENDER_ATTACHMENTPACK_P_H
diff --git a/src/runtime/dragon/dragonentity.cpp b/src/runtime/dragon/dragonentity.cpp
index f026f8e..2ffee1c 100644
--- a/src/runtime/dragon/dragonentity.cpp
+++ b/src/runtime/dragon/dragonentity.cpp
@@ -38,6 +38,7 @@
#include <Qt3DRender/qmaterial.h>
#include <Qt3DCore/qcomponentaddedchange.h>
+#include <Qt3DCore/qcomponentremovedchange.h>
#include <Qt3DCore/qnodecreatedchange.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DCore/qtransform.h>
@@ -86,6 +87,13 @@ void Entity::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
addComponent(componentIdAndType);
break;
}
+ case ComponentRemoved: {
+ QComponentRemovedChangePtr change = qSharedPointerCast<QComponentRemovedChange>(e);
+ removeComponent(change->componentId());
+ markDirty();
+ break;
+ }
+
case PropertyValueAdded: {
QPropertyNodeAddedChangePtr change = qSharedPointerCast<QPropertyNodeAddedChange>(e);
if (change->metaObject()->inherits(&QEntity::staticMetaObject)) {
@@ -166,6 +174,37 @@ void Entity::addComponent(Qt3DCore::QNodeIdTypePair idAndType)
markDirty();
}
+void Entity::removeComponent(QNodeId nodeId)
+{
+ if (m_transformComponent == nodeId) {
+ m_transformComponent = QNodeId();
+ } else if (m_cameraLensComponent == nodeId) {
+ m_cameraLensComponent = QNodeId();
+ } else if (m_layerComponents.contains(nodeId)) {
+ m_layerComponents.removeAll(nodeId);
+ } else if (m_levelOfDetailComponents.contains(nodeId)) {
+ m_levelOfDetailComponents.removeAll(nodeId);
+ } else if (m_rayCasterComponents.contains(nodeId)) {
+ m_rayCasterComponents.removeAll(nodeId);
+ } else if (m_materialComponent == nodeId) {
+ m_materialComponent = QNodeId();
+ } else if (m_shaderDataComponents.contains(nodeId)) {
+ m_shaderDataComponents.removeAll(nodeId);
+ } else if (m_geometryRendererComponent == nodeId) {
+ m_geometryRendererComponent = QNodeId();
+ } else if (m_objectPickerComponent == nodeId) {
+ m_objectPickerComponent = QNodeId();
+ } else if (m_lightComponents.contains(nodeId)) {
+ m_lightComponents.removeAll(nodeId);
+ } else if (m_environmentLightComponents.contains(nodeId)) {
+ m_environmentLightComponents.removeAll(nodeId);
+ } else if (m_computeComponent == nodeId) {
+ m_computeComponent = QNodeId();
+ } else if (m_armatureComponent == nodeId) {
+ m_armatureComponent = QNodeId();
+ }
+}
+
Qt3DCore::QNodeId Entity::parentId() const
{
return m_parentEntityId;
diff --git a/src/runtime/dragon/dragonentity_p.h b/src/runtime/dragon/dragonentity_p.h
index abd8957..2b15fdb 100644
--- a/src/runtime/dragon/dragonentity_p.h
+++ b/src/runtime/dragon/dragonentity_p.h
@@ -63,33 +63,33 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
void addComponent(Qt3DCore::QNodeIdTypePair idAndType);
+ void removeComponent(Qt3DCore::QNodeId nodeId);
Qt3DCore::QNodeId parentId() const;
Qt3DCore::QNodeId cameraLensComponent() const;
+ // TODO not so happy about this, only needed for tree building
+ Qt3DCore::QNodeIdVector treeChildren() const { return m_childEntityIds; }
+
QVector<Qt3DCore::QNodeId> m_childEntityIds;
+ Qt3DCore::QNodeId m_materialComponent;
+ QVector<Qt3DCore::QNodeId> m_layerComponents;
+ Qt3DCore::QNodeId m_transformComponent;
+ Qt3DCore::QNodeId m_geometryRendererComponent;
+ bool m_enabled = true;
-//private:
+private:
Qt3DCore::QNodeId m_parentEntityId;
- Qt3DCore::QNodeId m_transformComponent;
- Qt3DCore::QNodeId m_materialComponent;
Qt3DCore::QNodeId m_cameraLensComponent;
- QVector<Qt3DCore::QNodeId> m_layerComponents;
QVector<Qt3DCore::QNodeId> m_levelOfDetailComponents;
QVector<Qt3DCore::QNodeId> m_rayCasterComponents;
QVector<Qt3DCore::QNodeId> m_shaderDataComponents;
QVector<Qt3DCore::QNodeId> m_lightComponents;
QVector<Qt3DCore::QNodeId> m_environmentLightComponents;
- Qt3DCore::QNodeId m_geometryRendererComponent;
Qt3DCore::QNodeId m_objectPickerComponent;
Qt3DCore::QNodeId m_boundingVolumeDebugComponent;
Qt3DCore::QNodeId m_computeComponent;
Qt3DCore::QNodeId m_armatureComponent;
-
- bool m_enabled = true;
-
- // TODO not so happy about this, only needed for tree building
- Qt3DCore::QNodeIdVector treeChildren() const { return m_childEntityIds; }
};
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/dragonglbuffer.cpp b/src/runtime/dragon/dragonglbuffer.cpp
index 93a73e4..98bca2e 100644
--- a/src/runtime/dragon/dragonglbuffer.cpp
+++ b/src/runtime/dragon/dragonglbuffer.cpp
@@ -57,16 +57,17 @@ GLBuffer::GLBuffer(const ActivatedSurface &surface, const Immutable<LoadedBuffer
: m_glContext(surface.openGLContext())
{
GLuint bufferId = 0;
- m_glContext->functions()->glGenBuffers(1, &bufferId);
+ QOpenGLFunctions *f = m_glContext->functions();
+ f->glGenBuffers(1, &bufferId);
// Since we are uploading, the type doesn't matter
GLenum glType = GL_ARRAY_BUFFER;
- m_glContext->functions()->glBindBuffer(glType, bufferId);
+ f->glBindBuffer(glType, bufferId);
// TODO: Why do we first orphan the buffer?
- m_glContext->functions()->glBufferData(glType, buffer->data.size(), nullptr, GL_STATIC_DRAW);
- m_glContext->functions()->glBufferData(glType,
- buffer->data.size(),
- buffer->data.constData(),
- GL_STATIC_DRAW);
+ f->glBufferData(glType, buffer->data.size(), nullptr, GL_STATIC_DRAW);
+ f->glBufferData(glType,
+ buffer->data.size(),
+ buffer->data.constData(),
+ GL_STATIC_DRAW);
m_bufferId = bufferId;
}
@@ -92,21 +93,20 @@ GLBuffer::~GLBuffer()
GLuint GLBuffer::bufferId() const
{
- // Q_ASSERT(m_resource != nullptr);
- // return m_resource->m_bufferId;
return m_bufferId;
}
void GLBuffer::reload(const Immutable<LoadedBuffer> &loadedBuffer)
{
GLenum glType = GL_ARRAY_BUFFER;
- m_glContext->functions()->glBindBuffer(glType, m_bufferId);
- m_glContext->functions()->glBufferData(glType, loadedBuffer->data.size(),
- nullptr,
- GL_STATIC_DRAW);
- m_glContext->functions()->glBufferData(glType, loadedBuffer->data.size(),
- loadedBuffer->data.constData(),
- GL_STATIC_DRAW);
+ QOpenGLFunctions *f = m_glContext->functions();
+ f->glBindBuffer(glType, m_bufferId);
+ f->glBufferData(glType, loadedBuffer->data.size(),
+ nullptr,
+ GL_STATIC_DRAW);
+ f->glBufferData(glType, loadedBuffer->data.size(),
+ loadedBuffer->data.constData(),
+ GL_STATIC_DRAW);
}
} // namespace Dragon
diff --git a/src/runtime/dragon/dragonglbuffer_p.h b/src/runtime/dragon/dragonglbuffer_p.h
index ca64c7d..54fcb30 100644
--- a/src/runtime/dragon/dragonglbuffer_p.h
+++ b/src/runtime/dragon/dragonglbuffer_p.h
@@ -76,17 +76,13 @@ struct GLBuffer
~GLBuffer();
GLuint bufferId() const;
- void init();
+ void reload(const Immutable<LoadedBuffer> &loadedBuffer);
+
+private:
GLuint m_bufferId = 0;
QOpenGLContext *m_glContext = nullptr;
Immutable<LoadedBuffer> m_loadedBuffer;
-
-
-public:
- void reload(const Immutable<LoadedBuffer> &loadedBuffer);
-private:
-// QSharedPointer<Resource> m_resource;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/dragonglshader.cpp b/src/runtime/dragon/dragonglshader.cpp
index 9f0c57d..3081fee 100644
--- a/src/runtime/dragon/dragonglshader.cpp
+++ b/src/runtime/dragon/dragonglshader.cpp
@@ -115,9 +115,6 @@ GLShader::GLShader(const ActivatedSurface &gl, const Immutable<Qt3DRender::Drago
GLShader &result = *this;
result.dna = shader->dna();
- // TODO consider dropping
- result.shader = shader;
-
// TODO remember to delete
result.shaderProgram.reset(new QOpenGLShaderProgram);
@@ -155,14 +152,6 @@ GLShader::GLShader(const ActivatedSurface &gl, const Immutable<Qt3DRender::Drago
return;
}
- // result.shaderProgram.reset(shaderProgram);
-
- // TODO I don't think either can ever happen, consider removing
- if (Q_UNLIKELY(shaderProgram == nullptr) || shader->isLoaded()) {
- qWarning() << "ERROR: Shader not loaded";
- return;
- }
-
// Ensure the Shader node knows about the program interface
// Find an already loaded shader that shares the same QOpenGLShaderProgram
@@ -199,8 +188,6 @@ GLShader::GLShader(const ActivatedSurface &gl, const Immutable<Qt3DRender::Drago
result.storageBlocks = glHelper->programShaderStorageBlocks(shaderProgram->programId());
result.storageBlocks = nameToNameId(result.storageBlocks);
}
-
-// return result;
}
}
diff --git a/src/runtime/dragon/dragonglshader_p.h b/src/runtime/dragon/dragonglshader_p.h
index cc5e3d6..9d12b29 100644
--- a/src/runtime/dragon/dragonglshader_p.h
+++ b/src/runtime/dragon/dragonglshader_p.h
@@ -111,8 +111,6 @@ struct GLShader
QVector<ShaderUniformBlock> uniformBlocks;
QVector<ShaderStorageBlock> storageBlocks;
- // TODO consider dropping in favor of releasing memory
- Immutable<Shader> shader;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/dragongltexture_p.h b/src/runtime/dragon/dragongltexture_p.h
index 48a20fa..d82b1fe 100644
--- a/src/runtime/dragon/dragongltexture_p.h
+++ b/src/runtime/dragon/dragongltexture_p.h
@@ -56,7 +56,6 @@ namespace Dragon {
struct LoadedTexture;
-// TODO move to separate file
struct GLTexture
{
QAbstractTexture::Target actualTarget = QAbstractTexture::TargetAutomatic;
@@ -68,9 +67,9 @@ struct GLTexture
int textureId() const
{
- if (openGLTexture == nullptr) {
+ if (!openGLTexture)
return -1;
- }
+
return int(openGLTexture->textureId());
}
diff --git a/src/runtime/dragon/dragonmanager_p.h b/src/runtime/dragon/dragonmanager_p.h
deleted file mode 100644
index 4af7fd7..0000000
--- a/src/runtime/dragon/dragonmanager_p.h
+++ /dev/null
@@ -1,411 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DRAGONMANAGER_P_H
-#define DRAGONMANAGER_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 <Qt3DCore/private/qresourcemanager_p.h>
-
-#include <Qt3DCore/QNodeId>
-#include <QtCore/qrefcount.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DCore {
-
-template <typename T>
-class Handlee
-{
-public:
- struct Data {
- union {
- quintptr counter;
- Data *nextFree;
- };
- };
-
- Handlee() = default;
-
- Handlee(Data *d_)
- : d(d_)
- , counter(d_->counter)
- {
- qDebug() << "Constructing handle";
- if (d)
- refCount = new QBasicAtomicInt(0);
- }
-
- Handlee(const Handlee &other)
- : d(other.d)
- , counter(other.counter)
- , refCount(other.refCount)
- {
- qDebug() << "Copy constructed";
- if (refCount != nullptr)
- refCount->ref();
- }
-
- ~Handlee()
- {
- qDebug() << "Destroying handle";
- if (refCount != nullptr) {
- qDebug() << "Ref count" << refCount->load();
- if (refCount->load() == 0)
- delete refCount;
- else
- refCount->deref();
- }
- }
-
- Handlee &operator=(const Handlee &other)
- {
- qDebug() << "Copy assigned";
- d = other.d;
- counter = other.counter;
- refCount = other.refCount;
- return *this;
- }
-
- inline const T *operator->() const;
- inline T *operator->();
-
- inline T *data() const;
-
- quintptr handle() const { return reinterpret_cast<quintptr>(d); }
-
- bool isNull() const
- {
- return d == nullptr;
- }
-
- Data *data_ptr() const { return d; }
-
- bool operator==(const Handlee &other) const { return d == other.d && counter == other.counter; }
- bool operator!=(const Handlee &other) const { return !operator==(other); }
-private:
- Data *d = nullptr;
- quintptr counter = 0;
- QBasicAtomicInt *refCount = nullptr;
-};
-
-template<typename T>
-class HandleDataa : public Handlee<T>::Data
-{
-public:
- T data;
-};
-
-template<typename T>
-inline const T *Handlee<T>::operator->() const
-{
- Q_ASSERT(d != nullptr);
- Q_ASSERT(counter == d->counter);
- return (d && counter == d->counter) ? &static_cast<HandleDataa<T> *>(d)->data : nullptr;
-}
-
-template<typename T>
-inline T *Handlee<T>::operator->()
-{
- // Only allow writing to the object behind the handle if we are the only
- // handle referring to the object.
- // This is similar to copy-on-write, but instead of copying, we crash.
- Q_ASSERT(refCount->load() == 1);
- if (refCount->load() > 1)
- qWarning() << "ERROR: QHandle access to operator-> on shared non-const object.";
- return (d && counter == d->counter) ? &static_cast<HandleDataa<T> *>(d)->data : nullptr;
-}
-
-// TODO remove or make private
-template<typename T>
-inline T *Handlee<T>::data() const
-{
- return (d && counter == d->counter) ? &static_cast<HandleDataa<T> *>(d)->data : nullptr;
-}
-
-template <typename ValueType>
-class ResourceManager
-{
-public:
- using Handle = Handlee<ValueType>;
- using HandleData = HandleDataa<ValueType>;
-
- using iterator = typename QVector<Handle>::iterator;
- using const_iterator = typename QVector<Handle>::const_iterator;
-
- ResourceManager()
- {
- }
-
- ~ResourceManager()
- {
- m_activeHandles.clear();
- deallocateBuckets();
- }
-
- Handle acquire()
- {
- return allocateResource();
- }
-
- void release(const Handle &handle)
- {
- remove(handle);
- }
-
- bool contains(const QNodeId &id) const
- {
- return m_keyToHandleMap.contains(id);
- }
-
- Handle getOrAcquireHandle(const QNodeId &id)
- {
- Handle handle = m_keyToHandleMap.value(id);
- if (handle.isNull()) {
- // Test that the handle hasn't been set (in the meantime between the read unlock and the write lock)
- Handle &handleToSet = m_keyToHandleMap[id];
- if (handleToSet.isNull()) {
- handleToSet = allocateResource();
- }
- return handleToSet;
- }
- return handle;
- }
-
- void insert(QNodeId id, ValueType data)
- {
- // TODO ugly, just call the constructor
- Handle handle = getOrAcquireHandle(id);
- ValueType *currentData = handle.operator->();
- *currentData = data;
- }
-
- Handle lookupHandle(const QNodeId &id)
- {
- return m_keyToHandleMap.value(id);
- }
-
- ValueType *lookupResource(const QNodeId &id)
- {
- ValueType* ret = nullptr;
- {
- Handle handle = m_keyToHandleMap.value(id);
- if (!handle.isNull())
- ret = handle.operator->();
- }
- return ret;
- }
-
- ValueType *getOrCreateResource(const QNodeId &id)
- {
- const Handle handle = getOrAcquireHandle(id);
- return handle.data();
- }
-
- void remove(const QNodeId &id)
- {
- Handle handle = m_keyToHandleMap.take(id);
- if (!handle.isNull())
- remove(handle);
- }
-
- Handle allocateResource()
- {
- if (!m_freeList)
- allocateBucket();
- typename Handle::Data *d = m_freeList;
-// new (d) HandleData; // TODO May not be aligned!
- m_freeList = m_freeList->nextFree;
- d->counter = m_allocCounter;
- m_allocCounter += 2; // ensure this will never clash with a pointer in nextFree by keeping the lowest bit set
- Handle handle(d);
- m_activeHandles.push_back(handle);
- return handle;
- }
-
- void remove(const Handle &handle)
- {
- m_activeHandles.removeOne(handle);
- typename Handle::Data *d = handle.data_ptr();
- HandleData *data = static_cast<HandleData*>(d);
-// data->~HandleData();
- d->nextFree = m_freeList;
- m_freeList = d;
- performCleanup(&static_cast<HandleDataa<ValueType> *>(d)->data, Int2Type<QResourceInfo<ValueType>::needsCleanup>());
- }
-
- void for_each(std::function<void(ValueType*)> f)
- {
- Bucket *b = m_firstBucket;
- while (b) {
- for (int idx = 0; idx < Bucket::NumEntries; ++idx) {
- ValueType *t = &b->data[idx].data;
- f(t);
- }
- b = b->header.next;
- }
- }
-
- int count() const {
- return m_activeHandles.size();
- }
-
- QVector<Handle> activeHandles() const {
- return m_activeHandles;
- }
-
- QList<QNodeId> keys() const
- {
- return m_keyToHandleMap.keys();
- }
-
- size_t size() const
- {
- return m_keyToHandleMap.size();
- }
-
- const Handle operator[](QNodeId id) const
- {
- const Handle handle = m_keyToHandleMap.value(id);
- return m_keyToHandleMap[id];
- }
-
-// ValueType* operator[](QNodeId id)
-// {
-// ValueType* ret = nullptr;
-// {
-// Handle handle = m_keyToHandleMap.value(id);
-// if (!handle.isNull())
-// ret = handle.operator->();
-// }
-// return ret;
-// }
-
- iterator begin()
- {
- return m_activeHandles.begin();
- }
-
- const_iterator begin() const
- {
- return m_activeHandles.begin();
- }
-
- iterator end()
- {
- return m_activeHandles.end();
- }
-
- const_iterator end() const
- {
- return m_activeHandles.end();
- }
-
-private:
- struct Bucket
- {
- struct Header
- {
- Bucket *next;
- } header;
- enum {
- Size = 4096,
- DataSize = Size - sizeof(Header),
- NumEntries = DataSize / sizeof(HandleData)
- };
- HandleData data[NumEntries];
-// int8_t data[DataSize];
- };
-
- Bucket *m_firstBucket = nullptr;
- QVector<Handle> m_activeHandles;
- typename Handle::Data *m_freeList = nullptr;
- int m_allocCounter = 1;
-
- void allocateBucket()
- {
- // no free handle, allocate a new
- // allocate aligned memory
- Bucket *b = static_cast<Bucket *>(AlignedAllocator::allocate(sizeof(Bucket)));
-
- // placement new
- new (b) Bucket;
-
- b->header.next = m_firstBucket;
- m_firstBucket = b;
-
-// HandleData *data = reinterpret_cast<HandleData*>(b->data);
- for (int i = 0; i < Bucket::NumEntries - 1; ++i) {
-// data[i].nextFree = &data[i + 1];
- b->data[i].nextFree = &b->data[i + 1];
- }
- b->data[Bucket::NumEntries - 1].nextFree = nullptr;
- m_freeList = &b->data[0];
- }
-
- void deallocateBuckets()
- {
- Bucket *b = m_firstBucket;
- while (b) {
- Bucket *n = b->header.next;
- // Call dtor explicitly
- b->~Bucket();
- // Release aligned memory
- AlignedAllocator::release(b);
- b = n;
- }
- }
-
- void performCleanup(ValueType *r, Int2Type<true>)
- {
- r->cleanup();
- }
-
- void performCleanup(ValueType *, Int2Type<false>)
- {}
-
-private:
- QHash<QNodeId, Handle> m_keyToHandleMap;
-};
-
-} // Qt3DCore
-QT_END_NAMESPACE
-
-#endif // DRAGONMANAGER_P_H
diff --git a/src/runtime/dragon/dragonmapper_p.h b/src/runtime/dragon/dragonmapper_p.h
index 6865143..130c60c 100644
--- a/src/runtime/dragon/dragonmapper_p.h
+++ b/src/runtime/dragon/dragonmapper_p.h
@@ -177,8 +177,6 @@ Qt3DCore::QBackendNode *NodeFunctor<Backend, BackendTarget>::create(const Qt3DCo
node.setPeerId(peerId);
// TODO consider getting rid of this long-lived pointer
node.setManager(m_nodes);
- // TODO operator[] does not work
-// (*m_nodes)[peerId] = node;
m_nodes->insert(peerId, node);
return wrapper;
}
diff --git a/src/runtime/dragon/dragonoffscreensurfacehelper.cpp b/src/runtime/dragon/dragonoffscreensurfacehelper.cpp
index aef5335..0c68cca 100644
--- a/src/runtime/dragon/dragonoffscreensurfacehelper.cpp
+++ b/src/runtime/dragon/dragonoffscreensurfacehelper.cpp
@@ -45,10 +45,12 @@ OffscreenSurfaceHelper::OffscreenSurfaceHelper(const QSurfaceFormat &format, QOb
void OffscreenSurfaceHelper::createOffscreenSurface()
{
- m_offscreenSurface = new QOffscreenSurface;
- m_offscreenSurface->setParent(this);
- m_offscreenSurface->setFormat(m_format);
- m_offscreenSurface->create();
+ if (!m_offscreenSurface) {
+ m_offscreenSurface = new QOffscreenSurface;
+ m_offscreenSurface->setParent(this);
+ m_offscreenSurface->setFormat(m_format);
+ m_offscreenSurface->create();
+ }
}
QOffscreenSurface *OffscreenSurfaceHelper::offscreenSurface() const
diff --git a/src/runtime/dragon/dragonrenderbuffer.cpp b/src/runtime/dragon/dragonrenderbuffer.cpp
index 9734174..f675c59 100644
--- a/src/runtime/dragon/dragonrenderbuffer.cpp
+++ b/src/runtime/dragon/dragonrenderbuffer.cpp
@@ -83,7 +83,7 @@ RenderBuffer::~RenderBuffer()
void RenderBuffer::bind()
{
- if (!m_renderBuffer)
+ if (!m_renderBuffer || !m_context)
return;
m_context->functions()->glBindRenderbuffer(GL_RENDERBUFFER, m_renderBuffer);
diff --git a/src/runtime/dragon/dragonrendercommand_p.h b/src/runtime/dragon/dragonrendercommand_p.h
index 9ac6d4c..08f5812 100644
--- a/src/runtime/dragon/dragonrendercommand_p.h
+++ b/src/runtime/dragon/dragonrendercommand_p.h
@@ -68,53 +68,26 @@ class RenderCommand
{
public:
Immutable<Shader> m_shader;
- Immutable<LoadedBuffer> m_buffer;
Immutable<GeometryRenderer> m_geometryRenderer;
Immutable<Geometry> m_geometry;
Immutable<Material> m_material;
Immutable<Entity> m_entity;
-// Value<Matrix4x4> m_worldTransform;
ParameterNameToIdMap m_parameterIds; // added in Dragon
-// ParameterNameToParameterMap m_parameterMap; // added in Dragon
-
- ShaderParameterPack m_parameterPack; // Might need to be reworked so as to be able to destroy the
-
- // HBuffer m_indirectDrawBuffer; // Reference to indirect draw buffer (valid only
- // m_drawIndirect == true)
// TODO add back render state set
Immutable<RenderStateSet> m_renderStateSet;
-// QVector<Value<Attribute>> m_attributes;
- QVector<Qt3DCore::QNodeId> m_attributes;
- // TODO never set!
float m_depth = 0.0f;
- // TODO initialize
- int m_changeCost;
- uint m_shaderDna;
+ // TODO: Currently only m_depth based sorting is supported in dragonrenderviewjobs.
+ // If StateChangeCost or Material sorting will not be supported, these can be removed.
+ int m_changeCost = 0;
+ uint m_shaderDna = 0;
enum CommandType { Draw, Compute };
CommandType m_type = Draw;
- int m_workGroups[3];
-
- // Values filled for draw calls
- GLsizei m_primitiveCount = 0; // TODO consider size_t
- QGeometryRenderer::PrimitiveType m_primitiveType;
- int m_restartIndexValue = 0;
- int m_firstInstance = 0;
- int m_firstVertex = 0;
- int m_verticesPerPatch = 0;
- int m_instanceCount = 0;
- int m_indexOffset = 0;
-
- // Could be organized in a struct to avoid repeating the name
- uint m_indirectAttributeByteOffset = 0;
- bool m_drawIndirect = 0;
- bool m_primitiveRestartEnabled = 0;
- bool m_isValid = 0;
QHash<QString, int> m_fragOutputs;
};
diff --git a/src/runtime/dragon/dragonrenderer.cpp b/src/runtime/dragon/dragonrenderer.cpp
index d530e6f..72b7301 100644
--- a/src/runtime/dragon/dragonrenderer.cpp
+++ b/src/runtime/dragon/dragonrenderer.cpp
@@ -39,6 +39,7 @@
#include <private/dragonrendertarget_p.h>
#include <private/dragonblitframebuffer_p.h>
#include <private/dragonrenderview_p.h>
+#include <private/dragonscene2d_p.h>
// For Qt3DRender::Render::SurfaceLocker (private export)
#include <Qt3DRender/private/platformsurfacefilter_p.h>
@@ -79,36 +80,6 @@ GraphicsApiFilterData contextInfo(const QOpenGLContext &m_gl)
return m_contextInfo;
}
-// TODO consider debug logging
-// void debugLogging() {
-// // Note: at this point we are certain the context (m_gl) is current with a surface
-// const QByteArray debugLoggingMode = qgetenv("QT3DRENDER_DEBUG_LOGGING");
-// const bool enableDebugLogging = !debugLoggingMode.isEmpty();
-
-// if (enableDebugLogging && !m_debugLogger) {
-// if (m_gl->hasExtension("GL_KHR_debug")) {
-// qCDebug(Backend) << "Qt3D: Enabling OpenGL debug logging";
-// m_debugLogger.reset(new QOpenGLDebugLogger);
-// if (m_debugLogger->initialize()) {
-// QObject::connect(m_debugLogger.data(), &QOpenGLDebugLogger::messageLogged,
-// &logOpenGLDebugMessage); const QString mode =
-// QString::fromLocal8Bit(debugLoggingMode);
-// m_debugLogger->startLogging(mode.startsWith(QLatin1String("sync"),
-// Qt::CaseInsensitive)
-// ? QOpenGLDebugLogger::SynchronousLogging
-// : QOpenGLDebugLogger::AsynchronousLogging);
-
-// const auto msgs = m_debugLogger->loggedMessages();
-// for (const QOpenGLDebugMessage &msg : msgs)
-// logOpenGLDebugMessage(msg);
-// }
-// } else {
-// qCDebug(Backend) << "Qt3D: OpenGL debug logging requested but GL_KHR_debug not
-// supported";
-// }
-// }
-//}
-
/*!
\brief Renderer lives on a separate thread performs the actual rendering of the RenderCommands
from each RenderView.
@@ -153,6 +124,8 @@ Renderer::~Renderer()
m_offscreenHelper->deleteLater();
if (m_ownedContext)
m_glContext->deleteLater();
+ if (m_ownedShareContext)
+ m_shareContext->deleteLater();
}
/*!
@@ -177,16 +150,16 @@ void Renderer::initialize(QOpenGLContext *context)
}
if (!m_glContext->shareContext()) {
- // TODO don't forget to delete this
m_shareContext = new QOpenGLContext;
m_shareContext->setFormat(m_glContext->format());
m_shareContext->setShareContext(m_glContext);
m_shareContext->create();
+ m_ownedShareContext = true;
} else {
m_shareContext = m_glContext->shareContext();
}
- m_offscreenHelper = new OffscreenSurfaceHelper(m_shareContext->format());
+ m_offscreenHelper = new OffscreenSurfaceHelper(m_glContext->format());
m_offscreenHelper->moveToThread(QCoreApplication::instance()->thread());
QMetaObject::invokeMethod(m_offscreenHelper, "createOffscreenSurface");
@@ -194,11 +167,16 @@ void Renderer::initialize(QOpenGLContext *context)
m_waitForInitializationToBeCompleted.release();
}
-QOpenGLContext *Renderer::openGLContext()
+QOpenGLContext *Renderer::openGLContext() const
{
return m_glContext;
}
+QOpenGLContext *Renderer::shareContext() const
+{
+ return m_shareContext;
+}
+
void Renderer::addLatestData(FrameInput data)
{
QMutexLocker lock(&m_latestDataMutex);
@@ -235,86 +213,54 @@ void Renderer::render()
Q_ASSERT(m_glContext != nullptr);
- // QOffscreenSurface offscreenSurface;
- // offscreenSurface.create();
- {
- // Scoped to make sure OpenGLResources go out of scope before the offscreen surface
- Frame frame;
- while (m_running.load() > 0) {
- // TODO we probably need to move this inside doRender...
- // TODO we should wait for render views to appear :)
- // RenderCommand dummy;
- // RenderView view;
- // view.renderCommands.push_back(std::move(dummy));
- // renderViews.push_back(std::move(view));
-
- frame = doRender(std::move(frame));
- }
- // Make sure there is a context to use for the cleanup of resources
- Q_ASSERT(m_offscreenHelper->offscreenSurface());
- m_glContext->makeCurrent(m_offscreenHelper->offscreenSurface());
+ Frame frame;
+ while (m_running.load() > 0) {
+ // TODO we probably need to move this inside doRender...
+ // TODO we should wait for render views to appear :)
+ frame = doRender(std::move(frame));
}
+ // Make sure there is a context to use for the cleanup of resources
+ Q_ASSERT(m_offscreenHelper->offscreenSurface());
+ m_glContext->makeCurrent(m_offscreenHelper->offscreenSurface());
}
-class BoundShader
+void Renderer::checkContextInfoRequested()
{
-public:
- BoundShader(const std::shared_ptr<ActivatedSurface> &surface, Immutable<GLShader> shader)
- : m_shader(shader)
- , m_surface(surface)
- {
- m_shader->shaderProgram->bind();
+ QMutexLocker lock(&m_latestDataMutex);
+ if (m_contextInfoRequested) {
+ // This is the only input/output we allow the renderer
+ // to perform with the aspect apart from the render views.
+ // Everything else, such as uploading textures or shaders
+ // needs to be submitted with the views and happens below,
+ // while preparing rendering.
+ m_writeContextInfoSemaphore.acquire();
+ const RenderViews views = m_requestedContextInfoViews;
+ for (const auto &view : views) {
+ auto *surface = view->surface;
+ Render::SurfaceLocker lock(surface);
+ if (!lock.isSurfaceValid()) {
+ continue;
+ }
+ ActivatedSurface gl(surface, m_glContext, &lock);
+ if (!gl.isValid()) {
+ continue;
+ }
+ m_contextInfo = gl.contextInfo();
+ break;
+ }
+ m_contextInfoRequested = false;
+ m_requestedContextInfoViews = {};
+ m_readContextInfoSemaphore.release();
}
+}
- ~BoundShader() { m_shader->shaderProgram->release(); }
-
- Immutable<GLShader> m_shader;
- std::shared_ptr<ActivatedSurface> m_surface;
-};
-
-// TODO rename, this is not only rendering but also running commands
+// Render and run commands of the frame
Renderer::Frame Renderer::doRender(Renderer::Frame frame)
{
- // TODO this function got uglier than expected, clean it up
Q_ASSERT(m_glContext != nullptr);
- Q_ASSERT(m_shareContext != nullptr);
- // Q_ASSERT(m_state != nullptr);
- // QThread::msleep(250); // TODO replace with semaphore
- {
- // In case someone has requested context info, we don't render,
- // but only gather context info
-
- // TODO this is basically implementing QPromise (for a QFuture),
- // which perhaps is something to consider actually doing...
- QMutexLocker lock(&m_latestDataMutex);
- if (m_contextInfoRequested) {
- // This is the only input/output we allow the renderer
- // to perform with the aspect apart from the render views.
- // Everything else, such as uploading textures or shaders
- // needs to be submitted with the views and happens below,
- // while preparing rendering.
- m_writeContextInfoSemaphore.acquire();
- GraphicsApiFilterData result;
- RenderViews views = m_requestedContextInfoViews;
- for (const auto &view : views) {
- auto *surface = view->surface;
- Render::SurfaceLocker lock(surface);
- if (!lock.isSurfaceValid()) {
- continue;
- }
- ActivatedSurface gl(surface, m_glContext, &lock);
- if (!gl.isValid()) {
- continue;
- }
- m_contextInfo = gl.contextInfo();
- break;
- }
- m_contextInfoRequested = false;
- m_requestedContextInfoViews = {};
- m_readContextInfoSemaphore.release();
- }
- }
+ // In case someone has requested context info, we gather context info
+ checkContextInfoRequested();
// TODO jobs expect us to receive and upload textures, if that fails below,
// we're in a position where we do not know about said data anymore...
@@ -336,6 +282,7 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
const auto &attributes = frameInput.attributes;
const auto &loadedBuffers = frameInput.loadedBuffers;
const auto &leafNodes = frameInput.frameGraph.leafNodes;
+ const auto &scene2ds = frameInput.scene2ds;
if (renderViews.size() == 0) {
// TODO make throttle target a max FPS
@@ -360,7 +307,14 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
// We need a list of texture IDs that are used in render targets and hence cannot be shared
for (const auto &renderTarget : renderView->attachmentPack.outputs) {
- texturesUsedInRenderTargets.push_back(renderTarget->textureUuid);
+ if (!texturesUsedInRenderTargets.contains(renderTarget->textureUuid))
+ texturesUsedInRenderTargets.push_back(renderTarget->textureUuid);
+ }
+ }
+ for (const auto &scene2d : scene2ds) {
+ if (scene2d->m_texture.id() != 0
+ && !texturesUsedInRenderTargets.contains(scene2d->m_texture)) {
+ texturesUsedInRenderTargets.push_back(scene2d->m_texture);
}
}
@@ -368,10 +322,15 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
RenderStateSet stateSet;
bool preparationsComplete = false;
- // TODO use an iterator for improved performance
- for (auto *surface : surfaceViews.keys()) {
+
+ QHashIterator<QSurface *, QVector<SurfaceInfo>> surfaceViewsIterator(surfaceViews);
+ while (surfaceViewsIterator.hasNext()) {
+
+ const auto view = surfaceViewsIterator.next();
+ auto *surface = view.key();
+
// Preparations need an OpenGL context, but it can be any, so let's pick the first valid surface
- const auto &surfaceInfos = surfaceViews[surface];
+ const auto &surfaceInfos = view.value();
Render::SurfaceLocker lock(surface);
if (!lock.isSurfaceValid()) {
@@ -397,8 +356,6 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
m_glContext->functions()->glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,
&maxTextureUnits);
frame.maxTextureImageUnits = maxTextureUnits;
- //qCDebug(Render::Backend)
- // << "context supports" << maxTextureUnits << "texture units";
}
// TODO not nice to have to take this by reference, but what can we do?
@@ -443,6 +400,15 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
loadedTextures,
updateGLTextureHelper);
+ if (frame.uploadedTextures.anythingDirty()) {
+ for (auto &tex : qAsConst(frame.uploadedTextures)) {
+ if (!tex->openGLTexture.isNull()) {
+ m_snaggedTextures[tex->loadedTexture->texture->peerId()]
+ = tex->openGLTexture;
+ }
+ }
+ }
+
auto createGLShaderHelper = [&activeSurface](const QNodeId &id,
const Immutable<Shader> &shader) {
Q_UNUSED(id);
@@ -459,7 +425,6 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
return GLBuffer(activeSurface, buffer);
};
- // TODO rename loaded -> generated
frame.uploadedBuffers = synchronizeNew(std::move(frame.uploadedBuffers),
loadedBuffers,
createGLBufferHelper);
@@ -474,8 +439,6 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
tmp.reload(loadedBuffer);
return tmp;
});
- // auto result = glBuffer;
- // result->reload(loadedBuffer);
return result;
};
@@ -483,19 +446,15 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
loadedBuffers,
reloadGLBufferHelper);
- QHash<VAOIdentifier, bool> updatedTable;
// Per-view preparations
for (const auto &surfaceInfo : surfaceInfos) {
const auto &view = surfaceInfo.renderView;
const auto &leafNodeId = surfaceInfo.leafNodeId;
const auto &commands = frameInput.renderCommands[leafNodeId]->commands;
for (const auto &acommand : commands) {
-// const auto &command = *acommand->renderCommand;
const auto &command = *acommand;
if (command.m_type == RenderCommand::Compute) {
- // TODO implement compute commands
- qWarning()
- << "WARNING: Compute commands are not implemented in Dragon renderer yet";
+ qWarning() << "WARNING: Compute commands are not implemented in Dragon renderer yet";
continue;
}
@@ -524,7 +483,6 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
// Create render target
if (!view->renderTargetId.isNull()) {
auto defaultFBO = m_glContext->defaultFramebufferObject();
- // TODO bad name, rename
// TODO consider why this is here, iOS apparently
auto lastBoundFBOId = activeSurface.glHelper()->boundFrameBufferObject();
const auto &renderTargetNodeId = view->renderTargetId;
@@ -570,11 +528,6 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
}
const auto &glTexture = frame.uploadedTextures[attachment->textureUuid];
needsResize |= (glTexture->size() != s);
-
- // TODO move this to where we use the render target
- // it is needed if we need to read back the buffer
- // if (attachment->point == QRenderTargetOutput::Color0)
- // m_renderTargetFormat = glTexture->properties.format;
}
if (needsResize) {
@@ -594,26 +547,20 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
preparationsComplete = true;
}
- if (!preparationsComplete)
- return frame;
+ Q_ASSERT(preparationsComplete);
// TODO might be better to just have to call swapBuffers manually
bool autoSwapBuffers = m_renderType == RenderType::Threaded;
- DrawContext drawContext = activeSurface.beginDrawing(autoSwapBuffers);
+ activeSurface.beginDrawing(autoSwapBuffers);
- // TODO consider what m_ownCurrent was used for in SubmissionContext
-
- // TODO consider caching per surface again
- // if (m_glHelpers[surface] == nullptr) {
- // // TODO would be nice if we didn't have to pass this as non-const
- // // TODO could perhaps live on ActivatedSurface?
- // m_glHelpers.insert(surface, gl.resolveHighestOpenGLFunctions());
- // }
- // gl.setGlHelper(m_glHelpers[surface]);
-
- // Preparation
// TODO consider doing preparation and submission in one go
+ // Lock scene2ds as they might be rendering simultaniously otherwise
+ for (const auto &scene2d : scene2ds) {
+ if (scene2d->m_texture.id() != 0 && scene2d->m_mutex)
+ scene2d->m_mutex->lock();
+ }
+
// Submission
for (const auto &surfaceInfo : surfaceInfos) {
const auto &view = surfaceInfo.renderView;
@@ -632,15 +579,12 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
activeSurface.clearBackBuffer(view->clearBackBufferInfo);
// TODO make it return a viewport, used by other functions that need one
- activeSurface.viewport(view->viewport, view->surfaceSize * view->devicePixelRatio);
+ activeSurface.setViewport(view->viewport, view->surfaceSize * view->devicePixelRatio);
for (const auto &acommand : commands) {
-// const auto &command = *acommand->renderCommand;
const auto &command = *acommand;
if (command.m_type == RenderCommand::Compute) {
- // TODO implement compute commands
- qWarning()
- << "WARNING: Compute commands are not implemented in Dragon renderer yet";
+ qWarning() << "WARNING: Compute commands are not implemented in Dragon renderer yet";
continue;
}
@@ -657,7 +601,6 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
Q_ASSERT(frame.uploadedVaos.contains(vaoKey));
const auto &vao = frame.uploadedVaos[vaoKey];
- // gl->performDraw(command, glShader, frameInput.attributes, vao);
Commands::draw(activeSurface,
view,
cameraMatrices,
@@ -690,6 +633,15 @@ Renderer::Frame Renderer::doRender(Renderer::Frame frame)
// TODO consider blit framebuffer info
// TODO bind framebuffer
}
+
+ // Unlock scene2ds
+ for (const auto &scene2d : scene2ds) {
+ if (scene2d->m_texture.id() != 0 && scene2d->m_mutex)
+ scene2d->m_mutex->unlock();
+ }
+
+ // Make sure to reset to defaults before finishing frame
+ stateSet = activeSurface.applyStateSet(stateSet, RenderStateSet::defaultRenderStateSet());
}
frame.number += 1;
@@ -709,6 +661,7 @@ void Renderer::beginShutdown()
} else {
Q_ASSERT(m_offscreenHelper->offscreenSurface());
m_glContext->makeCurrent(m_offscreenHelper->offscreenSurface());
+ clear();
}
}
@@ -736,6 +689,7 @@ void RenderThread::run()
// Enter the main OpenGL submission loop.
m_renderer->render();
+ m_renderer->clear();
// Clean up any OpenGL resources
// m_renderer->releaseGraphicsResources();
diff --git a/src/runtime/dragon/dragonrenderer_p.h b/src/runtime/dragon/dragonrenderer_p.h
index af8e31a..8a4a8cd 100644
--- a/src/runtime/dragon/dragonrenderer_p.h
+++ b/src/runtime/dragon/dragonrenderer_p.h
@@ -62,29 +62,16 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
-namespace Render {
-// TODO SubmissionContext needs to be replaced because it expects to access the Renderer...
-// While we're here: how much of it is needed?
-class SubmissionContext;
-
-// Consider the need for a shader cache with the new jobs - is it persistent across application
-// runs?
-class ShaderCache;
-
-// TODO do we need the VSyncFrameAdvanceService?
-class VSyncFrameAdvanceService;
-
-// TODO do we need the offscreen surface?
-} // namespace Render
-
namespace Dragon {
// renderer.h
+struct Scene2DState;
struct GLBuffer;
struct GLShader;
struct GLTexture;
class Renderer;
class GraphicsHelperInterface;
+
class RenderThread : public QThread
{
Q_OBJECT
@@ -118,6 +105,7 @@ struct FrameInput
ValueContainer<Parameter> parameters;
ValueContainer<Matrix4x4> worldTransforms;
ValueContainer<Shader> shaders;
+ ValueContainer<Scene2DState> scene2ds;
TreeInfo frameGraph;
};
@@ -169,11 +157,25 @@ public:
QSemaphore nextFrameSemaphore;
- QOpenGLContext *openGLContext();
+ QOpenGLContext *openGLContext() const;
+ QOpenGLContext *shareContext() const;
void beginShutdown();
void endShutdown();
+
+ const QHash<Qt3DCore::QNodeId, QSharedPointer<QOpenGLTexture>> &textures() const
+ {
+ return m_snaggedTextures;
+ }
+ void clear()
+ {
+ m_snaggedTextures.clear();
+ }
+
private:
+
+ void checkContextInfoRequested();
+
// Render thread
QScopedPointer<RenderThread> m_renderThread;
QAtomicInt m_running;
@@ -182,9 +184,9 @@ private:
QMutex m_latestDataMutex;
// Context
- // QScopedPointer<Render::SubmissionContext> m_submissionContext;
QMutex m_shareContextMutex;
bool m_ownedContext = false;
+ bool m_ownedShareContext = false;
// TODO Protect behind a read-only barrier with a mutex, similar to RenderQueue
QQueue<FrameInput> m_latestData;
@@ -208,13 +210,10 @@ private:
OffscreenSurfaceHelper *m_offscreenHelper;
- RenderType m_renderType;
-
- // // Shaders
- // Render::ShaderCache *m_shaderCache = nullptr;
+ // List of textures and their ids after they have been uploaded
+ QHash<Qt3DCore::QNodeId, QSharedPointer<QOpenGLTexture>> m_snaggedTextures;
- // // Other
- // QScopedPointer<Render::VSyncFrameAdvanceService> m_vsyncFrameAdvanceService;
+ RenderType m_renderType;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/dragonrendertarget.cpp b/src/runtime/dragon/dragonrendertarget.cpp
index 18eca9d..c6a4c8f 100644
--- a/src/runtime/dragon/dragonrendertarget.cpp
+++ b/src/runtime/dragon/dragonrendertarget.cpp
@@ -36,7 +36,6 @@
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <Qt3DCore/qpropertynodeaddedchange.h>
#include <Qt3DCore/qpropertynoderemovedchange.h>
-#include <QVariant>
QT_BEGIN_NAMESPACE
diff --git a/src/runtime/dragon/dragonrendertarget_p.h b/src/runtime/dragon/dragonrendertarget_p.h
index f54f7e7..dea8392 100644
--- a/src/runtime/dragon/dragonrendertarget_p.h
+++ b/src/runtime/dragon/dragonrendertarget_p.h
@@ -68,9 +68,9 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
-//private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
+private:
QVector<Qt3DCore::QNodeId> m_renderOutputs;
};
diff --git a/src/runtime/dragon/dragonrendertargetoutput_p.h b/src/runtime/dragon/dragonrendertargetoutput_p.h
index 07e2794..66fe5de 100644
--- a/src/runtime/dragon/dragonrendertargetoutput_p.h
+++ b/src/runtime/dragon/dragonrendertargetoutput_p.h
@@ -88,34 +88,6 @@ struct AttachmentPack
QVector<int> drawBuffers;
};
-//AttachmentPack attachmentPackFromTarget(const Value<RenderTarget> &target, const ValueContainer<RenderTarget> &renderTargets)
-//{
-// AttachmentPack result;
-// // Copy attachments
-// const auto outputIds = target->renderOutputs();
-// for (Qt3DCore::QNodeId outputId : outputIds) {
-// const RenderTargetOutput *output = attachmentManager->lookupResource(outputId);
-// if (output)
-// result.outputs.append(*output->attachment());
-// }
-
-// // Create actual DrawBuffers list that is used for glDrawBuffers
-
-// // If nothing is specified, use all the attachments as draw buffers
-// if (drawBuffers.isEmpty()) {
-// m_drawBuffers.reserve(m_attachments.size());
-// for (const Attachment &attachment : qAsConst(m_attachments))
-// // only consider Color Attachments
-// if (attachment.m_point <= QRenderTargetOutput::Color15)
-// m_drawBuffers.push_back((int) attachment.m_point);
-// } else {
-// m_drawBuffers.reserve(drawBuffers.size());
-// for (QRenderTargetOutput::AttachmentPoint drawBuffer : drawBuffers)
-// if (drawBuffer <= QRenderTargetOutput::Color15)
-// m_drawBuffers.push_back((int) drawBuffer);
-// }
-//}
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/dragonrenderview_p.h b/src/runtime/dragon/dragonrenderview_p.h
index 23e3a28..11e612b 100644
--- a/src/runtime/dragon/dragonrenderview_p.h
+++ b/src/runtime/dragon/dragonrenderview_p.h
@@ -61,7 +61,7 @@
#include <private/dragonblitframebuffer_p.h>
#include <private/dragonrendertarget_p.h>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragonoptional_p.h>
@@ -83,7 +83,6 @@ class Parameter;
class Entity;
class RenderCommand;
-// TODO move to dragonrendercommand_p.h
struct ClearColorInfo
{
int drawBufferIndex = 0;
@@ -113,7 +112,6 @@ struct BlitFramebufferInfo
Immutable<BlitFramebuffer> node;
};
-// TODO consider moving into separate file
struct CameraMatrices {
Matrix4x4 projectionMatrix;
Matrix4x4 viewMatrix;
@@ -127,8 +125,6 @@ struct RenderView
Qt3DCore::QNodeId leafNodeId;
QSurface *surface = nullptr; // TODO consider wrapping this together with a surface locker
- QVector<Immutable<RenderCommand>> renderCommands;
-// Matrix4x4 projectionMatrix;
bool hasCamera = false;
QMemoryBarrier::Operations memoryBarrier{};
@@ -158,14 +154,8 @@ struct RenderView
// Misc needed to set uniforms
Immutable<CameraLens> cameraLens;
Immutable<Entity> cameraNode;
-// Matrix4x4 viewMatrix;
-// Matrix4x4 viewProjectionMatrix;
-// Vector3D eyePosition;
-// Vector3D eyeViewDirection;
// Render state set
- // TODO consider if this needs to be a Value - it shouldn't change on its own
- bool hasRenderStateSet = false;
Immutable<RenderStateSet> renderStateSet;
bool noDraw = false;
@@ -174,9 +164,6 @@ struct RenderView
QVector<Qt3DRender::QSortPolicy::SortType> sortingTypes;
Optional<BlitFramebufferInfo> blitFrameBufferInfo;
- // TODO consider these
-// Qt3DCore::QNodeIdVector m_layerFilterIds;
-// Qt3DCore::QNodeIdVector m_proximityFilterIds;
};
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/dragonscene2d.cpp b/src/runtime/dragon/dragonscene2d.cpp
new file mode 100644
index 0000000..b65cf16
--- /dev/null
+++ b/src/runtime/dragon/dragonscene2d.cpp
@@ -0,0 +1,416 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DCore/qpropertynodeaddedchange.h>
+#include <Qt3DCore/qpropertynoderemovedchange.h>
+#include <Qt3DQuickScene2D/qscene2d.h>
+
+#include <QtCore/qthread.h>
+#include <QtCore/qatomic.h>
+#include <QtGui/qevent.h>
+#include <QtGui/qopenglcontext.h>
+#include <QtGui/qopenglfunctions.h>
+
+#include <private/qscene2d_p.h>
+#include <private/dragonscene2d_p.h>
+#include <private/scene2dmanager_p.h>
+#include <private/scene2devent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef GL_DEPTH24_STENCIL8
+#define GL_DEPTH24_STENCIL8 0x88F0
+#endif
+
+namespace Qt3DRender {
+
+using namespace Quick;
+
+namespace Dragon {
+
+Q_GLOBAL_STATIC(QThread, renderThread)
+Q_GLOBAL_STATIC(QAtomicInt, renderThreadClientCount)
+
+RenderQmlEventHandler::RenderQmlEventHandler(Scene2DData *node)
+ : QObject()
+ , m_node(node)
+{
+}
+
+// Event handler for the RenderQmlToTexture::renderThread
+bool RenderQmlEventHandler::event(QEvent *e)
+{
+ switch (static_cast<Scene2DEvent::Type>(e->type())) {
+
+ case Scene2DEvent::Render: {
+ m_node->render();
+ return true;
+ }
+
+ case Scene2DEvent::Initialize: {
+ m_node->initializeRender();
+ return true;
+ }
+
+ case Scene2DEvent::Quit: {
+ m_node->cleanup();
+ return true;
+ }
+
+ default:
+ break;
+ }
+ return QObject::event(e);
+}
+
+Scene2D::Scene2D()
+ : BackendNode()
+{
+ m_data.reset(new Scene2DData());
+}
+
+Scene2D::~Scene2D()
+{
+
+}
+
+void Scene2D::setOutput(Qt3DCore::QNodeId outputId)
+{
+ m_data->m_outputId = outputId;
+}
+
+void Scene2D::initializeSharedObject()
+{
+ if (!m_data->m_initialized && m_data->m_shareContext) {
+
+ // bail out if we're running autotests
+ if (!m_data->m_sharedObject->m_renderManager
+ || m_data->m_sharedObject->m_renderManager->thread() == QThread::currentThread()) {
+ return;
+ }
+
+ renderThreadClientCount->fetchAndAddAcquire(1);
+
+ renderThread->setObjectName(QStringLiteral("Scene2D::renderThread"));
+ m_data->m_renderThread = renderThread;
+ m_data->m_sharedObject->m_renderThread = m_data->m_renderThread;
+
+ // Create event handler for the render thread
+ m_data->m_sharedObject->m_renderObject = new RenderQmlEventHandler(m_data.data());
+ m_data->m_sharedObject->m_renderObject->moveToThread(m_data->m_sharedObject->m_renderThread);
+ if (!m_data->m_sharedObject->m_renderThread->isRunning())
+ m_data->m_sharedObject->m_renderThread->start();
+
+ // Notify main thread we have been initialized
+ QCoreApplication::postEvent(m_data->m_sharedObject->m_renderManager,
+ new Scene2DEvent(Scene2DEvent::Initialized));
+ // Initialize render thread
+ QCoreApplication::postEvent(m_data->m_sharedObject->m_renderObject,
+ new Scene2DEvent(Scene2DEvent::Initialize));
+
+ m_data->m_initialized = true;
+ }
+}
+
+void Scene2D::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+{
+ const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QScene2DData>>(change);
+ const auto &data = typedChange->data;
+ m_data->m_renderPolicy = data.renderPolicy;
+ setSharedObject(data.sharedObject);
+ setOutput(data.output);
+ m_data->m_mouseEnabled = data.mouseEnabled;
+}
+
+void Scene2D::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
+{
+ switch (e->type()) {
+
+ case Qt3DCore::PropertyUpdated: {
+
+ Qt3DCore::QPropertyUpdatedChangePtr propertyChange
+ = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
+ if (propertyChange->propertyName() == QByteArrayLiteral("renderPolicy")) {
+ m_data->m_renderPolicy = propertyChange->value().value<QScene2D::RenderPolicy>();
+ } else if (propertyChange->propertyName() == QByteArrayLiteral("output")) {
+ Qt3DCore::QNodeId outputId = propertyChange->value().value<Qt3DCore::QNodeId>();
+ setOutput(outputId);
+ }
+ // TODO add mouse related properties
+ break;
+ }
+ // TODO add pick entities
+
+ default:
+ break;
+ }
+ BackendNode::sceneChangeEvent(e);
+}
+
+void Scene2D::setSharedObject(Qt3DRender::Scene2DSharedObjectPtr sharedObject)
+{
+ m_data->m_sharedObject = sharedObject;
+ if (!m_data->m_initialized)
+ initializeSharedObject();
+}
+
+void Scene2DData::initializeRender()
+{
+ if (!m_renderInitialized && m_sharedObject.data() != nullptr) {
+ if (!m_shareContext){
+ qDebug() << Q_FUNC_INFO << "Renderer not initialized.";
+ QCoreApplication::postEvent(m_sharedObject->m_renderObject,
+ new Scene2DEvent(Scene2DEvent::Initialize));
+ return;
+ }
+ m_context = new QOpenGLContext();
+ m_context->setFormat(m_shareContext->format());
+ m_context->setShareContext(m_shareContext);
+ m_context->create();
+
+ m_context->makeCurrent(m_sharedObject->m_surface);
+ m_sharedObject->m_renderControl->initialize(m_context);
+
+ m_context->doneCurrent();
+
+ QCoreApplication::postEvent(m_sharedObject->m_renderManager,
+ new Scene2DEvent(Scene2DEvent::Prepare));
+ m_renderInitialized = true;
+ }
+}
+
+bool Scene2DData::updateFbo(QOpenGLTexture *texture, const QSize &size)
+{
+ QOpenGLFunctions *gl = m_context->functions();
+ if (m_fbo == 0) {
+ gl->glGenFramebuffers(1, &m_fbo);
+ gl->glGenRenderbuffers(1, &m_rbo);
+ }
+ // TODO: Add another codepath when GL_DEPTH24_STENCIL8 is not supported
+ gl->glBindRenderbuffer(GL_RENDERBUFFER, m_rbo);
+ gl->glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
+ size.width(), size.height());
+ gl->glBindRenderbuffer(GL_RENDERBUFFER, 0);
+
+ gl->glBindFramebuffer(GL_FRAMEBUFFER, m_fbo);
+ gl->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, texture->textureId(), 0);
+ gl->glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_rbo);
+ GLenum status = gl->glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ gl->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+ if (status != GL_FRAMEBUFFER_COMPLETE)
+ return false;
+ return true;
+}
+
+void Scene2DData::syncRenderControl()
+{
+ if (m_sharedObject->isSyncRequested()) {
+
+ m_sharedObject->clearSyncRequest();
+
+ m_sharedObject->m_renderControl->sync();
+
+ // gui thread can now continue
+ m_sharedObject->wake();
+ }
+}
+
+void Scene2DData::render()
+{
+ if (m_initialized && m_renderInitialized && m_sharedObject.data() != nullptr) {
+
+ QMutexLocker lock(&m_sharedObject->m_mutex);
+
+ QOpenGLTexture *texture = m_texture.data();
+ QMutex *textureLock = &m_mutex;
+
+ m_context->makeCurrent(m_sharedObject->m_surface);
+
+ if (!texture) {
+ // Need to call sync even if the texture is not in use
+ syncRenderControl();
+ m_context->doneCurrent();
+ return;
+ }
+
+ textureLock->lock();
+
+ if (m_outputDirty) {
+ const QSize textureSize = QSize(texture->width(), texture->height());
+ updateFbo(texture, textureSize);
+ m_textureSize = textureSize;
+ }
+
+
+ if (m_fbo != m_sharedObject->m_quickWindow->renderTargetId())
+ m_sharedObject->m_quickWindow->setRenderTarget(m_fbo, m_textureSize);
+
+ // Call disallow rendering while mutex is locked
+ if (m_renderPolicy == QScene2D::SingleShot)
+ m_sharedObject->disallowRender();
+
+ // Sync
+ if (m_sharedObject->isSyncRequested()) {
+
+ m_sharedObject->clearSyncRequest();
+
+ m_sharedObject->m_renderControl->sync();
+ }
+
+ // Render
+ m_sharedObject->m_renderControl->render();
+
+ // Tell main thread we are done so it can begin cleanup if this is final frame
+ if (m_renderPolicy == QScene2D::SingleShot)
+ QCoreApplication::postEvent(m_sharedObject->m_renderManager,
+ new Scene2DEvent(Scene2DEvent::Rendered));
+
+ m_sharedObject->m_quickWindow->resetOpenGLState();
+ m_context->functions()->glFlush();
+ if (texture->isAutoMipMapGenerationEnabled())
+ texture->generateMipMaps();
+
+ textureLock->unlock();
+
+ m_context->doneCurrent();
+
+ // gui thread can now continue
+ m_sharedObject->wake();
+ }
+}
+
+// this function gets called while the main thread is waiting
+void Scene2DData::cleanup()
+{
+ if (m_renderInitialized && m_initialized) {
+ m_context->makeCurrent(m_sharedObject->m_surface);
+ m_sharedObject->m_renderControl->invalidate();
+ m_context->functions()->glDeleteFramebuffers(1, &m_fbo);
+ m_context->functions()->glDeleteRenderbuffers(1, &m_rbo);
+ m_context->doneCurrent();
+ m_renderInitialized = false;
+ }
+ if (m_initialized) {
+ delete m_sharedObject->m_renderObject;
+ m_sharedObject->m_renderObject = nullptr;
+ delete m_context;
+ m_context = nullptr;
+ m_initialized = false;
+ }
+ if (m_sharedObject) {
+ // wake up the main thread
+ m_sharedObject->wake();
+ m_sharedObject = nullptr;
+ }
+ if (m_renderThread) {
+ renderThreadClientCount->fetchAndSubAcquire(1);
+ if (renderThreadClientCount->load() == 0)
+ renderThread->quit();
+ }
+ m_texture.reset();
+}
+
+ValueContainer<Scene2DState> updateScene2Ds(ValueContainer<Scene2DState> scene2dstate,
+ const ValueContainer<Scene2D> &scene2ds,
+ const QHash<Qt3DCore::QNodeId,
+ QSharedPointer<QOpenGLTexture> > *loadedTextures,
+ const ValueContainer<RenderTargetOutput> &outputs,
+ QOpenGLContext *shareContext)
+{
+ scene2dstate.reset();
+ const auto &keys = scene2ds.keys();
+ for (auto key : keys) {
+ Scene2D scene2d = *scene2ds[key];
+
+ if (!scene2d.m_data->m_initialized) {
+ scene2d.m_data->m_shareContext = shareContext;
+ scene2d.setSharedObject(scene2d.m_data->m_sharedObject);
+
+ RenderTargetOutput output = *outputs[scene2d.m_data->m_outputId];
+ Attachment attachment;
+ attachment.m_name = output.name;
+ attachment.m_mipLevel = output.mipLevel;
+ attachment.m_layer = output.layer;
+ attachment.m_textureUuid = output.textureUuid;
+ attachment.m_point = output.point;
+
+ scene2d.m_data->m_attachmentData = attachment;
+ if (loadedTextures->contains(attachment.m_textureUuid))
+ scene2d.m_data->m_texture = (*loadedTextures)[attachment.m_textureUuid];
+
+ scene2dstate[key] = Scene2DState(key, attachment.m_textureUuid, nullptr);
+ continue;
+ }
+
+ if (outputs.dirty().contains(scene2d.m_data->m_outputId)) {
+ RenderTargetOutput output = *outputs[scene2d.m_data->m_outputId];
+ Attachment attachment;
+ attachment.m_name = output.name;
+ attachment.m_mipLevel = output.mipLevel;
+ attachment.m_layer = output.layer;
+ attachment.m_textureUuid = output.textureUuid;
+ attachment.m_point = output.point;
+ // reset texture if changed
+ if (scene2d.m_data->m_attachmentData.m_textureUuid != attachment.m_textureUuid)
+ scene2d.m_data->m_texture.reset();
+
+ scene2d.m_data->m_attachmentData = attachment;
+ scene2d.m_data->m_outputDirty = true;
+ }
+
+ if (!scene2d.m_data->m_texture) {
+ if (loadedTextures->contains(scene2d.m_data->m_attachmentData.m_textureUuid)) {
+ scene2d.m_data->m_texture
+ = (*loadedTextures)[scene2d.m_data->m_attachmentData.m_textureUuid];
+ }
+ scene2dstate[key]
+ = Scene2DState(key, scene2d.m_data->m_attachmentData.m_textureUuid, nullptr);
+ continue;
+ }
+
+ scene2dstate[key] = Scene2DState(key, scene2d.m_data->m_attachmentData.m_textureUuid,
+ &scene2d.m_data->m_mutex);
+ }
+ return scene2dstate;
+}
+
+} // namespace Dragon
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/runtime/dragon/dragonscene2d_p.h b/src/runtime/dragon/dragonscene2d_p.h
new file mode 100644
index 0000000..582f935
--- /dev/null
+++ b/src/runtime/dragon/dragonscene2d_p.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DRAGON_SCENE2D_P_H
+#define DRAGON_SCENE2D_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 <Qt3DCore/qnodeid.h>
+#include <Qt3DCore/qpropertyupdatedchange.h>
+#include <Qt3DRender/qpickevent.h>
+#include <Qt3DQuickScene2D/qscene2d.h>
+
+#include <private/qscene2d_p.h>
+#include <private/dragonrendertargetoutput_p.h>
+#include <private/dragonbackendnode_p.h>
+#include <private/dragonattachment_p.h>
+#include <private/dragontexturejobs_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Dragon {
+
+struct Scene2DData;
+
+class RenderQmlEventHandler : public QObject
+{
+ Q_OBJECT
+public:
+ RenderQmlEventHandler(Scene2DData *node);
+ bool event(QEvent *e) override;
+
+private:
+ Scene2DData *m_node;
+};
+
+struct Scene2DState
+{
+ Qt3DCore::QNodeId m_scene2d;
+ Qt3DCore::QNodeId m_texture;
+ QMutex *m_mutex = nullptr;
+
+ Scene2DState()
+ {
+ }
+
+ Scene2DState(Qt3DCore::QNodeId id, Qt3DCore::QNodeId tid, QMutex *mutex)
+ : m_scene2d(id), m_texture(tid), m_mutex(mutex)
+ {
+ }
+};
+
+struct Scene2DData
+{
+ QOpenGLContext *m_context = nullptr;
+ QOpenGLContext *m_shareContext = nullptr;
+ QThread *m_renderThread = nullptr;
+ Qt3DCore::QNodeId m_outputId;
+ QSharedPointer<Qt3DRender::Quick::Scene2DSharedObject> m_sharedObject;
+ Qt3DCore::QNodeId m_peerId;
+ Attachment m_attachmentData;
+ QMutex m_mutex;
+ QSharedPointer<QOpenGLTexture> m_texture = nullptr;
+
+ GLuint m_fbo = 0;
+ GLuint m_rbo = 0;
+ QSize m_textureSize;
+
+ bool m_initialized = false;
+ bool m_renderInitialized = false;
+ bool m_mouseEnabled = false;
+ bool m_outputDirty = true;
+ Qt3DRender::Quick::QScene2D::RenderPolicy m_renderPolicy
+ = Qt3DRender::Quick::QScene2D::Continuous;
+
+ void render();
+ void initializeRender();
+ void cleanup();
+ bool updateFbo(QOpenGLTexture *texture, const QSize &size);
+ void syncRenderControl();
+};
+
+class Scene2D : public BackendNode
+{
+public:
+ Scene2D();
+ Scene2D(const Scene2D &s)
+ : m_data(s.m_data)
+ {
+ }
+ ~Scene2D();
+
+ void setSharedObject(Qt3DRender::Quick::Scene2DSharedObjectPtr sharedObject);
+ void setOutput(Qt3DCore::QNodeId outputId);
+ void initializeSharedObject();
+
+ void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
+ void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+
+ QSharedPointer<Scene2DData> m_data;
+};
+
+ValueContainer<Scene2DState> updateScene2Ds(ValueContainer<Scene2DState> scene2dstate,
+ const ValueContainer<Scene2D> &scene2ds,
+ const QHash<Qt3DCore::QNodeId,
+ QSharedPointer<QOpenGLTexture> > *loadedTextures,
+ const ValueContainer<RenderTargetOutput> &outputs,
+ QOpenGLContext *shareContext);
+
+} // Dragon
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // DRAGON_SCENE2D_P_H
diff --git a/src/runtime/dragon/dragontask_p.h b/src/runtime/dragon/dragontask_p.h
index 35c38e4..4d3150c 100644
--- a/src/runtime/dragon/dragontask_p.h
+++ b/src/runtime/dragon/dragontask_p.h
@@ -86,12 +86,12 @@ public:
Q_ASSERT(false); // the source tasks don't need to be run
}
- Output result()
+ const Output &result() const
{
Q_ASSERT(m_isFinished);
return m_result;
}
- bool isFinished() { return m_isFinished; }
+ bool isFinished() const { return m_isFinished; }
private:
Output m_result;
@@ -207,13 +207,13 @@ struct Task : public Qt3DCore::QAspectJob
m_isFinished = true;
}
- const Output &result()
+ const Output &result() const
{
Q_ASSERT(m_isFinished);
return m_result;
}
- bool isFinished() { return m_isFinished; }
+ bool isFinished() const { return m_isFinished; }
private:
std::function<void()> m_function;
diff --git a/src/runtime/dragon/dragontexture.cpp b/src/runtime/dragon/dragontexture.cpp
index cae7980..01fc622 100644
--- a/src/runtime/dragon/dragontexture.cpp
+++ b/src/runtime/dragon/dragontexture.cpp
@@ -46,7 +46,7 @@ namespace Dragon {
void Texture::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
{
- DirtyFlags dirty;
+ DirtyFlags dirty = NotDirty;
switch (e->type()) {
case PropertyUpdated: {
diff --git a/src/runtime/dragon/dragontexture_p.h b/src/runtime/dragon/dragontexture_p.h
index 0a2c48c..9c85b1c 100644
--- a/src/runtime/dragon/dragontexture_p.h
+++ b/src/runtime/dragon/dragontexture_p.h
@@ -81,7 +81,7 @@ public:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void addDirtyFlag(DirtyFlags flags);
- DirtyFlags dirty;
+ DirtyFlags dirty = NotDirty;
TextureProperties properties;
TextureParameters parameters;
diff --git a/src/runtime/dragon/dragontrackingchangescontainer_p.h b/src/runtime/dragon/dragontrackingchangescontainer_p.h
index 8a76b1b..bba173c 100644
--- a/src/runtime/dragon/dragontrackingchangescontainer_p.h
+++ b/src/runtime/dragon/dragontrackingchangescontainer_p.h
@@ -79,6 +79,11 @@ public:
void markDirty(const Key &id) override
{
+ // If m_dirty already contains id, don't replace it. Otherwise there
+ // is a risk to override DirtyTreeInfo{} with DirtyInfo{}
+ if (m_dirty.contains(id))
+ return;
+
m_dirty.insert(id, DirtyInfo{});
}
diff --git a/src/runtime/dragon/framegraph/dragonblitframebuffer_p.h b/src/runtime/dragon/framegraph/dragonblitframebuffer_p.h
index 66b022f..b790862 100644
--- a/src/runtime/dragon/framegraph/dragonblitframebuffer_p.h
+++ b/src/runtime/dragon/framegraph/dragonblitframebuffer_p.h
@@ -73,7 +73,7 @@ public:
QBlitFramebuffer::InterpolationMethod interpolationMethod() const;
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
Qt3DCore::QNodeId m_sourceRenderTargetId;
diff --git a/src/runtime/dragon/framegraph/dragoncameraselectornode_p.h b/src/runtime/dragon/framegraph/dragoncameraselectornode_p.h
index 5676dd9..334ba64 100644
--- a/src/runtime/dragon/framegraph/dragoncameraselectornode_p.h
+++ b/src/runtime/dragon/framegraph/dragoncameraselectornode_p.h
@@ -63,7 +63,7 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
Qt3DCore::QNodeId cameraUuid() const;
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
Qt3DCore::QNodeId m_cameraUuid;
diff --git a/src/runtime/dragon/framegraph/dragonclearbuffers.cpp b/src/runtime/dragon/framegraph/dragonclearbuffers.cpp
index cffc940..0882140 100644
--- a/src/runtime/dragon/framegraph/dragonclearbuffers.cpp
+++ b/src/runtime/dragon/framegraph/dragonclearbuffers.cpp
@@ -48,9 +48,9 @@ static QVector4D vec4dFromColor(const QColor &color)
ClearBuffers::ClearBuffers()
: FrameGraphNode(FrameGraphNode::ClearBuffers)
- , m_type(QClearBuffers::None)
- , m_clearDepthValue(1.f)
- , m_clearStencilValue(0)
+ , type(QClearBuffers::None)
+ , clearDepthValue(1.f)
+ , clearStencilValue(0)
{
}
@@ -59,12 +59,12 @@ void ClearBuffers::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr
FrameGraphNode::initializeFromPeer(change);
const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QClearBuffersData>>(change);
const auto &data = typedChange->data;
- m_type = data.buffersType;
- m_clearColorAsColor = data.clearColor;
- m_clearColor = vec4dFromColor(m_clearColorAsColor);
- m_clearDepthValue = data.clearDepthValue;
- m_clearStencilValue = data.clearStencilValue;
- m_colorBufferId = data.bufferId;
+ type = data.buffersType;
+ clearColorAsColor = data.clearColor;
+ clearColor = vec4dFromColor(clearColorAsColor);
+ clearDepthValue = data.clearDepthValue;
+ clearStencilValue = data.clearStencilValue;
+ colorBufferId = data.bufferId;
}
void ClearBuffers::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
@@ -72,61 +72,26 @@ void ClearBuffers::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
if (e->type() == PropertyUpdated) {
QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e);
if (propertyChange->propertyName() == QByteArrayLiteral("buffers")) {
- m_type = static_cast<QClearBuffers::BufferType>(propertyChange->value().toInt());
+ type = static_cast<QClearBuffers::BufferType>(propertyChange->value().toInt());
markDirty();
} else if (propertyChange->propertyName() == QByteArrayLiteral("clearColor")) {
- m_clearColorAsColor = propertyChange->value().value<QColor>();
- m_clearColor = vec4dFromColor(m_clearColorAsColor);
+ clearColorAsColor = propertyChange->value().value<QColor>();
+ clearColor = vec4dFromColor(clearColorAsColor);
markDirty();
} else if (propertyChange->propertyName() == QByteArrayLiteral("clearDepthValue")) {
- m_clearDepthValue = propertyChange->value().toFloat();
+ clearDepthValue = propertyChange->value().toFloat();
markDirty();
} else if (propertyChange->propertyName() == QByteArrayLiteral("clearStencilValue")) {
- m_clearStencilValue = propertyChange->value().toInt();
+ clearStencilValue = propertyChange->value().toInt();
markDirty();
} else if (propertyChange->propertyName() == QByteArrayLiteral("colorBuffer")) {
- m_colorBufferId = propertyChange->value().value<QNodeId>();
+ colorBufferId = propertyChange->value().value<QNodeId>();
markDirty();
}
}
FrameGraphNode::sceneChangeEvent(e);
}
-QClearBuffers::BufferType ClearBuffers::type() const
-{
- return m_type;
-}
-
-QColor ClearBuffers::clearColorAsColor() const
-{
- return m_clearColorAsColor;
-}
-
-QVector4D ClearBuffers::clearColor() const
-{
- return m_clearColor;
-}
-
-float ClearBuffers::clearDepthValue() const
-{
- return m_clearDepthValue;
-}
-
-int ClearBuffers::clearStencilValue() const
-{
- return m_clearStencilValue;
-}
-
-Qt3DCore::QNodeId ClearBuffers::bufferId() const
-{
- return m_colorBufferId;
-}
-
-bool ClearBuffers::clearsAllColorBuffers() const
-{
- return m_colorBufferId.isNull();
-}
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/framegraph/dragonclearbuffers_p.h b/src/runtime/dragon/framegraph/dragonclearbuffers_p.h
index 7e62136..7f28fd3 100644
--- a/src/runtime/dragon/framegraph/dragonclearbuffers_p.h
+++ b/src/runtime/dragon/framegraph/dragonclearbuffers_p.h
@@ -61,36 +61,21 @@ class ClearBuffers : public FrameGraphNode
{
public:
ClearBuffers();
-
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
- // TODO remove getters and make into a struct
- QClearBuffers::BufferType type() const;
- float clearDepthValue() const;
- int clearStencilValue() const;
- Qt3DCore::QNodeId bufferId() const;
-
+ QClearBuffers::BufferType type;
// in the backend we store this as a QVector4D, as the clearBuffer
// functions do support all float values (also those not clamped to [0,1])
// (for non-clamped float or int buffer types)
// we don't support this in the frontend yet, but let's keep our options for now
// and avoid QColor->QVector4D conversion every frame.
- QVector4D clearColor() const;
-
+ QVector4D clearColor;
// some clear operations only accept clamped values
- QColor clearColorAsColor() const;
-
- bool clearsAllColorBuffers() const;
-
-//private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
- QClearBuffers::BufferType m_type;
- QVector4D m_clearColor;
- QColor m_clearColorAsColor;
- float m_clearDepthValue;
- int m_clearStencilValue;
- Qt3DCore::QNodeId m_colorBufferId;
+ QColor clearColorAsColor;
+ float clearDepthValue;
+ int clearStencilValue;
+ Qt3DCore::QNodeId colorBufferId;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/framegraph/dragondispatchcompute_p.h b/src/runtime/dragon/framegraph/dragondispatchcompute_p.h
index 941feff..407ed0a 100644
--- a/src/runtime/dragon/framegraph/dragondispatchcompute_p.h
+++ b/src/runtime/dragon/framegraph/dragondispatchcompute_p.h
@@ -63,7 +63,7 @@ public:
inline int y() const Q_DECL_NOTHROW { return m_workGroups[1]; }
inline int z() const Q_DECL_NOTHROW { return m_workGroups[2]; }
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
int m_workGroups[3];
diff --git a/src/runtime/dragon/framegraph/dragonframegraph.pri b/src/runtime/dragon/framegraph/dragonframegraph.pri
deleted file mode 100644
index 9784a19..0000000
--- a/src/runtime/dragon/framegraph/dragonframegraph.pri
+++ /dev/null
@@ -1,103 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/cameraselectornode_p.h \
- $$PWD/clearbuffers_p.h \
- $$PWD/framegraphnode_p.h \
- $$PWD/framegraphvisitor_p.h \
- $$PWD/layerfilternode_p.h \
- $$PWD/nodraw_p.h \
- $$PWD/qcameraselector.h \
- $$PWD/qcameraselector_p.h \
- $$PWD/qclearbuffers.h \
- $$PWD/qclearbuffers_p.h \
- $$PWD/qframegraphnode.h \
- $$PWD/qframegraphnode_p.h \
- $$PWD/qlayerfilter.h \
- $$PWD/qlayerfilter_p.h \
- $$PWD/qnodraw.h \
- $$PWD/qrenderpassfilter.h \
- $$PWD/qrenderpassfilter_p.h \
- $$PWD/qrendertargetselector.h \
- $$PWD/qrendertargetselector_p.h \
- $$PWD/qsortpolicy.h \
- $$PWD/qsortpolicy_p.h \
- $$PWD/qrenderstateset.h \
- $$PWD/qrenderstateset_p.h \
- $$PWD/qtechniquefilter.h \
- $$PWD/qtechniquefilter_p.h \
- $$PWD/qviewport.h \
- $$PWD/qviewport_p.h \
- $$PWD/renderpassfilternode_p.h \
- $$PWD/rendertargetselectornode_p.h \
- $$PWD/sortpolicy_p.h \
- $$PWD/statesetnode_p.h \
- $$PWD/techniquefilternode_p.h \
- $$PWD/viewportnode_p.h \
- $$PWD/qfrustumculling.h \
- $$PWD/frustumculling_p.h \
- $$PWD/qdispatchcompute.h \
- $$PWD/dispatchcompute_p.h \
- $$PWD/qrendersurfaceselector.h \
- $$PWD/qrendersurfaceselector_p.h \
- $$PWD/rendersurfaceselector_p.h \
- $$PWD/qdispatchcompute_p.h \
- $$PWD/qrendercapture.h \
- $$PWD/qrendercapture_p.h \
- $$PWD/rendercapture_p.h \
- $$PWD/qbuffercapture.h \
- $$PWD/qbuffercapture_p.h \
- $$PWD/buffercapture_p.h \
- $$PWD/qframegraphnodecreatedchange.h \
- $$PWD/qframegraphnodecreatedchange_p.h \
- $$PWD/qmemorybarrier.h \
- $$PWD/qmemorybarrier_p.h \
- $$PWD/memorybarrier_p.h \
- $$PWD/qproximityfilter.h \
- $$PWD/qproximityfilter_p.h \
- $$PWD/proximityfilter_p.h \
- $$PWD/qblitframebuffer.h \
- $$PWD/qblitframebuffer_p.h \
- $$PWD/blitframebuffer_p.h
-
-SOURCES += \
- $$PWD/cameraselectornode.cpp \
- $$PWD/clearbuffers.cpp \
- $$PWD/framegraphnode.cpp \
- $$PWD/framegraphvisitor.cpp \
- $$PWD/layerfilternode.cpp \
- $$PWD/nodraw.cpp \
- $$PWD/qcameraselector.cpp \
- $$PWD/qclearbuffers.cpp \
- $$PWD/qframegraphnode.cpp \
- $$PWD/qlayerfilter.cpp \
- $$PWD/qnodraw.cpp \
- $$PWD/qrenderpassfilter.cpp \
- $$PWD/qrendertargetselector.cpp \
- $$PWD/qsortpolicy.cpp \
- $$PWD/qrenderstateset.cpp \
- $$PWD/qtechniquefilter.cpp \
- $$PWD/qviewport.cpp \
- $$PWD/renderpassfilternode.cpp \
- $$PWD/rendertargetselectornode.cpp \
- $$PWD/sortpolicy.cpp \
- $$PWD/statesetnode.cpp \
- $$PWD/techniquefilternode.cpp \
- $$PWD/viewportnode.cpp \
- $$PWD/qfrustumculling.cpp \
- $$PWD/frustumculling.cpp \
- $$PWD/qdispatchcompute.cpp \
- $$PWD/dispatchcompute.cpp \
- $$PWD/qrendersurfaceselector.cpp \
- $$PWD/rendersurfaceselector.cpp \
- $$PWD/qrendercapture.cpp \
- $$PWD/rendercapture.cpp \
- $$PWD/qbuffercapture.cpp \
- $$PWD/buffercapture.cpp \
- $$PWD/qframegraphnodecreatedchange.cpp \
- $$PWD/qmemorybarrier.cpp \
- $$PWD/memorybarrier.cpp \
- $$PWD/qproximityfilter.cpp \
- $$PWD/proximityfilter.cpp \
- $$PWD/qblitframebuffer.cpp \
- $$PWD/blitframebuffer.cpp
diff --git a/src/runtime/dragon/framegraph/dragonframegraphnode_p.h b/src/runtime/dragon/framegraph/dragonframegraphnode_p.h
index 71e2f7f..680f834 100644
--- a/src/runtime/dragon/framegraph/dragonframegraphnode_p.h
+++ b/src/runtime/dragon/framegraph/dragonframegraphnode_p.h
@@ -95,16 +95,15 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
-//protected:
FrameGraphNode(FrameGraphNodeType nodeType, Qt3DCore::QBackendNode::Mode mode = Qt3DCore::QBackendNode::ReadOnly);
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
-//private:
+ Qt3DCore::QNodeIdVector treeChildren() const { return m_childFrameGraphNodeIds; }
+
+private:
FrameGraphNodeType m_nodeType;
QVector<Qt3DCore::QNodeId> m_childFrameGraphNodeIds;
- Qt3DCore::QNodeIdVector treeChildren() const { return m_childFrameGraphNodeIds; }
-
friend class FrameGraphVisitor;
};
diff --git a/src/runtime/dragon/framegraph/dragonlayerfilternode.cpp b/src/runtime/dragon/framegraph/dragonlayerfilternode.cpp
index 269055f..cc3be42 100644
--- a/src/runtime/dragon/framegraph/dragonlayerfilternode.cpp
+++ b/src/runtime/dragon/framegraph/dragonlayerfilternode.cpp
@@ -45,7 +45,7 @@ namespace Dragon {
LayerFilterNode::LayerFilterNode()
: FrameGraphNode(FrameGraphNode::LayerFilter)
- , m_filterMode(QLayerFilter::AcceptAnyMatchingLayers)
+ , filterMode(QLayerFilter::AcceptAnyMatchingLayers)
{
}
@@ -54,8 +54,8 @@ void LayerFilterNode::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBaseP
FrameGraphNode::initializeFromPeer(change);
const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QLayerFilterData>>(change);
const auto &data = typedChange->data;
- setLayerIds(data.layerIds);
- m_filterMode = data.filterMode;
+ layerIds = data.layerIds;
+ filterMode = data.filterMode;
}
void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
@@ -64,7 +64,7 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
case PropertyValueAdded: {
const auto change = qSharedPointerCast<QPropertyNodeAddedChange>(e);
if (change->propertyName() == QByteArrayLiteral("layer")) {
- m_layerIds.append(change->addedNodeId());
+ layerIds.append(change->addedNodeId());
markDirty();
}
break;
@@ -73,7 +73,7 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
case PropertyValueRemoved: {
const auto change = qSharedPointerCast<QPropertyNodeRemovedChange>(e);
if (change->propertyName() == QByteArrayLiteral("layer")) {
- m_layerIds.removeOne(change->removedNodeId());
+ layerIds.removeOne(change->removedNodeId());
markDirty();
}
break;
@@ -82,7 +82,7 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
case PropertyUpdated: {
const auto change = qSharedPointerCast<QPropertyUpdatedChange>(e);
if (change->propertyName() == QByteArrayLiteral("filterMode")) {
- m_filterMode = static_cast<QLayerFilter::FilterMode>(change->value().value<int>());
+ filterMode = static_cast<QLayerFilter::FilterMode>(change->value().value<int>());
markDirty();
}
break;
@@ -95,21 +95,6 @@ void LayerFilterNode::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
FrameGraphNode::sceneChangeEvent(e);
}
-QNodeIdVector LayerFilterNode::layerIds() const
-{
- return m_layerIds;
-}
-
-void LayerFilterNode::setLayerIds(const QNodeIdVector &list)
-{
- m_layerIds = list;
-}
-
-QLayerFilter::FilterMode LayerFilterNode::filterMode() const
-{
- return m_filterMode;
-}
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/framegraph/dragonlayerfilternode_p.h b/src/runtime/dragon/framegraph/dragonlayerfilternode_p.h
index 6731e55..8c0f23f 100644
--- a/src/runtime/dragon/framegraph/dragonlayerfilternode_p.h
+++ b/src/runtime/dragon/framegraph/dragonlayerfilternode_p.h
@@ -58,16 +58,10 @@ public:
LayerFilterNode();
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
- Qt3DCore::QNodeIdVector layerIds() const;
- void setLayerIds(const Qt3DCore::QNodeIdVector &list);
-
- QLayerFilter::FilterMode filterMode() const;
-
-//private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
- Qt3DCore::QNodeIdVector m_layerIds;
- QLayerFilter::FilterMode m_filterMode;
+ Qt3DCore::QNodeIdVector layerIds;
+ QLayerFilter::FilterMode filterMode;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/framegraph/dragonmemorybarrier_p.h b/src/runtime/dragon/framegraph/dragonmemorybarrier_p.h
index 75c8e43..257d2b5 100644
--- a/src/runtime/dragon/framegraph/dragonmemorybarrier_p.h
+++ b/src/runtime/dragon/framegraph/dragonmemorybarrier_p.h
@@ -61,7 +61,7 @@ public:
QMemoryBarrier::Operations waitOperations() const;
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
QMemoryBarrier::Operations m_waitOperations;
};
diff --git a/src/runtime/dragon/framegraph/dragonproximityfilter_p.h b/src/runtime/dragon/framegraph/dragonproximityfilter_p.h
index 4d75b91..f887f18 100644
--- a/src/runtime/dragon/framegraph/dragonproximityfilter_p.h
+++ b/src/runtime/dragon/framegraph/dragonproximityfilter_p.h
@@ -66,7 +66,7 @@ public:
void setEntityId(Qt3DCore::QNodeId entityId) { m_entityId = entityId; }
#endif
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
float m_distanceThreshold;
diff --git a/src/runtime/dragon/framegraph/dragonrendercapture_p.h b/src/runtime/dragon/framegraph/dragonrendercapture_p.h
index fad7341..d62a8c8 100644
--- a/src/runtime/dragon/framegraph/dragonrendercapture_p.h
+++ b/src/runtime/dragon/framegraph/dragonrendercapture_p.h
@@ -63,11 +63,9 @@ public:
void addRenderCapture(int captureId, const QImage &image);
void sendRenderCaptures();
-//protected:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) final;
-//private:
-
+private:
QVector<QRenderCaptureRequest> m_requestedCaptures;
QVector<RenderCaptureDataPtr> m_renderCaptureData;
};
diff --git a/src/runtime/dragon/framegraph/dragonrenderpassfilternode_p.h b/src/runtime/dragon/framegraph/dragonrenderpassfilternode_p.h
index 451c453..3bc2317 100644
--- a/src/runtime/dragon/framegraph/dragonrenderpassfilternode_p.h
+++ b/src/runtime/dragon/framegraph/dragonrenderpassfilternode_p.h
@@ -64,13 +64,10 @@ public:
void removeFilter(Qt3DCore::QNodeId criterionId);
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
QVector<Qt3DCore::QNodeId> m_filters;
-
- // TODO move to Dragon
- // TODO why is this not just a QVector<QNodeId>?
Dragon::ParameterPack m_parameterPack;
};
diff --git a/src/runtime/dragon/framegraph/dragonrendersurfaceselector_p.h b/src/runtime/dragon/framegraph/dragonrendersurfaceselector_p.h
index 2976a17..b47dad5 100644
--- a/src/runtime/dragon/framegraph/dragonrendersurfaceselector_p.h
+++ b/src/runtime/dragon/framegraph/dragonrendersurfaceselector_p.h
@@ -67,7 +67,7 @@ public:
inline int height() const Q_DECL_NOTHROW { return m_height; }
inline float devicePixelRatio() const Q_DECL_NOTHROW { return m_devicePixelRatio; }
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
QSurface *m_surface;
diff --git a/src/runtime/dragon/framegraph/dragonrendertargetselectornode_p.h b/src/runtime/dragon/framegraph/dragonrendertargetselectornode_p.h
index f8cfc08..213a579 100644
--- a/src/runtime/dragon/framegraph/dragonrendertargetselectornode_p.h
+++ b/src/runtime/dragon/framegraph/dragonrendertargetselectornode_p.h
@@ -64,7 +64,7 @@ public:
Qt3DCore::QNodeId renderTargetUuid() const { return m_renderTargetUuid; }
QVector<QRenderTargetOutput::AttachmentPoint> outputs() const { return m_outputs; }
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
Qt3DCore::QNodeId m_renderTargetUuid;
diff --git a/src/runtime/dragon/framegraph/dragonsortcriterion.cpp b/src/runtime/dragon/framegraph/dragonsortcriterion.cpp
deleted file mode 100644
index 53fd5c9..0000000
--- a/src/runtime/dragon/framegraph/dragonsortcriterion.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 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 "dragonsortcriterion_p.h"
-#include <Qt3DCore/qnodepropertychange.h>
-#include <QVariant>
-
-QT_BEGIN_NAMESPACE
-
-using namespace Qt3DCore;
-
-namespace Qt3DRender {
-namespace Dragon {
-
-SortCriterion::SortCriterion()
- : BackendNode()
- , m_type(QSortCriterion::StateChangeCost)
-{
-}
-
-void SortCriterion::updateFromPeer(Qt3DCore::QNode *peer)
-{
- QSortCriterion *criterion = static_cast<QSortCriterion *>(peer);
- m_type = criterion->sort();
-}
-
-QSortCriterion::SortType SortCriterion::sortType() const
-{
- return m_type;
-}
-
-void SortCriterion::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- QNodePropertyChangePtr propertyChange = qSharedPointerCast<QNodePropertyChange>(e);
- if (e->type() == NodeUpdated && propertyChange->propertyName() == QByteArrayLiteral("sort")) {
- m_type = static_cast<QSortCriterion::SortType>(propertyChange->value().toInt());
- }
- markDirty();
-
- BackendNode::sceneChangeEvent(e);
-}
-
-} // namespace Dragon
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/runtime/dragon/framegraph/dragonsortpolicy_p.h b/src/runtime/dragon/framegraph/dragonsortpolicy_p.h
index 7d15514..b4ff739 100644
--- a/src/runtime/dragon/framegraph/dragonsortpolicy_p.h
+++ b/src/runtime/dragon/framegraph/dragonsortpolicy_p.h
@@ -61,7 +61,7 @@ public:
QVector<Qt3DRender::QSortPolicy::SortType> sortTypes() const;
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
QVector<Qt3DRender::QSortPolicy::SortType> m_sortTypes;
diff --git a/src/runtime/dragon/framegraph/dragonstatesetnode_p.h b/src/runtime/dragon/framegraph/dragonstatesetnode_p.h
index 6605b7a..f025758 100644
--- a/src/runtime/dragon/framegraph/dragonstatesetnode_p.h
+++ b/src/runtime/dragon/framegraph/dragonstatesetnode_p.h
@@ -59,12 +59,11 @@ public:
inline bool hasRenderStates() const { return !m_renderStates.empty(); }
QVector<Qt3DCore::QNodeId> renderStates() const;
-//protected:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
void addRenderState(Qt3DCore::QNodeId renderStateId);
void removeRenderState(Qt3DCore::QNodeId renderStateId);
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
QVector<Qt3DCore::QNodeId> m_renderStates;
};
diff --git a/src/runtime/dragon/framegraph/dragontechniquefilternode_p.h b/src/runtime/dragon/framegraph/dragontechniquefilternode_p.h
index 169e41f..e52a9dd 100644
--- a/src/runtime/dragon/framegraph/dragontechniquefilternode_p.h
+++ b/src/runtime/dragon/framegraph/dragontechniquefilternode_p.h
@@ -72,14 +72,13 @@ public:
QVector<Qt3DCore::QNodeId> filters() const;
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void appendFilter(Qt3DCore::QNodeId criterionId);
void removeFilter(Qt3DCore::QNodeId criterionId);
QVector<Qt3DCore::QNodeId> m_filters;
- // TODO move to Dragon
Dragon::ParameterPack m_parameterPack;
};
diff --git a/src/runtime/dragon/framegraph/dragonviewportnode_p.h b/src/runtime/dragon/framegraph/dragonviewportnode_p.h
index 5754e8a..dd6a94c 100644
--- a/src/runtime/dragon/framegraph/dragonviewportnode_p.h
+++ b/src/runtime/dragon/framegraph/dragonviewportnode_p.h
@@ -74,7 +74,7 @@ public:
static QRectF computeViewport(const QRectF &childViewport, const ViewportNode &parentViewport);
-//private:
+private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
float m_xMin;
diff --git a/src/runtime/dragon/framegraph/framegraph.pri b/src/runtime/dragon/framegraph/framegraph.pri
index 8214f87..159cdeb 100644
--- a/src/runtime/dragon/framegraph/framegraph.pri
+++ b/src/runtime/dragon/framegraph/framegraph.pri
@@ -14,7 +14,6 @@ SOURCES += \
$$PWD/dragonrenderpassfilternode.cpp \
$$PWD/dragonrendersurfaceselector.cpp \
$$PWD/dragonrendertargetselectornode.cpp \
-# $$PWD/dragonsortcriterion.cpp \ TODO where is this coming from (misses a header)
$$PWD/dragonsortpolicy.cpp \
$$PWD/dragonstatesetnode.cpp \
$$PWD/dragontechniquefilternode.cpp \
diff --git a/src/runtime/dragon/geometry/dragonbuffer.cpp b/src/runtime/dragon/geometry/dragonbuffer.cpp
index 0a97150..294b18f 100644
--- a/src/runtime/dragon/geometry/dragonbuffer.cpp
+++ b/src/runtime/dragon/geometry/dragonbuffer.cpp
@@ -87,7 +87,7 @@ void Buffer::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
bool operator ==(const Buffer &a, const Buffer &b)
{
return compareGenerators(a.m_generator, b.m_generator) && a.m_access == b.m_access && a.m_data == b.m_data
- && a.m_type == b.m_type && a.m_usage == b.m_usage;
+ && a.m_usage == b.m_usage;
}
} // Dragon
diff --git a/src/runtime/dragon/geometry/dragonbuffer_p.h b/src/runtime/dragon/geometry/dragonbuffer_p.h
index 63fde0a..eaa1f48 100644
--- a/src/runtime/dragon/geometry/dragonbuffer_p.h
+++ b/src/runtime/dragon/geometry/dragonbuffer_p.h
@@ -69,7 +69,6 @@ public:
QByteArray m_data;
QBuffer::AccessType m_access = QBuffer::Write;
QBufferDataGeneratorPtr m_generator;
- QBuffer::BufferType m_type;
};
bool operator ==(const Buffer &a, const Buffer &b);
diff --git a/src/runtime/dragon/geometry/dragongeometryrenderer.cpp b/src/runtime/dragon/geometry/dragongeometryrenderer.cpp
index 3114168..17af18c 100644
--- a/src/runtime/dragon/geometry/dragongeometryrenderer.cpp
+++ b/src/runtime/dragon/geometry/dragongeometryrenderer.cpp
@@ -66,11 +66,6 @@ GeometryRenderer::GeometryRenderer()
{
}
-//void GeometryRenderer::setManager(GeometryRendererManager *manager)
-//{
-// m_manager = manager;
-//}
-
void GeometryRenderer::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
{
const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QGeometryRendererData>>(change);
@@ -230,42 +225,6 @@ void GeometryRenderer::unsetDirty()
m_dirty = false;
}
-
-void GeometryRenderer::setTriangleVolumes(const QVector<RayCasting::QBoundingVolume *> &volumes)
-{
- qDeleteAll(m_triangleVolumes);
- m_triangleVolumes = volumes;
-}
-
-QVector<RayCasting::QBoundingVolume *> GeometryRenderer::triangleData() const
-{
- return m_triangleVolumes;
-}
-
-//GeometryRendererFunctor::GeometryRendererFunctor(AbstractRenderer *renderer, GeometryRendererManager *manager)
-// : m_manager(manager)
-// , m_renderer(renderer)
-//{
-//}
-
-//Qt3DCore::QBackendNode *GeometryRendererFunctor::create(const Qt3DCore::QNodeCreatedChangeBasePtr &change) const
-//{
-// GeometryRenderer *geometryRenderer = m_manager->getOrCreateResource(change->subjectId());
-// geometryRenderer->setManager(m_manager);
-// geometryRenderer->setRenderer(m_renderer);
-// return geometryRenderer;
-//}
-
-//Qt3DCore::QBackendNode *GeometryRendererFunctor::get(Qt3DCore::QNodeId id) const
-//{
-// return m_manager->lookupResource(id);
-//}
-
-//void GeometryRendererFunctor::destroy(Qt3DCore::QNodeId id) const
-//{
-// m_manager->releaseResource(id);
-//}
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/geometry/dragongeometryrenderer_p.h b/src/runtime/dragon/geometry/dragongeometryrenderer_p.h
index ff1bd82..e9aafc0 100644
--- a/src/runtime/dragon/geometry/dragongeometryrenderer_p.h
+++ b/src/runtime/dragon/geometry/dragongeometryrenderer_p.h
@@ -61,7 +61,6 @@ class Q_AUTOTEST_EXPORT GeometryRenderer : public BackendNode
public:
GeometryRenderer();
-// void setManager(GeometryRendererManager *manager);
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
void executeFunctor();
@@ -81,11 +80,6 @@ public:
inline QGeometryFactoryPtr geometryFactory() const { return m_geometryFactory; }
void unsetDirty();
- // Build triangle data Job thread
- void setTriangleVolumes(const QVector<RayCasting::QBoundingVolume *> &volumes);
- // Pick volumes job
- QVector<RayCasting::QBoundingVolume *> triangleData() const;
-
private:
Qt3DCore::QNodeId m_geometryId;
@@ -104,18 +98,6 @@ private:
QVector<RayCasting::QBoundingVolume *> m_triangleVolumes;
};
-//class GeometryRendererFunctor : public Qt3DCore::QBackendNodeMapper
-//{
-//public:
-// explicit GeometryRendererFunctor(AbstractRenderer *renderer, GeometryRendererManager *manager);
-// Qt3DCore::QBackendNode *create(const Qt3DCore::QNodeCreatedChangeBasePtr &change) const override;
-// Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const override;
-// void destroy(Qt3DCore::QNodeId id) const override;
-//private:
-// GeometryRendererManager *m_manager;
-// AbstractRenderer *m_renderer;
-//};
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/geometry/dragonsphere_p.h b/src/runtime/dragon/geometry/dragonsphere_p.h
index f5d733d..78ea99f 100644
--- a/src/runtime/dragon/geometry/dragonsphere_p.h
+++ b/src/runtime/dragon/geometry/dragonsphere_p.h
@@ -83,7 +83,7 @@ public:
void setCenter(const Vector3D &c);
Vector3D center() const override;
- inline bool isNull() { return m_center == Vector3D() && m_radius == 0.0f; }
+ inline bool isNull() const { return m_center == Vector3D() && m_radius == 0.0f; }
void setRadius(float r);
float radius() const override;
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelperes2.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelperes2.cpp
index 1409b3c..98e7f7e 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelperes2.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelperes2.cpp
@@ -30,7 +30,7 @@
#include "dragongraphicshelperes2_p.h"
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragongraphicsutils_p.h>
#include <private/dragonrenderbuffer_p.h>
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3.cpp
index 6bf0947..d37262a 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3.cpp
@@ -30,7 +30,7 @@
#include "dragongraphicshelperes3_p.h"
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragongraphicsutils_p.h>
#include <QOpenGLExtraFunctions>
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3_2.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3_2.cpp
index e35177b..dce8a01 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3_2.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelperes3_2.cpp
@@ -34,7 +34,7 @@
#include <Qt3DRender/qrendertargetoutput.h>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl2.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl2.cpp
index 44a2c47..b969dbf 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl2.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl2.cpp
@@ -35,7 +35,7 @@
#include <QOpenGLFunctions_2_0>
#include <QtOpenGLExtensions/QOpenGLExtensions>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragongraphicsutils_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_2.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_2.cpp
index 98ab287..ca74858 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_2.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_2.cpp
@@ -36,7 +36,7 @@
#include <QOpenGLFunctions_3_3_Core>
#include <QtOpenGLExtensions/qopenglextensions.h>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragongraphicsutils_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_3.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_3.cpp
index 18e0561..a89c7b7 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_3.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl3_3.cpp
@@ -35,7 +35,7 @@
#include <QOpenGLFunctions_3_3_Core>
#include <QtOpenGLExtensions/qopenglextensions.h>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragongraphicsutils_p.h>
# ifndef QT_OPENGL_3_2
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl4.cpp b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl4.cpp
index 1d7fbd6..7c55a44 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl4.cpp
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelpergl4.cpp
@@ -35,7 +35,7 @@
#include <QOpenGLFunctions_4_3_Core>
#include <QtOpenGLExtensions/qopenglextensions.h>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <private/dragongraphicsutils_p.h>
# ifndef QT_OPENGL_4_3
diff --git a/src/runtime/dragon/graphicshelpers/dragongraphicshelperinterface_p.h b/src/runtime/dragon/graphicshelpers/dragongraphicshelperinterface_p.h
index f913d1b..5bcb4ed 100644
--- a/src/runtime/dragon/graphicshelpers/dragongraphicshelperinterface_p.h
+++ b/src/runtime/dragon/graphicshelpers/dragongraphicshelperinterface_p.h
@@ -48,7 +48,7 @@
#include <private/dragonshadervariables_p.h>
#include <private/dragonuniform_p.h>
-#include <private/dragonattachmentpack_p.h>
+#include <private/dragonattachment_p.h>
#include <Qt3DRender/qmemorybarrier.h>
diff --git a/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp b/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp
index dbbc007..2e1b321 100644
--- a/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp
+++ b/src/runtime/dragon/jobs/dragonboundingvolumejobs.cpp
@@ -183,6 +183,8 @@ LocalBoundingVolumes calculateLocalBoundingVolumes(LocalBoundingVolumes localBou
const ValueContainer<Geometry> &geometries,
const ValueContainer<Buffer> &buffers)
{
+ localBoundingVolumes.reset();
+
if (!entities.anythingDirty() && !attributes.anythingDirty()
&& !geometryRenderers.anythingDirty() && !geometries.anythingDirty() && !buffers.anythingDirty())
return localBoundingVolumes;
@@ -333,8 +335,6 @@ LocalBoundingVolumes calculateLocalBoundingVolumes(LocalBoundingVolumes localBou
return result;
};
- localBoundingVolumes.reset();
-
localBoundingVolumes = rebuildAll(std::move(localBoundingVolumes),
entities,
calculateBoundingVolume);
@@ -346,6 +346,8 @@ WorldBoundingVolumes calculateWorldBoundingVolumes(WorldBoundingVolumes worldBou
const LocalBoundingVolumes &localBoundingVolumes,
const ValueContainer<Matrix4x4> &worldTransforms)
{
+ worldBoundingVolumes.reset();
+
if (!localBoundingVolumes.anythingDirty() && !worldTransforms.anythingDirty())
return worldBoundingVolumes;
@@ -361,7 +363,6 @@ WorldBoundingVolumes calculateWorldBoundingVolumes(WorldBoundingVolumes worldBou
return result;
};
- worldBoundingVolumes.reset();
worldBoundingVolumes = rebuildAll(std::move(worldBoundingVolumes),
localBoundingVolumes,
calculateBoundingVolume);
diff --git a/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp b/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp
index fc9ce1a..6371cf9 100644
--- a/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp
+++ b/src/runtime/dragon/jobs/dragonrenderviewjobs.cpp
@@ -244,33 +244,32 @@ RenderViews buildRenderViews(RenderViews renderViews,
const auto cb = node.as<Dragon::ClearBuffers>();
ClearBackBufferInfo info;
- QClearBuffers::BufferTypeFlags type = cb->type();
+ QClearBuffers::BufferTypeFlags type = cb->type;
if (type & QClearBuffers::StencilBuffer) {
- info.stencil = cb->clearStencilValue();
+ info.stencil = cb->clearStencilValue;
info.buffers |= QClearBuffers::StencilBuffer;
}
if (type & QClearBuffers::DepthBuffer) {
- info.depth = cb->clearDepthValue();
+ info.depth = cb->clearDepthValue;
info.buffers |= QClearBuffers::DepthBuffer;
}
// keep track of global ClearColor (if set) and collect all DrawBuffer-specific
// ClearColors
if (type & QClearBuffers::ColorBuffer) {
- // TODO make bufferId public
- if (cb->bufferId().isNull()) {
- info.color = cb->clearColor();
+ if (cb->colorBufferId.isNull()) {
+ info.color = cb->clearColor;
info.buffers |= QClearBuffers::ColorBuffer;
} else {
ClearColorInfo clearColorInfo;
- clearColorInfo.clearColor = cb->clearColor();
+ clearColorInfo.clearColor = cb->clearColor;
qWarning() << "WARNING: Reached incomplete code!";
// TODO add back attachmentPoint
// clearColorInfo.attchmentPoint =
// targetOutput->point();
// Note: a job is later performed to find the drawIndex from the buffer
// attachment point using the AttachmentPack
- renderView.specificClearColorBuffers.insert(cb->bufferId(), clearColorInfo);
+ renderView.specificClearColorBuffers.insert(cb->colorBufferId, clearColorInfo);
}
}
@@ -450,20 +449,6 @@ RenderViews buildRenderViews(RenderViews renderViews,
return renderViews;
} // namespace Dragon
-struct ParameterInfo {
- int nameId;
- Immutable<Parameter> handle;
-
- bool operator<(const int otherNameId) const Q_DECL_NOEXCEPT;
- bool operator<(const ParameterInfo &other) const Q_DECL_NOEXCEPT;
-};
-typedef QVector<ParameterInfo> ParameterInfoList;
-
-struct RenderPassParameterData {
- Immutable<RenderPass> pass;
- ParameterInfoList parameterInfo;
-};
-
enum StandardUniform {
ModelMatrix,
ViewMatrix,
@@ -489,38 +474,6 @@ enum StandardUniform {
SkinningPalette
};
-// TODO consider moving to a common helper header
-GLint glDataTypeFromAttributeDataType(QAttribute::VertexBaseType dataType)
-{
- switch (dataType) {
- case QAttribute::Byte:
- return GL_BYTE;
- case QAttribute::UnsignedByte:
- return GL_UNSIGNED_BYTE;
- case QAttribute::Short:
- return GL_SHORT;
- case QAttribute::UnsignedShort:
- return GL_UNSIGNED_SHORT;
- case QAttribute::Int:
- return GL_INT;
- case QAttribute::UnsignedInt:
- return GL_UNSIGNED_INT;
- case QAttribute::HalfFloat:
-#ifdef GL_HALF_FLOAT
- return GL_HALF_FLOAT;
-#endif
-#ifndef QT_OPENGL_ES_2 // Otherwise compile error as Qt defines GL_DOUBLE as GL_FLOAT when using ES2
- case QAttribute::Double:
- return GL_DOUBLE;
-#endif
- case QAttribute::Float:
- break;
- default:
- qWarning() << Q_FUNC_INFO << "unsupported dataType:" << dataType;
- }
- return GL_FLOAT;
-}
-
// We accept the entity if it contains any of the layers that are in the layer
// filter
bool containsAnyMatchingLayers(const Immutable<Entity> &entity,
@@ -781,7 +734,7 @@ RenderCommands buildDrawRenderCommands(RenderCommands renderCommands,
bool accepted = true;
for (const auto &layerFilter : renderView->layerFilters) {
- const auto &filterLayers = layerFilter->m_layerIds;
+ const auto &filterLayers = layerFilter->layerIds;
if (!containsAnyMatchingLayers(entity, filterLayers))
accepted = false;
}
@@ -791,9 +744,6 @@ RenderCommands buildDrawRenderCommands(RenderCommands renderCommands,
}
for (const auto &entity : filteredEntities) {
- // GeometryRenderer *geometryRenderer = nullptr;
- // HGeometryRenderer geometryRendererHandle =
- // entity->componentHandle<GeometryRenderer>();
if (entity->m_geometryRendererComponent.isNull())
continue;
Q_ASSERT(geometryRenderers.contains(entity->m_geometryRendererComponent));
@@ -1123,7 +1073,6 @@ GatheredParameters gatherMaterialParameters(GatheredParameters gatherResult,
if (Q_UNLIKELY(!material->isEnabled()))
continue;
- // TODO remove getter an make effect public
Q_ASSERT(effects.contains(material->effect()));
const auto &effect = effects[material->effect()];
diff --git a/src/runtime/dragon/jobs/dragonrenderviewjobs_p.h b/src/runtime/dragon/jobs/dragonrenderviewjobs_p.h
index 6b3a5a6..33b82c4 100644
--- a/src/runtime/dragon/jobs/dragonrenderviewjobs_p.h
+++ b/src/runtime/dragon/jobs/dragonrenderviewjobs_p.h
@@ -72,26 +72,6 @@ struct LocalBoundingVolumeResult;
// The same key is used by the render commands and parameter gatherer
using RenderViews = ValueContainer<RenderView>;
-struct RenderPassAndParameterIds
-{
- Immutable<RenderPass> renderPass;
- ParameterNameToIdMap parameters;
-};
-
-// TODO could this be replaced by a renderPass node id to parameter map?
-struct RenderPassAndParameters
-{
- Immutable<RenderPass> renderPass;
- ParameterNameToParameterMap parameters;
-};
-
-//struct RenderViewParameterData
-//{
-// // material id -> render pass + parameters
-// // TODO might not need Value here...
-// QHash<Qt3DCore::QNodeId, QVector<Value<RenderPassAndParameters>>> renderPassAndParameters;
-//};
-
struct RenderPassParameterIds
{
Immutable<RenderPass> renderPass;
diff --git a/src/runtime/dragon/jobs/dragonshaderjobs.cpp b/src/runtime/dragon/jobs/dragonshaderjobs.cpp
deleted file mode 100644
index e5201f0..0000000
--- a/src/runtime/dragon/jobs/dragonshaderjobs.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dragonshaderjobs_p.h"
-
-#include <private/dragonglshader_p.h>
-#include <private/dragonactivatedsurface_p.h>
-#include <private/graphicshelperinterface_p.h>
-#include <private/dragonjobs_common_p.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace Qt3DCore;
-
-namespace Qt3DRender {
-namespace Dragon {
-
-//ValueContainer<GLShader> uploadShaders(ValueContainer<GLShader> uploadedShaders,
-// const ValueContainer<Shader> &shaders)
-//{
-// auto uploadShader = [](const QNodeId &id, const Value<Shader> &shader, ActivatedSurface &gl) {
-// GLShader result;
-// result.dna = shader->dna();
-
-// // TODO consider dropping
-// result.shader = shader;
-
-// // TODO remember to delete
-// result.shaderProgram.reset(new QOpenGLShaderProgram);
-
-// auto *shaderProgram = result.shaderProgram.data(); // convenience
-
-// // Compile shaders
-// const auto shaderCode = shader->shaderCode();
-// QString logs;
-// for (int i = QShaderProgram::Vertex; i <= QShaderProgram::Compute; ++i) {
-// QShaderProgram::ShaderType type = static_cast<const QShaderProgram::ShaderType>(i);
-// if (!shaderCode.at(i).isEmpty()) {
-// // Note: logs only return the error but not all the shader code
-// // we could append it
-// if (!shaderProgram->addCacheableShaderFromSourceCode(shaderType(type),
-// shaderCode.at(i)))
-// logs += shaderProgram->log();
-// }
-// }
-
-// // Call glBindFragDataLocation and link the program
-// // Since we are sharing shaders in the backend, we assume that if using custom
-// // fragOutputs, they should all be the same for a given shader
-
-// // TODO add back support for frag outputs
-// // bindFragOutputs(shaderProgram->programId(), shaderNode->fragOutputs());
-
-// const bool linkSucceeded = shaderProgram->link();
-// logs += shaderProgram->log();
-
-// // TODO add back support for logs
-// // shader->setLog(logs);
-// // shader->setStatus(linkSucceeded ? QShaderProgram::Ready : QShaderProgram::Error);
-
-// if (!linkSucceeded) {
-// qWarning() << "WARNING: Shader linking failed";
-// return GLShader();
-// }
-
-// // result.shaderProgram.reset(shaderProgram);
-
-// // TODO I don't think either can ever happen, consider removing
-// if (Q_UNLIKELY(shaderProgram == nullptr) || shader->isLoaded()) {
-// qDebug() << "Failed loading";
-// return GLShader();
-// }
-
-// // Ensure the Shader node knows about the program interface
-
-// // Find an already loaded shader that shares the same QOpenGLShaderProgram
-// // Introspect and set up interface description on Shader backend node
-
-// // TODO should not have access to glHelper here, should use ActivatedSurface helper functions
-// // or this entire function could go inside ActivatedSurface
-// auto *glHelper = gl.glHelper();
-// const auto &uniforms = glHelper->programUniformsAndLocations(shaderProgram->programId());
-// const auto &setters = s_standardUniformSetters;
-
-// for (const auto &uniform : uniforms) {
-// const auto &nameId = uniform.m_nameId;
-// const auto &setter = setters[nameId];
-// if (setter == StandardUniform::Invalid) {
-// result.uniforms.append(uniform);
-// continue;
-// }
-// StandardShaderUniform standardShaderUniform;
-// standardShaderUniform.standardUniform = setter;
-// standardShaderUniform.shaderUniform = uniform;
-// result.standardUniforms.append(standardShaderUniform);
-// }
-
-// result.attributes = glHelper->programAttributesAndLocations(shaderProgram->programId());
-// if (glHelper->supportsFeature(Render::GraphicsHelperInterface::UniformBufferObject))
-// result.uniformBlocks = glHelper->programUniformBlocks(shaderProgram->programId());
-// if (glHelper->supportsFeature(Render::GraphicsHelperInterface::ShaderStorageObject))
-// result.storageBlocks = glHelper->programShaderStorageBlocks(shaderProgram->programId());
-
-// // TODO maybe prepare uniforms now?
-
-// return result;
-// };
-
-// // TODO cannot do this here, need to run on RenderThread
-//// uploadedShaders = synchronizeKeys(uploadedShaders, shaders, uploadShader);
-
-// return uploadedShaders;
-//};
-
-} // namespace Dragon
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/runtime/dragon/jobs/dragontransformjobs.cpp b/src/runtime/dragon/jobs/dragontransformjobs.cpp
index ba71dbb..6d15796 100644
--- a/src/runtime/dragon/jobs/dragontransformjobs.cpp
+++ b/src/runtime/dragon/jobs/dragontransformjobs.cpp
@@ -45,29 +45,6 @@ using namespace Qt3DCore;
namespace Qt3DRender {
namespace Dragon {
-// OLD ALTERNATIVE
-//Matrix4x4 calculateWorldTransform(QNodeId id, const ValueContainer<Entity> &entities,
-// const ValueContainer<Transform> &transforms)
-//{
-// const auto &entity = entities[id];
-// auto parent = entity;
-
-// Matrix4x4 worldTransform;
-// if (entity->m_transformComponent != QNodeId()) {
-// const auto &transform = transforms[entity->m_transformComponent];
-// worldTransform = transform->m_transformMatrix;
-// }
-
-// while (const auto &parentId = parent->m_parentEntityId) {
-// parent = entities[parentId];
-// if (parent->m_transformComponent != QNodeId()) {
-// auto parentTransform = transforms[parent->m_transformComponent];
-// worldTransform = parentTransform->m_transformMatrix * worldTransform;
-// }
-// }
-// return worldTransform;
-//}
-
ValueContainer<Matrix4x4> calculateWorldTransforms(ValueContainer<Matrix4x4> worldTransforms,
const ValueContainer<Entity> &entities,
const ValueContainer<Transform> &transforms,
diff --git a/src/runtime/dragon/jobs/dragontreejobs_p.h b/src/runtime/dragon/jobs/dragontreejobs_p.h
index f7c323b..9dd4955 100644
--- a/src/runtime/dragon/jobs/dragontreejobs_p.h
+++ b/src/runtime/dragon/jobs/dragontreejobs_p.h
@@ -64,12 +64,6 @@ struct InheritanceInfo
// TODO consider adding an ancestor list that includes ourselves (useful to build render views)
QVector<Key> ancestors;
QVector<Key> descendants;
-
- // Note: The parent is not stored because it was never used.
- // Feel free to add it if you need it.
-
- // TODO added for conveniance, consider dropping
- Key id;
QVector<Key> children;
void clear()
@@ -125,7 +119,6 @@ TreeInfo generateInheritanceTable(TreeInfo inheritanceTable, T nodes, Qt3DCore::
const auto &node = nodes[id];
auto tableNode = *(inheritanceTable.nodes[id]);
inheritanceTable.nodes.markDirty(id);
- tableNode.id = id;
tableNode.children = node->treeChildren();
inheritanceTable.nodes[id] = tableNode;
}
diff --git a/src/runtime/dragon/jobs/jobs.pri b/src/runtime/dragon/jobs/jobs.pri
index b9329f2..32ae5ec 100644
--- a/src/runtime/dragon/jobs/jobs.pri
+++ b/src/runtime/dragon/jobs/jobs.pri
@@ -3,7 +3,6 @@ HEADERS += \
$$PWD/dragonbufferjobs_p.h \
$$PWD/dragonmaterialjobs_p.h \
$$PWD/dragonrenderviewjobs_p.h \
- $$PWD/dragonshaderjobs_p.h \
$$PWD/dragontexturejobs_p.h \
$$PWD/dragontransformjobs_p.h \
$$PWD/dragontreejobs_p.h \
@@ -14,7 +13,6 @@ SOURCES += \
$$PWD/dragonbufferjobs.cpp \
$$PWD/dragonmaterialjobs.cpp \
$$PWD/dragonrenderviewjobs.cpp \
- $$PWD/dragonshaderjobs.cpp \
$$PWD/dragontexturejobs.cpp \
$$PWD/dragontransformjobs.cpp \
$$PWD/dragontreejobs.cpp \
diff --git a/src/runtime/dragon/materialsystem/dragonfilterkey.cpp b/src/runtime/dragon/materialsystem/dragonfilterkey.cpp
index c576c29..05878f7 100644
--- a/src/runtime/dragon/materialsystem/dragonfilterkey.cpp
+++ b/src/runtime/dragon/materialsystem/dragonfilterkey.cpp
@@ -72,11 +72,7 @@ bool FilterKey::operator ==(const FilterKey &other) const
{
if (&other == this)
return true;
- // TODO create a QVaraint::fastCompare function that returns false
- // if types are not equal. For now, applying
- // https://codereview.qt-project.org/#/c/204484/
- // and adding the following early comparison of the types should give
- // an equivalent performance gain:
+
return (other.value().type() == value().type() &&
other.name() == name() &&
other.value() == value());
diff --git a/src/runtime/dragon/materialsystem/dragonparameter_p.h b/src/runtime/dragon/materialsystem/dragonparameter_p.h
index 79baacc..ba5d1a3 100644
--- a/src/runtime/dragon/materialsystem/dragonparameter_p.h
+++ b/src/runtime/dragon/materialsystem/dragonparameter_p.h
@@ -69,9 +69,7 @@ public:
const UniformValue &uniformValue() const { return m_uniformValue; }
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
- // TODO remove getters and make members public
-//private:
-
+private:
QString m_name;
UniformValue m_uniformValue;
int m_nameId;
diff --git a/src/runtime/dragon/materialsystem/dragonrenderpass.cpp b/src/runtime/dragon/materialsystem/dragonrenderpass.cpp
index 56f8421..b4ea1d8 100644
--- a/src/runtime/dragon/materialsystem/dragonrenderpass.cpp
+++ b/src/runtime/dragon/materialsystem/dragonrenderpass.cpp
@@ -80,8 +80,7 @@ void RenderPass::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
if (change->propertyName() == QByteArrayLiteral("shaderProgram")) {
m_shaderUuid = change->value().value<Qt3DCore::QNodeId>();
markDirty();
- }
- if (change->propertyName() == QByteArrayLiteral("enabled")) {
+ } else if (change->propertyName() == QByteArrayLiteral("enabled")) {
m_enabled = change->value().toBool();
markDirty();
}
diff --git a/src/runtime/dragon/materialsystem/dragonrenderpass_p.h b/src/runtime/dragon/materialsystem/dragonrenderpass_p.h
index 285cee6..840772a 100644
--- a/src/runtime/dragon/materialsystem/dragonrenderpass_p.h
+++ b/src/runtime/dragon/materialsystem/dragonrenderpass_p.h
@@ -62,7 +62,6 @@ class RenderPass : public BackendNode
public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
- // TODO remove and remove m_ from members
Qt3DCore::QNodeId shaderProgram() const;
QVector<Qt3DCore::QNodeId> filterKeys() const;
QVector<Qt3DCore::QNodeId> parameters() const;
@@ -77,12 +76,13 @@ public:
void addRenderState(Qt3DCore::QNodeId renderStateId);
void removeRenderState(Qt3DCore::QNodeId renderStateId);
+ bool m_enabled = true;
+private:
Qt3DCore::QNodeId m_shaderUuid;
QVector<Qt3DCore::QNodeId> m_filterKeyList;
Dragon::ParameterPack m_parameterPack;
QVector<Qt3DCore::QNodeId> m_renderStates;
- bool m_enabled = true;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/materialsystem/dragonshader.cpp b/src/runtime/dragon/materialsystem/dragonshader.cpp
index 2ebc72f..b2283b8 100644
--- a/src/runtime/dragon/materialsystem/dragonshader.cpp
+++ b/src/runtime/dragon/materialsystem/dragonshader.cpp
@@ -45,7 +45,6 @@ namespace Dragon {
Shader::Shader()
: BackendNode()
- , m_isLoaded(false)
, m_dna(0)
, m_oldDna(0)
, m_status(QShaderProgram::NotReady)
@@ -67,7 +66,6 @@ void Shader::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &chang
m_shaderCode[QShaderProgram::Geometry] = data.geometryShaderCode;
m_shaderCode[QShaderProgram::Fragment] = data.fragmentShaderCode;
m_shaderCode[QShaderProgram::Compute] = data.computeShaderCode;
- m_isLoaded = false;
updateDNA();
// markDirty(AbstractRenderer::ShadersDirty);
}
@@ -103,7 +101,6 @@ void Shader::setShaderCode(QShaderProgram::ShaderType type, const QByteArray &co
return;
m_shaderCode[type] = code;
- m_isLoaded = false;
setStatus(QShaderProgram::NotReady);
updateDNA();
// markDirty(AbstractRenderer::ShadersDirty);
@@ -375,7 +372,6 @@ void Shader::initializeFromReference(const Shader &other)
m_shaderStorageBlockNamesIds = other.m_shaderStorageBlockNamesIds;
m_shaderStorageBlockNames = other.m_shaderStorageBlockNames;
m_shaderStorageBlocks = other.m_shaderStorageBlocks;
- m_isLoaded = other.m_isLoaded;
setStatus(other.status());
setLog(other.log());
}
diff --git a/src/runtime/dragon/materialsystem/dragonshader_p.h b/src/runtime/dragon/materialsystem/dragonshader_p.h
index cb7899e..0fbbe95 100644
--- a/src/runtime/dragon/materialsystem/dragonshader_p.h
+++ b/src/runtime/dragon/materialsystem/dragonshader_p.h
@@ -88,9 +88,7 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
- // TODO makes no sense here, we need to introduce LoadedShader type
- bool isLoaded() const { return m_isLoaded; }
- void setLoaded(bool loaded) { m_isLoaded = loaded; }
+ // TODO: Shader DNA not really used in dragon, consider removing
ProgramDNA dna() const Q_DECL_NOTHROW { return m_dna; }
inline QVector<ShaderUniform> uniforms() const { return m_uniforms; }
@@ -115,7 +113,6 @@ public:
inline bool hasPendingNotifications() const { return !m_pendingNotifications.empty(); }
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
- // TODO remove getters and make invariant members public
private:
QVector<QString> m_uniformsNames;
@@ -139,10 +136,9 @@ private:
QVector<QByteArray> m_shaderCode;
- bool m_isLoaded;
ProgramDNA m_dna;
ProgramDNA m_oldDna;
-// GraphicsContext *m_graphicsContext;
+
QMetaObject::Connection m_contextConnection;
QString m_log;
QShaderProgram::Status m_status;
@@ -160,8 +156,6 @@ private:
void initializeFromReference(const Shader &other);
void setLog(const QString &log);
void setStatus(QShaderProgram::Status status);
-
-// friend class GraphicsContext;
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/runtime/dragon/materialsystem/dragonshaderbuilder.cpp b/src/runtime/dragon/materialsystem/dragonshaderbuilder.cpp
deleted file mode 100644
index 7ca58fa..0000000
--- a/src/runtime/dragon/materialsystem/dragonshaderbuilder.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "dragonshaderbuilder_p.h"
-
-#include <Qt3DRender/private/qshaderprogrambuilder_p.h>
-#include <Qt3DRender/private/qurlhelper_p.h>
-
-#include <QtGui/private/qshaderformat_p.h>
-#include <QtGui/private/qshadergraphloader_p.h>
-#include <QtGui/private/qshadergenerator_p.h>
-#include <QtGui/private/qshadernodesloader_p.h>
-
-#include <QFile>
-#include <QFileInfo>
-#include <QUrl>
-
-static void initResources()
-{
-#ifdef QT_STATIC
- Q_INIT_RESOURCE(materialsystem);
-#endif
-}
-
-QT_BEGIN_NAMESPACE
-
-class GlobalShaderPrototypes
-{
-public:
- GlobalShaderPrototypes()
- {
- initResources();
- setPrototypesFile(QStringLiteral(":/prototypes/default.json"));
- }
-
- QString prototypesFile() const
- {
- return m_fileName;
- }
-
- void setPrototypesFile(const QString &fileName)
- {
- m_fileName = fileName;
- load();
- }
-
- QHash<QString, QShaderNode> prototypes() const
- {
- return m_prototypes;
- }
-
-private:
- void load()
- {
- QFile file(m_fileName);
- if (!file.open(QFile::ReadOnly)) {
- qWarning() << "Couldn't open file:" << m_fileName;
- return;
- }
-
- QShaderNodesLoader loader;
- loader.setDevice(&file);
- loader.load();
- m_prototypes = loader.nodes();
- }
-
- QString m_fileName;
- QHash<QString, QShaderNode> m_prototypes;
-};
-
-Q_GLOBAL_STATIC(GlobalShaderPrototypes, qt3dGlobalShaderPrototypes)
-
-using namespace Qt3DCore;
-
-namespace Qt3DRender {
-namespace Dragon {
-
-QString ShaderBuilder::getPrototypesFile()
-{
- return qt3dGlobalShaderPrototypes->prototypesFile();
-}
-
-void ShaderBuilder::setPrototypesFile(const QString &file)
-{
- qt3dGlobalShaderPrototypes->setPrototypesFile(file);
-}
-
-QStringList ShaderBuilder::getPrototypeNames()
-{
- return qt3dGlobalShaderPrototypes->prototypes().keys();
-}
-
-Qt3DCore::QNodeId ShaderBuilder::shaderProgramId() const
-{
- return m_shaderProgramId;
-}
-
-QStringList ShaderBuilder::enabledLayers() const
-{
- return m_enabledLayers;
-}
-
-
-void ShaderBuilder::setEnabledLayers(const QStringList &layers)
-{
- if (m_enabledLayers == layers)
- return;
-
- m_enabledLayers = layers;
-
- for (QHash<ShaderType, QUrl>::const_iterator it = m_graphs.cbegin(); it != m_graphs.cend(); ++it) {
- if (!it.value().isEmpty())
- m_dirtyTypes.insert(it.key());
- }
-}
-
-GraphicsApiFilterData ShaderBuilder::graphicsApi() const
-{
- return m_graphicsApi;
-}
-
-void ShaderBuilder::setGraphicsApi(const GraphicsApiFilterData &graphicsApi)
-{
- if (m_graphicsApi == graphicsApi)
- return;
-
- m_graphicsApi = graphicsApi;
- for (QHash<ShaderType, QUrl>::const_iterator it = m_graphs.cbegin(); it != m_graphs.cend(); ++it) {
- if (!it.value().isEmpty())
- m_dirtyTypes.insert(it.key());
- }
-}
-
-QUrl ShaderBuilder::shaderGraph(ShaderBuilder::ShaderType type) const
-{
- return m_graphs.value(type);
-}
-
-void ShaderBuilder::setShaderGraph(ShaderBuilder::ShaderType type, const QUrl &url)
-{
- if (url != m_graphs.value(type)) {
- m_graphs.insert(type, url);
- m_dirtyTypes.insert(type);
- }
-}
-
-QByteArray ShaderBuilder::shaderCode(ShaderBuilder::ShaderType type) const
-{
- return m_codes.value(type);
-}
-
-bool ShaderBuilder::isShaderCodeDirty(ShaderBuilder::ShaderType type) const
-{
- return m_dirtyTypes.contains(type);
-}
-
-static QByteArray deincludify(const QByteArray &contents, const QString &filePath);
-
-static QByteArray deincludify(const QString &filePath)
-{
- QFile f(filePath);
- if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
- qWarning() << "Could not read shader source file:" << f.fileName();
- return QByteArray();
- }
-
- QByteArray contents = f.readAll();
- return deincludify(contents, filePath);
-}
-
-static QByteArray deincludify(const QByteArray &contents, const QString &filePath)
-{
- QByteArrayList lines = contents.split('\n');
- const QByteArray includeDirective = QByteArrayLiteral("#pragma include");
- for (int i = 0; i < lines.count(); ++i) {
- const auto line = lines[i].simplified();
- if (line.startsWith(includeDirective)) {
- const QString includePartialPath = QString::fromUtf8(line.mid(includeDirective.count() + 1));
-
- QString includePath = QFileInfo(includePartialPath).isAbsolute() ? includePartialPath
- : QFileInfo(filePath).absolutePath() + QLatin1Char('/') + includePartialPath;
- if (qEnvironmentVariableIsSet("QT3D_GLSL100_WORKAROUND")) {
- QString candidate = includePath + QLatin1String("100");
- if (QFile::exists(candidate))
- includePath = candidate;
- }
- lines.removeAt(i);
- QByteArray includedContents = deincludify(includePath);
- lines.insert(i, includedContents);
- QString lineDirective = QString(QStringLiteral("#line %1")).arg(i + 2);
- lines.insert(i + 1, lineDirective.toUtf8());
- }
- }
-
- return lines.join('\n');
-}
-
-void ShaderBuilder::generateCode(ShaderBuilder::ShaderType type)
-{
- const auto graphPath = QUrlHelper::urlToLocalFileOrQrc(shaderGraph(type));
- QFile file(graphPath);
- if (!file.open(QFile::ReadOnly)) {
- qWarning() << "Couldn't open file:" << graphPath;
- return;
- }
-
- auto graphLoader = QShaderGraphLoader();
- graphLoader.setPrototypes(qt3dGlobalShaderPrototypes->prototypes());
- graphLoader.setDevice(&file);
- graphLoader.load();
-
- if (graphLoader.status() == QShaderGraphLoader::Error)
- return;
-
- const auto graph = graphLoader.graph();
-
- auto format = QShaderFormat();
- format.setApi(m_graphicsApi.m_api == QGraphicsApiFilter::OpenGLES ? QShaderFormat::OpenGLES
- : m_graphicsApi.m_profile == QGraphicsApiFilter::CoreProfile ? QShaderFormat::OpenGLCoreProfile
- : m_graphicsApi.m_profile == QGraphicsApiFilter::CompatibilityProfile ? QShaderFormat::OpenGLCompatibilityProfile
- : QShaderFormat::OpenGLNoProfile);
- format.setVersion(QVersionNumber(m_graphicsApi.m_major, m_graphicsApi.m_minor));
- format.setExtensions(m_graphicsApi.m_extensions);
- format.setVendor(m_graphicsApi.m_vendor);
-
- auto generator = QShaderGenerator();
- generator.format = format;
- generator.graph = graph;
-
- const auto code = generator.createShaderCode(m_enabledLayers);
- m_codes.insert(type, deincludify(code, graphPath + QStringLiteral(".glsl")));
- m_dirtyTypes.remove(type);
-}
-
-void ShaderBuilder::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- if (e->type() == PropertyUpdated) {
- QPropertyUpdatedChangePtr propertyChange = e.staticCast<QPropertyUpdatedChange>();
- QVariant propertyValue = propertyChange->value();
-
- if (propertyChange->propertyName() == QByteArrayLiteral("shaderProgram"))
- m_shaderProgramId = propertyValue.value<Qt3DCore::QNodeId>();
- else if (propertyChange->propertyName() == QByteArrayLiteral("enabledLayers"))
- setEnabledLayers(propertyValue.toStringList());
- else if (propertyChange->propertyName() == QByteArrayLiteral("vertexShaderGraph"))
- setShaderGraph(Vertex, propertyValue.toUrl());
- else if (propertyChange->propertyName() == QByteArrayLiteral("tessellationControlShaderGraph"))
- setShaderGraph(TessellationControl, propertyValue.toUrl());
- else if (propertyChange->propertyName() == QByteArrayLiteral("tessellationEvaluationShaderGraph"))
- setShaderGraph(TessellationEvaluation, propertyValue.toUrl());
- else if (propertyChange->propertyName() == QByteArrayLiteral("geometryShaderGraph"))
- setShaderGraph(Geometry, propertyValue.toUrl());
- else if (propertyChange->propertyName() == QByteArrayLiteral("fragmentShaderGraph"))
- setShaderGraph(Fragment, propertyValue.toUrl());
- else if (propertyChange->propertyName() == QByteArrayLiteral("computeShaderGraph"))
- setShaderGraph(Compute, propertyValue.toUrl());
-
- markDirty();
- }
- BackendNode::sceneChangeEvent(e);
-}
-
-void ShaderBuilder::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
-{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QShaderProgramBuilderData>>(change);
- const auto &data = typedChange->data;
-
- m_shaderProgramId = data.shaderProgramId;
- m_enabledLayers = data.enabledLayers;
- setShaderGraph(Vertex, data.vertexShaderGraph);
- setShaderGraph(TessellationControl, data.tessellationControlShaderGraph);
- setShaderGraph(TessellationEvaluation, data.tessellationEvaluationShaderGraph);
- setShaderGraph(Geometry, data.geometryShaderGraph);
- setShaderGraph(Fragment, data.fragmentShaderGraph);
- setShaderGraph(Compute, data.computeShaderGraph);
-}
-
-} // namespace Dragon
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
diff --git a/src/runtime/dragon/materialsystem/dragonshaderbuilder_p.h b/src/runtime/dragon/materialsystem/dragonshaderbuilder_p.h
deleted file mode 100644
index 455cb08..0000000
--- a/src/runtime/dragon/materialsystem/dragonshaderbuilder_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) 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.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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT3DRENDER_DRAGON_SHADERBUILDER_H
-#define QT3DRENDER_DRAGON_SHADERBUILDER_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 <private/dragonbackendnode_p.h>
-#include <Qt3DRender/private/qgraphicsapifilter_p.h>
-
-#include <Qt3DCore/qpropertyupdatedchange.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-
-namespace Dragon {
-
-class ShaderBuilder : public BackendNode
-{
-public:
- enum ShaderType {
- Vertex = 0,
- TessellationControl,
- TessellationEvaluation,
- Geometry,
- Fragment,
- Compute
- };
-
- static QString getPrototypesFile();
- static void setPrototypesFile(const QString &file);
- static QStringList getPrototypeNames();
-
- Qt3DCore::QNodeId shaderProgramId() const;
- QStringList enabledLayers() const;
-
- GraphicsApiFilterData graphicsApi() const;
- void setGraphicsApi(const GraphicsApiFilterData &graphicsApi);
-
- QUrl shaderGraph(ShaderType type) const;
- void setShaderGraph(ShaderType type, const QUrl &url);
-
- QByteArray shaderCode(ShaderType type) const;
- bool isShaderCodeDirty(ShaderType type) const;
-
- void generateCode(ShaderType type);
-
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
-
-private:
- void setEnabledLayers(const QStringList &layers);
-
- GraphicsApiFilterData m_graphicsApi;
- Qt3DCore::QNodeId m_shaderProgramId;
- QStringList m_enabledLayers;
- QHash<ShaderType, QUrl> m_graphs;
- QHash<ShaderType, QByteArray> m_codes;
- QSet<ShaderType> m_dirtyTypes;
-};
-
-} // namespace Dragon
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-#endif // QT3DRENDER_DRAGON_SHADERBUILDER_H
diff --git a/src/runtime/dragon/materialsystem/dragonshaderdata.cpp b/src/runtime/dragon/materialsystem/dragonshaderdata.cpp
index 7db470c..4c4a160 100644
--- a/src/runtime/dragon/materialsystem/dragonshaderdata.cpp
+++ b/src/runtime/dragon/materialsystem/dragonshaderdata.cpp
@@ -51,9 +51,6 @@ const int qNodeIdTypeId = qMetaTypeId<Qt3DCore::QNodeId>();
}
-// TODO remove
-//QVector<Qt3DCore::QNodeId> ShaderData::m_updatedShaderData;
-
void ShaderData::initializeFromPeer(const QNodeCreatedChangeBasePtr &change)
{
const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QShaderDataData>>(change);
@@ -202,30 +199,6 @@ void ShaderData::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
BackendNode::sceneChangeEvent(e);
}
-//RenderShaderDataFunctor::RenderShaderDataFunctor(AbstractRenderer *renderer, NodeManagers *managers)
-// : m_managers(managers)
-// , m_renderer(renderer)
-//{
-//}
-
-//Qt3DCore::QBackendNode *RenderShaderDataFunctor::create(const Qt3DCore::QNodeCreatedChangeBasePtr &change) const
-//{
-// ShaderData *backend = m_managers->shaderDataManager()->getOrCreateResource(change->subjectId());
-// backend->setManagers(m_managers);
-// backend->setRenderer(m_renderer);
-// return backend;
-//}
-
-//Qt3DCore::QBackendNode *RenderShaderDataFunctor::get(Qt3DCore::QNodeId id) const
-//{
-// return m_managers->shaderDataManager()->lookupResource(id);
-//}
-
-//void RenderShaderDataFunctor::destroy(Qt3DCore::QNodeId id) const
-//{
-// m_managers->shaderDataManager()->releaseResource(id);
-//}
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/materialsystem/dragonshaderdata_p.h b/src/runtime/dragon/materialsystem/dragonshaderdata_p.h
index b5ca212..da15ccf 100644
--- a/src/runtime/dragon/materialsystem/dragonshaderdata_p.h
+++ b/src/runtime/dragon/materialsystem/dragonshaderdata_p.h
@@ -54,6 +54,8 @@ namespace Qt3DRender {
namespace Dragon {
+// TODO: Dragon doesn't currently use anything from this class.
+// So consider refactoring / removing.
class ShaderData : public BackendNode
{
public:
@@ -75,7 +77,6 @@ public:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
- // TODO remove getters and make members public
protected:
PropertyReaderInterfacePtr m_propertyReader;
@@ -89,31 +90,12 @@ protected:
// Contains property that are defined like: postionTransformed: ModelToEye
QHash<QString, TransformType> m_transformedProperties;
-
-// static QVector<Qt3DCore::QNodeId> m_updatedShaderData;
Matrix4x4 m_worldMatrix;
- Matrix4x4 m_viewMatrix;
void clearUpdatedProperties();
ShaderData *lookupResource(Qt3DCore::QNodeId id);
-
- friend class RenderShaderDataFunctor;
};
-//class RenderShaderDataFunctor : public Qt3DCore::QBackendNodeMapper
-//{
-//public:
-// explicit RenderShaderDataFunctor(AbstractRenderer *renderer, NodeManagers *managers);
-
-// Qt3DCore::QBackendNode *create(const Qt3DCore::QNodeCreatedChangeBasePtr &change) const final;
-// Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const final;
-// void destroy(Qt3DCore::QNodeId id) const final;
-
-//private:
-// NodeManagers *m_managers;
-// AbstractRenderer *m_renderer;
-//};
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/materialsystem/dragontechnique.cpp b/src/runtime/dragon/materialsystem/dragontechnique.cpp
index aa77212..bc0f04b 100644
--- a/src/runtime/dragon/materialsystem/dragontechnique.cpp
+++ b/src/runtime/dragon/materialsystem/dragontechnique.cpp
@@ -68,7 +68,6 @@ void Technique::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
markDirty();
} else if (change->propertyName() == QByteArrayLiteral("graphicsApiFilterData")) {
m_graphicsApiFilterData = change->value().value<GraphicsApiFilterData>();
- m_isCompatibleWithRenderer = false;
markDirty();
}
break;
@@ -141,59 +140,6 @@ GraphicsApiFilterData Technique::graphicsApiFilter() const
return m_graphicsApiFilterData;
}
-// TODO consider if this works as expected in Dragon and can be removed now
-//bool Technique::isCompatibleWithRenderer() const
-//{
-// return m_isCompatibleWithRenderer;
-//}
-
-//void Technique::setCompatibleWithRenderer(bool compatible)
-//{
-// m_isCompatibleWithRenderer = compatible;
-//}
-
-//bool Technique::isCompatibleWithFilters(const QNodeIdVector &filterKeyIds) const
-//{
-// // TODO implement this again
-// qWarning() << Q_FUNC_INFO << "not implemented";
-//// // There is a technique filter so we need to check for a technique with suitable criteria.
-//// // Check for early bail out if the technique doesn't have sufficient number of criteria and
-//// // can therefore never satisfy the filter
-//// if (m_filterKeyList.size() < filterKeyIds.size())
-//// return false;
-
-//// // Iterate through the filter criteria and for each one search for a criteria on the
-//// // technique that satisfies it
-//// for (const QNodeId filterKeyId : filterKeyIds) {
-//// FilterKey *filterKey = m_nodeManager->filterKeyManager()->lookupResource(filterKeyId);
-
-//// bool foundMatch = false;
-
-//// for (const QNodeId techniqueFilterKeyId : qAsConst(m_filterKeyList)) {
-//// FilterKey *techniqueFilterKey = m_nodeManager->filterKeyManager()->lookupResource(techniqueFilterKeyId);
-//// if ((foundMatch = (*techniqueFilterKey == *filterKey)))
-//// break;
-//// }
-
-//// // No match for TechniqueFilter criterion in any of the technique's criteria.
-//// // So no way this can match. Don't bother checking the rest of the criteria.
-//// if (!foundMatch)
-//// return false;
-//// }
-//// return true;
-// return true;
-//}
-
-//void Technique::setNodeManager(NodeManagers *nodeManager)
-//{
-//// m_nodeManager = nodeManager;
-//}
-
-//NodeManagers *Technique::nodeManager() const
-//{
-// return m_nodeManager;
-//}
-
void Technique::appendFilterKey(Qt3DCore::QNodeId criterionId)
{
if (!m_filterKeyList.contains(criterionId))
@@ -205,31 +151,6 @@ void Technique::removeFilterKey(Qt3DCore::QNodeId criterionId)
m_filterKeyList.removeOne(criterionId);
}
-//TechniqueFunctor::TechniqueFunctor(AbstractRenderer *renderer, NodeManagers *manager)
-// : m_manager(manager)
-// , m_renderer(renderer)
-//{
-//}
-
-//QBackendNode *TechniqueFunctor::create(const QNodeCreatedChangeBasePtr &change) const
-//{
-// Technique *technique = m_manager->techniqueManager()->getOrCreateResource(change->subjectId());
-// technique->setNodeManager(m_manager);
-// technique->setRenderer(m_renderer);
-// return technique;
-//}
-
-//QBackendNode *TechniqueFunctor::get(QNodeId id) const
-//{
-// return m_manager->techniqueManager()->lookupResource(id);
-//}
-
-//void TechniqueFunctor::destroy(QNodeId id) const
-//{
-// m_manager->techniqueManager()->releaseResource(id);
-
-//}
-
} // namespace Dragon
} // namespace Qt3DRender
diff --git a/src/runtime/dragon/materialsystem/dragontechnique_p.h b/src/runtime/dragon/materialsystem/dragontechnique_p.h
index eee7e61..74be2cf 100644
--- a/src/runtime/dragon/materialsystem/dragontechnique_p.h
+++ b/src/runtime/dragon/materialsystem/dragontechnique_p.h
@@ -48,7 +48,6 @@
#include <Qt3DRender/private/qgraphicsapifilter_p.h>
#include <QVector>
-#include <QStringList>
QT_BEGIN_NAMESPACE
@@ -70,30 +69,23 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
QVector<Qt3DCore::QNodeId> parameters() const;
- void appendRenderPass(Qt3DCore::QNodeId renderPassId);
- void removeRenderPass(Qt3DCore::QNodeId renderPassId);
-
- void appendFilterKey(Qt3DCore::QNodeId criterionId);
- void removeFilterKey(Qt3DCore::QNodeId criterionId);
-
- // TODO remove getters and use public members
QVector<Qt3DCore::QNodeId> filterKeys() const;
QVector<Qt3DCore::QNodeId> renderPasses() const;
GraphicsApiFilterData graphicsApiFilter() const;
-// bool isCompatibleWithRenderer() const;
-// void setCompatibleWithRenderer(bool compatible);
-
-// bool isCompatibleWithFilters(const Qt3DCore::QNodeIdVector &filterKeyIds) const;
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final;
private:
+ void appendRenderPass(Qt3DCore::QNodeId renderPassId);
+ void removeRenderPass(Qt3DCore::QNodeId renderPassId);
+
+ void appendFilterKey(Qt3DCore::QNodeId criterionId);
+ void removeFilterKey(Qt3DCore::QNodeId criterionId);
GraphicsApiFilterData m_graphicsApiFilterData;
Dragon::ParameterPack m_parameterPack;
QVector<Qt3DCore::QNodeId> m_filterKeyList;
QVector<Qt3DCore::QNodeId> m_renderPasses;
- bool m_isCompatibleWithRenderer = false;
};
} // namespace Dragon
diff --git a/src/runtime/dragon/materialsystem/materialsystem.pri b/src/runtime/dragon/materialsystem/materialsystem.pri
index b6b701c..b01dbc0 100644
--- a/src/runtime/dragon/materialsystem/materialsystem.pri
+++ b/src/runtime/dragon/materialsystem/materialsystem.pri
@@ -5,7 +5,6 @@ HEADERS += \
$$PWD/dragonparameter_p.h \
$$PWD/dragonrenderpass_p.h \
$$PWD/dragonshader_p.h \
- $$PWD/dragonshaderbuilder_p.h \
$$PWD/dragonshaderdata_p.h \
$$PWD/dragontechnique_p.h
@@ -16,6 +15,5 @@ SOURCES += \
$$PWD/dragonparameter.cpp \
$$PWD/dragonrenderpass.cpp \
$$PWD/dragonshader.cpp \
- $$PWD/dragonshaderbuilder.cpp \
$$PWD/dragonshaderdata.cpp \
$$PWD/dragontechnique.cpp
diff --git a/src/runtime/dragon/qdragonrenderaspect.cpp b/src/runtime/dragon/qdragonrenderaspect.cpp
index c087ed7..e6d57c0 100644
--- a/src/runtime/dragon/qdragonrenderaspect.cpp
+++ b/src/runtime/dragon/qdragonrenderaspect.cpp
@@ -30,7 +30,6 @@
#include "qdragonrenderaspect_p.h"
// General
-#include <private/dragonmanager_p.h>
#include <private/dragonrenderer_p.h>
// Frontend nodes
@@ -81,6 +80,7 @@
#include <Qt3DRender/qtechniquefilter.h>
#include <Qt3DRender/qtexture.h>
#include <Qt3DRender/qviewport.h>
+#include <Qt3DQuickScene2D/qscene2d.h>
// Frame graph nodes
#include <private/dragonblitframebuffer_p.h>
@@ -101,9 +101,9 @@
#include <private/dragonstatesetnode_p.h>
#include <private/dragontechniquefilternode_p.h>
#include <private/dragonviewportnode_p.h>
+#include <private/dragonscene2d_p.h>
// Jobs
-#include <private/dragonshaderjobs_p.h>
#include <private/dragontransformjobs_p.h>
#include <private/dragonboundingvolumejobs_p.h>
@@ -213,6 +213,7 @@ QDragonRenderAspect::QDragonRenderAspect(Renderer::RenderType renderType)
registerBackendType<QShaderData>(m_shaderDatas);
registerBackendType<QShaderProgram>(m_shaders);
registerBackendType<QRenderState>(m_renderStates);
+ registerBackendType<Quick::QScene2D>(m_scene2ds);
// Custom functors
registerBackendType<QRenderSettings>(QSharedPointer<RenderSettingsFunctor>::create(this));
@@ -285,6 +286,13 @@ QDragonRenderAspect::QDragonRenderAspect(Renderer::RenderType renderType)
m_textures,
m_loadTextureImages);
+ m_updateScene2Ds = TaskPtr<ValueContainer<Scene2DState>>::create(updateScene2Ds,
+ Self,
+ m_scene2ds,
+ m_snaggedTexturesSource,
+ m_renderTargetOutputs,
+ m_shareContextSource);
+
// TODO might as well upload them as well...
m_loadBuffers = TaskPtr<LoadedBuffers>::create(loadBuffers, Self, m_buffers);
@@ -410,6 +418,7 @@ QDragonRenderAspect::QDragonRenderAspect(Renderer::RenderType renderType)
const ValueContainer<Attribute> &attributes,
const ValueContainer<Parameter> &parameters,
const ValueContainer<Matrix4x4> &worldTransforms,
+ const ValueContainer<Scene2DState> &scene2ds,
const ValueContainer<CameraMatrices> &renderViewCameraMatrices) {
// TODO how do we handle incremental changes?
// TODO if nothing changed, do we really need to upload again?
@@ -427,6 +436,7 @@ QDragonRenderAspect::QDragonRenderAspect(Renderer::RenderType renderType)
data.parameters = parameters;
data.worldTransforms = worldTransforms;
data.frameGraph = frameGraph;
+ data.scene2ds = scene2ds;
m_renderer->addLatestData(data);
return true;
};
@@ -441,6 +451,7 @@ QDragonRenderAspect::QDragonRenderAspect(Renderer::RenderType renderType)
m_attributes,
m_parameters,
m_calculateWorldTransforms,
+ m_updateScene2Ds,
cameraMatrices);
// TODO would be nice to have a taskmanager that all the above are put into
@@ -450,6 +461,7 @@ QDragonRenderAspect::QDragonRenderAspect(Renderer::RenderType renderType)
m_printTransforms,
m_loadTextures,
m_loadTextureImages,
+ m_updateScene2Ds,
m_loadBuffers,
m_generateFrameGraph,
m_buildRenderViews,
@@ -515,6 +527,8 @@ QVector<Qt3DCore::QAspectJobPtr> QDragonRenderAspect::jobsToExecute(qint64 time)
m_rootFrameGraphNodeSource->setInput(m_renderSettings->activeFrameGraphID());
m_rootEntitySource->setInput(rootEntityId());
+ m_shareContextSource->setInput(m_renderer->shareContext());
+ m_snaggedTexturesSource->setInput(&m_renderer->textures());
// TODO add all to a task container that generates this
return m_jobs;
diff --git a/src/runtime/dragon/qdragonrenderaspect_p.h b/src/runtime/dragon/qdragonrenderaspect_p.h
index b660823..e788243 100644
--- a/src/runtime/dragon/qdragonrenderaspect_p.h
+++ b/src/runtime/dragon/qdragonrenderaspect_p.h
@@ -49,7 +49,6 @@
#include <private/dragonentity_p.h>
#include <private/dragonfilterkey_p.h>
#include <private/dragonframegraphnode_p.h>
-#include <private/dragonmanager_p.h>
#include <private/dragonmapper_p.h>
#include <private/dragonmaterial_p.h>
#include <private/dragonparameter_p.h>
@@ -76,6 +75,7 @@
#include <private/dragonrenderer_p.h>
#include <private/dragonrenderviewjobs_p.h>
#include <private/dragontexturejobs_p.h>
+#include <private/dragonscene2d_p.h>
#include <Qt3DCore/QAbstractAspect>
#include <Qt3DCore/QAspectJob>
@@ -147,6 +147,7 @@ private:
NodeFunctorPtr<Shader> m_shaders = NodeFunctorPtr<Shader>::create();
NodeFunctorPtr<ShaderData> m_shaderDatas = NodeFunctorPtr<ShaderData>::create();
NodeFunctorPtr<RenderStateNode> m_renderStates = NodeFunctorPtr<RenderStateNode>::create();
+ NodeFunctorPtr<Scene2D> m_scene2ds = NodeFunctorPtr<Scene2D>::create();
// Frame graph
ValueContainer<FrameGraphNode> m_frameGraphNodesContainer;
@@ -154,12 +155,16 @@ private:
&m_frameGraphNodesContainer);
RenderSettings *m_renderSettings = nullptr;
- // Qt3DCore::ResourceManager<Buffer> m_bufferManager;
// TODO boilerplate, consider generating
SourceTaskPtr<Qt3DCore::QNodeId> m_rootEntitySource = SourceTaskPtr<Qt3DCore::QNodeId>::create();
SourceTaskPtr<Qt3DCore::QNodeId> m_rootFrameGraphNodeSource
= SourceTaskPtr<Qt3DCore::QNodeId>::create();
+ SourceTaskPtr<QOpenGLContext *> m_shareContextSource = SourceTaskPtr<QOpenGLContext *>::create();
+
+ typedef QHash<Qt3DCore::QNodeId, QSharedPointer<QOpenGLTexture>> NodeIdTextureHash;
+ SourceTaskPtr<const NodeIdTextureHash *> m_snaggedTexturesSource
+ = SourceTaskPtr<const NodeIdTextureHash *>::create();
// TODO look into ways of declaring templates based on function spec
// TODO or look for a way to store multiple tasks in a simple container
@@ -182,6 +187,7 @@ private:
TaskPtr<RenderViews> m_buildRenderViews;
TaskPtr<RenderCommands> m_buildRenderCommands;
TaskPtr<AppliedRenderCommandss> m_applyParameters;
+ TaskPtr<ValueContainer<Scene2DState>> m_updateScene2Ds;
QScopedPointer<Renderer> m_renderer;
friend class RenderSettingsFunctor;
diff --git a/src/runtime/dragon/renderer/dragondraw.cpp b/src/runtime/dragon/renderer/dragondraw.cpp
index 38ca6a8..91057fe 100644
--- a/src/runtime/dragon/renderer/dragondraw.cpp
+++ b/src/runtime/dragon/renderer/dragondraw.cpp
@@ -494,8 +494,6 @@ bool draw(const ActivatedSurface &activatedSurface,
{
QOpenGLContext *openGLContext = activatedSurface.openGLContext();
GraphicsHelperInterface *graphicsHelper = activatedSurface.glHelper();
- // TODO no need to deref here, just change from . to -> below
-// RenderCommand command = *cmd->renderCommand;
RenderCommand command = *cmd;
// TODO consider "global state" from executeCommandSubmission
// bindVertexArrayObject(vao);
diff --git a/src/runtime/dragon/renderer/dragonopenglvertexarrayobject_p.h b/src/runtime/dragon/renderer/dragonopenglvertexarrayobject_p.h
index 537b52d..072c1b2 100644
--- a/src/runtime/dragon/renderer/dragonopenglvertexarrayobject_p.h
+++ b/src/runtime/dragon/renderer/dragonopenglvertexarrayobject_p.h
@@ -92,8 +92,6 @@ public:
struct VAOVertexAttribute
{
- Mutable<GLBuffer> bufferHandle;
-
// TODO should we just store the Attribute instead of copying this?
GLBuffer::Type attributeType;
int location;
diff --git a/src/runtime/dragon/renderer/dragonshaderparameterpack_p.h b/src/runtime/dragon/renderer/dragonshaderparameterpack_p.h
index 09b36e0..551d810 100644
--- a/src/runtime/dragon/renderer/dragonshaderparameterpack_p.h
+++ b/src/runtime/dragon/renderer/dragonshaderparameterpack_p.h
@@ -77,6 +77,8 @@ struct BlockToSSBO {
typedef QHash<int, UniformValue> PackUniformHash;
+// TODO: Dragon doesn't currently use anything else than NamedTexture from this class.
+// So consider refactoring / removing.
class Q_AUTOTEST_EXPORT ShaderParameterPack
{
public:
diff --git a/src/runtime/dragon/renderstates/dragonrenderstates.cpp b/src/runtime/dragon/renderstates/dragonrenderstates.cpp
index a5de9de..a2aa883 100644
--- a/src/runtime/dragon/renderstates/dragonrenderstates.cpp
+++ b/src/runtime/dragon/renderstates/dragonrenderstates.cpp
@@ -69,7 +69,7 @@ void AlphaFunc::updateProperty(const char *name, const QVariant &value)
{
if (name == QByteArrayLiteral("alphaFunction"))
std::get<0>(m_values) = value.toInt();
- if (name == QByteArrayLiteral("referenceValue"))
+ else if (name == QByteArrayLiteral("referenceValue"))
std::get<1>(m_values) = value.toFloat();
}
diff --git a/src/runtime/q3dsdatainputentry_p.h b/src/runtime/q3dsdatainputentry_p.h
index e8cb0f3..af096a5 100644
--- a/src/runtime/q3dsdatainputentry_p.h
+++ b/src/runtime/q3dsdatainputentry_p.h
@@ -46,20 +46,17 @@
#include <QString>
#include <QHash>
#include <QVariant>
+#include <QDataStream>
+#include <QByteArray>
QT_BEGIN_NAMESPACE
struct Q3DSV_PRIVATE_EXPORT Q3DSDataInputEntry
{
typedef QHash<QString, Q3DSDataInputEntry> Map;
- // Metadata key - Datainput name mapping. Internally
- // key is type QString, as QVariant does not work that well
- // as keys to QMultiHash. Accesses to this map are therefore
- // done using QVariant automatic cast to QString (UIA format
- // anyway stores metadata as strings, so that is the usual use case).
- // TODO: use case of keys that are of different internal type but
- // equivalent after auto cast to QString eg. "9.0" type string vs "9.0" type float?
- typedef QMultiHash<QString, QString> MetadataMap;
+ // Metadata key - Datainput name mapping for faster lookups
+ // when enquiring datainputs that have metadata with specified key.
+ typedef QMultiHash<QVariant, QString> MetadataMap;
enum Type {
TypeString,
@@ -75,17 +72,24 @@ struct Q3DSV_PRIVATE_EXPORT Q3DSDataInputEntry
Type type = TypeString;
float minValue = 0;
float maxValue = 0;
- // As per QT3DS-2205 we currently need only a single key-value pair per datainput.
- // For efficiency we use separate items for both, as there is no need for more
- // elaborate containers.
- QVariant metaDataKey;
- QVariant metaData;
+
+ QHash<QVariant, QVariant> metadata;
// Just check that relative minmax values are sane, which also
// covers the case when both are at default value of 0.0 i.e. unset.
bool hasMinMax() const { return maxValue > minValue; }
};
+inline uint qHash(const QVariant &key)
+{
+ QByteArray ar;
+ QDataStream ds(&ar, QIODevice::WriteOnly);
+
+ ds << key;
+
+ return qHashBits(ar, ds.device()->pos());
+}
+
Q_DECLARE_TYPEINFO(Q3DSDataInputEntry, Q_MOVABLE_TYPE);
QT_END_NAMESPACE
diff --git a/src/runtime/q3dsdistancefieldglyphcache.cpp b/src/runtime/q3dsdistancefieldglyphcache.cpp
index 5f555ba..6086917 100644
--- a/src/runtime/q3dsdistancefieldglyphcache.cpp
+++ b/src/runtime/q3dsdistancefieldglyphcache.cpp
@@ -35,6 +35,7 @@
#include <QtQuick/private/qsgareaallocator_p.h>
#include <QtCore/qmath.h>
+#include <QtCore/qendian.h>
#if QT_VERSION >= QT_VERSION_CHECK(5,12,2)
@@ -143,6 +144,10 @@ Q3DSDistanceFieldGlyphCache::Q3DSDistanceFieldGlyphCache(const QRawFont &font, Q
{
Q3DSGraphicsLimits gfxLimits = Q3DS::graphicsLimits();
m_isOpenGLES = gfxLimits.format.renderableType() == QSurfaceFormat::OpenGLES;
+
+ m_maxTextureSize = Q3DSDISTANCEFIELDGLYPHCACHE_MAXIMUM_TEXURE_SIZE;
+
+ loadPregeneratedCache(font);
}
Q3DSDistanceFieldGlyphCache::~Q3DSDistanceFieldGlyphCache()
@@ -151,7 +156,7 @@ Q3DSDistanceFieldGlyphCache::~Q3DSDistanceFieldGlyphCache()
int Q3DSDistanceFieldGlyphCache::maxTextureSize() const
{
- return Q3DSDISTANCEFIELDGLYPHCACHE_MAXIMUM_TEXURE_SIZE;
+ return m_maxTextureSize;
}
Q3DSDistanceFieldGlyphCache::TextureInfo *Q3DSDistanceFieldGlyphCache::textureInfo(int index) const
@@ -323,6 +328,239 @@ Q3DSDistanceFieldGlyphCache::TextureInfo *Q3DSDistanceFieldGlyphCache::textureIn
return textureInfo(id - 1);
}
+// This is all copy-pasted from Qt Quick, as sharing it would require some refactoring, and we
+// need to work with Qt 5.12.2 at the moment.
+namespace {
+ struct Qtdf {
+ // We need these structs to be tightly packed, but some compilers we use do not
+ // support #pragma pack(1), so we need to hardcode the offsets/sizes in the
+ // file format
+ enum TableSize {
+ HeaderSize = 14,
+ GlyphRecordSize = 46,
+ TextureRecordSize = 17
+ };
+
+ enum Offset {
+ // Header
+ majorVersion = 0,
+ minorVersion = 1,
+ pixelSize = 2,
+ textureSize = 4,
+ flags = 8,
+ headerPadding = 9,
+ numGlyphs = 10,
+
+ // Glyph record
+ glyphIndex = 0,
+ textureOffsetX = 4,
+ textureOffsetY = 8,
+ textureWidth = 12,
+ textureHeight = 16,
+ xMargin = 20,
+ yMargin = 24,
+ boundingRectX = 28,
+ boundingRectY = 32,
+ boundingRectWidth = 36,
+ boundingRectHeight = 40,
+ textureIndex = 44,
+
+ // Texture record
+ allocatedX = 0,
+ allocatedY = 4,
+ allocatedWidth = 8,
+ allocatedHeight = 12,
+ texturePadding = 16
+
+ };
+
+ template <typename T>
+ static inline T fetch(const char *data, Offset offset)
+ {
+ return qFromBigEndian<T>(data + int(offset));
+ }
+ };
+}
+
+bool Q3DSDistanceFieldGlyphCache::loadPregeneratedCache(const QRawFont &font)
+{
+ // The pregenerated data must be loaded first, otherwise the area allocator
+ // will be wrong
+ if (m_areaAllocator != nullptr) {
+ qWarning("Font cache must be loaded before cache is used");
+ return false;
+ }
+
+ QByteArray qtdfTable = font.fontTable("qtdf");
+ if (qtdfTable.isEmpty())
+ return false;
+
+ typedef QHash<TextureInfo *, QVector<glyph_t> > GlyphTextureHash;
+
+ GlyphTextureHash glyphTextures;
+
+ if (uint(qtdfTable.size()) < Qtdf::HeaderSize) {
+ qWarning("Invalid qtdf table in font '%s'",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ const char *qtdfTableStart = qtdfTable.constData();
+ const char *qtdfTableEnd = qtdfTableStart + qtdfTable.size();
+
+ int padding = 0;
+ int textureCount = 0;
+ {
+ quint8 majorVersion = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::majorVersion);
+ quint8 minorVersion = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::minorVersion);
+ if (majorVersion != 5 || minorVersion != 12) {
+ qWarning("Invalid version of qtdf table %d.%d in font '%s'",
+ majorVersion,
+ minorVersion,
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ qreal pixelSize = qreal(Qtdf::fetch<quint16>(qtdfTableStart, Qtdf::pixelSize));
+ m_maxTextureSize = int(Qtdf::fetch<quint32>(qtdfTableStart, Qtdf::textureSize));
+ m_doubleGlyphResolution = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::flags) == 1;
+ padding = Qtdf::fetch<quint8>(qtdfTableStart, Qtdf::headerPadding);
+
+ if (pixelSize <= 0.0) {
+ qWarning("Invalid pixel size in '%s'", qPrintable(font.familyName()));
+ return false;
+ }
+
+ if (m_maxTextureSize <= 0) {
+ qWarning("Invalid texture size in '%s'", qPrintable(font.familyName()));
+ return false;
+ }
+
+ if (padding != Q3DSDISTANCEFIELDGLYPHCACHE_PADDING) {
+ qWarning("Padding mismatch in '%s'. Font requires %d, but Qt is compiled with %d.",
+ qPrintable(font.familyName()),
+ padding,
+ Q3DSDISTANCEFIELDGLYPHCACHE_PADDING);
+ }
+
+ m_referenceFont.setPixelSize(pixelSize);
+
+ quint32 glyphCount = Qtdf::fetch<quint32>(qtdfTableStart, Qtdf::numGlyphs);
+ m_unusedGlyphs.reserve(int(glyphCount));
+
+ const char *allocatorData = qtdfTableStart + Qtdf::HeaderSize;
+ {
+ m_areaAllocator = new QSGAreaAllocator(QSize(0, 0));
+ allocatorData = m_areaAllocator->deserialize(allocatorData, qtdfTableEnd - allocatorData);
+ if (allocatorData == nullptr)
+ return false;
+ }
+
+ if (m_areaAllocator->size().height() % m_maxTextureSize != 0) {
+ qWarning("Area allocator size mismatch in '%s'", qPrintable(font.familyName()));
+ return false;
+ }
+
+ textureCount = m_areaAllocator->size().height() / m_maxTextureSize;
+ m_maxTextureCount = qMax(m_maxTextureCount, textureCount);
+
+ const char *textureRecord = allocatorData;
+ for (int i = 0; i < textureCount; ++i, textureRecord += Qtdf::TextureRecordSize) {
+ if (textureRecord + Qtdf::TextureRecordSize > qtdfTableEnd) {
+ qWarning("qtdf table too small in font '%s'.",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ TextureInfo *tex = textureInfo(i);
+ tex->allocatedArea.setX(int(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedX)));
+ tex->allocatedArea.setY(int(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedY)));
+ tex->allocatedArea.setWidth(int(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedWidth)));
+ tex->allocatedArea.setHeight(int(Qtdf::fetch<quint32>(textureRecord, Qtdf::allocatedHeight)));
+ tex->padding = Qtdf::fetch<quint8>(textureRecord, Qtdf::texturePadding);
+ }
+
+ const char *glyphRecord = textureRecord;
+ for (quint32 i = 0; i < glyphCount; ++i, glyphRecord += Qtdf::GlyphRecordSize) {
+ if (glyphRecord + Qtdf::GlyphRecordSize > qtdfTableEnd) {
+ qWarning("qtdf table too small in font '%s'.",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ glyph_t glyph = Qtdf::fetch<quint32>(glyphRecord, Qtdf::glyphIndex);
+ m_unusedGlyphs.insert(glyph);
+
+ GlyphData &glyphData = emptyData(glyph);
+
+#define FROM_FIXED_POINT(value) \
+(qreal(value)/qreal(65536))
+
+ glyphData.texCoord.x = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureOffsetX));
+ glyphData.texCoord.y = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureOffsetY));
+ glyphData.texCoord.width = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureWidth));
+ glyphData.texCoord.height = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::textureHeight));
+ glyphData.texCoord.xMargin = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::xMargin));
+ glyphData.texCoord.yMargin = FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::yMargin));
+ glyphData.boundingRect.setX(FROM_FIXED_POINT(Qtdf::fetch<qint32>(glyphRecord, Qtdf::boundingRectX)));
+ glyphData.boundingRect.setY(FROM_FIXED_POINT(Qtdf::fetch<qint32>(glyphRecord, Qtdf::boundingRectY)));
+ glyphData.boundingRect.setWidth(FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::boundingRectWidth)));
+ glyphData.boundingRect.setHeight(FROM_FIXED_POINT(Qtdf::fetch<quint32>(glyphRecord, Qtdf::boundingRectHeight)));
+
+#undef FROM_FIXED_POINT
+
+ int textureIndex = Qtdf::fetch<quint16>(glyphRecord, Qtdf::textureIndex);
+ if (textureIndex < 0 || textureIndex >= textureCount) {
+ qWarning("Invalid texture index %d (texture count == %d) in '%s'",
+ textureIndex,
+ textureCount,
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+
+ TextureInfo *texInfo = textureInfo(textureIndex);
+ m_glyphsTexture.insert(glyph, texInfo);
+
+ glyphTextures[texInfo].append(glyph);
+ }
+
+ const uchar *textureData = reinterpret_cast<const uchar *>(glyphRecord);
+ for (int i = 0; i < textureCount; ++i) {
+
+ TextureInfo *texInfo = textureInfo(i);
+
+ int width = texInfo->allocatedArea.width();
+ int height = texInfo->allocatedArea.height();
+ qint64 size = width * height;
+ if (reinterpret_cast<const char *>(textureData + size) > qtdfTableEnd) {
+ qWarning("qtdf table too small in font '%s'.",
+ qPrintable(font.familyName()));
+ return false;
+ }
+
+ resizeTexture(texInfo, width, height);
+
+ memcpy(texInfo->copy.bits(), textureData, size);
+ textureData += size;
+
+ for (Qt3DRender::QAbstractTextureImage *textureImage : texInfo->texture->textureImages())
+ static_cast<Q3DSDistanceFieldTextureImage *>(textureImage)->updateGenerator();
+
+
+ QVector<glyph_t> glyphs = glyphTextures.value(texInfo);
+
+ Texture t;
+ t.textureId = uint(i + 1);
+ t.size = texInfo->copy.size();
+
+ setGlyphsTexture(glyphs, t);
+ }
+ }
+
+ return true;
+}
+
QT_END_NAMESPACE
#endif // QT_VERSION >= QT_VERSION_CHECK(5,12,2)
diff --git a/src/runtime/q3dsdistancefieldglyphcache_p.h b/src/runtime/q3dsdistancefieldglyphcache_p.h
index a93dc6d..e29f614 100644
--- a/src/runtime/q3dsdistancefieldglyphcache_p.h
+++ b/src/runtime/q3dsdistancefieldglyphcache_p.h
@@ -75,12 +75,14 @@ public:
TextureInfo *textureInfoById(uint textureId) const;
private:
+ bool loadPregeneratedCache(const QRawFont &font);
TextureInfo *textureInfo(int index) const;
int maxTextureSize() const;
void resizeTexture(TextureInfo *info, int width, int height);
QSGAreaAllocator *m_areaAllocator = nullptr;
+ int m_maxTextureSize = 0;
int m_maxTextureCount = 3;
bool m_isOpenGLES = false;
diff --git a/src/runtime/q3dsdistancefieldmaterialgenerator.cpp b/src/runtime/q3dsdistancefieldmaterialgenerator.cpp
index 8dacef1..abb1b4d 100644
--- a/src/runtime/q3dsdistancefieldmaterialgenerator.cpp
+++ b/src/runtime/q3dsdistancefieldmaterialgenerator.cpp
@@ -42,7 +42,8 @@
QT_BEGIN_NAMESPACE
-Qt3DRender::QMaterial *Q3DSDistanceFieldMaterialGenerator::generateMaterial(const QVector<Qt3DRender::QParameter *> &params)
+Qt3DRender::QMaterial *Q3DSDistanceFieldMaterialGenerator::generateMaterial(const QVector<Qt3DRender::QParameter *> &params,
+ bool dropShadow)
{
Qt3DRender::QMaterial *material = new Qt3DRender::QMaterial;
Qt3DRender::QEffect *effect = new Qt3DRender::QEffect;
@@ -53,13 +54,10 @@ Qt3DRender::QMaterial *Q3DSDistanceFieldMaterialGenerator::generateMaterial(cons
Q3DSDefaultMaterialGenerator::addDefaultApiFilter(technique, &isGLES);
Qt3DRender::QShaderProgram *shaderProgram = new Qt3DRender::QShaderProgram;
- if (isGLES) {
- shaderProgram->setVertexShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QLatin1String("qrc:/q3ds/shaders/distancefieldtext.vert"))));
- shaderProgram->setFragmentShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QLatin1String("qrc:/q3ds/shaders/distancefieldtext.frag"))));
- } else {
- shaderProgram->setVertexShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QLatin1String("qrc:/q3ds/shaders/distancefieldtext_core.vert"))));
- shaderProgram->setFragmentShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QLatin1String("qrc:/q3ds/shaders/distancefieldtext_core.frag"))));
- }
+
+ QString name = QStringLiteral("distancefieldtext") + (dropShadow ? QStringLiteral("_dropshadow") : QString()) + (!isGLES ? QStringLiteral("_core") : QString());
+ shaderProgram->setVertexShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/q3ds/shaders/") + name + QStringLiteral(".vert"))));
+ shaderProgram->setFragmentShaderCode(Qt3DRender::QShaderProgram::loadSource(QUrl(QStringLiteral("qrc:/q3ds/shaders/") + name + QStringLiteral(".frag"))));
Qt3DRender::QRenderPass *renderPass = new Qt3DRender::QRenderPass;
Qt3DRender::QFilterKey *transFilterKey = new Qt3DRender::QFilterKey;
diff --git a/src/runtime/q3dsdistancefieldmaterialgenerator_p.h b/src/runtime/q3dsdistancefieldmaterialgenerator_p.h
index bb85c73..07ef527 100644
--- a/src/runtime/q3dsdistancefieldmaterialgenerator_p.h
+++ b/src/runtime/q3dsdistancefieldmaterialgenerator_p.h
@@ -55,7 +55,8 @@ class QMaterial;
class Q3DSDistanceFieldMaterialGenerator
{
public:
- Qt3DRender::QMaterial *generateMaterial(const QVector<Qt3DRender::QParameter *> &params);
+ Qt3DRender::QMaterial *generateMaterial(const QVector<Qt3DRender::QParameter *> &params,
+ bool dropShadow);
};
QT_END_NAMESPACE
diff --git a/src/runtime/q3dsengine.cpp b/src/runtime/q3dsengine.cpp
index c69ef1f..6c7be72 100644
--- a/src/runtime/q3dsengine.cpp
+++ b/src/runtime/q3dsengine.cpp
@@ -1557,11 +1557,7 @@ void Q3DSEngine::setDataInputValue(const QString &name, const QVariant &value)
void Q3DSEngine::setDataInputMetaData(const QString &diName,
const QVariant &key, const QVariant &metaData)
{
- // Metadata has a single entry as per QT3DS-2205, so just
- // overwrite existing values and update the datainput entry
- // map held by presentation
- m_dataInputEntries[diName].metaDataKey = key;
- m_dataInputEntries[diName].metaData = metaData;
+ m_dataInputEntries[diName].metadata.insert(key, metaData);
presentation()->setDataInputEntries(&m_dataInputEntries);
}
@@ -1586,6 +1582,13 @@ void Q3DSEngine::setDataInputMax(const QString &name, float max)
}
}
+void Q3DSEngine::removeDatainputMetadata(const QString &name, const QVariant &key)
+{
+ m_dataInputEntries[name].metadata.remove(key);
+
+ presentation()->setDataInputEntries(&m_dataInputEntries);
+}
+
float Q3DSEngine::dataInputMin(const QString &name) const
{
if (m_dataInputEntries[name].type == Q3DSDataInputEntry::TypeRangedNumber)
@@ -1602,26 +1605,33 @@ float Q3DSEngine::dataInputMax(const QString &name) const
return 0.0f;
}
-QVector<Q3DSDataInput *> Q3DSEngine::dataInputs() const
+QVector<Q3DSDataInput *> Q3DSEngine::dataInputs()
{
- QVector<Q3DSDataInput *> dataInputs;
- for (const UipPresentation &pres : qAsConst(m_uipPresentations)) {
- if (pres.sceneManager)
- dataInputs.append(pres.sceneManager->dataInputs());
- }
+ if (m_dataInputs.isEmpty())
+ initializeDataInputs();
- return dataInputs;
+ return m_dataInputs;
}
-QVector<Q3DSDataInput *> Q3DSEngine::dataInputs(const QVariant &metadataKey) const
+QVector<Q3DSDataInput *> Q3DSEngine::dataInputs(const QVariant &metadataKey)
{
- QVector<Q3DSDataInput *> dataInputs;
- for (const UipPresentation &pres : qAsConst(m_uipPresentations)) {
- if (pres.sceneManager)
- dataInputs.append(pres.sceneManager->dataInputs(metadataKey));
+ if (m_dataInputs.isEmpty())
+ initializeDataInputs();
+
+ const auto dataInputMetas = presentation()->dataInputMetadatas();
+ QVector<Q3DSDataInput *> outVec;
+
+ // Which datainputs have this metadata key associated?
+ Q3DSDataInputEntry::MetadataMap::const_iterator di_metaiter = dataInputMetas->find(metadataKey);
+ while (di_metaiter != dataInputMetas->end()) {
+ for (const auto &di_iter : qAsConst(m_dataInputs)) {
+ if (di_iter->name() == di_metaiter.value() && di_metaiter.key() == metadataKey)
+ outVec.append(di_iter);
+ }
+ ++di_metaiter;
}
- return dataInputs;
+ return outVec;
}
bool Q3DSEngine::isValidDataInput(const Q3DSDataInput *di) const
@@ -1636,22 +1646,22 @@ bool Q3DSEngine::isValidDataInput(const Q3DSDataInput *di) const
return false;
}
-QVariant Q3DSEngine::dataInputMetaData(const Q3DSDataInput *di) const
+QVariant Q3DSEngine::dataInputMetaData(const Q3DSDataInput *di, const QVariant &key) const
{
if (m_uipPresentations.isEmpty())
return {};
for (const UipPresentation &pres : qAsConst(m_uipPresentations)) {
if (pres.presentation->isValidDataInput(di)) {
- const auto diEntry(
- pres.presentation->dataInputEntries()->value(di->name()));
- return diEntry.metaData;
+ auto diEntry = pres.presentation->dataInputEntries()->value(di->name());
+ if (diEntry.metadata.contains(key))
+ return diEntry.metadata.value(key);
}
}
return {};
}
-QVariant Q3DSEngine::dataInputMetaDataKey(const Q3DSDataInput *di) const
+QList<QVariant> Q3DSEngine::dataInputMetaDataKeys(const Q3DSDataInput *di) const
{
if (m_uipPresentations.isEmpty())
return {};
@@ -1660,7 +1670,7 @@ QVariant Q3DSEngine::dataInputMetaDataKey(const Q3DSDataInput *di) const
if (pres.presentation->isValidDataInput(di)) {
const auto diEntry(
pres.presentation->dataInputEntries()->value(di->name()));
- return diEntry.metaDataKey;
+ return diEntry.metadata.keys();
}
}
return {};
@@ -1836,6 +1846,17 @@ void Q3DSEngine::registerQmlTypes()
qmlRegisterType<Q3DSBehaviorObject, 2>("QtStudio3D.Behavior", 2, 0, "Behavior");
}
+void Q3DSEngine::initializeDataInputs()
+{
+ auto dataInputEntries = presentation()->dataInputEntries();
+
+ // Lazy create datainput objects when requested by a call to
+ // getDatainputs() / dataInputs() API function.
+ const auto keys = dataInputEntries->keys();
+ for (auto &it : keys)
+ m_dataInputs.append(new Q3DSDataInput(nullptr, it, this));
+}
+
void Q3DSEngine::loadBehaviors()
{
m_behaviorLoadTime = 0;
@@ -2002,6 +2023,9 @@ Q3DSGraphObject *Q3DSEngine::findObjectByHashIdOrNameOrPath(Q3DSGraphObject *thi
if (actualPresentation)
*actualPresentation = pres;
+ if (!pres)
+ return nullptr;
+
bool firstElem = true;
Q3DSGraphObject *obj = thisObject;
for (const QString &s : attr.split(QLatin1Char('.'), QString::SkipEmptyParts)) {
diff --git a/src/runtime/q3dsengine_p.h b/src/runtime/q3dsengine_p.h
index ab43209..386f95c 100644
--- a/src/runtime/q3dsengine_p.h
+++ b/src/runtime/q3dsengine_p.h
@@ -169,12 +169,13 @@ public:
void setDataInputValue(const QString &name, const QVariant &value);
void setDataInputMin(const QString &name, float min);
void setDataInputMax(const QString &name, float max);
- QVector<Q3DSDataInput *> dataInputs() const;
- QVector<Q3DSDataInput *> dataInputs(const QVariant &metadataKey) const;
+ QVector<Q3DSDataInput *> dataInputs();
+ QVector<Q3DSDataInput *> dataInputs(const QVariant &metadataKey);
bool isValidDataInput(const Q3DSDataInput *di) const;
- QVariant dataInputMetaData(const Q3DSDataInput *di) const;
- QVariant dataInputMetaDataKey(const Q3DSDataInput *di) const;
+ QVariant dataInputMetaData(const Q3DSDataInput *di, const QVariant &key) const;
+ QList<QVariant> dataInputMetaDataKeys(const Q3DSDataInput *di) const;
void setDataInputMetaData(const QString &diName, const QVariant &key, const QVariant &metaData);
+ void removeDatainputMetadata(const QString &name, const QVariant &key);
float dataInputMin(const QString &name) const;
float dataInputMax(const QString &name) const;
void fireEvent(Q3DSGraphObject *target, Q3DSUipPresentation *presentation, const QString &event);
@@ -288,6 +289,7 @@ private:
void behaviorFrameUpdate(float dt);
QRect calculateViewport(const QSize &surfaceSize, const QSize &presentationSize) const;
void registerQmlTypes();
+ void initializeDataInputs();
QObject *m_surface = nullptr;
QSize m_implicitSize;
@@ -300,6 +302,11 @@ private:
QVector<Q3DSInlineQmlSubPresentation *> m_inlineQmlPresentations;
Q3DSDataInputEntry::Map m_dataInputEntries;
Q3DSDataInputEntry::MetadataMap m_dataInputMetaData;
+ // In addition to datainput bookkeeping data, let engine instantiate
+ // and manage actual datainput objects created. This removes the need
+ // to create datainputs on-the-fly when Q3DSPresentation API client
+ // requests a list of datainputs
+ QVector<Q3DSDataInput *> m_dataInputs;
QQmlEngine *m_qmlSubPresentationEngine = nullptr;
bool m_ownsQmlSubPresentationEngine = false;
diff --git a/src/runtime/q3dsinputmanager.cpp b/src/runtime/q3dsinputmanager.cpp
index 323b2a3..4547956 100644
--- a/src/runtime/q3dsinputmanager.cpp
+++ b/src/runtime/q3dsinputmanager.cpp
@@ -141,6 +141,32 @@ QMatrix4x4 calculateCameraViewMatrix(const QMatrix4x4 &cameraWorldTransform)
QVector3D(upVector));
return QMatrix4x4(m);
}
+
+// A copy of QVector3D::unproject with the difference that if obj.w() is nearly zero, we don't
+// set it to one as that is extremely wrong, at least for our purposes.
+// For determining pick rays, nearly zero values are good enough even if they may not result in
+// completely pixel-accurate picks.
+// This allows much larger far clip values to be used in cameras before picking breaks.
+QVector3D unproject(const QVector3D &vector,
+ const QMatrix4x4 &modelView, const QMatrix4x4 &projection,
+ const QRect &viewport)
+{
+ QMatrix4x4 inverse = QMatrix4x4( projection * modelView ).inverted();
+
+ QVector4D tmp(vector, 1.0f);
+ tmp.setX((tmp.x() - float(viewport.x())) / float(viewport.width()));
+ tmp.setY((tmp.y() - float(viewport.y())) / float(viewport.height()));
+ tmp = tmp * 2.0f - QVector4D(1.0f, 1.0f, 1.0f, 1.0f);
+
+ QVector4D obj = inverse * tmp;
+ // Don't change the w unless it is actually zero
+ if (obj.w() == 0.f)
+ obj.setW(0.000000001f);
+ obj /= obj.w();
+
+ return obj.toVector3D();
+}
+
}
void Q3DSInputManager::castRayIntoLayer(Q3DSLayerNode *layer, const QPointF &pos,
@@ -176,9 +202,9 @@ void Q3DSInputManager::castRayIntoLayer(Q3DSLayerNode *layer, const QPointF &pos
QRect viewport(-1, -1, 2, 2);
QVector3D nearPos(float(pos.x()), float(pos.y()), 0.0f);
- nearPos = nearPos.unproject(viewMatrix, projectionMatrix, viewport);
+ nearPos = unproject(nearPos, viewMatrix, projectionMatrix, viewport);
QVector3D farPos(float(pos.x()), float(pos.y()), 1.0f);
- farPos = farPos.unproject(viewMatrix, projectionMatrix, viewport);
+ farPos = unproject(farPos, viewMatrix, projectionMatrix, viewport);
QVector3D origin(nearPos);
QVector3D direction((farPos - nearPos).normalized());
diff --git a/src/runtime/q3dsmaterial_p.h b/src/runtime/q3dsmaterial_p.h
index 45fd7b2..ffab641 100644
--- a/src/runtime/q3dsmaterial_p.h
+++ b/src/runtime/q3dsmaterial_p.h
@@ -169,6 +169,7 @@ struct Q3DSV_PRIVATE_EXPORT PropertyElement
, max(0.0f)
, usageType(Diffuse)
, magFilterType(Linear)
+ , minFilterType(Linear)
, clampType(Clamp)
{}
};
diff --git a/src/runtime/q3dsres.qrc b/src/runtime/q3dsres.qrc
index e70f636..0c20267 100644
--- a/src/runtime/q3dsres.qrc
+++ b/src/runtime/q3dsres.qrc
@@ -132,5 +132,9 @@
<file alias="res/effectlib/gles2/shadowMapping.glsllib">../../res/effectlib/gles2/shadowMapping.glsllib</file>
<file alias="res/effectlib/gles2/SSAOCustomMaterial.glsllib">../../res/effectlib/gles2/SSAOCustomMaterial.glsllib</file>
<file alias="res/effectlib/gles2/tangentSpaceNormalTexture.glsllib">../../res/effectlib/gles2/tangentSpaceNormalTexture.glsllib</file>
+ <file>shaders/distancefieldtext_dropshadow_core.vert</file>
+ <file>shaders/distancefieldtext_dropshadow_core.frag</file>
+ <file>shaders/distancefieldtext_dropshadow.frag</file>
+ <file>shaders/distancefieldtext_dropshadow.vert</file>
</qresource>
</RCC>
diff --git a/src/runtime/q3dsscenemanager.cpp b/src/runtime/q3dsscenemanager.cpp
index b81fcd6..6c40962 100644
--- a/src/runtime/q3dsscenemanager.cpp
+++ b/src/runtime/q3dsscenemanager.cpp
@@ -495,7 +495,6 @@ Q3DSSceneManager::~Q3DSSceneManager()
delete m_textMatGen;
#if QT_VERSION >= QT_VERSION_CHECK(5,12,2)
delete m_distanceFieldMaterialGenerator;
- delete m_glyphCacheManager;
delete m_fontDatabase;
#endif
delete m_customMaterialGen;
@@ -573,6 +572,13 @@ void Q3DSSceneManager::updateSizes(const QSize &size, qreal dpr, const QRect &vi
data->frameDirty = Q3DSGraphObjectAttached::TextDirty;
data->frameChangeFlags |= Q3DSTextNode::TextureImageDepChanges;
}
+ } else if (obj->type() == Q3DSGraphObject::Light) {
+ // Force gathering of lights if there is a pending light visibility change
+ auto data = obj->attached<Q3DSNodeAttached>();
+ if (data && (data->frameChangeFlags & Q3DSNode::EyeballChanges) && data->layer3DS) {
+ auto layerData = data->layer3DS->attached<Q3DSLayerAttached>();
+ layerData->frameChangeFlags |= Q3DSLayerNode::LayerContentSubTreeLightsChange;
+ }
}
});
if (forceTreeVisit)
@@ -1361,6 +1367,7 @@ void Q3DSSceneManager::buildLayer(Q3DSLayerNode *layer3DS,
// parentSize could well be (0, 0) at this stage still, nevermind that
const QSize layerSize = calculateLayerSize(layer3DS, parentSize);
const QSize layerPixelSize = safeLayerPixelSize(layerSize, ssaaScaleFactor);
+ const QSize dummyLayerSize = QSize(1,1);
Q3DSLayerAttached *layerData = new Q3DSLayerAttached;
ViewportSet viewports;
@@ -1379,9 +1386,12 @@ void Q3DSSceneManager::buildLayer(Q3DSLayerNode *layer3DS,
// Create color and depth-stencil buffers for this layer
// Stereoscopic left-eye
- Qt3DRender::QAbstractTexture *colorTexLeft;
- Qt3DRender::QAbstractTexture *dsTexOrRbLeft;
- Qt3DRender::QRenderTarget *rtLeft = newLayerRenderTarget(layerPixelSize, msaaSampleCount, &colorTexLeft, &dsTexOrRbLeft, layerFgRoot, layer3DS);
+ Q3DSLayerAttached::SizeManagedTexture colorTexLeft;
+ Q3DSLayerAttached::SizeManagedTexture dsTexOrRbLeft;
+ // Mark textures being for stereoscopic usage
+ colorTexLeft.flags |= Q3DSLayerAttached::SizeManagedTexture::StereoscopicView;
+ dsTexOrRbLeft.flags |= Q3DSLayerAttached::SizeManagedTexture::StereoscopicView;
+ Qt3DRender::QRenderTarget *rtLeft = newLayerRenderTarget(dummyLayerSize, msaaSampleCount, &colorTexLeft.texture, &dsTexOrRbLeft.texture, layerFgRoot, layer3DS);
m_profiler->trackNewObject(rtLeft, Q3DSProfiler::RenderTargetObject,
"RT for layer %s", layer3DS->id().constData());
rtSelectorLeft->setTarget(rtLeft);
@@ -1391,9 +1401,12 @@ void Q3DSSceneManager::buildLayer(Q3DSLayerNode *layer3DS,
// Create color and depth-stencil buffers for this layer
// Stereoscopic right-eye
- Qt3DRender::QAbstractTexture *colorTexRight;
- Qt3DRender::QAbstractTexture *dsTexOrRbRight;
- Qt3DRender::QRenderTarget *rtRight = newLayerRenderTarget(layerPixelSize, msaaSampleCount, &colorTexRight, &dsTexOrRbRight, layerFgRoot, layer3DS);
+ Q3DSLayerAttached::SizeManagedTexture colorTexRight;
+ Q3DSLayerAttached::SizeManagedTexture dsTexOrRbRight;
+ // Mark textures being for stereoscopic usage
+ colorTexRight.flags |= Q3DSLayerAttached::SizeManagedTexture::StereoscopicView;
+ dsTexOrRbRight.flags |= Q3DSLayerAttached::SizeManagedTexture::StereoscopicView;
+ Qt3DRender::QRenderTarget *rtRight = newLayerRenderTarget(dummyLayerSize, msaaSampleCount, &colorTexRight.texture, &dsTexOrRbRight.texture, layerFgRoot, layer3DS);
m_profiler->trackNewObject(rtRight, Q3DSProfiler::RenderTargetObject,
"RT for layer %s", layer3DS->id().constData());
rtSelectorRight->setTarget(rtRight);
@@ -1435,10 +1448,10 @@ void Q3DSSceneManager::buildLayer(Q3DSLayerNode *layer3DS,
layerData->sizeManagedTextures << colorTex << dsTexOrRb;
// Setup for stereo left / eye
- layerData->eyeLeft->layerTexture = colorTexLeft;
- layerData->eyeRight->layerTexture = colorTexRight;
- layerData->eyeLeft->layerDS = dsTexOrRbLeft;
- layerData->eyeRight->layerDS = dsTexOrRbRight;
+ layerData->eyeLeft->layerTexture = colorTexLeft.texture;
+ layerData->eyeRight->layerTexture = colorTexRight.texture;
+ layerData->eyeLeft->layerDS = dsTexOrRbLeft.texture;
+ layerData->eyeRight->layerDS = dsTexOrRbRight.texture;
layerData->eyeLeft->compositorSourceParam = new Qt3DRender::QParameter(QLatin1String("texLeft"), layerData->eyeLeft->layerTexture);
layerData->eyeRight->compositorSourceParam = new Qt3DRender::QParameter(QLatin1String("texRight"), layerData->eyeRight->layerTexture);
layerData->eyeLeft->rtSelector = rtSelectorLeft;
@@ -2048,13 +2061,23 @@ void Q3DSSceneManager::setLayerSizeProperties(Q3DSLayerNode *layer3DS)
const QSize layerSize = safeLayerPixelSize(data->layerSize, 1); // for when SSAA is to be ignored
for (const Q3DSLayerAttached::SizeManagedTexture &t : data->sizeManagedTextures) {
if (!t.flags.testFlag(Q3DSLayerAttached::SizeManagedTexture::CustomSizeCalculation)) {
+ int w = layerSize.width();
+ int h = layerSize.height();
if (!t.flags.testFlag(Q3DSLayerAttached::SizeManagedTexture::IgnoreSSAA)) {
- t.texture->setWidth(layerPixelSize.width());
- t.texture->setHeight(layerPixelSize.height());
- } else {
- t.texture->setWidth(layerSize.width());
- t.texture->setHeight(layerSize.height());
+ w = layerPixelSize.width();
+ h = layerPixelSize.height();
+ }
+ if (t.flags.testFlag(Q3DSLayerAttached::SizeManagedTexture::StereoscopicView)
+ && !m_engine->isStereoscopic()) {
+ // When not in stereoscopic mode, reduce left & right eye texture sizes to
+ // not consume memory. Once user switches to stereoscopic, they will be resized
+ // automatically to full size again.
+ w = 1;
+ h = 1;
+
}
+ t.texture->setWidth(w);
+ t.texture->setHeight(h);
}
if (t.sizeChangeCallback)
t.sizeChangeCallback(layer3DS);
@@ -2270,15 +2293,51 @@ QVector<Qt3DRender::QCamera *> Q3DSSceneManager::buildCameras(Q3DSCameraNode *ca
return cameras;
}
-static QMatrix4x4 composeTransformMatrix(const QVector3D &position, const QVector3D &rotation, const QVector3D &scale)
+static QMatrix4x4 generateRotationMatrix(const QVector3D &nodeRotation,
+ Q3DSNode::RotationOrder order)
{
- const QMatrix3x3 rot3x3 = QQuaternion::fromEulerAngles(rotation).toRotationMatrix();
- QMatrix4x4 m;
- m(0, 0) = scale.x() * rot3x3(0, 0); m(0, 1) = scale.y() * rot3x3(0, 1); m(0, 2) = scale.z() * rot3x3(0, 2); m(0, 3) = position.x();
- m(1, 0) = scale.x() * rot3x3(1, 0); m(1, 1) = scale.y() * rot3x3(1, 1); m(1, 2) = scale.z() * rot3x3(1, 2); m(1, 3) = position.y();
- m(2, 0) = scale.x() * rot3x3(2, 0); m(2, 1) = scale.y() * rot3x3(2, 1); m(2, 2) = scale.z() * rot3x3(2, 2); m(2, 3) = position.z();
- m(3, 0) = 0.0f; m(3, 1) = 0.0f; m(3, 2) = 0.0f; m(3, 3) = 1.0f;
- return m;
+ QMatrix4x4 rotationMatrix;
+ switch (order) {
+ case Q3DSNode::XYZ:
+ case Q3DSNode::ZYXr:
+ rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
+ rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
+ rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
+ break;
+ case Q3DSNode::XYZr: // XYZr is what the editor outputs in practice
+ case Q3DSNode::ZYX:
+ rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
+ rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
+ rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
+ break;
+ case Q3DSNode::YZX:
+ case Q3DSNode::XZYr:
+ rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
+ rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
+ rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
+ break;
+ case Q3DSNode::ZXY:
+ case Q3DSNode::YXZr:
+ rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
+ rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
+ rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
+ break;
+ case Q3DSNode::XZY:
+ case Q3DSNode::YZXr:
+ rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
+ rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
+ rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
+ break;
+ case Q3DSNode::YXZ:
+ case Q3DSNode::ZXYr:
+ rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
+ rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
+ rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
+ break;
+ default:
+ break;
+ }
+ return rotationMatrix;
}
static QVector3D directionFromTransform(const QMatrix4x4 &t, bool lh)
@@ -2341,10 +2400,12 @@ void Q3DSSceneManager::setCameraProperties(Q3DSCameraNode *camNode, int changeFl
const bool leftHanded = camNode->orientation() == Q3DSNode::LeftHanded;
const float lhFactor = leftHanded ? -1.0f : 1.0f;
// ### pivot?
- QMatrix4x4 t = composeTransformMatrix(camNode->position(), camNode->rotation(), camNode->scale());
+ QMatrix4x4 t = generateRotationMatrix(camNode->rotation(), camNode->rotationOrder());
+
if (leftHanded)
adjustRotationLeftToRight(&t);
- const QVector3D pos(t(0, 3), t(1, 3), lhFactor * t(2, 3));
+ QVector3D pos = camNode->position();
+ pos.setZ(pos.z() * lhFactor);
camera->setPosition(pos);
cameraLeft->setPosition(pos);
cameraRight->setPosition(pos);
@@ -2356,9 +2417,7 @@ void Q3DSSceneManager::setCameraProperties(Q3DSCameraNode *camNode, int changeFl
cameraRight->setViewCenter(center);
// roll is handled in the up vector
QVector3D upVec(0, 1, 0);
- QMatrix4x4 rotZ;
- rotZ.rotate(camNode->rotation().z(), 0, 0, -lhFactor);
- upVec = rotZ * upVec;
+ upVec = t * upVec;
camera->setUpVector(upVec);
cameraLeft->setUpVector(upVec);
cameraRight->setUpVector(upVec);
@@ -2870,8 +2929,8 @@ void Q3DSSceneManager::updateOrthoShadowCam(Q3DSLayerAttached::PerLightShadowMap
maxDistanceX = distanceX;
}
- float clipNear = -qFabs(maxDistanceZ - minDistanceZ);
- float clipFar = qFabs(maxDistanceZ - minDistanceZ);
+ float clipNear = -qFabs(maxDistanceZ - minDistanceZ) / 2;
+ float clipFar = qFabs(maxDistanceZ - minDistanceZ) / 2;
d->shadowCamOrtho->setNearPlane(clipNear);
d->shadowCamOrtho->setFarPlane(clipFar);
@@ -3864,8 +3923,11 @@ void Q3DSSceneManager::buildLayerQuadEntity(Q3DSLayerNode *layer3DS, Qt3DCore::Q
renderPass->addParameter(data->eyeRight->compositorSourceParam);
- if (data->stereoModeParam)
+ if (data->stereoModeParam) {
+ if (!data->stereoModeParam->parent())
+ data->stereoModeParam->setParent(data->layerSceneRootEntity);
renderPass->addParameter(data->stereoModeParam);
+ }
}
technique->addRenderPass(renderPass);
@@ -4498,52 +4560,6 @@ Qt3DCore::QTransform *Q3DSSceneManager::initEntityForNode(Qt3DCore::QEntity *ent
}
namespace {
-QMatrix4x4 generateRotationMatrix(const QVector3D &nodeRotation, Q3DSNode::RotationOrder order)
-{
- QMatrix4x4 rotationMatrix;
- switch (order) {
- case Q3DSNode::XYZ:
- case Q3DSNode::ZYXr:
- rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
- rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
- rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
- break;
- case Q3DSNode::XYZr: // XYZr is what the editor outputs in practice
- case Q3DSNode::ZYX:
- rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
- rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
- rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
- break;
- case Q3DSNode::YZX:
- case Q3DSNode::XZYr:
- rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
- rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
- rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
- break;
- case Q3DSNode::ZXY:
- case Q3DSNode::YXZr:
- rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
- rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
- rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
- break;
- case Q3DSNode::XZY:
- case Q3DSNode::YZXr:
- rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
- rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
- rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
- break;
- case Q3DSNode::YXZ:
- case Q3DSNode::ZXYr:
- rotationMatrix.rotate(nodeRotation.y(), QVector3D(0, 1, 0));
- rotationMatrix.rotate(nodeRotation.x(), QVector3D(1, 0, 0));
- rotationMatrix.rotate(nodeRotation.z(), QVector3D(0, 0, 1));
- break;
- default:
- break;
- }
- return rotationMatrix;
-}
-
float clampOpacity(float f)
{
f = qBound(0.0f, f, 1.0f);
@@ -4771,10 +4787,9 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
}
#if QT_VERSION >= QT_VERSION_CHECK(5,12,2)
- static bool distanceFieldRendering = distanceFieldsEnabled();
+ static bool shouldDistanceFieldRender = distanceFieldsEnabled();
- bool shouldDistanceFieldRender = distanceFieldRendering && !text3DS->shadow();
- if (data->entity != nullptr && shouldDistanceFieldRender != data->distanceFieldText) {
+ if (data->entity != nullptr && text3DS->shadow() != data->dropShadow) {
for (int i = 0; i < data->glyphsReferencedInSubentity.size(); ++i) {
QPair<Q3DSDistanceFieldGlyphCache *, QVector<quint32> > &glyphsReferenced = data->glyphsReferencedInSubentity[i];
if (glyphsReferenced.first != nullptr && !glyphsReferenced.second.isEmpty())
@@ -4801,6 +4816,7 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
#if QT_VERSION >= QT_VERSION_CHECK(5,12,2)
if (shouldDistanceFieldRender) {
data->distanceFieldText = true;
+ data->dropShadow = text3DS->shadow();
QVector2D boundingBox = text3DS->boundingBox();
QRawFont font = m_fontDatabase->findFont(text3DS->font());
@@ -4979,6 +4995,8 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
QVector<quint32> glyphIndexes;
Q3DSDistanceFieldGlyphCache *cache;
float fontScale;
+ float shadowOffsetX;
+ float shadowOffsetY;
};
QHash<Q3DSDistanceFieldGlyphCache::TextureInfo *, GlyphInfo> glyphsPerTexture;
@@ -5031,6 +5049,8 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
cache->processPendingGlyphs();
qreal fontPixelSize = glyphRun.rawFont().pixelSize();
+ float shadowOffsetX = float(fontPixelSize) * text3DS->shadowOffsetX() / 1000.0f;
+ float shadowOffsetY = float(fontPixelSize) * text3DS->shadowOffsetY() / 1000.0f;
qreal maxTexMargin = cache->distanceFieldRadius();
qreal fontScale = cache->fontScale(fontPixelSize);
qreal margin = 2;
@@ -5066,11 +5086,24 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
float cy1 = float(position.y() - metrics.baselineY) + offsetY;
float cy2 = cy1 + float(metrics.height);
+ if (text3DS->shadow()) {
+ cx2 += shadowOffsetX;
+ cy2 += shadowOffsetY;
+ }
+
float tx1 = float(c.x + c.xMargin);
float tx2 = tx1 + float(c.width);
float ty1 = float(c.y + c.yMargin);
float ty2 = ty1 + float(c.height);
+ float ttx2 = tx2;
+ float tty2 = ty2;
+
+ if (text3DS->shadow()) {
+ tx2 += float(c.width) * shadowOffsetX / float(metrics.width);
+ ty2 += float(c.height) * shadowOffsetY / float(metrics.height);
+ }
+
const QSGDistanceFieldGlyphCache::Texture *texture = cache->glyphTexture(glyphIndex);
if (texture->textureId == 0) {
qWarning() << "Empty texture for glyph" << glyphIndex;
@@ -5081,9 +5114,11 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
GlyphInfo &glyphInfo = glyphsPerTexture[textureInfo];
glyphInfo.fontScale = float(fontScale);
+ glyphInfo.shadowOffsetX = shadowOffsetX;
+ glyphInfo.shadowOffsetY = shadowOffsetY;
QVector<float> &vertexes = glyphInfo.vertexes;
- vertexes.reserve(vertexes.size() + 10);
+ vertexes.reserve(vertexes.size() + 20 + (text3DS->shadow() ? 16 : 0));
vertexes.append(cx1);
vertexes.append(0.0);
@@ -5091,23 +5126,51 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
vertexes.append(tx1);
vertexes.append(ty1);
+ if (text3DS->shadow()) {
+ vertexes.append(tx1);
+ vertexes.append(ty1);
+ vertexes.append(ttx2);
+ vertexes.append(tty2);
+ }
+
vertexes.append(cx2);
vertexes.append(0.0);
vertexes.append(cy1);
vertexes.append(tx2);
vertexes.append(ty1);
+ if (text3DS->shadow()) {
+ vertexes.append(tx1);
+ vertexes.append(ty1);
+ vertexes.append(ttx2);
+ vertexes.append(tty2);
+ }
+
vertexes.append(cx2);
vertexes.append(0.0);
vertexes.append(cy2);
vertexes.append(tx2);
vertexes.append(ty2);
+ if (text3DS->shadow()) {
+ vertexes.append(tx1);
+ vertexes.append(ty1);
+ vertexes.append(ttx2);
+ vertexes.append(tty2);
+ }
+
vertexes.append(cx1);
vertexes.append(0.0);
vertexes.append(cy2);
vertexes.append(tx1);
vertexes.append(ty2);
+
+ if (text3DS->shadow()) {
+ vertexes.append(tx1);
+ vertexes.append(ty1);
+ vertexes.append(ttx2);
+ vertexes.append(tty2);
+ }
}
}
}
@@ -5150,11 +5213,23 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
Qt3DRender::QParameter *fontScaleParam = new Qt3DRender::QParameter;
fontScaleParam->setName(QLatin1String("fontScale"));
- Qt3DRender::QMaterial *material = m_distanceFieldMaterialGenerator->generateMaterial({ colorParam,
- textureParam,
- fontScaleParam,
- textureWidthParam,
- textureHeightParam });
+ QVector<Qt3DRender::QParameter *> params = { colorParam,
+ textureParam,
+ fontScaleParam,
+ textureWidthParam,
+ textureHeightParam };
+
+ if (text3DS->shadow()) {
+ Qt3DRender::QParameter *shadowColorParam = new Qt3DRender::QParameter;
+ shadowColorParam->setName(QLatin1String("shadowColor"));
+ params.append(shadowColorParam);
+
+ Qt3DRender::QParameter *shadowOffsetParam = new Qt3DRender::QParameter;
+ shadowOffsetParam->setName(QLatin1String("shadowOffset"));
+ params.append(shadowOffsetParam);
+ }
+
+ Qt3DRender::QMaterial *material = m_distanceFieldMaterialGenerator->generateMaterial(params, text3DS->shadow());
subentity->addComponent(material);
subentities.append(subentity);
}
@@ -5162,6 +5237,7 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
QHash<Q3DSDistanceFieldGlyphCache::TextureInfo *, GlyphInfo>::const_iterator it;
int subentityIndex = 0;
+ int shadowRgb = int(2.55f * (100 - int(text3DS->shadowStrength())));
for (it = glyphsPerTexture.constBegin(); it != glyphsPerTexture.constEnd(); ++it) {
const GlyphInfo &glyphInfo = it.value();
const QVector<float> &vertexes = glyphInfo.vertexes;
@@ -5178,7 +5254,7 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
{
Q3DSTextMesh *mesh = qobject_cast<Q3DSTextMesh *>(component);
if (mesh != nullptr)
- mesh->setVertexes(vertexes);
+ mesh->setVertexes(vertexes, text3DS->shadow());
}
{
@@ -5194,6 +5270,10 @@ Qt3DCore::QEntity *Q3DSSceneManager::buildText(Q3DSTextNode *text3DS, Q3DSLayerN
parameter->setValue(color * data->globalOpacity);
data->colorParam.append(parameter);
+ } else if (parameter->name() == QLatin1String("shadowColor")) {
+ parameter->setValue(QColor(shadowRgb, shadowRgb, shadowRgb));
+ } else if (parameter->name() == QLatin1String("shadowOffset")) {
+ parameter->setValue(QVector2D(glyphInfo.shadowOffsetX, glyphInfo.shadowOffsetY));
} else if (parameter->name() == QLatin1String("_qt_texture")) {
parameter->setValue(QVariant::fromValue(it.key()->texture));
} else if (parameter->name() == QLatin1String("fontScale")) {
@@ -8324,6 +8404,8 @@ void Q3DSSceneManager::setPendingVisibilities()
{
const bool noAnimations = currentSlide() && (currentSlide()->animations().isEmpty()
&& (currentSlide()->parent() ? static_cast<Q3DSSlide *>(currentSlide()->parent())->animations().isEmpty() : true));
+
+ QVector<Q3DSLayerNode *> layerNodes;
for (auto it = m_pendingObjectVisibility.constBegin(); it != m_pendingObjectVisibility.constEnd(); ++it) {
if (it.key()->isNode() && it.key()->type() != Q3DSGraphObject::Layer && it.key()->type() != Q3DSGraphObject::Camera) {
Q3DSNode *node = static_cast<Q3DSNode *>(it.key());
@@ -8346,7 +8428,8 @@ void Q3DSSceneManager::setPendingVisibilities()
const bool enabled = it.value() && layer3DS->flags().testFlag(Q3DSNode::Active);
data->visibilityTag = enabled ? Q3DSGraphObjectAttached::Visible
: Q3DSGraphObjectAttached::Hidden;
- updateGlobals(layer3DS, UpdateGlobalsRecursively | UpdateGlobalsSkipTransform);
+ // defer updateGlobals for layers until we know the status of the camera.
+ layerNodes.push_back(static_cast<Q3DSLayerNode *>(it.key()));
if (data->compositorEntity) // may not exist if this is still buildLayer()
data->compositorEntity->setEnabled(enabled);
}
@@ -8376,6 +8459,9 @@ void Q3DSSceneManager::setPendingVisibilities()
it.key()->notifyPropertyChanges({{QString()}}, 0);
}
+ for (const auto layer : qAsConst(layerNodes))
+ updateGlobals(layer, UpdateGlobalsRecursively | UpdateGlobalsSkipTransform);
+
m_pendingObjectVisibility.clear();
}
@@ -9317,30 +9403,6 @@ void Q3DSSceneManager::setDataInputValue(const QString &dataInputName, const QVa
}
}
-QVector<Q3DSDataInput *> Q3DSSceneManager::dataInputs() const
-{
- const auto dataInputEntries = m_presentation->dataInputEntries();
-
- QVector<Q3DSDataInput *> outVec;
-
- for (auto &it : *dataInputEntries)
- outVec.append(new Q3DSDataInput(nullptr, it.name));
-
- return outVec;
-}
-
-QVector<Q3DSDataInput *> Q3DSSceneManager::dataInputs(const QVariant &metadataKey) const
-{
- const auto dataInputMetas = m_presentation->dataInputMetadatas();
- QVector<Q3DSDataInput *> outVec;
- const QList<QString> dis = dataInputMetas->values(metadataKey.toString());
-
- for (auto &it : dis)
- outVec.append(new Q3DSDataInput(nullptr, it));
-
- return outVec;
-}
-
void Q3DSSceneManager::handleEvent(const Q3DSGraphObject::Event &e)
{
Q3DSSlide *slide = currentSlide();
diff --git a/src/runtime/q3dsscenemanager_p.h b/src/runtime/q3dsscenemanager_p.h
index d1a4461..ce189e5 100644
--- a/src/runtime/q3dsscenemanager_p.h
+++ b/src/runtime/q3dsscenemanager_p.h
@@ -304,7 +304,8 @@ public:
struct SizeManagedTexture {
enum Flag {
IgnoreSSAA = 0x01,
- CustomSizeCalculation = 0x02
+ CustomSizeCalculation = 0x02,
+ StereoscopicView = 0x04
};
Q_DECLARE_FLAGS(Flags, Flag)
SizeManagedTexture() { }
@@ -456,6 +457,7 @@ class Q3DSTextAttached : public Q3DSNodeAttached
{
public:
bool distanceFieldText = false;
+ bool dropShadow = false;
Qt3DExtras::QPlaneMesh *mesh = nullptr;
Qt3DRender::QParameter *opacityParam = nullptr;
QVector<Qt3DRender::QParameter *> colorParam;
@@ -813,8 +815,6 @@ public:
Qt3DCore::QEntity *getRootEntity() const { return m_rootEntity; }
void setDataInputValue(const QString &dataInputName, const QVariant &value);
- QVector<Q3DSDataInput *> dataInputs() const;
- QVector<Q3DSDataInput *> dataInputs(const QVariant &metadataKey) const;
void changeSlideByName(Q3DSGraphObject *sceneOrComponent, const QString &name);
void changeSlideByIndex(Q3DSGraphObject *sceneOrComponent, int index);
void changeSlideByDirection(Q3DSGraphObject *sceneOrComponent, bool next, bool wrap);
diff --git a/src/runtime/q3dstextmesh.cpp b/src/runtime/q3dstextmesh.cpp
index 13fc8dd..4290204 100644
--- a/src/runtime/q3dstextmesh.cpp
+++ b/src/runtime/q3dstextmesh.cpp
@@ -64,30 +64,34 @@ namespace {
class Q3DSTextMeshGeometry : public Qt3DRender::QGeometry
{
public:
- Q3DSTextMeshGeometry(const QVector<float> &vertexes, Qt3DCore::QNode *parent = nullptr);
+ Q3DSTextMeshGeometry(bool shadow,
+ const QVector<float> &vertexes,
+ Qt3DCore::QNode *parent = nullptr);
private:
Qt3DRender::QBuffer *m_vertexBuffer;
Qt3DRender::QBuffer *m_indexBuffer;
Qt3DRender::QAttribute *m_positionAttribute;
Qt3DRender::QAttribute *m_textureCoordinateAttribute;
Qt3DRender::QAttribute *m_indexAttribute;
+ Qt3DRender::QAttribute *m_textureBoundsAttribute;
};
- Q3DSTextMeshGeometry::Q3DSTextMeshGeometry(const QVector<float> &vertexes,
+ Q3DSTextMeshGeometry::Q3DSTextMeshGeometry(bool shadow,
+ const QVector<float> &vertexes,
Qt3DCore::QNode *parent)
: Qt3DRender::QGeometry(parent)
{
- Q_ASSERT(vertexes.size() % 10 == 0);
-
m_vertexBuffer = new Qt3DRender::QBuffer(this);
m_vertexBuffer->setUsage(Qt3DRender::QBuffer::StaticDraw);
m_vertexBuffer->setAccessType(Qt3DRender::QBuffer::Read);
m_vertexBuffer->setData(QByteArray(reinterpret_cast<const char *>(vertexes.constData()),
int(vertexes.size() * sizeof(float))));
- const uint stride = (3 + 2) * sizeof(float);
+ const uint floatsPerVertex = shadow ? 3 + 2 + 4 : 3 + 2;
+ const uint stride = floatsPerVertex * sizeof(float);
- const uint vertexCount = uint(vertexes.size() / 5);
+ Q_ASSERT(uint(vertexes.size()) % floatsPerVertex == 0);
+ const uint vertexCount = uint(vertexes.size()) / floatsPerVertex;
Q_ASSERT(vertexCount % 4 == 0);
const uint quadCount = vertexCount / 4;
@@ -125,6 +129,20 @@ namespace {
m_textureCoordinateAttribute->setByteOffset(3 * sizeof(float));
m_textureCoordinateAttribute->setCount(vertexCount);
+ if (shadow) {
+ m_textureBoundsAttribute = new Qt3DRender::QAttribute(this);
+ m_textureBoundsAttribute->setName(QStringLiteral("textureBounds"));
+ m_textureBoundsAttribute->setVertexBaseType(Qt3DRender::QAttribute::Float);
+ m_textureBoundsAttribute->setVertexSize(4);
+ m_textureBoundsAttribute->setAttributeType(Qt3DRender::QAttribute::VertexAttribute);
+ m_textureBoundsAttribute->setBuffer(m_vertexBuffer);
+ m_textureBoundsAttribute->setByteStride(stride);
+ m_textureBoundsAttribute->setByteOffset(5 * sizeof(float));
+ m_textureBoundsAttribute->setCount(vertexCount);
+ } else {
+ m_textureBoundsAttribute = nullptr;
+ }
+
m_indexAttribute = new Qt3DRender::QAttribute(this);
m_indexAttribute->setAttributeType(Qt3DRender::QAttribute::IndexAttribute);
m_indexAttribute->setVertexBaseType(indexType);
@@ -134,6 +152,8 @@ namespace {
addAttribute(m_positionAttribute);
addAttribute(m_textureCoordinateAttribute);
addAttribute(m_indexAttribute);
+ if (shadow)
+ addAttribute(m_textureBoundsAttribute);
}
}
@@ -143,10 +163,10 @@ Q3DSTextMesh::Q3DSTextMesh(Qt3DCore::QNode *parent)
{
}
-void Q3DSTextMesh::setVertexes(const QVector<float> &vertexes)
+void Q3DSTextMesh::setVertexes(const QVector<float> &vertexes, bool dropShadow)
{
delete m_geometry;
- m_geometry = new Q3DSTextMeshGeometry(vertexes, this);
+ m_geometry = new Q3DSTextMeshGeometry(dropShadow, vertexes, this);
setGeometry(m_geometry);
}
diff --git a/src/runtime/q3dstextmesh_p.h b/src/runtime/q3dstextmesh_p.h
index 69b07a3..b68ecc9 100644
--- a/src/runtime/q3dstextmesh_p.h
+++ b/src/runtime/q3dstextmesh_p.h
@@ -56,7 +56,8 @@ public:
explicit Q3DSTextMesh(Qt3DCore::QNode *parent = nullptr);
~Q3DSTextMesh() override;
- void setVertexes(const QVector<float> &vertexes);
+ void setVertexes(const QVector<float> &vertexes,
+ bool dropShadow);
private:
Qt3DRender::QGeometry *m_geometry;
diff --git a/src/runtime/q3dsuiadocument.cpp b/src/runtime/q3dsuiadocument.cpp
index 4de2b58..2452fa6 100644
--- a/src/runtime/q3dsuiadocument.cpp
+++ b/src/runtime/q3dsuiadocument.cpp
@@ -90,9 +90,14 @@ const QVector<Q3DSQmlDocument> Q3DSUiaDocument::qmlDocuments() const
void Q3DSUiaDocument::updateMetadata()
{
m_dataInputMetadata.clear();
- for (const Q3DSDataInputEntry &it : qAsConst(m_dataInputEntries)) {
- if (!it.metaDataKey.isNull() && !it.metaData.isNull())
- m_dataInputMetadata.insert(it.metaDataKey.toString(), it.name);
+ QHash<QString, Q3DSDataInputEntry>::const_iterator i = m_dataInputEntries.constBegin();
+ while (i != m_dataInputEntries.constEnd()) {
+ QHash<QVariant, QVariant>::const_iterator i2 = i->metadata.constBegin();
+ while (i2 != i->metadata.constEnd()) {
+ m_dataInputMetadata.insert(i2.key(), QString(i.key()));
+ ++i2;
+ }
+ ++i;
}
}
diff --git a/src/runtime/q3dsuiaparser.cpp b/src/runtime/q3dsuiaparser.cpp
index 6a461e2..556d1ae 100644
--- a/src/runtime/q3dsuiaparser.cpp
+++ b/src/runtime/q3dsuiaparser.cpp
@@ -113,7 +113,6 @@ void Q3DSUiaParser::parsePresentations()
QStringRef type = attrs.value(QLatin1String("type"));
QStringRef minValue = attrs.value(QLatin1String("min"));
QStringRef maxValue = attrs.value(QLatin1String("max"));
- QStringRef metaDataKey = attrs.value(QLatin1String("metadatakey"));
QStringRef metaData = attrs.value(QLatin1String("metadata"));
if (name.isEmpty() || type.isEmpty()) {
r->raiseError(QObject::tr("Malformed dataInput element"));
@@ -122,10 +121,25 @@ void Q3DSUiaParser::parsePresentations()
Q3DSDataInputEntry e;
e.name = name.toString();
- if (!metaData.isEmpty())
- e.metaData = QVariant::fromValue(metaData.toString());
- if (!metaDataKey.isEmpty())
- e.metaDataKey = QVariant::fromValue(metaDataKey.toString());
+ if (!metaData.isEmpty()) {
+ auto metadataList = metaData.split(QLatin1Char('$'));
+
+ if (metadataList.size() & 1) {
+ qWarning("Malformed datainput metadata for datainput %s, cannot parse key"
+ " - value pairs. Stop parsing metadata.", qUtf8Printable(e.name));
+ } else {
+ for (int i = 0; i < metadataList.size(); i += 2) {
+ if (metadataList[i].isEmpty()) {
+ qWarning("Malformed datainput metadata for datainput %s - metadata"
+ " key empty. Stop parsing metadata.",
+ qUtf8Printable(e.name));
+ break;
+ }
+ e.metadata.insert(QVariant::fromValue(metadataList[i].toString()),
+ QVariant::fromValue(metadataList[i+1].toString()));
+ }
+ }
+ }
if (type == QStringLiteral("String")) {
e.type = Q3DSDataInputEntry::TypeString;
diff --git a/src/runtime/q3dsuippresentation.cpp b/src/runtime/q3dsuippresentation.cpp
index c7b48f8..0e654c5 100644
--- a/src/runtime/q3dsuippresentation.cpp
+++ b/src/runtime/q3dsuippresentation.cpp
@@ -2008,6 +2008,12 @@ void Q3DSDefaultMaterial::setProps(const V &attrs, PropSetFlags flags)
// Different default value.
parseProperty(attrs, flags, typeName, QStringLiteral("name"), &m_name);
+
+ // If name was not obtained, get default name from MaterialBase
+ if (m_name.isEmpty()) {
+ const QString materialBaseTypeName = QStringLiteral("MaterialBase");
+ parseProperty(attrs, flags, materialBaseTypeName, QStringLiteral("name"), &m_name);
+ }
}
void Q3DSDefaultMaterial::setProperties(const QXmlStreamAttributes &attrs, PropSetFlags flags)
@@ -2237,6 +2243,12 @@ void Q3DSReferencedMaterial::setProps(const V &attrs, PropSetFlags flags)
// Different default value.
parseProperty(attrs, flags, typeName, QStringLiteral("name"), &m_name);
+
+ // If name was not obtained, get default name from MaterialBase
+ if (m_name.isEmpty()) {
+ const QString materialBaseTypeName = QStringLiteral("MaterialBase");
+ parseProperty(attrs, flags, materialBaseTypeName, QStringLiteral("name"), &m_name);
+ }
}
void Q3DSReferencedMaterial::setProperties(const QXmlStreamAttributes &attrs, PropSetFlags flags)
@@ -2322,6 +2334,12 @@ void Q3DSCustomMaterialInstance::setProps(const V &attrs, PropSetFlags flags)
// Different default value.
parseProperty(attrs, flags, typeName, QStringLiteral("name"), &m_name);
+
+ // If name was not obtained, get default name from MaterialBase
+ if (m_name.isEmpty()) {
+ const QString materialBaseTypeName = QStringLiteral("MaterialBase");
+ parseProperty(attrs, flags, materialBaseTypeName, QStringLiteral("name"), &m_name);
+ }
}
void Q3DSCustomMaterialInstance::setProperties(const QXmlStreamAttributes &attrs, PropSetFlags flags)
@@ -4452,9 +4470,13 @@ void Q3DSUipPresentation::setDataInputEntries(const Q3DSDataInputEntry::Map *ent
void Q3DSUipPresentation::updateMetadata()
{
Q3DSDataInputEntry::MetadataMap map;
+
for (auto it = d->dataInputEntries->cbegin(); it != d->dataInputEntries->cend(); ++it) {
- if (!it->metaDataKey.isNull() && !it->metaData.isNull())
- map.insert(it->metaDataKey.toString(), it->name);
+ QHash<QVariant, QVariant>::const_iterator i2 = it->metadata.constBegin();
+ while (i2 != it->metadata.constEnd()) {
+ map.insert(i2.key(), it->name);
+ ++i2;
+ }
}
d->dataInputMetadata = map;
}
diff --git a/src/runtime/runtime.pro b/src/runtime/runtime.pro
index b29ec2c..d5cd7d5 100644
--- a/src/runtime/runtime.pro
+++ b/src/runtime/runtime.pro
@@ -1,7 +1,8 @@
TARGET = Qt3DStudioRuntime2
MODULE = 3dstudioruntime2
-QT += core-private gui-private qml quick quick-private 3dcore-private 3drender-private 3dlogic 3danimation 3dextras 3dquick 3dquickscene2d
+QT += core-private gui-private qml quick quick-private 3dcore-private 3drender-private 3dlogic \
+ 3danimation 3dextras 3dquick 3dquickscene2d 3dquickscene2d-private
SOURCES += \
q3dsuipparser.cpp \
diff --git a/src/runtime/shaders/distancefieldtext.frag b/src/runtime/shaders/distancefieldtext.frag
index 2c072bf..efcf89e 100644
--- a/src/runtime/shaders/distancefieldtext.frag
+++ b/src/runtime/shaders/distancefieldtext.frag
@@ -1,8 +1,8 @@
-varying vec2 sampleCoord;
-varying vec2 alphas;
+varying highp vec2 sampleCoord;
+varying highp vec2 alphas;
uniform sampler2D _qt_texture;
-uniform vec4 color;
+uniform highp vec4 color;
void main()
{
diff --git a/src/runtime/shaders/distancefieldtext.vert b/src/runtime/shaders/distancefieldtext.vert
index 50966cf..879545f 100644
--- a/src/runtime/shaders/distancefieldtext.vert
+++ b/src/runtime/shaders/distancefieldtext.vert
@@ -1,54 +1,54 @@
-uniform mat4 mvp;
-uniform mat4 modelView;
-uniform float fontScale;
+uniform highp mat4 mvp;
+uniform highp mat4 modelView;
+uniform highp float fontScale;
uniform int textureWidth;
uniform int textureHeight;
-attribute vec4 vCoord;
-attribute vec2 tCoord;
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
-varying vec2 sampleCoord;
-varying vec2 alphas;
+varying highp vec2 sampleCoord;
+varying highp vec2 alphas;
-float thresholdFunc(float scale)
+highp float thresholdFunc(highp float scale)
{
- float base = 0.5;
- float baseDev = 0.065;
- float devScaleMin = 0.15;
- float devScaleMax = 0.3;
+ highp float base = 0.5;
+ highp float baseDev = 0.065;
+ highp float devScaleMin = 0.15;
+ highp float devScaleMax = 0.3;
return base - ((clamp(scale, devScaleMin, devScaleMax) - devScaleMin) / (devScaleMax - devScaleMin) * -baseDev + baseDev);
}
-float spreadFunc(float scale)
+highp float spreadFunc(highp float scale)
{
return 0.06 / scale;
}
-vec2 alphaRange(float scale)
+highp vec2 alphaRange(highp float scale)
{
- float base = thresholdFunc(scale);
- float range = spreadFunc(scale);
- float alphaMin = max(0.0, base - range);
- float alphaMax = min(base + range, 1.0);
- return vec2(alphaMin, alphaMax);
+ highp float base = thresholdFunc(scale);
+ highp float range = spreadFunc(scale);
+ highp float alphaMin = max(0.0, base - range);
+ highp float alphaMax = min(base + range, 1.0);
+ return highp vec2(alphaMin, alphaMax);
}
-float determinantOfSubmatrix(mat4 m, int col0, int col1, int row0, int row1)
+highp float determinantOfSubmatrix(highp mat4 m, int col0, int col1, int row0, int row1)
{
return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0];
}
-float determinantOfSubmatrix(mat4 m, int col0, int col1, int col2, int row0, int row1, int row2)
+highp float determinantOfSubmatrix(highp mat4 m, int col0, int col1, int col2, int row0, int row1, int row2)
{
- float det = m[col0][row0] * determinantOfSubmatrix(m, col1, col2, row1, row2);
+ highp float det = m[col0][row0] * determinantOfSubmatrix(m, col1, col2, row1, row2);
det -= m[col1][row0] * determinantOfSubmatrix(m, col0, col2, row1, row2);
det += m[col2][row0] * determinantOfSubmatrix(m, col0, col1, row1, row2);
return det;
}
-float determinant(mat4 m)
+highp float determinant(highp mat4 m)
{
- float det = m[0][0] * determinantOfSubmatrix(m, 1, 2, 3, 1, 2, 3);
+ highp float det = m[0][0] * determinantOfSubmatrix(m, 1, 2, 3, 1, 2, 3);
det -= m[1][0] * determinantOfSubmatrix(m, 0, 2, 3, 1, 2, 3);
det += m[2][0] * determinantOfSubmatrix(m, 0, 1, 3, 1, 2, 3);
det -= m[3][0] * determinantOfSubmatrix(m, 0, 1, 2, 1, 2, 3);
@@ -57,8 +57,8 @@ float determinant(mat4 m)
void main()
{
- float scale = fontScale * sqrt(abs(determinant(modelView)));
+ highp float scale = fontScale * sqrt(abs(determinant(modelView)));
alphas = alphaRange(scale);
- sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight));
+ sampleCoord = tCoord * highp vec2(1.0 / highp float(textureWidth), 1.0 / highp float(textureHeight));
gl_Position = mvp * vCoord;
}
diff --git a/src/runtime/shaders/distancefieldtext_dropshadow.frag b/src/runtime/shaders/distancefieldtext_dropshadow.frag
new file mode 100644
index 0000000..da51c5c
--- /dev/null
+++ b/src/runtime/shaders/distancefieldtext_dropshadow.frag
@@ -0,0 +1,29 @@
+varying highp vec2 sampleCoord;
+varying highp vec2 alphas;
+varying highp vec2 shadowSampleCoord;
+varying highp vec4 normalizedTextureBounds;
+
+uniform sampler2D _qt_texture;
+uniform highp vec4 color;
+uniform highp vec4 shadowColor;
+
+void main()
+{
+ highp float shadowAlpha = smoothstep(alphas.x,
+ alphas.y,
+ texture2D(_qt_texture,
+ clamp(shadowSampleCoord,
+ normalizedTextureBounds.xy,
+ normalizedTextureBounds.zw)).a);
+ highp vec4 shadowPixel = shadowColor * shadowAlpha;
+
+ highp float textAlpha = smoothstep(alphas.x,
+ alphas.y,
+ texture2D(_qt_texture,
+ clamp(sampleCoord,
+ normalizedTextureBounds.xy,
+ normalizedTextureBounds.zw)).a);
+ highp vec4 textPixel = color * textAlpha;
+
+ gl_FragColor = mix(shadowPixel, textPixel, textPixel.a);
+}
diff --git a/src/runtime/shaders/distancefieldtext_dropshadow.vert b/src/runtime/shaders/distancefieldtext_dropshadow.vert
new file mode 100644
index 0000000..69fd211
--- /dev/null
+++ b/src/runtime/shaders/distancefieldtext_dropshadow.vert
@@ -0,0 +1,75 @@
+uniform highp mat4 mvp;
+uniform highp mat4 modelView;
+uniform highp float fontScale;
+uniform int textureWidth;
+uniform int textureHeight;
+uniform highp vec2 shadowOffset;
+
+attribute highp vec4 vCoord;
+attribute highp vec2 tCoord;
+attribute highp vec4 textureBounds;
+
+varying highp vec2 sampleCoord;
+varying highp vec2 shadowSampleCoord;
+varying highp vec2 alphas;
+varying highp vec4 normalizedTextureBounds;
+
+highp float thresholdFunc(highp float scale)
+{
+ highp float base = 0.5;
+ highp float baseDev = 0.065;
+ highp float devScaleMin = 0.15;
+ highp float devScaleMax = 0.3;
+ return base - ((clamp(scale, devScaleMin, devScaleMax) - devScaleMin) / (devScaleMax - devScaleMin) * -baseDev + baseDev);
+}
+
+highp float spreadFunc(highp float scale)
+{
+ return 0.06 / scale;
+}
+
+highp vec2 alphaRange(highp float scale)
+{
+ highp float base = thresholdFunc(scale);
+ highp float range = spreadFunc(scale);
+ highp float alphaMin = max(0.0, base - range);
+ highp float alphaMax = min(base + range, 1.0);
+ return highp vec2(alphaMin, alphaMax);
+}
+
+highp float determinantOfSubmatrix(highp mat4 m, int col0, int col1, int row0, int row1)
+{
+ return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0];
+}
+
+highp float determinantOfSubmatrix(highp mat4 m, int col0, int col1, int col2, int row0, int row1, int row2)
+{
+ highp float det = m[col0][row0] * determinantOfSubmatrix(m, col1, col2, row1, row2);
+ det -= m[col1][row0] * determinantOfSubmatrix(m, col0, col2, row1, row2);
+ det += m[col2][row0] * determinantOfSubmatrix(m, col0, col1, row1, row2);
+ return det;
+}
+
+highp float determinant(highp mat4 m)
+{
+ highp float det = m[0][0] * determinantOfSubmatrix(m, 1, 2, 3, 1, 2, 3);
+ det -= m[1][0] * determinantOfSubmatrix(m, 0, 2, 3, 1, 2, 3);
+ det += m[2][0] * determinantOfSubmatrix(m, 0, 1, 3, 1, 2, 3);
+ det -= m[3][0] * determinantOfSubmatrix(m, 0, 1, 2, 1, 2, 3);
+ return det;
+}
+
+void main()
+{
+ highp float scale = fontScale * sqrt(abs(determinant(modelView)));
+ alphas = alphaRange(scale);
+
+ highp vec2 textureSizeMultiplier = highp vec2(1.0 / highp float(textureWidth), 1.0 / highp float(textureHeight));
+
+ sampleCoord = tCoord * textureSizeMultiplier;
+ shadowSampleCoord = (tCoord - shadowOffset) * textureSizeMultiplier;
+ normalizedTextureBounds = highp vec4(textureBounds.xy * textureSizeMultiplier,
+ textureBounds.zw * textureSizeMultiplier);
+
+ gl_Position = mvp * vCoord;
+}
diff --git a/src/runtime/shaders/distancefieldtext_dropshadow_core.frag b/src/runtime/shaders/distancefieldtext_dropshadow_core.frag
new file mode 100644
index 0000000..46a1194
--- /dev/null
+++ b/src/runtime/shaders/distancefieldtext_dropshadow_core.frag
@@ -0,0 +1,34 @@
+#version 150 core
+
+in vec2 sampleCoord;
+in vec2 shadowSampleCoord;
+in vec4 normalizedTextureBounds;
+
+out vec4 fragColor;
+
+uniform sampler2D _qt_texture;
+uniform vec4 color;
+uniform vec4 shadowColor;
+
+in vec2 alphas;
+
+void main()
+{
+ float shadowAlpha = smoothstep(alphas.x,
+ alphas.y,
+ texture(_qt_texture,
+ clamp(shadowSampleCoord,
+ normalizedTextureBounds.xy,
+ normalizedTextureBounds.zw)).r);
+ vec4 shadowPixel = shadowColor * shadowAlpha;
+
+ float textAlpha = smoothstep(alphas.x,
+ alphas.y,
+ texture(_qt_texture,
+ clamp(sampleCoord,
+ normalizedTextureBounds.xy,
+ normalizedTextureBounds.zw)).r);
+ vec4 textPixel = color * textAlpha;
+
+ fragColor = mix(shadowPixel, textPixel, textPixel.a);
+}
diff --git a/src/runtime/shaders/distancefieldtext_dropshadow_core.vert b/src/runtime/shaders/distancefieldtext_dropshadow_core.vert
new file mode 100644
index 0000000..727dac5
--- /dev/null
+++ b/src/runtime/shaders/distancefieldtext_dropshadow_core.vert
@@ -0,0 +1,55 @@
+#version 150 core
+
+in vec4 vCoord;
+in vec2 tCoord;
+in vec4 textureBounds;
+
+out vec2 sampleCoord;
+out vec2 shadowSampleCoord;
+
+out vec2 alphas;
+out vec4 normalizedTextureBounds;
+
+uniform mat4 mvp;
+uniform mat4 modelView;
+uniform int textureWidth;
+uniform int textureHeight;
+uniform float fontScale;
+uniform vec2 shadowOffset;
+
+float thresholdFunc(float scale)
+{
+ float base = 0.5;
+ float baseDev = 0.065;
+ float devScaleMin = 0.15;
+ float devScaleMax = 0.3;
+ return base - ((clamp(scale, devScaleMin, devScaleMax) - devScaleMin) / (devScaleMax - devScaleMin) * -baseDev + baseDev);
+}
+
+float spreadFunc(float scale)
+{
+ return 0.06 / scale;
+}
+
+vec2 alphaRange(float scale)
+{
+ float base = thresholdFunc(scale);
+ float range = spreadFunc(scale);
+ float alphaMin = max(0.0, base - range);
+ float alphaMax = min(base + range, 1.0);
+ return vec2(alphaMin, alphaMax);
+}
+
+void main()
+{
+ float scale = fontScale * sqrt(abs(determinant(modelView)));
+ alphas = alphaRange(scale);
+
+ vec2 textureSizeMultiplier = vec2(1.0 / textureWidth, 1.0 / textureHeight);
+
+ sampleCoord = tCoord * textureSizeMultiplier;
+ shadowSampleCoord = (tCoord - shadowOffset) * textureSizeMultiplier;
+ normalizedTextureBounds = vec4(textureBounds.xy * textureSizeMultiplier,
+ textureBounds.zw * textureSizeMultiplier);
+ gl_Position = mvp * vCoord;
+}
diff --git a/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp b/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp
index 664d049..4469232 100644
--- a/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp
+++ b/src/runtime/slideplayerng/q3dsanimationmanagerng.cpp
@@ -143,8 +143,8 @@ static void buildAnimationData(const Q3DSSlide::AnimationTrackList &tracks,
component.type = Q3DSAnimationData::DataType::Component;
component.componentData.component = comp;
component.componentData.size = quint16(track.keyFrames().size());
- if (track.isDynamic())
- component.componentData.componentFlags = Q3DSAnimationData::ComponentFlags(component.componentData.componentFlags | Q3DSAnimationData::ComponentFlags::Dynamic);
+ component.componentData.componentFlags = track.isDynamic() ? Q3DSAnimationData::ComponentFlags::Dynamic
+ : Q3DSAnimationData::ComponentFlags::None;
animationDataList->push_back(component);
// 2. Add key frames for component track
diff --git a/tests/auto/uipparser/tst_q3dsuipparser.cpp b/tests/auto/uipparser/tst_q3dsuipparser.cpp
index 8f67b97..b9e8a02 100644
--- a/tests/auto/uipparser/tst_q3dsuipparser.cpp
+++ b/tests/auto/uipparser/tst_q3dsuipparser.cpp
@@ -286,7 +286,7 @@ void tst_Q3DSUipParser::dataModelParser()
v = p->propertiesForType(QStringLiteral("Layer"));
QVERIFY(!v->isEmpty());
- QVERIFY(v->count() >= 48);
+ QVERIFY(v->count() >= 45);
it = std::find_if(v->cbegin(), v->cend(), [](const Q3DSDataModelParser::Property &prop) { return prop.name == QStringLiteral("width"); });
QVERIFY(it != v->cend());
QCOMPARE(it->type, Q3DS::Float);