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

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/gui/rhi/qshader_p.h