1 | // Copyright (C) 2023 The Qt Company Ltd. |
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 QSHADER_P_H |
5 | #define QSHADER_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 a number of Qt sources files. This header file may change from |
13 | // version to version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtGui/private/qtguiglobal_p.h> |
19 | #include <rhi/qshader.h> |
20 | #include <QtCore/QAtomicInt> |
21 | #include <QtCore/QMap> |
22 | #include <QtCore/QDebug> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | struct Q_GUI_EXPORT QShaderPrivate |
27 | { |
28 | static const int QSB_VERSION = 9; |
29 | static const int QSB_VERSION_WITHOUT_INPUT_OUTPUT_INTERFACE_BLOCKS = 8; |
30 | static const int QSB_VERSION_WITHOUT_EXTENDED_STORAGE_BUFFER_INFO = 7; |
31 | static const int QSB_VERSION_WITHOUT_NATIVE_SHADER_INFO = 6; |
32 | static const int QSB_VERSION_WITHOUT_SEPARATE_IMAGES_AND_SAMPLERS = 5; |
33 | static const int QSB_VERSION_WITHOUT_VAR_ARRAYDIMS = 4; |
34 | static const int QSB_VERSION_WITH_CBOR = 3; |
35 | static const int QSB_VERSION_WITH_BINARY_JSON = 2; |
36 | static const int QSB_VERSION_WITHOUT_BINDINGS = 1; |
37 | |
38 | enum { |
39 | MslTessVertIndicesBufferBinding = 0, |
40 | MslTessVertTescOutputBufferBinding, |
41 | MslTessTescTessLevelBufferBinding, |
42 | MslTessTescPatchOutputBufferBinding, |
43 | MslTessTescParamsBufferBinding, |
44 | MslTessTescInputBufferBinding, |
45 | MslBufferSizeBufferBinding, |
46 | MslMultiViewMaskBufferBinding |
47 | }; |
48 | |
49 | QShaderPrivate() |
50 | : ref(1) |
51 | { |
52 | } |
53 | |
54 | QShaderPrivate(const QShaderPrivate &other) |
55 | : ref(1), |
56 | qsbVersion(other.qsbVersion), |
57 | stage(other.stage), |
58 | desc(other.desc), |
59 | shaders(other.shaders), |
60 | bindings(other.bindings), |
61 | combinedImageMap(other.combinedImageMap), |
62 | nativeShaderInfoMap(other.nativeShaderInfoMap) |
63 | { |
64 | } |
65 | |
66 | static QShaderPrivate *get(QShader *s) { return s->d; } |
67 | static const QShaderPrivate *get(const QShader *s) { return s->d; } |
68 | static int qtQsbVersion(QShader::SerializedFormatVersion qtVersion) { |
69 | switch (qtVersion) { |
70 | case QShader::SerializedFormatVersion::Qt_6_4: |
71 | return (QShaderPrivate::QSB_VERSION_WITHOUT_SEPARATE_IMAGES_AND_SAMPLERS + 1); |
72 | case QShader::SerializedFormatVersion::Qt_6_5: |
73 | return (QShaderPrivate::QSB_VERSION_WITHOUT_EXTENDED_STORAGE_BUFFER_INFO + 1); |
74 | default: |
75 | return QShaderPrivate::QSB_VERSION; |
76 | } |
77 | } |
78 | |
79 | QAtomicInt ref; |
80 | int qsbVersion = QSB_VERSION; |
81 | QShader::Stage stage = QShader::VertexStage; |
82 | QShaderDescription desc; |
83 | // QMap not QHash because we need to be able to iterate based on sorted keys |
84 | QMap<QShaderKey, QShaderCode> shaders; |
85 | QMap<QShaderKey, QShader::NativeResourceBindingMap> bindings; |
86 | QMap<QShaderKey, QShader::SeparateToCombinedImageSamplerMappingList> combinedImageMap; |
87 | QMap<QShaderKey, QShader::NativeShaderInfo> nativeShaderInfoMap; |
88 | }; |
89 | |
90 | QT_END_NAMESPACE |
91 | |
92 | #endif |
93 | |