Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgrenderbasetypes_p.h
Go to the documentation of this file.
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 QSSGRENDERBASETYPES_P_H
6#define QSSGRENDERBASETYPES_P_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/qtquick3dutilsexports.h>
20
21#include <QtGui/QVector2D>
22#include <QtGui/QVector3D>
23#include <QtGui/QVector4D>
24#include <QtGui/QMatrix4x4>
25#include <QtGui/QMatrix3x3>
26#include <QFloat16>
27
28#include <cmath>
29
30QT_BEGIN_NAMESPACE
31
32enum class QSSGRenderComponentType // stored in mesh files, the values must not change, must match Mesh::ComponentType
33{
34 UnsignedInt8 = 1,
35 Int8,
36 UnsignedInt16,
37 Int16,
38 UnsignedInt32,
39 Int32,
40 UnsignedInt64,
41 Int64,
42 Float16,
43 Float32,
44 Float64
45};
46
47enum class QSSGRenderDrawMode // stored in mesh files, the values must not change, must match Mesh::DrawMode
48{
49 Points = 1,
51 LineLoop, // Not supported
56};
57
58enum class QSSGRenderWinding // stored in mesh files, the values must not change, must match Mesh::Winding
59{
62};
63
64struct Q_QUICK3DUTILS_EXPORT QSSGRenderTextureFormat
65{
66 static constexpr quint8 DepthTextureFlag = 1u << 6;
67 static constexpr quint8 CompressedTextureFlag = 1u << 7;
68
69 enum Format : quint8 {
70 // Non-compressed formats
71 Unknown = 0,
72 R8,
73 R16,
74 R16F,
75 R32I,
76 R32UI,
77 R32F,
78 RG8,
79 RGBA8,
80 RGB8,
81 SRGB8,
82 SRGB8A8,
83 RGB565,
84 RGBA5551,
85 Alpha8,
86 Luminance8,
87 Luminance16,
88 LuminanceAlpha8,
89 RGBA16F,
90 RG16F,
91 RG32F,
92 RGB32F,
93 RGBA32F,
94 R11G11B10,
95 RGB9E5,
96 RGB10_A2,
97 RGB16F,
98 RGBA32UI,
99 RGB32UI,
100 RGBA16UI,
101 RGB16UI,
102 RGBA8UI,
103 RGB8UI,
104 RGBA32I,
105 RGB32I,
106 RGBA16I,
107 RGB16I,
108 RGBA8I,
109 RGB8I,
110 RGBE8,
111
112 // Depth textures
113 Depth16 = DepthTextureFlag + 1,
114 Depth24,
115 Depth32,
116 Depth24Stencil8,
117
118 // Compressed formats
119 RGBA_DXT1 = CompressedTextureFlag + 1,
120 RGB_DXT1,
121 RGBA_DXT3,
122 RGBA_DXT5,
123 R11_EAC_UNorm,
124 R11_EAC_SNorm,
125 RG11_EAC_UNorm,
126 RG11_EAC_SNorm,
127 RGB8_ETC2,
128 SRGB8_ETC2,
129 RGB8_PunchThrough_Alpha1_ETC2,
130 SRGB8_PunchThrough_Alpha1_ETC2,
131 RGBA8_ETC2_EAC,
132 SRGB8_Alpha8_ETC2_EAC,
133 RGBA_ASTC_4x4,
134 RGBA_ASTC_5x4,
135 RGBA_ASTC_5x5,
136 RGBA_ASTC_6x5,
137 RGBA_ASTC_6x6,
138 RGBA_ASTC_8x5,
139 RGBA_ASTC_8x6,
140 RGBA_ASTC_8x8,
141 RGBA_ASTC_10x5,
142 RGBA_ASTC_10x6,
143 RGBA_ASTC_10x8,
144 RGBA_ASTC_10x10,
145 RGBA_ASTC_12x10,
146 RGBA_ASTC_12x12,
147 SRGB8_Alpha8_ASTC_4x4,
148 SRGB8_Alpha8_ASTC_5x4,
149 SRGB8_Alpha8_ASTC_5x5,
150 SRGB8_Alpha8_ASTC_6x5,
151 SRGB8_Alpha8_ASTC_6x6,
152 SRGB8_Alpha8_ASTC_8x5,
153 SRGB8_Alpha8_ASTC_8x6,
154 SRGB8_Alpha8_ASTC_8x8,
155 SRGB8_Alpha8_ASTC_10x5,
156 SRGB8_Alpha8_ASTC_10x6,
157 SRGB8_Alpha8_ASTC_10x8,
158 SRGB8_Alpha8_ASTC_10x10,
159 SRGB8_Alpha8_ASTC_12x10,
160 SRGB8_Alpha8_ASTC_12x12,
161 BC1,
162 BC2,
163 BC3,
164 BC4,
165 BC5,
166 BC6H,
167 BC7,
168 };
169 Format format;
170
171 constexpr QSSGRenderTextureFormat(Format f) : format(f) {}
172
173 [[nodiscard]] constexpr bool isCompressedTextureFormat() const noexcept
174 {
175 return (format & CompressedTextureFlag);
176 }
177
178 [[nodiscard]] constexpr bool isUncompressedTextureFormat() const noexcept
179 {
180 return !isCompressedTextureFormat();
181 }
182
183 [[nodiscard]] bool isDepthTextureFormat() const noexcept
184 {
185 return (format & DepthTextureFlag);
186 }
187
188 [[nodiscard]] const char *toString() const;
189
190 [[nodiscard]] qint32 getSizeofFormat() const noexcept;
191
192 [[nodiscard]] qint32 getNumberOfComponent() const noexcept;
193
194 void decodeToFloat(void *inPtr, qint32 byteOfs, float *outPtr) const;
195 void encodeToPixel(float *inPtr, void *outPtr, qint32 byteOfs) const;
196
197 bool operator==(const QSSGRenderTextureFormat &other) const { return format == other.format; }
198 bool operator!=(const QSSGRenderTextureFormat &other) const { return format != other.format; }
199};
200
207
215
217{
222 FrontAndBack, // Not exposed in the front-end
223};
224
232
233template<typename TDataType>
235{
236 TDataType x;
237 TDataType y;
238 QSSGRenderGenericVec2(TDataType _x, TDataType _y) : x(_x), y(_y) {}
240 bool operator==(const QSSGRenderGenericVec2 &inOther) const { return x == inOther.x && y == inOther.y; }
241};
242
243template<typename TDataType>
245{
246 TDataType x;
247 TDataType y;
248 TDataType z;
249 QSSGRenderGenericVec3(TDataType _x, TDataType _y, TDataType _z) : x(_x), y(_y), z(_z) {}
251 bool operator==(const QSSGRenderGenericVec3 &inOther) const
252 {
253 return x == inOther.x && y == inOther.y && z == inOther.z;
254 }
255};
256
257template<typename TDataType>
259{
260 TDataType x;
261 TDataType y;
262 TDataType z;
263 TDataType w;
264 QSSGRenderGenericVec4(TDataType _x, TDataType _y, TDataType _z, TDataType _w) : x(_x), y(_y), z(_z), w(_w) {}
266 bool operator==(const QSSGRenderGenericVec4 &inOther) const
267 {
268 return x == inOther.x && y == inOther.y && z == inOther.z && w == inOther.w;
269 }
270};
271
273{
275 {
277 Integer, // qint32,
278 IntegerVec2, // qint32_2,
279 IntegerVec3, // qint32_3,
280 IntegerVec4, // qint32_4,
281 Boolean, // bool
282 BooleanVec2, // bool_2,
283 BooleanVec3, // bool_3,
284 BooleanVec4, // bool_4,
285 Float, // float,
286 Vec2, // QVector2D,
287 Vec3, // QVector3D,
288 Vec4, // QVector4D,
289 UnsignedInteger, // quint32,
290 UnsignedIntegerVec2, // quint32_2,
291 UnsignedIntegerVec3, // quint32_3,
292 UnsignedIntegerVec4, // quint32_4,
293 Matrix3x3, // QMatrix3x3,
294 Matrix4x4, // QMatrix4x4,
295 Rgba, // QColor
296 Size, // QSize
297 SizeF, // QSizeF
298 Point, // QPoint
299 PointF, // QPointF
300 Rect, // QRect
301 RectF, // QRectF
302 Quaternion, // QQuaternion
304 };
305
318}
319
332
342
343using QSSGRenderTextureCubeFaceT = std::underlying_type_t<QSSGRenderTextureCubeFace>;
344
345// Same order as expected by QRHI!
351
353constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaceNone { QSSGRenderTextureCubeFaceT(1 << 4) };
354
355class Q_QUICK3DUTILS_EXPORT QSSGBaseTypeHelpers
356{
357 QSSGBaseTypeHelpers() = default;
358public:
359 // Enum as string
360 static const char *toString(QSSGRenderTextureCubeFace value);
361 static const char *toString(QSSGRenderTextureTypeValue value);
362 static const char *toString(QSSGDepthDrawMode value);
363 static const char *toString(QSSGRenderWinding value);
364 static const char *toString(QSSGCullFaceMode value);
365 static const char *toString(QSSGRenderComponentType value);
366 static const char *toString(QSSGRenderTextureFormat::Format value);
367 static const char *toString(QSSGRenderTextureCoordOp value);
368 static const char *toString(QSSGRenderTextureFilterOp value);
369
370 static const char *displayName(QSSGRenderTextureCubeFace face);
371
372 static size_t getSizeOfType(QSSGRenderComponentType type);
373
374 // Note: These will wrap around
375 static constexpr QSSGRenderTextureCubeFace next(QSSGRenderTextureCubeFace face)
376 { return (face == QSSGRenderTextureCubeFaces[5]) ? QSSGRenderTextureCubeFaces[0] : QSSGRenderTextureCubeFace(quint8(face) + 1); }
377 static constexpr QSSGRenderTextureCubeFace prev(QSSGRenderTextureCubeFace face)
378 { return (face == QSSGRenderTextureCubeFaces[0]) ? QSSGRenderTextureCubeFaces[5] : QSSGRenderTextureCubeFace(quint8(face) - 1); }
379
380 static constexpr QSSGRenderTextureCubeFaceT indexOfCubeFace(QSSGRenderTextureCubeFace face) noexcept { return QSSGRenderTextureCubeFaceT(face) & 0xf; }
381};
382
383QT_END_NAMESPACE
384
385#endif // QSSGRENDERBASETYPES_P_H
QSSGRenderGenericVec2< bool > bvec2
QSSGRenderGenericVec4< bool > bvec4
QSSGRenderGenericVec3< bool > bvec3
static constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaces[]
QSSGRenderTextureCubeFace
QSSGRenderTextureCoordOp
QSSGRenderTextureFilterOp
constexpr QSSGRenderTextureCubeFaceT QSSGRenderTextureCubeFaceMask
QSSGRenderTextureTypeValue
constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaceNone
QSSGRenderGenericVec2(TDataType _x, TDataType _y)
bool operator==(const QSSGRenderGenericVec2 &inOther) const
QSSGRenderGenericVec3(TDataType _x, TDataType _y, TDataType _z)
bool operator==(const QSSGRenderGenericVec3 &inOther) const
bool operator==(const QSSGRenderGenericVec4 &inOther) const
QSSGRenderGenericVec4(TDataType _x, TDataType _y, TDataType _z, TDataType _w)