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
27QT_BEGIN_NAMESPACE
28
29namespace Qt3DRender {
30namespace Render {
31
32class FrameGraphNode;
33class ParameterManager;
34class Effect;
35class Entity;
36class Material;
37class RenderPass;
38class Technique;
39class TechniqueFilter;
40class RenderPassFilter;
41class NodeManagers;
42class ShaderDataManager;
43class TextureManager;
44class RenderStateManager;
45class RenderStateCollection;
46class RenderStateSet;
47
48Q_3DRENDERSHARED_PRIVATE_EXPORT Technique *findTechniqueForEffect(NodeManagers *manager,
49 const TechniqueFilter *techniqueFilter,
50 Effect *effect);
51
52typedef QVarLengthArray<RenderPass*, 4> RenderPassList;
53Q_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
59template<typename T>
60inline T variant_value(const QVariant &v)
61{
62 return *reinterpret_cast<const T *>(v.data());
63}
64
65struct 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};
75using ParameterInfoList = QList<ParameterInfo>;
76
77struct RenderPassParameterData
78{
79 RenderPass *pass;
80 ParameterInfoList parameterInfo;
81};
82QT3D_DECLARE_TYPEINFO_2(Qt3DRender, Render, RenderPassParameterData, Q_RELOCATABLE_TYPE)
83
84using MaterialParameterGathererData = QMultiHash<Qt3DCore::QNodeId, std::vector<RenderPassParameterData>>;
85
86Q_3DRENDERSHARED_PRIVATE_EXPORT void parametersFromMaterialEffectTechnique(ParameterInfoList *infoList,
87 ParameterManager *manager,
88 Material *material,
89 Effect *effect,
90 Technique *technique);
91
92Q_3DRENDERSHARED_PRIVATE_EXPORT void addParametersForIds(ParameterInfoList *params, ParameterManager *manager,
93 const QList<Qt3DCore::QNodeId> &parameterIds);
94
95template<class T>
96void parametersFromParametersProvider(ParameterInfoList *infoList,
97 ParameterManager *manager,
98 T *provider)
99{
100 addParametersForIds(infoList, manager, provider->parameters());
101}
102
103Q_3DRENDERSHARED_PRIVATE_EXPORT ParameterInfoList::const_iterator findParamInfo(ParameterInfoList *infoList,
104 const int nameId);
105
106Q_3DRENDERSHARED_PRIVATE_EXPORT void addStatesToRenderStateSet(RenderStateSet *stateSet,
107 const QList<Qt3DCore::QNodeId> stateIds,
108 RenderStateManager *manager);
109
110Q_3DRENDERSHARED_PRIVATE_EXPORT int findIdealNumberOfWorkers(int elementCount, int packetSize = 100, int maxJobCount = 1)
111;
112
113Q_3DRENDERSHARED_PRIVATE_EXPORT std::vector<Entity *> entitiesInSubset(const std::vector<Entity *> &entities,
114const std::vector<Entity *> &subset);
115
116} // namespace Render
117} // namespace Qt3DRender
118
119QT_END_NAMESPACE
120
121#endif // QT3DRENDER_RENDER_OPENGL_RENDERVIEWJOBUTILS_P_H
122

source code of qt3d/src/render/jobs/renderviewjobutils_p.h