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_MANAGERS_P_H
41#define QT3DRENDER_RENDER_MANAGERS_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 <Qt3DCore/private/qresourcemanager_p.h>
55#include <Qt3DCore/private/matrix4x4_p.h>
56#include <Qt3DRender/private/rendertargetoutput_p.h>
57#include <Qt3DRender/private/cameralens_p.h>
58#include <Qt3DRender/private/filterkey_p.h>
59#include <Qt3DRender/private/effect_p.h>
60#include <Qt3DRender/private/entity_p.h>
61#include <Qt3DRender/private/layer_p.h>
62#include <Qt3DRender/private/levelofdetail_p.h>
63#include <Qt3DRender/private/material_p.h>
64#include <Qt3DRender/private/shader_p.h>
65#include <Qt3DRender/private/shaderbuilder_p.h>
66#include <Qt3DRender/private/texture_p.h>
67#include <Qt3DRender/private/transform_p.h>
68#include <Qt3DRender/private/rendertarget_p.h>
69#include <Qt3DRender/private/renderpass_p.h>
70#include <Qt3DRender/private/renderstatenode_p.h>
71#include <Qt3DRender/private/parameter_p.h>
72#include <Qt3DRender/private/shaderdata_p.h>
73#include <Qt3DRender/private/handle_types_p.h>
74#include <Qt3DRender/private/textureimage_p.h>
75#include <Qt3DRender/private/attribute_p.h>
76#include <Qt3DRender/private/geometry_p.h>
77#include <Qt3DRender/private/objectpicker_p.h>
78#include <Qt3DRender/private/raycaster_p.h>
79#include <Qt3DRender/private/boundingvolumedebug_p.h>
80#include <Qt3DRender/private/light_p.h>
81#include <Qt3DRender/private/environmentlight_p.h>
82#include <Qt3DRender/private/computecommand_p.h>
83#include <Qt3DRender/private/armature_p.h>
84#include <Qt3DRender/private/skeleton_p.h>
85#include <Qt3DRender/private/joint_p.h>
86#include <Qt3DRender/private/shaderimage_p.h>
87
88QT_BEGIN_NAMESPACE
89
90namespace Qt3DRender {
91
92namespace Render {
93
94class Q_3DRENDERSHARED_PRIVATE_EXPORT AttachmentManager : public Qt3DCore::QResourceManager<
95 RenderTargetOutput,
96 Qt3DCore::QNodeId,
97 Qt3DCore::NonLockingPolicy>
98{
99public:
100 AttachmentManager() {}
101};
102
103class Q_3DRENDERSHARED_PRIVATE_EXPORT CameraManager : public Qt3DCore::QResourceManager<
104 CameraLens,
105 Qt3DCore::QNodeId,
106 Qt3DCore::NonLockingPolicy>
107{
108public:
109 CameraManager() {}
110};
111
112class Q_3DRENDERSHARED_PRIVATE_EXPORT FilterKeyManager : public Qt3DCore::QResourceManager<
113 FilterKey,
114 Qt3DCore::QNodeId,
115 Qt3DCore::NonLockingPolicy>
116
117{
118public:
119 FilterKeyManager() {}
120};
121
122class Q_3DRENDERSHARED_PRIVATE_EXPORT EffectManager : public Qt3DCore::QResourceManager<
123 Effect,
124 Qt3DCore::QNodeId,
125 Qt3DCore::NonLockingPolicy>
126{
127public:
128 EffectManager() {}
129};
130
131class Q_3DRENDERSHARED_PRIVATE_EXPORT EntityManager : public Qt3DCore::QResourceManager<
132 Entity,
133 Qt3DCore::QNodeId,
134 Qt3DCore::NonLockingPolicy>
135{
136public:
137 EntityManager() {}
138 ~EntityManager()
139 {
140 Allocator::for_each(f: [](Entity *e) {
141 if (e)
142 e->setNodeManagers(nullptr);
143 });
144 }
145};
146
147class FrameGraphNode;
148
149class Q_3DRENDERSHARED_PRIVATE_EXPORT FrameGraphManager
150{
151public:
152 FrameGraphManager() {}
153 ~FrameGraphManager();
154
155 bool containsNode(Qt3DCore::QNodeId id) const;
156 void appendNode(Qt3DCore::QNodeId id, FrameGraphNode *node);
157 FrameGraphNode* lookupNode(Qt3DCore::QNodeId id) const;
158 void releaseNode(Qt3DCore::QNodeId id);
159
160private:
161 QHash<Qt3DCore::QNodeId, FrameGraphNode*> m_nodes;
162};
163
164class Q_3DRENDERSHARED_PRIVATE_EXPORT LayerManager : public Qt3DCore::QResourceManager<
165 Layer,
166 Qt3DCore::QNodeId,
167 Qt3DCore::NonLockingPolicy>
168{
169public:
170 LayerManager() {}
171};
172
173class Q_3DRENDERSHARED_PRIVATE_EXPORT LevelOfDetailManager : public Qt3DCore::QResourceManager<
174 LevelOfDetail,
175 Qt3DCore::QNodeId,
176 Qt3DCore::NonLockingPolicy>
177{
178public:
179 LevelOfDetailManager() {}
180};
181
182class Q_3DRENDERSHARED_PRIVATE_EXPORT MaterialManager : public Qt3DCore::QResourceManager<
183 Material,
184 Qt3DCore::QNodeId,
185 Qt3DCore::NonLockingPolicy>
186{
187public:
188 MaterialManager() {}
189};
190
191class Q_3DRENDERSHARED_PRIVATE_EXPORT MatrixManager : public Qt3DCore::QResourceManager<
192 Matrix4x4,
193 Qt3DCore::QNodeId,
194 Qt3DCore::NonLockingPolicy>
195{
196public:
197 MatrixManager() {}
198};
199
200class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderManager : public Qt3DCore::QResourceManager<
201 Shader,
202 Qt3DCore::QNodeId,
203 Qt3DCore::ObjectLevelLockingPolicy>
204{
205public:
206 ShaderManager() {}
207
208 // Called in AspectThread by Shader node functor destroy
209 void addShaderIdToCleanup(Qt3DCore::QNodeId id)
210 {
211 m_shaderIdsToCleanup.push_back(t: id);
212 }
213
214 void removeShaderIdFromIdsToCleanup(Qt3DCore::QNodeId id)
215 {
216 m_shaderIdsToCleanup.removeAll(t: id);
217 }
218
219 bool hasShaderIdToCleanup(Qt3DCore::QNodeId id) const
220 {
221 return m_shaderIdsToCleanup.contains(t: id);
222 }
223
224 QVector<Qt3DCore::QNodeId> shaderIdsToCleanup() const
225 {
226 return m_shaderIdsToCleanup;
227 }
228
229 // Called by RenderThread in updateGLResources (locked)
230 QVector<Qt3DCore::QNodeId> takeShaderIdsToCleanup()
231 {
232 return std::move(m_shaderIdsToCleanup);
233 }
234
235private:
236 QVector<Qt3DCore::QNodeId> m_shaderIdsToCleanup;
237};
238
239class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilderManager : public Qt3DCore::QResourceManager<
240 ShaderBuilder,
241 Qt3DCore::QNodeId,
242 Qt3DCore::NonLockingPolicy>
243{
244public:
245 ShaderBuilderManager() {}
246};
247
248class Q_3DRENDERSHARED_PRIVATE_EXPORT TextureManager : public Qt3DCore::QResourceManager<
249 Texture,
250 Qt3DCore::QNodeId,
251 Qt3DCore::NonLockingPolicy>
252{
253public:
254 TextureManager() {}
255
256 // Called in AspectThread by Texture node functor destroy
257 void addTextureIdToCleanup(Qt3DCore::QNodeId id)
258 {
259 m_textureIdsToCleanup.push_back(t: id);
260 }
261
262 // Called in AspectThread by Texture node functor create
263 void removeTextureIdToCleanup(Qt3DCore::QNodeId id)
264 {
265 m_textureIdsToCleanup.removeAll(t: id);
266 }
267
268 // Called by RenderThread in updateGLResources (locked)
269 QVector<Qt3DCore::QNodeId> takeTexturesIdsToCleanup()
270 {
271 return std::move(m_textureIdsToCleanup);
272 }
273
274#ifdef QT_BUILD_INTERNAL
275 // For unit testing purposes only
276 QVector<Qt3DCore::QNodeId> textureIdsToCleanup() const
277 {
278 return m_textureIdsToCleanup;
279 }
280
281#endif
282
283private:
284 QVector<Qt3DCore::QNodeId> m_textureIdsToCleanup;
285};
286
287class Q_3DRENDERSHARED_PRIVATE_EXPORT TransformManager : public Qt3DCore::QResourceManager<
288 Transform,
289 Qt3DCore::QNodeId,
290 Qt3DCore::NonLockingPolicy>
291{
292public:
293 TransformManager() {}
294};
295
296class Q_3DRENDERSHARED_PRIVATE_EXPORT RenderTargetManager : public Qt3DCore::QResourceManager<
297 RenderTarget,
298 Qt3DCore::QNodeId,
299 Qt3DCore::NonLockingPolicy>
300{
301public:
302 RenderTargetManager() {}
303
304 // Called in AspectThread by RenderTarget node functor destroy
305 void addRenderTargetIdToCleanup(Qt3DCore::QNodeId id)
306 {
307 m_renderTargetIdsToCleanup.push_back(t: id);
308 }
309
310 // Called in AspectThread by RenderTarget node functor create
311 void removeRenderTargetToCleanup(Qt3DCore::QNodeId id)
312 {
313 m_renderTargetIdsToCleanup.removeAll(t: id);
314 }
315
316 // Called by RenderThread in updateGLResources (locked)
317 QVector<Qt3DCore::QNodeId> takeRenderTargetIdsToCleanup()
318 {
319 return std::move(m_renderTargetIdsToCleanup);
320 }
321
322#ifdef QT_BUILD_INTERNAL
323 // For unit testing purposes only
324 QVector<Qt3DCore::QNodeId> renderTargetIdsToCleanup() const
325 {
326 return m_renderTargetIdsToCleanup;
327 }
328#endif
329
330private:
331 QVector<Qt3DCore::QNodeId> m_renderTargetIdsToCleanup;
332};
333
334class Q_3DRENDERSHARED_PRIVATE_EXPORT RenderPassManager : public Qt3DCore::QResourceManager<
335 RenderPass,
336 Qt3DCore::QNodeId,
337 Qt3DCore::NonLockingPolicy>
338{
339public:
340 RenderPassManager() {}
341};
342
343
344class Q_3DRENDERSHARED_PRIVATE_EXPORT ParameterManager : public Qt3DCore::QResourceManager<
345 Parameter,
346 Qt3DCore::QNodeId,
347 Qt3DCore::NonLockingPolicy>
348{
349public:
350 ParameterManager() {}
351};
352
353class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderImageManager : public Qt3DCore::QResourceManager<
354 ShaderImage,
355 Qt3DCore::QNodeId,
356 Qt3DCore::NonLockingPolicy>
357{
358public:
359 ShaderImageManager() {}
360};
361
362class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderDataManager : public Qt3DCore::QResourceManager<
363 ShaderData,
364 Qt3DCore::QNodeId,
365 Qt3DCore::NonLockingPolicy>
366{
367public:
368 ShaderDataManager() {}
369};
370
371class Q_3DRENDERSHARED_PRIVATE_EXPORT TextureImageManager : public Qt3DCore::QResourceManager<
372 TextureImage,
373 Qt3DCore::QNodeId,
374 Qt3DCore::NonLockingPolicy>
375{
376};
377
378class Q_3DRENDERSHARED_PRIVATE_EXPORT AttributeManager : public Qt3DCore::QResourceManager<
379 Attribute,
380 Qt3DCore::QNodeId,
381 Qt3DCore::NonLockingPolicy>
382{
383};
384
385class Q_3DRENDERSHARED_PRIVATE_EXPORT GeometryManager : public Qt3DCore::QResourceManager<
386 Geometry,
387 Qt3DCore::QNodeId,
388 Qt3DCore::NonLockingPolicy>
389{
390};
391
392class Q_3DRENDERSHARED_PRIVATE_EXPORT ObjectPickerManager : public Qt3DCore::QResourceManager<
393 ObjectPicker,
394 Qt3DCore::QNodeId,
395 Qt3DCore::NonLockingPolicy>
396{
397};
398
399class Q_3DRENDERSHARED_PRIVATE_EXPORT RayCasterManager : public Qt3DCore::QResourceManager<
400 RayCaster,
401 Qt3DCore::QNodeId,
402 Qt3DCore::NonLockingPolicy>
403{
404};
405
406#if 0
407class BoundingVolumeDebugManager : public Qt3DCore::QResourceManager<
408 BoundingVolumeDebug,
409 Qt3DCore::QNodeId,
410 Qt3DCore::ObjectLevelLockingPolicy>
411{
412};
413#endif
414
415class Q_3DRENDERSHARED_PRIVATE_EXPORT LightManager : public Qt3DCore::QResourceManager<
416 Light,
417 Qt3DCore::QNodeId,
418 Qt3DCore::NonLockingPolicy>
419{
420public:
421 LightManager() {}
422};
423
424class Q_3DRENDERSHARED_PRIVATE_EXPORT EnvironmentLightManager : public Qt3DCore::QResourceManager<
425 EnvironmentLight,
426 Qt3DCore::QNodeId,
427 Qt3DCore::NonLockingPolicy>
428{
429public:
430 EnvironmentLightManager() {}
431};
432
433class Q_3DRENDERSHARED_PRIVATE_EXPORT ComputeCommandManager : public Qt3DCore::QResourceManager<
434 ComputeCommand,
435 Qt3DCore::QNodeId,
436 Qt3DCore::NonLockingPolicy>
437{
438public:
439 ComputeCommandManager() {}
440};
441
442class Q_3DRENDERSHARED_PRIVATE_EXPORT RenderStateManager : public Qt3DCore::QResourceManager<
443 RenderStateNode,
444 Qt3DCore::QNodeId,
445 Qt3DCore::NonLockingPolicy>
446{
447};
448
449class Q_3DRENDERSHARED_PRIVATE_EXPORT ArmatureManager : public Qt3DCore::QResourceManager<
450 Armature,
451 Qt3DCore::QNodeId,
452 Qt3DCore::NonLockingPolicy>
453{
454};
455
456class Q_3DRENDERSHARED_PRIVATE_EXPORT SkeletonManager : public Qt3DCore::QResourceManager<
457 Skeleton,
458 Qt3DCore::QNodeId,
459 Qt3DCore::NonLockingPolicy>
460{
461public:
462 enum DirtyFlag {
463 SkeletonDataDirty,
464 SkeletonTransformsDirty
465 };
466
467 void addDirtySkeleton(DirtyFlag dirtyFlag, HSkeleton skeletonHandle);
468 QVector<HSkeleton> takeDirtySkeletons(DirtyFlag dirtyFlag);
469
470private:
471 QVector<HSkeleton> m_dirtyDataSkeletons;
472 QVector<HSkeleton> m_dirtyTransformSkeletons;
473};
474
475class Q_3DRENDERSHARED_PRIVATE_EXPORT JointManager : public Qt3DCore::QResourceManager<
476 Joint,
477 Qt3DCore::QNodeId,
478 Qt3DCore::NonLockingPolicy>
479{
480public:
481 void addDirtyJoint(Qt3DCore::QNodeId jointId);
482 void removeDirtyJoint(Qt3DCore::QNodeId jointId);
483 QVector<HJoint> dirtyJoints();
484
485private:
486 QVector<HJoint> m_dirtyJoints;
487};
488
489} // namespace Render
490} // namespace Qt3DRender
491
492Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::FilterKey, Q_REQUIRES_CLEANUP)
493Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Effect, Q_REQUIRES_CLEANUP)
494Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Entity, Q_REQUIRES_CLEANUP)
495Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Layer, Q_REQUIRES_CLEANUP)
496Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Material, Q_REQUIRES_CLEANUP)
497Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Shader, Q_REQUIRES_CLEANUP)
498Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::RenderTarget, Q_REQUIRES_CLEANUP)
499Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Texture, Q_REQUIRES_CLEANUP)
500Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::RenderPass, Q_REQUIRES_CLEANUP)
501Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::TextureImage, Q_REQUIRES_CLEANUP)
502Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Attribute, Q_REQUIRES_CLEANUP)
503Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Geometry, Q_REQUIRES_CLEANUP)
504Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ObjectPicker, Q_REQUIRES_CLEANUP)
505Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::RayCaster, Q_REQUIRES_CLEANUP)
506Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::BoundingVolumeDebug, Q_REQUIRES_CLEANUP)
507Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ComputeCommand, Q_REQUIRES_CLEANUP)
508Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Parameter, Q_REQUIRES_CLEANUP)
509Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Transform, Q_REQUIRES_CLEANUP)
510Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Armature, Q_REQUIRES_CLEANUP)
511Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Skeleton, Q_REQUIRES_CLEANUP)
512Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Joint, Q_REQUIRES_CLEANUP)
513Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ShaderBuilder, Q_REQUIRES_CLEANUP)
514Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ShaderImage, Q_REQUIRES_CLEANUP)
515
516QT_END_NAMESPACE
517
518
519#endif // QT3DRENDER_RENDER_MANAGERS_P_H
520

source code of qt3d/src/render/backend/managers_p.h