diff options
author | Kaj Grönholm <kaj.gronholm@qt.io> | 2019-02-18 15:48:38 +0200 |
---|---|---|
committer | Kaj Grönholm <kaj.gronholm@qt.io> | 2019-02-25 12:20:38 +0000 |
commit | 50b304d7585f8b1dda030e721aa78fb2bb63ac37 (patch) | |
tree | 5f31247d9c2f3cb28bbfb3bc089afc0b78d2b463 /src | |
parent | 7b5a181ec93260fd0f71a7d72d1b43572fce1d9d (diff) |
Dragon cleanups and improvements #3
Misc cleanups and improvements, including:
- Removing duplicate isCompatibleWithFilters from Technique.
- Removing dragonshaderjobs and dragonshaderbuilder as they weren't
used anywhere.
- Removing glDataTypeFromAttributeDataType which exists also in
dragonactivatedsurface.cpp
- Removing unused dragonframegraph.pri
Task-number: QT3DS-3045
Change-Id: I33de06ffd495fa5a53fbe9e60c6cee5026bf1c03
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src')
49 files changed, 71 insertions, 1279 deletions
diff --git a/src/runtime/dragon/dragonglshader.cpp b/src/runtime/dragon/dragonglshader.cpp index 4ee89af..3081fee 100644 --- a/src/runtime/dragon/dragonglshader.cpp +++ b/src/runtime/dragon/dragonglshader.cpp @@ -152,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 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/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/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/dragonshaderjobs_p.h b/src/runtime/dragon/jobs/dragonshaderjobs_p.h deleted file mode 100644 index e7aa448..0000000 --- a/src/runtime/dragon/jobs/dragonshaderjobs_p.h +++ /dev/null @@ -1,62 +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 SHADERJOBS_P_H -#define SHADERJOBS_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 <private/dragonvaluecontainer_p.h> - -QT_BEGIN_NAMESPACE - -namespace Qt3DRender { -namespace Dragon { - -class Shader; -struct GLShader; - -ValueContainer<GLShader> uploadShaders(ValueContainer<GLShader> uploadedShaders, - const ValueContainer<Shader> &shader); -} // namespace Dragon -} // namespace Qt3DRender - -QT_END_NAMESPACE - -#endif // SHADERJOBS_P_H 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 d1b223c..0fbbe95 100644 --- a/src/runtime/dragon/materialsystem/dragonshader_p.h +++ b/src/runtime/dragon/materialsystem/dragonshader_p.h @@ -88,9 +88,6 @@ 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; } @@ -116,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; @@ -140,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; @@ -161,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 d524e1f..e6d57c0 100644 --- a/src/runtime/dragon/qdragonrenderaspect.cpp +++ b/src/runtime/dragon/qdragonrenderaspect.cpp @@ -104,7 +104,6 @@ #include <private/dragonscene2d_p.h> // Jobs -#include <private/dragonshaderjobs_p.h> #include <private/dragontransformjobs_p.h> #include <private/dragonboundingvolumejobs_p.h> 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/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(); } |