summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-07-17 12:43:47 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-07-18 10:29:32 +0200
commita7ca5cdec02ce67e28dacd0e6e2e5d666d872dcd (patch)
tree901f86fbb675c6b1c494697e781e1bb46a7bb91a
parentb63aaf574c6b4b5a40e2f137f077c694bcf79ae0 (diff)
RenderStates: fix override of nested RenderStates
When merging states, make sure we don't add several states of the same types with possibly different values. We should only add states with type we don't already have. Since the FG traversal is done from leaf to root, we know that the states we already contain should override any state that may have been specified higher up in the FG branch. Change-Id: I9bd1eadd37e8addf740a4b85b2318f9be269fedb Task-number: QTBUG-76766 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/render/renderers/opengl/jobs/renderviewjobutils.cpp14
-rw-r--r--src/render/renderers/opengl/jobs/renderviewjobutils_p.h6
-rw-r--r--src/render/renderers/opengl/renderer/renderview.cpp5
-rw-r--r--src/render/renderers/opengl/renderstates/renderstateset.cpp15
-rw-r--r--src/render/renderers/opengl/renderstates/renderstateset_p.h3
-rw-r--r--src/render/renderstates/genericstate_p.h2
-rw-r--r--src/render/renderstates/renderstatenode_p.h2
-rw-r--r--tests/auto/render/qrenderstate/tst_qrenderstate.cpp8
-rw-r--r--tests/manual/manual.pro3
-rw-r--r--tests/manual/qtbug-76766/FrameGraph.qml140
-rw-r--r--tests/manual/qtbug-76766/Material1.qml93
-rw-r--r--tests/manual/qtbug-76766/Material2.qml105
-rw-r--r--tests/manual/qtbug-76766/PostProcess.qml117
-rw-r--r--tests/manual/qtbug-76766/SceneRoot.qml176
-rw-r--r--tests/manual/qtbug-76766/expected_output.pngbin0 -> 22639 bytes
-rw-r--r--tests/manual/qtbug-76766/main.cpp74
-rw-r--r--tests/manual/qtbug-76766/main.qml76
-rw-r--r--tests/manual/qtbug-76766/qml.qrc11
-rw-r--r--tests/manual/qtbug-76766/qtbug-76766.pro10
-rw-r--r--tests/manual/qtbug-76766/shaders.qrc6
-rw-r--r--tests/manual/qtbug-76766/shaders/shader.frag11
-rw-r--r--tests/manual/qtbug-76766/shaders/shader.vert36
22 files changed, 894 insertions, 19 deletions
diff --git a/src/render/renderers/opengl/jobs/renderviewjobutils.cpp b/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
index acb38ffb9..49e85e1d3 100644
--- a/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
+++ b/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
@@ -193,8 +193,10 @@ void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, const FrameGraphN
rv->setStateSet(stateSet);
}
+ // Add states from new stateSet we might be missing
+ // but don' t override existing states (lower StateSetNode always has priority)
if (rStateSet->hasRenderStates())
- addToRenderStateSet(stateSet, rStateSet->renderStates(), manager->renderStateManager());
+ addUniqueStatesToRenderStateSet(stateSet, rStateSet->renderStates(), manager->renderStateManager());
break;
}
@@ -417,14 +419,16 @@ void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList,
parametersFromParametersProvider(infoList, manager, technique);
}
-void addToRenderStateSet(RenderStateSet *stateSet,
- const QVector<Qt3DCore::QNodeId> stateIds,
- RenderStateManager *manager)
+// Only add states with types we don't already have
+void addUniqueStatesToRenderStateSet(RenderStateSet *stateSet,
+ const QVector<Qt3DCore::QNodeId> stateIds,
+ RenderStateManager *manager)
{
for (const Qt3DCore::QNodeId &stateId : stateIds) {
RenderStateNode *node = manager->lookupResource(stateId);
- if (node->isEnabled())
+ if (node->isEnabled() && !stateSet->hasStateOfType(node->type())) {
stateSet->addState(node->impl());
+ }
}
}
diff --git a/src/render/renderers/opengl/jobs/renderviewjobutils_p.h b/src/render/renderers/opengl/jobs/renderviewjobutils_p.h
index 90c4a53cc..bd2e12534 100644
--- a/src/render/renderers/opengl/jobs/renderviewjobutils_p.h
+++ b/src/render/renderers/opengl/jobs/renderviewjobutils_p.h
@@ -150,9 +150,9 @@ void parametersFromParametersProvider(ParameterInfoList *infoList,
Q_AUTOTEST_EXPORT ParameterInfoList::const_iterator findParamInfo(ParameterInfoList *infoList,
const int nameId);
-Q_AUTOTEST_EXPORT void addToRenderStateSet(RenderStateSet *stateSet,
- const QVector<Qt3DCore::QNodeId> stateIds,
- RenderStateManager *manager);
+Q_AUTOTEST_EXPORT void addUniqueStatesToRenderStateSet(RenderStateSet *stateSet,
+ const QVector<Qt3DCore::QNodeId> stateIds,
+ RenderStateManager *manager);
typedef QHash<int, QVariant> UniformBlockValueBuilderHash;
diff --git a/src/render/renderers/opengl/renderer/renderview.cpp b/src/render/renderers/opengl/renderer/renderview.cpp
index be9968d06..2c96939a7 100644
--- a/src/render/renderers/opengl/renderer/renderview.cpp
+++ b/src/render/renderers/opengl/renderer/renderview.cpp
@@ -603,10 +603,7 @@ QVector<RenderCommand *> RenderView::buildDrawRenderCommands(const QVector<Entit
RenderPass *pass = passData.pass;
if (pass->hasRenderStates()) {
command->m_stateSet = new RenderStateSet();
- addToRenderStateSet(command->m_stateSet, pass->renderStates(), m_manager->renderStateManager());
-
- // Merge per pass stateset with global stateset
- // so that the local stateset only overrides
+ addUniqueStatesToRenderStateSet(command->m_stateSet, pass->renderStates(), m_manager->renderStateManager());
if (m_stateSet != nullptr)
command->m_stateSet->merge(m_stateSet);
command->m_changeCost = m_renderer->defaultRenderState()->changeCost(command->m_stateSet);
diff --git a/src/render/renderers/opengl/renderstates/renderstateset.cpp b/src/render/renderers/opengl/renderstates/renderstateset.cpp
index f7fc279a1..b14695c77 100644
--- a/src/render/renderers/opengl/renderstates/renderstateset.cpp
+++ b/src/render/renderers/opengl/renderstates/renderstateset.cpp
@@ -103,9 +103,24 @@ StateMaskSet RenderStateSet::stateMask() const
return m_stateMask;
}
+// This modifies our state to add states from others
+// if we don't already contain a state with that type set
void RenderStateSet::merge(RenderStateSet *other)
{
m_stateMask |= other->stateMask();
+ const QVector<StateVariant> otherStates = other->states();
+
+ // We only add states which are new (different type)
+ for (const StateVariant &otherState : otherStates) {
+ const bool hasFoundStateOfSameType = hasStateOfType(otherState.type);
+ if (!hasFoundStateOfSameType)
+ m_states.push_back(otherState);
+ }
+}
+
+bool RenderStateSet::hasStateOfType(StateMask type) const
+{
+ return (type & stateMask());
}
bool RenderStateSet::contains(const StateVariant &ds) const
diff --git a/src/render/renderers/opengl/renderstates/renderstateset_p.h b/src/render/renderers/opengl/renderstates/renderstateset_p.h
index 09b58b859..29be4d2f1 100644
--- a/src/render/renderers/opengl/renderstates/renderstateset_p.h
+++ b/src/render/renderers/opengl/renderstates/renderstateset_p.h
@@ -93,6 +93,9 @@ public:
QVector<StateVariant> states() const { return m_states; }
+ bool hasStateOfType(StateMask type) const;
+
+
/**
* @brief contains - check if this set contains a matching piece of state
* @param ds
diff --git a/src/render/renderstates/genericstate_p.h b/src/render/renderstates/genericstate_p.h
index 69c3dee15..b07487d65 100644
--- a/src/render/renderstates/genericstate_p.h
+++ b/src/render/renderstates/genericstate_p.h
@@ -96,7 +96,7 @@ public:
bool equalTo(const RenderStateImpl &renderState) const override
{
const GenericState *other = static_cast<const GenericState*>(&renderState);
- return (other != NULL && other->m_values == m_values);
+ return (other != nullptr && other->m_values == m_values);
}
StateMask mask() const override
diff --git a/src/render/renderstates/renderstatenode_p.h b/src/render/renderstates/renderstatenode_p.h
index 886bb0c95..277b8a7c8 100644
--- a/src/render/renderstates/renderstatenode_p.h
+++ b/src/render/renderstates/renderstatenode_p.h
@@ -65,7 +65,7 @@ public:
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
- StateMaskSet mask() const { return m_impl.type; }
+ StateMask type() const { return m_impl.type; }
StateVariant impl() const { return m_impl; }
protected:
diff --git a/tests/auto/render/qrenderstate/tst_qrenderstate.cpp b/tests/auto/render/qrenderstate/tst_qrenderstate.cpp
index 6e90f4ce1..dc2a9b242 100644
--- a/tests/auto/render/qrenderstate/tst_qrenderstate.cpp
+++ b/tests/auto/render/qrenderstate/tst_qrenderstate.cpp
@@ -183,8 +183,8 @@ private Q_SLOTS:
// THEN
RenderStateNode *backend1 = createBackendNode(frontend1);
RenderStateNode *backend2 = createBackendNode(frontend2);
- QVERIFY(backend1->mask() == mask);
- QVERIFY(backend2->mask() == mask);
+ QVERIFY(backend1->type() == mask);
+ QVERIFY(backend2->type() == mask);
QVERIFY(backend1->impl() != backend2->impl());
// WHEN
@@ -268,8 +268,8 @@ private Q_SLOTS:
// THEN
RenderStateNode *backend1 = createBackendNode(frontend1);
RenderStateNode *backend2 = createBackendNode(frontend2);
- QVERIFY(backend1->mask() == mask);
- QVERIFY(backend2->mask() == mask);
+ QVERIFY(backend1->type() == mask);
+ QVERIFY(backend2->type() == mask);
QVERIFY(backend1->impl() != backend2->impl());
// WHEN
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 4900add69..5b197ff47 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -61,7 +61,8 @@ SUBDIRS += \
raycasting-qml \
shared_texture_image \
texture_property_updates \
- qtbug-72236
+ qtbug-72236 \
+ qtbug-76766
qtHaveModule(widgets): {
SUBDIRS += \
diff --git a/tests/manual/qtbug-76766/FrameGraph.qml b/tests/manual/qtbug-76766/FrameGraph.qml
new file mode 100644
index 000000000..0b096bc19
--- /dev/null
+++ b/tests/manual/qtbug-76766/FrameGraph.qml
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.9
+import Qt3D.Render 2.9
+
+RenderSurfaceSelector {
+ id: surfaceSelector
+
+ readonly property Layer layer: Layer {
+ recursive: true
+ }
+
+ property alias camera: cameraSelector.camera
+ property alias clearColor: clearBuffers.clearColor
+ property alias fbo : renderToFboSelector.target
+
+ Viewport {
+ normalizedRect: Qt.rect(0.0, 0.0, 1.0, 1.0)
+
+ // 1st: render scene to texture
+ RenderTargetSelector {
+ id : renderToFboSelector
+
+ RenderStateSet {
+ renderStates: [
+ MultiSampleAntiAliasing {},
+ DepthTest {
+ depthFunction: DepthTest.Less
+ },
+ CullFace{
+ mode: CullFace.Back
+ }
+ ]
+
+ ClearBuffers {
+ id: clearBuffers
+ buffers: ClearBuffers.ColorDepthBuffer
+ NoDraw {}
+ }
+
+ CameraSelector {
+ id: cameraSelector
+
+ LayerFilter {
+ layers: [layer]
+ filterMode: LayerFilter.DiscardAllMatchingLayers
+ TechniqueFilter {
+ RenderPassFilter {
+ matchAny: FilterKey { name: "pass"; value: 0 }
+ }
+ SortPolicy {
+ sortTypes: [SortPolicy.BackToFront]
+ RenderPassFilter {
+ matchAny: FilterKey { name: "pass"; value: 1 }
+ }
+ }
+ }
+ }
+
+ RenderStateSet {
+ renderStates: [
+ DepthTest {
+ depthFunction: DepthTest.Always
+ }
+ ]
+ LayerFilter {
+ layers: [layer]
+ filterMode: LayerFilter.AcceptAnyMatchingLayers
+ TechniqueFilter {
+ RenderPassFilter {
+ matchAny: FilterKey { name: "pass"; value: 0 }
+ }
+ SortPolicy {
+ sortTypes: [SortPolicy.BackToFront]
+ RenderPassFilter {
+ matchAny: FilterKey { name: "pass"; value: 1 }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ RenderStateSet {
+ renderStates: [
+ DepthTest {depthFunction: DepthTest.Always},
+ BlendEquation {},
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.One
+ sourceAlpha: BlendEquationArguments.One
+ destinationRgb: BlendEquationArguments.Zero
+ destinationAlpha: BlendEquationArguments.Zero
+ }
+ ]
+
+ RenderPassFilter {
+ matchAny : FilterKey { name : "pass"; value : "final" }
+ }
+ }
+ }
+}
diff --git a/tests/manual/qtbug-76766/Material1.qml b/tests/manual/qtbug-76766/Material1.qml
new file mode 100644
index 000000000..069d99c74
--- /dev/null
+++ b/tests/manual/qtbug-76766/Material1.qml
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+
+Material {
+ id: root
+
+ property color color: Qt.rgba(0.15, 0.35, 0.50, 1.0)
+
+ parameters: [
+ Parameter { name: "color"; value: Qt.vector3d(root.color.r, root.color.g, root.color.b) }
+ ]
+
+
+ effect: Effect {
+ property string vertex: "qrc:/shaders/shader.vert"
+ property string fragment: "qrc:/shaders/shader.frag"
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource(parent.vertex)
+ fragmentShaderCode: loadSource(parent.fragment)
+ }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 3
+ }
+ renderPasses: RenderPass {
+ filterKeys: [
+ FilterKey {
+ name: "pass"
+ value: 0
+ }
+ ]
+ shaderProgram: gl3Shader
+ }
+ }
+ ]
+ }
+}
+
+
diff --git a/tests/manual/qtbug-76766/Material2.qml b/tests/manual/qtbug-76766/Material2.qml
new file mode 100644
index 000000000..0af0ecb6c
--- /dev/null
+++ b/tests/manual/qtbug-76766/Material2.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+
+Material {
+ id: root
+
+ property color color: Qt.rgba(0.15, 0.35, 0.50, 1.0)
+
+ parameters: [
+ Parameter { name: "color"; value: Qt.vector3d(root.color.r, root.color.g, root.color.b) }
+ ]
+
+
+ effect: Effect {
+ property string vertex: "qrc:/shaders/shader.vert"
+ property string fragment: "qrc:/shaders/shader.frag"
+
+ FilterKey {
+ id: forward
+ name: "renderingStyle"
+ value: "forward"
+ }
+
+ ShaderProgram {
+ id: gl3Shader
+ vertexShaderCode: loadSource(parent.vertex)
+ fragmentShaderCode: loadSource(parent.fragment)
+ }
+
+ techniques: [
+ // OpenGL 3.1
+ Technique {
+ filterKeys: [ forward ]
+ graphicsApiFilter {
+ api: GraphicsApiFilter.OpenGL
+ profile: GraphicsApiFilter.CoreProfile
+ majorVersion: 3
+ minorVersion: 3
+ }
+ renderPasses: [
+ RenderPass {
+ filterKeys: [
+ FilterKey {
+ name: "pass"
+ value: 1
+ }
+ ]
+ shaderProgram: gl3Shader
+ renderStates: [
+ NoDepthMask {},
+ BlendEquation {},
+ BlendEquationArguments {
+ sourceRgb: BlendEquationArguments.One
+ destinationRgb: BlendEquationArguments.One
+ sourceAlpha: BlendEquationArguments.Zero
+ destinationAlpha: BlendEquationArguments.One
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
+
+
diff --git a/tests/manual/qtbug-76766/PostProcess.qml b/tests/manual/qtbug-76766/PostProcess.qml
new file mode 100644
index 000000000..cd4c9c0c6
--- /dev/null
+++ b/tests/manual/qtbug-76766/PostProcess.qml
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.9
+import Qt3D.Render 2.9
+import Qt3D.Extras 2.0
+
+Entity {
+ id: root
+
+ property Texture colorTexture
+ readonly property int samples : colorTexture ? colorTexture.samples : 1
+
+ Effect {
+ id: materialEffect
+ techniques : [
+ // OpenGL 3.2
+ Technique {
+ graphicsApiFilter {
+ api : GraphicsApiFilter.OpenGL
+ profile : GraphicsApiFilter.CoreProfile
+ minorVersion : 3
+ majorVersion : 2
+ }
+
+ renderPasses : RenderPass {
+ filterKeys : FilterKey { name : "pass"; value : "final" }
+
+ shaderProgram : ShaderProgram {
+ vertexShaderCode:
+ "#version 150 core
+
+ in vec3 vertexPosition;
+ out vec2 texCoords;
+
+ void main() {
+ texCoords = vec2(0.5) + vec2(0.5) * vertexPosition.xz;
+ gl_Position = vec4(vertexPosition.x, vertexPosition.z, 0.0, 1.0);
+ }"
+ fragmentShaderCode:
+ "#version 150 core
+
+ uniform sampler2DMS source;
+
+ in vec2 texCoords;
+ out vec4 fragColor;
+
+ void main() {
+ vec4 c = vec4(0.0);
+ c += texelFetch(source, ivec2(gl_FragCoord), 0);
+ fragColor = vec4(c.rgb / max(c.a, 0.01), c.a);
+ }"
+ }
+ }
+ }
+ ]
+ }
+
+ Material {
+ id: materialWithoutTexture
+
+ parameters: [
+ Parameter { name: "source"; value: colorTexture },
+ Parameter { name: "samples"; value: root.samples }
+ ]
+
+ effect: materialEffect
+ }
+
+ PlaneMesh {
+ id: planeMesh
+ width: 2.0
+ height: 2.0
+ meshResolution: Qt.size(2, 2)
+ }
+
+ components : [
+ planeMesh,
+ materialWithoutTexture
+ ]
+}
diff --git a/tests/manual/qtbug-76766/SceneRoot.qml b/tests/manual/qtbug-76766/SceneRoot.qml
new file mode 100644
index 000000000..6e34633b1
--- /dev/null
+++ b/tests/manual/qtbug-76766/SceneRoot.qml
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt3D.Core 2.0
+import Qt3D.Render 2.0
+import Qt3D.Extras 2.0
+import Qt3D.Input 2.0
+import QtQuick 2.0 as QQ2
+import QtQuick 2.12
+
+
+Entity {
+ id: sceneRoot
+
+ Camera {
+ id: camera
+ projectionType: CameraLens.OrthographicProjection
+ left: -2
+ right: 2
+ top: 2
+ bottom: -2
+ nearPlane: 0.1
+ farPlane: 1000.0
+ position: Qt.vector3d(0.0, 0.0, 1.0)
+ upVector: Qt.vector3d(0.0, 1.0, 0.0)
+ viewCenter: Qt.vector3d(0.0, 0.0, 0.0)
+ }
+
+ RenderTarget {
+ id: renderTargetFBO
+ attachments : [
+ RenderTargetOutput {
+ attachmentPoint : RenderTargetOutput.Color0
+ texture : Texture2DMultisample {
+ id : colorAttachment
+ width : scene3d.width
+ height : scene3d.height
+ format : Texture.RGBA8_UNorm
+ generateMipMaps : false
+ samples: 1
+ }
+ },
+ RenderTargetOutput {
+ attachmentPoint : RenderTargetOutput.Depth
+ texture : Texture2DMultisample {
+ width : scene3d.width
+ height : scene3d.height
+ format : Texture.D32F
+ generateMipMaps : false
+ samples: 1
+ }
+ }
+ ]
+ }
+
+ components: [
+ RenderSettings {
+ activeFrameGraph: FrameGraph {
+ id: framegraph
+ camera: camera
+ fbo: renderTargetFBO
+ }
+ renderPolicy: RenderSettings.Always
+ }
+ ]
+
+ Entity {
+ id: firstPassEntities
+
+ Entity {
+ components: [
+ Transform {
+ translation: Qt.vector3d(0,0,-2)
+ },
+ Material1 {
+ color: "red"
+ },
+ SphereMesh {
+ }
+ ]
+ }
+
+
+ Entity {
+ components: [
+ Transform {
+ translation: Qt.vector3d(1,0,-1)
+ },
+ Material2 {
+ color: "green"
+ },
+ SphereMesh {
+ }
+ ]
+ }
+ }
+
+ Entity {
+ id: secondPassEntities
+ components: [framegraph.layer]
+
+ Entity {
+ components: [
+ Transform {
+ translation: Qt.vector3d(0,0,-4)
+ scale: 0.5
+ },
+ Material1 {
+ ColorAnimation on color {
+ from: "black"
+ to: "purple"
+ duration: 2000
+ loops: Animation.Infinite
+ }
+ },
+ SphereMesh {
+ }
+ ]
+ }
+
+
+ Entity {
+ components: [
+ Transform {
+ translation: Qt.vector3d(1,0,-3)
+ scale: 0.5
+ },
+ Material2 {
+ color: "orange"
+ },
+ SphereMesh {
+ }
+ ]
+ }
+ }
+
+ PostProcess {
+ colorTexture: colorAttachment
+ }
+}
diff --git a/tests/manual/qtbug-76766/expected_output.png b/tests/manual/qtbug-76766/expected_output.png
new file mode 100644
index 000000000..8f642e843
--- /dev/null
+++ b/tests/manual/qtbug-76766/expected_output.png
Binary files differ
diff --git a/tests/manual/qtbug-76766/main.cpp b/tests/manual/qtbug-76766/main.cpp
new file mode 100644
index 000000000..f9d49846a
--- /dev/null
+++ b/tests/manual/qtbug-76766/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQuickView>
+#include <QOpenGLContext>
+
+void setSurfaceFormat()
+{
+ QSurfaceFormat format;
+#ifdef QT_OPENGL_ES_2
+ format.setRenderableType(QSurfaceFormat::OpenGLES);
+#else
+ if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
+ format.setVersion(4, 3);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+ }
+#endif
+ format.setDepthBufferSize(24);
+ format.setSamples(4);
+ format.setStencilBufferSize(8);
+ QSurfaceFormat::setDefaultFormat(format);
+}
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+ setSurfaceFormat();
+
+ QQuickView view;
+
+ view.resize(1920, 1080);
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ view.setSource(QUrl("qrc:/main.qml"));
+ view.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/qtbug-76766/main.qml b/tests/manual/qtbug-76766/main.qml
new file mode 100644
index 000000000..9b8f4b691
--- /dev/null
+++ b/tests/manual/qtbug-76766/main.qml
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.12
+import QtQuick.Scene3D 2.12
+import Qt3D.Render 2.12
+
+Item {
+ anchors.fill: parent
+
+ Scene3D {
+ id: scene3d
+ anchors.fill: parent
+ focus: true
+ cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
+
+ SceneRoot {
+ id: root
+ }
+ }
+
+ Image {
+ width: 400
+ fillMode: Image.PreserveAspectFit
+ source: "qrc:/expected_output.png"
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ text: "This is the expected output"
+ }
+ Rectangle {
+ anchors.fill: parent
+ color: "transparent"
+ border {
+ color: "white"
+ width: 2
+ }
+ }
+ }
+}
diff --git a/tests/manual/qtbug-76766/qml.qrc b/tests/manual/qtbug-76766/qml.qrc
new file mode 100644
index 000000000..b1f8c2c21
--- /dev/null
+++ b/tests/manual/qtbug-76766/qml.qrc
@@ -0,0 +1,11 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>SceneRoot.qml</file>
+ <file>FrameGraph.qml</file>
+ <file>PostProcess.qml</file>
+ <file>Material1.qml</file>
+ <file>Material2.qml</file>
+ <file>expected_output.png</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/qtbug-76766/qtbug-76766.pro b/tests/manual/qtbug-76766/qtbug-76766.pro
new file mode 100644
index 000000000..f332d7d57
--- /dev/null
+++ b/tests/manual/qtbug-76766/qtbug-76766.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += qml quick
+CONFIG += c++11
+
+SOURCES += main.cpp
+
+RESOURCES += qml.qrc \
+ shaders.qrc
+
diff --git a/tests/manual/qtbug-76766/shaders.qrc b/tests/manual/qtbug-76766/shaders.qrc
new file mode 100644
index 000000000..665814e55
--- /dev/null
+++ b/tests/manual/qtbug-76766/shaders.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>shaders/shader.frag</file>
+ <file>shaders/shader.vert</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/qtbug-76766/shaders/shader.frag b/tests/manual/qtbug-76766/shaders/shader.frag
new file mode 100644
index 000000000..92d304640
--- /dev/null
+++ b/tests/manual/qtbug-76766/shaders/shader.frag
@@ -0,0 +1,11 @@
+#version 150 core
+
+uniform vec3 color;
+
+out vec4 fragColor;
+
+void main()
+{
+ fragColor = vec4(color,1.0);
+}
+
diff --git a/tests/manual/qtbug-76766/shaders/shader.vert b/tests/manual/qtbug-76766/shaders/shader.vert
new file mode 100644
index 000000000..fa836855d
--- /dev/null
+++ b/tests/manual/qtbug-76766/shaders/shader.vert
@@ -0,0 +1,36 @@
+#version 150 core
+
+in vec3 vertexPosition;
+in vec3 vertexNormal;
+in vec2 vertexTexCoord;
+in vec4 vertexTangent;
+
+out vec3 worldPosition;
+out vec3 worldNormal;
+out vec4 worldTangent;
+out vec2 texCoord;
+
+uniform mat4 modelMatrix;
+uniform mat3 modelNormalMatrix;
+uniform mat4 mvp;
+
+void main()
+{
+ // Scale texture coordinates for for fragment shader
+ texCoord = vertexTexCoord;
+
+ // Transform position, normal, and tangent to world coords
+ worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0));
+ worldNormal = normalize(modelNormalMatrix * vertexNormal);
+ worldTangent.xyz = normalize(vec3(modelMatrix * vec4(vertexTangent.xyz, 0.0)));
+ worldTangent.w = vertexTangent.w;
+
+ // Calculate animated vertex positions
+
+ float sinPos = (vertexPosition.z)+(vertexPosition.x);
+ float sinPos2 = (vertexPosition.y/2)+(vertexPosition.z);
+ vec3 vertMod = vec3(vertexPosition.x,vertexPosition.y,vertexPosition.z);
+
+ // Calculate vertex position in clip coordinates
+ gl_Position = mvp * vec4(vertexPosition, 1.0);
+}