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

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