Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qshaderdescription.h
Go to the documentation of this file.
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 QSHADERDESCRIPTION_H
5#define QSHADERDESCRIPTION_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is part of the RHI API, with limited compatibility guarantees.
12// Usage of this API may make your code source and binary incompatible with
13// future versions of Qt.
14//
15
16#include <QtGui/qtguiglobal.h>
17#include <QtCore/qstring.h>
18#include <QtCore/qlist.h>
19#include <array>
20
22
24class QDataStream;
25
26class Q_GUI_EXPORT QShaderDescription
27{
28public:
33 void detach();
34
35 bool isValid() const;
36
37 void serialize(QDataStream *stream, int version) const;
38 QByteArray toJson() const;
39
40 static QShaderDescription deserialize(QDataStream *stream, int version);
41
124
168
170 ReadOnlyImage = 1 << 0,
171 WriteOnlyImage = 1 << 1
172 };
173 Q_DECLARE_FLAGS(ImageFlags, ImageFlag)
174
176 QualifierReadOnly = 1 << 0,
177 QualifierWriteOnly = 1 << 1,
178 QualifierCoherent = 1 << 2,
179 QualifierVolatile = 1 << 3,
180 QualifierRestrict = 1 << 4,
181 };
182 Q_DECLARE_FLAGS(QualifierFlags, QualifierFlag)
183
184 // Optional data (like decorations) usually default to an otherwise invalid value (-1 or 0). This is intentional.
185
189 int offset = 0;
190 int size = 0;
191 QList<int> arrayDims;
192 int arrayStride = 0;
193 int matrixStride = 0;
194 bool matrixIsRowMajor = false;
195 QList<BlockVariable> structMembers;
196 };
197
201 int location = -1;
202 int binding = -1;
203 int descriptorSet = -1;
205 ImageFlags imageFlags;
206 QList<int> arrayDims;
207 bool perPatch = false;
208 QList<BlockVariable> structMembers;
209 };
210
213 QByteArray structName; // instanceName
214 int size = 0;
215 int binding = -1;
216 int descriptorSet = -1;
217 QList<BlockVariable> members;
218 };
219
222 int size = 0;
223 QList<BlockVariable> members;
224 };
225
229 int knownSize = 0;
230 int binding = -1;
231 int descriptorSet = -1;
232 QList<BlockVariable> members;
233 int runtimeArrayStride = 0;
234 QualifierFlags qualifierFlags;
235 };
236
237 QList<InOutVariable> inputVariables() const;
238 QList<InOutVariable> outputVariables() const;
239 QList<UniformBlock> uniformBlocks() const;
240 QList<PushConstantBlock> pushConstantBlocks() const;
241 QList<StorageBlock> storageBlocks() const;
242 QList<InOutVariable> combinedImageSamplers() const;
243 QList<InOutVariable> separateImages() const;
244 QList<InOutVariable> separateSamplers() const;
245 QList<InOutVariable> storageImages() const;
246
248 // must match SpvBuiltIn
249 PositionBuiltin = 0,
250 PointSizeBuiltin = 1,
251 ClipDistanceBuiltin = 3,
252 CullDistanceBuiltin = 4,
253 VertexIdBuiltin = 5,
254 InstanceIdBuiltin = 6,
255 PrimitiveIdBuiltin = 7,
256 InvocationIdBuiltin = 8,
257 LayerBuiltin = 9,
258 ViewportIndexBuiltin = 10,
259 TessLevelOuterBuiltin = 11,
260 TessLevelInnerBuiltin = 12,
261 TessCoordBuiltin = 13,
262 PatchVerticesBuiltin = 14,
263 FragCoordBuiltin = 15,
264 PointCoordBuiltin = 16,
265 FrontFacingBuiltin = 17,
266 SampleIdBuiltin = 18,
267 SamplePositionBuiltin = 19,
268 SampleMaskBuiltin = 20,
269 FragDepthBuiltin = 22,
270 NumWorkGroupsBuiltin = 24,
271 WorkgroupSizeBuiltin = 25,
272 WorkgroupIdBuiltin = 26,
273 LocalInvocationIdBuiltin = 27,
274 GlobalInvocationIdBuiltin = 28,
275 LocalInvocationIndexBuiltin = 29,
276 VertexIndexBuiltin = 42,
277 InstanceIndexBuiltin = 43
278 };
279
285
286 QList<BuiltinVariable> inputBuiltinVariables() const;
287 QList<BuiltinVariable> outputBuiltinVariables() const;
288
289 std::array<uint, 3> computeShaderLocalSize() const;
290
291 uint tessellationOutputVertexCount() const;
292
299
300 TessellationMode tessellationMode() const;
301
307
308 TessellationWindingOrder tessellationWindingOrder() const;
309
316
317 TessellationPartitioning tessellationPartitioning() const;
318
319private:
322#ifndef QT_NO_DEBUG_STREAM
323 friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription &);
324#endif
325 friend Q_GUI_EXPORT bool operator==(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept;
326};
327
328Q_DECLARE_OPERATORS_FOR_FLAGS(QShaderDescription::ImageFlags)
329Q_DECLARE_OPERATORS_FOR_FLAGS(QShaderDescription::QualifierFlags)
330
331#ifndef QT_NO_DEBUG_STREAM
332Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription &);
339#endif
340
341Q_GUI_EXPORT bool operator==(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept;
342Q_GUI_EXPORT bool operator==(const QShaderDescription::InOutVariable &lhs, const QShaderDescription::InOutVariable &rhs) noexcept;
343Q_GUI_EXPORT bool operator==(const QShaderDescription::BlockVariable &lhs, const QShaderDescription::BlockVariable &rhs) noexcept;
344Q_GUI_EXPORT bool operator==(const QShaderDescription::UniformBlock &lhs, const QShaderDescription::UniformBlock &rhs) noexcept;
346Q_GUI_EXPORT bool operator==(const QShaderDescription::StorageBlock &lhs, const QShaderDescription::StorageBlock &rhs) noexcept;
348
349inline bool operator!=(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept
350{
351 return !(lhs == rhs);
352}
353
355{
356 return !(lhs == rhs);
357}
358
360{
361 return !(lhs == rhs);
362}
363
365{
366 return !(lhs == rhs);
367}
368
370{
371 return !(lhs == rhs);
372}
373
375{
376 return !(lhs == rhs);
377}
378
380{
381 return !(lhs == rhs);
382}
383
385
386#endif
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
TessellationWindingOrder
\value UnknownTessellationWindingOrder \value CwTessellationWindingOrder \value CcwTessellationWindin...
VariableType
Represents the type of a variable or block member.
BuiltinType
\variable QShaderDescription::BuiltinVariable::type
TessellationMode
\value UnknownTessellationMode \value TrianglesTessellationMode \value QuadTessellationMode \value Is...
TessellationPartitioning
\value UnknownTessellationPartitioning \value EqualTessellationPartitioning \value FractionalEvenTess...
QualifierFlag
Qualifier flags.
Combined button and popup list for selecting options.
EGLStreamKHR stream
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLint location
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum type
GLenum GLuint GLintptr offset
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
static const struct ImageFormatTab ImageFormatRg16Snorm[]
static const struct ImageFormatTab ImageFormatRg32f[]
static const struct ImageFormatTab ImageFormatRg16ui[]
static const struct ImageFormatTab ImageFormatRg8Snorm[]
static const struct ImageFormatTab ImageFormatRgb10A2[]
static const struct ImageFormatTab ImageFormatRg8ui[]
static const struct ImageFormatTab ImageFormatR32i[]
static const struct ImageFormatTab ImageFormatRg16f[]
static const struct ImageFormatTab ImageFormatR16i[]
static const struct ImageFormatTab ImageFormatRgb10a2ui[]
static const struct ImageFormatTab ImageFormatR8[]
static const struct ImageFormatTab ImageFormatRg16i[]
static const struct ImageFormatTab ImageFormatRg32ui[]
static const struct ImageFormatTab ImageFormatRgba32i[]
static const struct ImageFormatTab ImageFormatRgba16Snorm[]
static const struct ImageFormatTab ImageFormatRgba32ui[]
static const struct ImageFormatTab ImageFormatR8Snorm[]
static const struct ImageFormatTab ImageFormatRg16[]
static const struct TessellationModeTab IsolineTessellationMode[]
static const struct ImageFormatTab ImageFormatR32f[]
static const struct ImageFormatTab ImageFormatRgba8[]
static const struct TessellationPartitioningTab FractionalOddTessellationPartitioning[]
static const struct ImageFormatTab ImageFormatRgba16f[]
static const struct ImageFormatTab ImageFormatRgba16ui[]
static const struct ImageFormatTab ImageFormatR8i[]
static const struct ImageFormatTab ImageFormatR16[]
static const struct ImageFormatTab ImageFormatRgba8Snorm[]
static const struct ImageFormatTab ImageFormatR8ui[]
static const struct ImageFormatTab ImageFormatRg8i[]
static const struct ImageFormatTab ImageFormatR16f[]
static const struct ImageFormatTab ImageFormatRg32i[]
static const struct ImageFormatTab ImageFormatR11fG11fB10f[]
static const struct ImageFormatTab ImageFormatRg8[]
static const struct ImageFormatTab ImageFormatR16ui[]
static const struct ImageFormatTab ImageFormatRgba8i[]
static const struct ImageFormatTab ImageFormatR16Snorm[]
static const struct ImageFormatTab ImageFormatRgba16i[]
static const struct ImageFormatTab ImageFormatUnknown[]
static const struct TessellationWindingOrderTab CcwTessellationWindingOrder[]
static const struct ImageFormatTab ImageFormatRgba16[]
static const struct ImageFormatTab ImageFormatRgba8ui[]
static const struct ImageFormatTab ImageFormatRgba32f[]
static const struct ImageFormatTab ImageFormatR32ui[]
bool operator!=(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept
Q_GUI_EXPORT bool operator==(const QShaderDescription &lhs, const QShaderDescription &rhs) noexcept
Q_GUI_EXPORT QDebug operator<<(QDebug, const QShaderDescription &)
unsigned int uint
Definition qtypes.h:34
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QSharedPointer< T > other(t)
[5]
\variable QShaderDescription::InOutVariable::name
\variable QShaderDescription::StorageBlock::blockName
\variable QShaderDescription::UniformBlock::blockName
\variable QShaderDescription::PushConstantBlock::name
\variable QShaderDescription::BlockVariable::name