1 | // Copyright (C) 2008-2012 NVIDIA Corporation. |
2 | // Copyright (C) 2019 The Qt Company Ltd. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
4 | |
5 | #ifndef QSSG_RENDER_DYNAMIC_OBJECT_SYSTEM_H |
6 | #define QSSG_RENDER_DYNAMIC_OBJECT_SYSTEM_H |
7 | |
8 | // |
9 | // W A R N I N G |
10 | // ------------- |
11 | // |
12 | // This file is not part of the Qt API. It exists purely as an |
13 | // implementation detail. This header file may change from version to |
14 | // version without notice, or even be removed. |
15 | // |
16 | // We mean it. |
17 | // |
18 | |
19 | #include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h> |
20 | #include <QtQuick3DUtils/private/qqsbcollection_p.h> |
21 | |
22 | #include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h> |
23 | #include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h> |
24 | #include <QtQuick3DRuntimeRender/private/qssgrendershaderkeys_p.h> |
25 | |
26 | #include <QtGui/QVector2D> |
27 | |
28 | #include <QtCore/QString> |
29 | #include <QtCore/QReadWriteLock> |
30 | |
31 | QT_BEGIN_NAMESPACE |
32 | |
33 | class QSSGRenderContextInterface; |
34 | |
35 | struct QSSGCustomShaderMetaData |
36 | { |
37 | enum Flag { |
38 | UsesScreenTexture = 1 << 0, |
39 | UsesDepthTexture = 1 << 1, |
40 | UsesAoTexture = 1 << 2, |
41 | OverridesPosition = 1 << 3, |
42 | UsesProjectionMatrix = 1 << 4, |
43 | UsesInverseProjectionMatrix = 1 << 5, |
44 | UsesScreenMipTexture = 1 << 6, |
45 | UsesVarColor = 1 << 7, |
46 | UsesSharedVars = 1 << 8, |
47 | UsesIblOrientation = 1 << 9, |
48 | UsesLightmap = 1 << 10, |
49 | UsesSkinning = 1 << 11, |
50 | UsesMorphing = 1 << 12 |
51 | }; |
52 | Q_DECLARE_FLAGS(Flags, Flag) |
53 | |
54 | Flags flags; |
55 | QSet<QByteArray> customFunctions; |
56 | QSSGShaderFeatures features; |
57 | }; |
58 | |
59 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGCustomShaderMetaData::Flags) |
60 | |
61 | class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGShaderLibraryManager |
62 | { |
63 | Q_DISABLE_COPY(QSSGShaderLibraryManager) |
64 | public: |
65 | typedef QHash<QByteArray, QByteArray> TPathDataMap; |
66 | typedef QSet<QString> TPathSet; |
67 | |
68 | TPathDataMap m_expandedFiles; |
69 | QHash<QByteArray, QSSGCustomShaderMetaData> m_metadata; |
70 | QByteArray m_vertShader; |
71 | QByteArray m_fragShader; |
72 | |
73 | QQsbCollection::EntryMap m_preGeneratedShaderEntries; |
74 | |
75 | QReadWriteLock m_lock; |
76 | |
77 | static QString getShaderCodeLibraryDirectory(); |
78 | |
79 | explicit QSSGShaderLibraryManager(); |
80 | |
81 | ~QSSGShaderLibraryManager(); |
82 | |
83 | void setShaderSource(const QByteArray &inShaderPathKey, QSSGShaderCache::ShaderType type, |
84 | const QByteArray &inSource, const QSSGCustomShaderMetaData &meta); |
85 | |
86 | // Does not load any shaders, only information about the content of the pregenerated shaders |
87 | void loadPregeneratedShaderInfo(); |
88 | |
89 | void resolveIncludeFiles(QByteArray &theReadBuffer, const QByteArray &inMaterialInfoString); |
90 | QByteArray getIncludeContents(const QByteArray &inShaderPathKey); |
91 | |
92 | QByteArray getShaderSource(const QByteArray &inShaderPathKey, QSSGShaderCache::ShaderType type); |
93 | QSSGCustomShaderMetaData getShaderMetaData(const QByteArray &inShaderPathKey, QSSGShaderCache::ShaderType type); |
94 | |
95 | void setShaderCodeLibraryVersion(const QByteArray &version); |
96 | |
97 | static bool compare(const QSSGShaderDefaultMaterialKey &key1, const QSSGShaderDefaultMaterialKey &key2); |
98 | }; |
99 | |
100 | QT_END_NAMESPACE |
101 | |
102 | #endif |
103 | |