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 | |
88 | QT_BEGIN_NAMESPACE |
89 | |
90 | namespace Qt3DRender { |
91 | |
92 | namespace Render { |
93 | |
94 | class Q_3DRENDERSHARED_PRIVATE_EXPORT AttachmentManager : public Qt3DCore::QResourceManager< |
95 | RenderTargetOutput, |
96 | Qt3DCore::QNodeId, |
97 | Qt3DCore::NonLockingPolicy> |
98 | { |
99 | public: |
100 | AttachmentManager() {} |
101 | }; |
102 | |
103 | class Q_3DRENDERSHARED_PRIVATE_EXPORT CameraManager : public Qt3DCore::QResourceManager< |
104 | CameraLens, |
105 | Qt3DCore::QNodeId, |
106 | Qt3DCore::NonLockingPolicy> |
107 | { |
108 | public: |
109 | CameraManager() {} |
110 | }; |
111 | |
112 | class Q_3DRENDERSHARED_PRIVATE_EXPORT FilterKeyManager : public Qt3DCore::QResourceManager< |
113 | FilterKey, |
114 | Qt3DCore::QNodeId, |
115 | Qt3DCore::NonLockingPolicy> |
116 | |
117 | { |
118 | public: |
119 | FilterKeyManager() {} |
120 | }; |
121 | |
122 | class Q_3DRENDERSHARED_PRIVATE_EXPORT EffectManager : public Qt3DCore::QResourceManager< |
123 | Effect, |
124 | Qt3DCore::QNodeId, |
125 | Qt3DCore::NonLockingPolicy> |
126 | { |
127 | public: |
128 | EffectManager() {} |
129 | }; |
130 | |
131 | class Q_3DRENDERSHARED_PRIVATE_EXPORT EntityManager : public Qt3DCore::QResourceManager< |
132 | Entity, |
133 | Qt3DCore::QNodeId, |
134 | Qt3DCore::NonLockingPolicy> |
135 | { |
136 | public: |
137 | EntityManager() {} |
138 | ~EntityManager() |
139 | { |
140 | Allocator::for_each(f: [](Entity *e) { |
141 | if (e) |
142 | e->setNodeManagers(nullptr); |
143 | }); |
144 | } |
145 | }; |
146 | |
147 | class FrameGraphNode; |
148 | |
149 | class Q_3DRENDERSHARED_PRIVATE_EXPORT FrameGraphManager |
150 | { |
151 | public: |
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 | |
160 | private: |
161 | QHash<Qt3DCore::QNodeId, FrameGraphNode*> m_nodes; |
162 | }; |
163 | |
164 | class Q_3DRENDERSHARED_PRIVATE_EXPORT LayerManager : public Qt3DCore::QResourceManager< |
165 | Layer, |
166 | Qt3DCore::QNodeId, |
167 | Qt3DCore::NonLockingPolicy> |
168 | { |
169 | public: |
170 | LayerManager() {} |
171 | }; |
172 | |
173 | class Q_3DRENDERSHARED_PRIVATE_EXPORT LevelOfDetailManager : public Qt3DCore::QResourceManager< |
174 | LevelOfDetail, |
175 | Qt3DCore::QNodeId, |
176 | Qt3DCore::NonLockingPolicy> |
177 | { |
178 | public: |
179 | LevelOfDetailManager() {} |
180 | }; |
181 | |
182 | class Q_3DRENDERSHARED_PRIVATE_EXPORT MaterialManager : public Qt3DCore::QResourceManager< |
183 | Material, |
184 | Qt3DCore::QNodeId, |
185 | Qt3DCore::NonLockingPolicy> |
186 | { |
187 | public: |
188 | MaterialManager() {} |
189 | }; |
190 | |
191 | class Q_3DRENDERSHARED_PRIVATE_EXPORT MatrixManager : public Qt3DCore::QResourceManager< |
192 | Matrix4x4, |
193 | Qt3DCore::QNodeId, |
194 | Qt3DCore::NonLockingPolicy> |
195 | { |
196 | public: |
197 | MatrixManager() {} |
198 | }; |
199 | |
200 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderManager : public Qt3DCore::QResourceManager< |
201 | Shader, |
202 | Qt3DCore::QNodeId, |
203 | Qt3DCore::ObjectLevelLockingPolicy> |
204 | { |
205 | public: |
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 | |
235 | private: |
236 | QVector<Qt3DCore::QNodeId> m_shaderIdsToCleanup; |
237 | }; |
238 | |
239 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderBuilderManager : public Qt3DCore::QResourceManager< |
240 | ShaderBuilder, |
241 | Qt3DCore::QNodeId, |
242 | Qt3DCore::NonLockingPolicy> |
243 | { |
244 | public: |
245 | ShaderBuilderManager() {} |
246 | }; |
247 | |
248 | class Q_3DRENDERSHARED_PRIVATE_EXPORT TextureManager : public Qt3DCore::QResourceManager< |
249 | Texture, |
250 | Qt3DCore::QNodeId, |
251 | Qt3DCore::NonLockingPolicy> |
252 | { |
253 | public: |
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 | |
283 | private: |
284 | QVector<Qt3DCore::QNodeId> m_textureIdsToCleanup; |
285 | }; |
286 | |
287 | class Q_3DRENDERSHARED_PRIVATE_EXPORT TransformManager : public Qt3DCore::QResourceManager< |
288 | Transform, |
289 | Qt3DCore::QNodeId, |
290 | Qt3DCore::NonLockingPolicy> |
291 | { |
292 | public: |
293 | TransformManager() {} |
294 | }; |
295 | |
296 | class Q_3DRENDERSHARED_PRIVATE_EXPORT RenderTargetManager : public Qt3DCore::QResourceManager< |
297 | RenderTarget, |
298 | Qt3DCore::QNodeId, |
299 | Qt3DCore::NonLockingPolicy> |
300 | { |
301 | public: |
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 | |
330 | private: |
331 | QVector<Qt3DCore::QNodeId> m_renderTargetIdsToCleanup; |
332 | }; |
333 | |
334 | class Q_3DRENDERSHARED_PRIVATE_EXPORT RenderPassManager : public Qt3DCore::QResourceManager< |
335 | RenderPass, |
336 | Qt3DCore::QNodeId, |
337 | Qt3DCore::NonLockingPolicy> |
338 | { |
339 | public: |
340 | RenderPassManager() {} |
341 | }; |
342 | |
343 | |
344 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ParameterManager : public Qt3DCore::QResourceManager< |
345 | Parameter, |
346 | Qt3DCore::QNodeId, |
347 | Qt3DCore::NonLockingPolicy> |
348 | { |
349 | public: |
350 | ParameterManager() {} |
351 | }; |
352 | |
353 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderImageManager : public Qt3DCore::QResourceManager< |
354 | ShaderImage, |
355 | Qt3DCore::QNodeId, |
356 | Qt3DCore::NonLockingPolicy> |
357 | { |
358 | public: |
359 | ShaderImageManager() {} |
360 | }; |
361 | |
362 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ShaderDataManager : public Qt3DCore::QResourceManager< |
363 | ShaderData, |
364 | Qt3DCore::QNodeId, |
365 | Qt3DCore::NonLockingPolicy> |
366 | { |
367 | public: |
368 | ShaderDataManager() {} |
369 | }; |
370 | |
371 | class Q_3DRENDERSHARED_PRIVATE_EXPORT TextureImageManager : public Qt3DCore::QResourceManager< |
372 | TextureImage, |
373 | Qt3DCore::QNodeId, |
374 | Qt3DCore::NonLockingPolicy> |
375 | { |
376 | }; |
377 | |
378 | class Q_3DRENDERSHARED_PRIVATE_EXPORT AttributeManager : public Qt3DCore::QResourceManager< |
379 | Attribute, |
380 | Qt3DCore::QNodeId, |
381 | Qt3DCore::NonLockingPolicy> |
382 | { |
383 | }; |
384 | |
385 | class Q_3DRENDERSHARED_PRIVATE_EXPORT GeometryManager : public Qt3DCore::QResourceManager< |
386 | Geometry, |
387 | Qt3DCore::QNodeId, |
388 | Qt3DCore::NonLockingPolicy> |
389 | { |
390 | }; |
391 | |
392 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ObjectPickerManager : public Qt3DCore::QResourceManager< |
393 | ObjectPicker, |
394 | Qt3DCore::QNodeId, |
395 | Qt3DCore::NonLockingPolicy> |
396 | { |
397 | }; |
398 | |
399 | class Q_3DRENDERSHARED_PRIVATE_EXPORT RayCasterManager : public Qt3DCore::QResourceManager< |
400 | RayCaster, |
401 | Qt3DCore::QNodeId, |
402 | Qt3DCore::NonLockingPolicy> |
403 | { |
404 | }; |
405 | |
406 | #if 0 |
407 | class BoundingVolumeDebugManager : public Qt3DCore::QResourceManager< |
408 | BoundingVolumeDebug, |
409 | Qt3DCore::QNodeId, |
410 | Qt3DCore::ObjectLevelLockingPolicy> |
411 | { |
412 | }; |
413 | #endif |
414 | |
415 | class Q_3DRENDERSHARED_PRIVATE_EXPORT LightManager : public Qt3DCore::QResourceManager< |
416 | Light, |
417 | Qt3DCore::QNodeId, |
418 | Qt3DCore::NonLockingPolicy> |
419 | { |
420 | public: |
421 | LightManager() {} |
422 | }; |
423 | |
424 | class Q_3DRENDERSHARED_PRIVATE_EXPORT EnvironmentLightManager : public Qt3DCore::QResourceManager< |
425 | EnvironmentLight, |
426 | Qt3DCore::QNodeId, |
427 | Qt3DCore::NonLockingPolicy> |
428 | { |
429 | public: |
430 | EnvironmentLightManager() {} |
431 | }; |
432 | |
433 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ComputeCommandManager : public Qt3DCore::QResourceManager< |
434 | ComputeCommand, |
435 | Qt3DCore::QNodeId, |
436 | Qt3DCore::NonLockingPolicy> |
437 | { |
438 | public: |
439 | ComputeCommandManager() {} |
440 | }; |
441 | |
442 | class Q_3DRENDERSHARED_PRIVATE_EXPORT RenderStateManager : public Qt3DCore::QResourceManager< |
443 | RenderStateNode, |
444 | Qt3DCore::QNodeId, |
445 | Qt3DCore::NonLockingPolicy> |
446 | { |
447 | }; |
448 | |
449 | class Q_3DRENDERSHARED_PRIVATE_EXPORT ArmatureManager : public Qt3DCore::QResourceManager< |
450 | Armature, |
451 | Qt3DCore::QNodeId, |
452 | Qt3DCore::NonLockingPolicy> |
453 | { |
454 | }; |
455 | |
456 | class Q_3DRENDERSHARED_PRIVATE_EXPORT SkeletonManager : public Qt3DCore::QResourceManager< |
457 | Skeleton, |
458 | Qt3DCore::QNodeId, |
459 | Qt3DCore::NonLockingPolicy> |
460 | { |
461 | public: |
462 | enum DirtyFlag { |
463 | SkeletonDataDirty, |
464 | SkeletonTransformsDirty |
465 | }; |
466 | |
467 | void addDirtySkeleton(DirtyFlag dirtyFlag, HSkeleton skeletonHandle); |
468 | QVector<HSkeleton> takeDirtySkeletons(DirtyFlag dirtyFlag); |
469 | |
470 | private: |
471 | QVector<HSkeleton> m_dirtyDataSkeletons; |
472 | QVector<HSkeleton> m_dirtyTransformSkeletons; |
473 | }; |
474 | |
475 | class Q_3DRENDERSHARED_PRIVATE_EXPORT JointManager : public Qt3DCore::QResourceManager< |
476 | Joint, |
477 | Qt3DCore::QNodeId, |
478 | Qt3DCore::NonLockingPolicy> |
479 | { |
480 | public: |
481 | void addDirtyJoint(Qt3DCore::QNodeId jointId); |
482 | void removeDirtyJoint(Qt3DCore::QNodeId jointId); |
483 | QVector<HJoint> dirtyJoints(); |
484 | |
485 | private: |
486 | QVector<HJoint> m_dirtyJoints; |
487 | }; |
488 | |
489 | } // namespace Render |
490 | } // namespace Qt3DRender |
491 | |
492 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::FilterKey, Q_REQUIRES_CLEANUP) |
493 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Effect, Q_REQUIRES_CLEANUP) |
494 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Entity, Q_REQUIRES_CLEANUP) |
495 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Layer, Q_REQUIRES_CLEANUP) |
496 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Material, Q_REQUIRES_CLEANUP) |
497 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Shader, Q_REQUIRES_CLEANUP) |
498 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::RenderTarget, Q_REQUIRES_CLEANUP) |
499 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Texture, Q_REQUIRES_CLEANUP) |
500 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::RenderPass, Q_REQUIRES_CLEANUP) |
501 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::TextureImage, Q_REQUIRES_CLEANUP) |
502 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Attribute, Q_REQUIRES_CLEANUP) |
503 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Geometry, Q_REQUIRES_CLEANUP) |
504 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ObjectPicker, Q_REQUIRES_CLEANUP) |
505 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::RayCaster, Q_REQUIRES_CLEANUP) |
506 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::BoundingVolumeDebug, Q_REQUIRES_CLEANUP) |
507 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ComputeCommand, Q_REQUIRES_CLEANUP) |
508 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Parameter, Q_REQUIRES_CLEANUP) |
509 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Transform, Q_REQUIRES_CLEANUP) |
510 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Armature, Q_REQUIRES_CLEANUP) |
511 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Skeleton, Q_REQUIRES_CLEANUP) |
512 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Joint, Q_REQUIRES_CLEANUP) |
513 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ShaderBuilder, Q_REQUIRES_CLEANUP) |
514 | Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::ShaderImage, Q_REQUIRES_CLEANUP) |
515 | |
516 | QT_END_NAMESPACE |
517 | |
518 | |
519 | #endif // QT3DRENDER_RENDER_MANAGERS_P_H |
520 | |