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