1// Copyright (C) 2015 Paul Lemire
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_BUFFERMANAGER_H
5#define QT3DRENDER_RENDER_BUFFERMANAGER_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 <Qt3DRender/private/buffer_p.h>
20
21QT_BEGIN_NAMESPACE
22
23namespace Qt3DRender {
24
25namespace Render {
26
27class Q_3DRENDERSHARED_PRIVATE_EXPORT BufferManager : public Qt3DCore::QResourceManager<
28 Buffer,
29 Qt3DCore::QNodeId,
30 Qt3DCore::ObjectLevelLockingPolicy>
31{
32public:
33 BufferManager();
34 ~BufferManager();
35
36 // Aspect Thread
37 void addDirtyBuffer(Qt3DCore::QNodeId bufferId);
38 QList<Qt3DCore::QNodeId> takeDirtyBuffers();
39
40 // Aspect Thread
41 void addBufferReference(Qt3DCore::QNodeId bufferId);
42 void removeBufferReference(Qt3DCore::QNodeId bufferId);
43
44 // Render Thread (no concurrent access)
45 QList<Qt3DCore::QNodeId> takeBuffersToRelease();
46
47private:
48 QList<Qt3DCore::QNodeId> m_dirtyBuffers;
49 QHash<Qt3DCore::QNodeId, int> m_bufferReferences;
50 QMutex m_mutex;
51};
52
53} // namespace Render
54} // namespace Qt3DRender
55
56Q_DECLARE_RESOURCE_INFO(Qt3DRender::Render::Buffer, Q_REQUIRES_CLEANUP)
57
58QT_END_NAMESPACE
59
60
61#endif // QT3DRENDER_RENDER_BUFFERMANAGER_H
62

source code of qt3d/src/render/geometry/buffermanager_p.h