| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the Qt3D module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 21 | ** packaging of this file. Please review the following information to | 
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 24 | ** | 
| 25 | ** GNU General Public License Usage | 
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 31 | ** included in the packaging of this file. Please review the following | 
| 32 | ** information to ensure the GNU General Public License requirements will | 
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 35 | ** | 
| 36 | ** $QT_END_LICENSE$ | 
| 37 | ** | 
| 38 | ****************************************************************************/ | 
| 39 |  | 
| 40 | #ifndef QT3DRENDER_RENDER_OPENGL_RENDERVIEWJOBUTILS_P_H | 
| 41 | #define QT3DRENDER_RENDER_OPENGL_RENDERVIEWJOBUTILS_P_H | 
| 42 |  | 
| 43 | // | 
| 44 | //  W A R N I N G | 
| 45 | //  ------------- | 
| 46 | // | 
| 47 | // This file is not part of the Qt API.  It exists for the convenience | 
| 48 | // of other Qt classes.  This header file may change from version to | 
| 49 | // version without notice, or even be removed. | 
| 50 | // | 
| 51 | // We mean it. | 
| 52 | // | 
| 53 |  | 
| 54 | #include <Qt3DRender/qt3drender_global.h> | 
| 55 | #include <Qt3DCore/qnodeid.h> | 
| 56 | #include <QtCore/qhash.h> | 
| 57 | #include <QtCore/qvariant.h> | 
| 58 | #include <QMatrix4x4> | 
| 59 | #include <Qt3DRender/private/uniform_p.h> | 
| 60 | #include <Qt3DRender/private/handle_types_p.h> | 
| 61 | #include <Qt3DRender/private/aligned_malloc_p.h> | 
| 62 | #include  <shadervariables_p.h> | 
| 63 |  | 
| 64 | QT_BEGIN_NAMESPACE | 
| 65 |  | 
| 66 | namespace Qt3DCore { | 
| 67 | class QFrameAllocator; | 
| 68 | } | 
| 69 |  | 
| 70 | namespace Qt3DRender { | 
| 71 | namespace Render { | 
| 72 |  | 
| 73 | class FrameGraphNode; | 
| 74 | class ParameterManager; | 
| 75 | class Effect; | 
| 76 | class Entity; | 
| 77 | class Material; | 
| 78 | class RenderPass; | 
| 79 | class Technique; | 
| 80 | class TechniqueFilter; | 
| 81 | class RenderPassFilter; | 
| 82 | class NodeManagers; | 
| 83 | class ShaderDataManager; | 
| 84 | class ShaderData; | 
| 85 | class TextureManager; | 
| 86 | class RenderStateManager; | 
| 87 | class RenderStateCollection; | 
| 88 | class RenderStateSet; | 
| 89 |  | 
| 90 | namespace OpenGL { | 
| 91 | class Renderer; | 
| 92 | class RenderView; | 
| 93 | struct ShaderUniform; | 
| 94 |  | 
| 95 | Q_AUTOTEST_EXPORT void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, | 
| 96 |                                                                  const FrameGraphNode *fgLeaf); | 
| 97 |  | 
| 98 | Q_AUTOTEST_EXPORT Technique *findTechniqueForEffect(NodeManagers *manager, | 
| 99 |                                                     const TechniqueFilter *techniqueFilter, | 
| 100 |                                                     Effect *effect); | 
| 101 |  | 
| 102 | typedef QVarLengthArray<RenderPass*, 4> RenderPassList; | 
| 103 | Q_AUTOTEST_EXPORT RenderPassList findRenderPassesForTechnique(NodeManagers *manager, | 
| 104 |                                                               const RenderPassFilter *passFilter, | 
| 105 |                                                               Technique *technique); | 
| 106 |  | 
| 107 | // Extracts the type T from a QVariant v without using QVariant::value which is slow | 
| 108 | // Note: Assumes you are 100% sure about the type you requested | 
| 109 | template<typename T> | 
| 110 | inline T variant_value(const QVariant &v) | 
| 111 | { | 
| 112 |     return *reinterpret_cast<const T *>(v.data()); | 
| 113 | } | 
| 114 |  | 
| 115 | struct ParameterInfo | 
| 116 | { | 
| 117 |     explicit ParameterInfo(const int nameId = -1, const HParameter &handle = HParameter()); | 
| 118 |  | 
| 119 |     int nameId; | 
| 120 |     HParameter handle; | 
| 121 |  | 
| 122 |     bool operator<(const int otherNameId) const Q_DECL_NOEXCEPT; | 
| 123 |     bool operator<(const ParameterInfo &other) const Q_DECL_NOEXCEPT; | 
| 124 | }; | 
| 125 | typedef QVector<ParameterInfo> ParameterInfoList; | 
| 126 |  | 
| 127 | struct RenderPassParameterData | 
| 128 | { | 
| 129 |     RenderPass *pass; | 
| 130 |     ParameterInfoList parameterInfo; | 
| 131 | }; | 
| 132 | QT3D_DECLARE_TYPEINFO_3(Qt3DRender, Render, OpenGL, RenderPassParameterData, Q_MOVABLE_TYPE) | 
| 133 |  | 
| 134 | using MaterialParameterGathererData = QMultiHash<Qt3DCore::QNodeId, QVector<RenderPassParameterData>>; | 
| 135 |  | 
| 136 | Q_AUTOTEST_EXPORT void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList, | 
| 137 |                                                              ParameterManager *manager, | 
| 138 |                                                              Material *material, | 
| 139 |                                                              Effect *effect, | 
| 140 |                                                              Technique *technique); | 
| 141 |  | 
| 142 | Q_AUTOTEST_EXPORT void addParametersForIds(ParameterInfoList *params, ParameterManager *manager, | 
| 143 |                                            const QVector<Qt3DCore::QNodeId> ¶meterIds); | 
| 144 |  | 
| 145 | template<class T> | 
| 146 | void parametersFromParametersProvider(ParameterInfoList *infoList, | 
| 147 |                                       ParameterManager *manager, | 
| 148 |                                       T *provider) | 
| 149 | { | 
| 150 |     addParametersForIds(infoList, manager, provider->parameters()); | 
| 151 | } | 
| 152 |  | 
| 153 | Q_AUTOTEST_EXPORT ParameterInfoList::const_iterator findParamInfo(ParameterInfoList *infoList, | 
| 154 |                                                                   const int nameId); | 
| 155 |  | 
| 156 | Q_AUTOTEST_EXPORT void addStatesToRenderStateSet(RenderStateSet *stateSet, | 
| 157 |                                                  const QVector<Qt3DCore::QNodeId> stateIds, | 
| 158 |                                                  RenderStateManager *manager); | 
| 159 |  | 
| 160 | typedef QHash<int, QVariant> UniformBlockValueBuilderHash; | 
| 161 |  | 
| 162 | struct Q_AUTOTEST_EXPORT UniformBlockValueBuilder | 
| 163 | { | 
| 164 |     UniformBlockValueBuilder(); | 
| 165 |     ~UniformBlockValueBuilder(); | 
| 166 |  | 
| 167 |     QT3D_ALIGNED_MALLOC_AND_FREE() | 
| 168 |  | 
| 169 |     void buildActiveUniformNameValueMapHelper(const ShaderData *currentShaderData, | 
| 170 |                                               const QString &blockName, | 
| 171 |                                               const QString &qmlPropertyName, | 
| 172 |                                               const QVariant &value); | 
| 173 |     void buildActiveUniformNameValueMapStructHelper(const ShaderData *rShaderData, | 
| 174 |                                                     const QString &blockName, | 
| 175 |                                                     const QString &qmlPropertyName = QString()); | 
| 176 |  | 
| 177 |     bool updatedPropertiesOnly; | 
| 178 |     QHash<QString, ShaderUniform> uniforms; | 
| 179 |     UniformBlockValueBuilderHash activeUniformNamesToValue; | 
| 180 |     ShaderDataManager *shaderDataManager; | 
| 181 |     TextureManager *textureManager; | 
| 182 |     Matrix4x4 viewMatrix; | 
| 183 | }; | 
| 184 |  | 
| 185 | } // namespace OpenGL | 
| 186 | } // namespace Render | 
| 187 | } // namespace Qt3DRender | 
| 188 |  | 
| 189 | QT_END_NAMESPACE | 
| 190 |  | 
| 191 | #endif // QT3DRENDER_RENDER_OPENGL_RENDERVIEWJOBUTILS_P_H | 
| 192 |  |