| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QT3DRENDER_RENDER_RENDERVIEWJOBUTILS_P_H |
| 5 | #define QT3DRENDER_RENDER_RENDERVIEWJOBUTILS_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists for the convenience |
| 12 | // of other Qt classes. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <Qt3DRender/qt3drender_global.h> |
| 19 | #include <Qt3DRender/private/qt3drender_global_p.h> |
| 20 | #include <Qt3DCore/qnodeid.h> |
| 21 | #include <QtCore/qhash.h> |
| 22 | #include <QtCore/qvariant.h> |
| 23 | #include <Qt3DRender/private/uniform_p.h> |
| 24 | #include <Qt3DRender/private/handle_types_p.h> |
| 25 | #include <Qt3DRender/private/shaderdata_p.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | namespace Qt3DRender { |
| 30 | namespace Render { |
| 31 | |
| 32 | class FrameGraphNode; |
| 33 | class ParameterManager; |
| 34 | class Effect; |
| 35 | class Entity; |
| 36 | class Material; |
| 37 | class RenderPass; |
| 38 | class Technique; |
| 39 | class TechniqueFilter; |
| 40 | class RenderPassFilter; |
| 41 | class NodeManagers; |
| 42 | class ShaderDataManager; |
| 43 | class TextureManager; |
| 44 | class RenderStateManager; |
| 45 | class RenderStateCollection; |
| 46 | class RenderStateSet; |
| 47 | |
| 48 | Q_3DRENDERSHARED_PRIVATE_EXPORT Technique *findTechniqueForEffect(NodeManagers *manager, |
| 49 | const TechniqueFilter *techniqueFilter, |
| 50 | Effect *effect); |
| 51 | |
| 52 | typedef QVarLengthArray<RenderPass*, 4> RenderPassList; |
| 53 | Q_3DRENDERSHARED_PRIVATE_EXPORT RenderPassList findRenderPassesForTechnique(NodeManagers *manager, |
| 54 | const RenderPassFilter *passFilter, |
| 55 | Technique *technique); |
| 56 | |
| 57 | // Extracts the type T from a QVariant v without using QVariant::value which is slow |
| 58 | // Note: Assumes you are 100% sure about the type you requested |
| 59 | template<typename T> |
| 60 | inline T variant_value(const QVariant &v) |
| 61 | { |
| 62 | return *reinterpret_cast<const T *>(v.data()); |
| 63 | } |
| 64 | |
| 65 | struct ParameterInfo |
| 66 | { |
| 67 | explicit ParameterInfo(const int nameId = -1, const HParameter &handle = HParameter()); |
| 68 | |
| 69 | int nameId; |
| 70 | HParameter handle; |
| 71 | |
| 72 | bool operator<(const int otherNameId) const noexcept; |
| 73 | bool operator<(const ParameterInfo &other) const noexcept; |
| 74 | }; |
| 75 | using ParameterInfoList = QList<ParameterInfo>; |
| 76 | |
| 77 | struct RenderPassParameterData |
| 78 | { |
| 79 | RenderPass *pass; |
| 80 | ParameterInfoList parameterInfo; |
| 81 | }; |
| 82 | QT3D_DECLARE_TYPEINFO_2(Qt3DRender, Render, RenderPassParameterData, Q_RELOCATABLE_TYPE) |
| 83 | |
| 84 | using MaterialParameterGathererData = QMultiHash<Qt3DCore::QNodeId, std::vector<RenderPassParameterData>>; |
| 85 | |
| 86 | Q_3DRENDERSHARED_PRIVATE_EXPORT void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList, |
| 87 | ParameterManager *manager, |
| 88 | Material *material, |
| 89 | Effect *effect, |
| 90 | Technique *technique); |
| 91 | |
| 92 | Q_3DRENDERSHARED_PRIVATE_EXPORT void addParametersForIds(ParameterInfoList *params, ParameterManager *manager, |
| 93 | const QList<Qt3DCore::QNodeId> ¶meterIds); |
| 94 | |
| 95 | template<class T> |
| 96 | void parametersFromParametersProvider(ParameterInfoList *infoList, |
| 97 | ParameterManager *manager, |
| 98 | T *provider) |
| 99 | { |
| 100 | addParametersForIds(infoList, manager, provider->parameters()); |
| 101 | } |
| 102 | |
| 103 | Q_3DRENDERSHARED_PRIVATE_EXPORT ParameterInfoList::const_iterator findParamInfo(ParameterInfoList *infoList, |
| 104 | const int nameId); |
| 105 | |
| 106 | Q_3DRENDERSHARED_PRIVATE_EXPORT void addStatesToRenderStateSet(RenderStateSet *stateSet, |
| 107 | const QList<Qt3DCore::QNodeId> stateIds, |
| 108 | RenderStateManager *manager); |
| 109 | |
| 110 | Q_3DRENDERSHARED_PRIVATE_EXPORT int findIdealNumberOfWorkers(int elementCount, int packetSize = 100, int maxJobCount = 1) |
| 111 | ; |
| 112 | |
| 113 | Q_3DRENDERSHARED_PRIVATE_EXPORT std::vector<Entity *> entitiesInSubset(const std::vector<Entity *> &entities, |
| 114 | const std::vector<Entity *> &subset); |
| 115 | |
| 116 | } // namespace Render |
| 117 | } // namespace Qt3DRender |
| 118 | |
| 119 | QT_END_NAMESPACE |
| 120 | |
| 121 | #endif // QT3DRENDER_RENDER_OPENGL_RENDERVIEWJOBUTILS_P_H |
| 122 | |