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// Qt-Security score:significant reason:default
5
6
7#ifndef QSSGRENDERBASETYPES_P_H
8#define QSSGRENDERBASETYPES_P_H
9
10//
11// W A R N I N G
12// -------------
13//
14// This file is not part of the Qt API. It exists purely as an
15// implementation detail. This header file may change from version to
16// version without notice, or even be removed.
17//
18// We mean it.
19//
20
21#include <QtQuick3DUtils/qtquick3dutilsexports.h>
22
23#include <QtCore/qvariant.h>
24
25#include <QtGui/QVector2D>
26#include <QtGui/QVector3D>
27#include <QtGui/QVector4D>
28#include <QtGui/QMatrix4x4>
29#include <QtGui/QMatrix3x3>
30#include <QFloat16>
31
32#include <cmath>
33
34QT_BEGIN_NAMESPACE
35
36enum class QSSGRenderComponentType // stored in mesh files, the values must not change, must match Mesh::ComponentType
37{
38 UnsignedInt8 = 1,
39 Int8,
40 UnsignedInt16,
41 Int16,
42 UnsignedInt32,
43 Int32,
44 UnsignedInt64,
45 Int64,
46 Float16,
47 Float32,
48 Float64
49};
50
51enum class QSSGRenderDrawMode // stored in mesh files, the values must not change, must match Mesh::DrawMode
52{
53 Points = 1,
55 LineLoop, // Not supported
60};
61
62enum class QSSGRenderWinding // stored in mesh files, the values must not change, must match Mesh::Winding
63{
66};
67
78
79struct Q_QUICK3DUTILS_EXPORT QSSGRenderTextureFormat
80{
81 static constexpr quint8 DepthTextureFlag = 1u << 6;
82 static constexpr quint8 CompressedTextureFlag = 1u << 7;
83
84 enum Format : quint8 {
85 // Non-compressed formats
86 Unknown = 0,
87 R8,
88 R16,
89 R16F,
90 R32I,
91 R32UI,
92 R32F,
93 RG8,
94 RGBA8,
95 RGB8,
96 SRGB8,
97 SRGB8A8,
98 RGB565,
99 RGBA5551,
100 Alpha8,
101 Luminance8,
102 Luminance16,
103 LuminanceAlpha8,
104 RGBA16F,
105 RG16F,
106 RG32F,
107 RGB32F,
108 RGBA32F,
109 R11G11B10,
110 RGB9E5,
111 RGB10_A2,
112 RGB16F,
113 RGBA32UI,
114 RGB32UI,
115 RGBA16UI,
116 RGB16UI,
117 RGBA8UI,
118 RGB8UI,
119 RGBA32I,
120 RGB32I,
121 RGBA16I,
122 RGB16I,
123 RGBA8I,
124 RGB8I,
125 RGBE8,
126
127 // Depth textures
128 Depth16 = DepthTextureFlag + 1,
129 Depth24,
130 Depth32,
131 Depth24Stencil8,
132
133 // Compressed formats
134 RGBA_DXT1 = CompressedTextureFlag + 1,
135 RGB_DXT1,
136 RGBA_DXT3,
137 RGBA_DXT5,
138 R11_EAC_UNorm,
139 R11_EAC_SNorm,
140 RG11_EAC_UNorm,
141 RG11_EAC_SNorm,
142 RGB8_ETC2,
143 SRGB8_ETC2,
144 RGB8_PunchThrough_Alpha1_ETC2,
145 SRGB8_PunchThrough_Alpha1_ETC2,
146 RGBA8_ETC2_EAC,
147 SRGB8_Alpha8_ETC2_EAC,
148 RGBA_ASTC_4x4,
149 RGBA_ASTC_5x4,
150 RGBA_ASTC_5x5,
151 RGBA_ASTC_6x5,
152 RGBA_ASTC_6x6,
153 RGBA_ASTC_8x5,
154 RGBA_ASTC_8x6,
155 RGBA_ASTC_8x8,
156 RGBA_ASTC_10x5,
157 RGBA_ASTC_10x6,
158 RGBA_ASTC_10x8,
159 RGBA_ASTC_10x10,
160 RGBA_ASTC_12x10,
161 RGBA_ASTC_12x12,
162 SRGB8_Alpha8_ASTC_4x4,
163 SRGB8_Alpha8_ASTC_5x4,
164 SRGB8_Alpha8_ASTC_5x5,
165 SRGB8_Alpha8_ASTC_6x5,
166 SRGB8_Alpha8_ASTC_6x6,
167 SRGB8_Alpha8_ASTC_8x5,
168 SRGB8_Alpha8_ASTC_8x6,
169 SRGB8_Alpha8_ASTC_8x8,
170 SRGB8_Alpha8_ASTC_10x5,
171 SRGB8_Alpha8_ASTC_10x6,
172 SRGB8_Alpha8_ASTC_10x8,
173 SRGB8_Alpha8_ASTC_10x10,
174 SRGB8_Alpha8_ASTC_12x10,
175 SRGB8_Alpha8_ASTC_12x12,
176 BC1,
177 BC2,
178 BC3,
179 BC4,
180 BC5,
181 BC6H,
182 BC7,
183 };
184 Format format;
185
186 constexpr QSSGRenderTextureFormat(Format f) : format(f) {}
187
188 [[nodiscard]] constexpr bool isCompressedTextureFormat() const noexcept
189 {
190 return (format & CompressedTextureFlag);
191 }
192
193 [[nodiscard]] constexpr bool isUncompressedTextureFormat() const noexcept
194 {
195 return !isCompressedTextureFormat();
196 }
197
198 [[nodiscard]] bool isDepthTextureFormat() const noexcept
199 {
200 return (format & DepthTextureFlag);
201 }
202
203 [[nodiscard]] const char *toString() const;
204
205 [[nodiscard]] qint32 getSizeofFormat() const noexcept;
206
207 [[nodiscard]] qint32 getNumberOfComponent() const noexcept;
208
209 void decodeToFloat(void *inPtr, qint32 byteOfs, float *outPtr) const;
210 void encodeToPixel(float *inPtr, void *outPtr, qint32 byteOfs) const;
211
212 bool operator==(const QSSGRenderTextureFormat &other) const { return format == other.format; }
213 bool operator!=(const QSSGRenderTextureFormat &other) const { return format != other.format; }
214};
215
222
230
232{
237 FrontAndBack, // Not exposed in the front-end
238};
239
247
248template<typename TDataType>
250{
251 TDataType x;
252 TDataType y;
253 QSSGRenderGenericVec2(TDataType _x, TDataType _y) : x(_x), y(_y) {}
255 bool operator==(const QSSGRenderGenericVec2 &inOther) const { return x == inOther.x && y == inOther.y; }
256};
257
258template<typename TDataType>
260{
261 TDataType x;
262 TDataType y;
263 TDataType z;
264 QSSGRenderGenericVec3(TDataType _x, TDataType _y, TDataType _z) : x(_x), y(_y), z(_z) {}
266 bool operator==(const QSSGRenderGenericVec3 &inOther) const
267 {
268 return x == inOther.x && y == inOther.y && z == inOther.z;
269 }
270};
271
272template<typename TDataType>
274{
275 TDataType x;
276 TDataType y;
277 TDataType z;
278 TDataType w;
279 QSSGRenderGenericVec4(TDataType _x, TDataType _y, TDataType _z, TDataType _w) : x(_x), y(_y), z(_z), w(_w) {}
281 bool operator==(const QSSGRenderGenericVec4 &inOther) const
282 {
283 return x == inOther.x && y == inOther.y && z == inOther.z && w == inOther.w;
284 }
285};
286
288{
290 {
292 Integer, // qint32,
293 IntegerVec2, // qint32_2,
294 IntegerVec3, // qint32_3,
295 IntegerVec4, // qint32_4,
296 Boolean, // bool
297 BooleanVec2, // bool_2,
298 BooleanVec3, // bool_3,
299 BooleanVec4, // bool_4,
300 Float, // float,
301 Vec2, // QVector2D,
302 Vec3, // QVector3D,
303 Vec4, // QVector4D,
304 UnsignedInteger, // quint32,
305 UnsignedIntegerVec2, // quint32_2,
306 UnsignedIntegerVec3, // quint32_3,
307 UnsignedIntegerVec4, // quint32_4,
308 Matrix3x3, // QMatrix3x3,
309 Matrix4x4, // QMatrix4x4,
310 Rgba, // QColor
311 Size, // QSize
312 SizeF, // QSizeF
313 Point, // QPoint
314 PointF, // QPointF
315 Rect, // QRect
316 RectF, // QRectF
317 Quaternion, // QQuaternion
319 };
320
333}
334
347
357
358using QSSGRenderTextureCubeFaceT = std::underlying_type_t<QSSGRenderTextureCubeFace>;
359
360// Same order as expected by QRHI!
366
368constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaceNone { QSSGRenderTextureCubeFaceT(1 << 4) };
369
370class Q_QUICK3DUTILS_EXPORT QSSGBaseTypeHelpers
371{
372 QSSGBaseTypeHelpers() = default;
373public:
374 // Enum as string
375 static const char *toString(QSSGRenderTextureCubeFace value);
376 static const char *toString(QSSGRenderTextureTypeValue value);
377 static const char *toString(QSSGDepthDrawMode value);
378 static const char *toString(QSSGRenderWinding value);
379 static const char *toString(QSSGCullFaceMode value);
380 static const char *toString(QSSGRenderComponentType value);
381 static const char *toString(QSSGRenderTextureFormat::Format value);
382 static const char *toString(QSSGRenderTextureCoordOp value);
383 static const char *toString(QSSGRenderTextureFilterOp value);
384 static QByteArray toString(QSSGRenderSamplerType value);
385
386 static const char *displayName(QSSGRenderTextureCubeFace face);
387
388 static size_t getSizeOfType(QSSGRenderComponentType type);
389
390 // Note: These will wrap around
391 static constexpr QSSGRenderTextureCubeFace next(QSSGRenderTextureCubeFace face)
392 { return (face == QSSGRenderTextureCubeFaces[5]) ? QSSGRenderTextureCubeFaces[0] : QSSGRenderTextureCubeFace(quint8(face) + 1); }
393 static constexpr QSSGRenderTextureCubeFace prev(QSSGRenderTextureCubeFace face)
394 { return (face == QSSGRenderTextureCubeFaces[0]) ? QSSGRenderTextureCubeFaces[5] : QSSGRenderTextureCubeFace(quint8(face) - 1); }
395
396 static constexpr QSSGRenderTextureCubeFaceT indexOfCubeFace(QSSGRenderTextureCubeFace face) noexcept { return QSSGRenderTextureCubeFaceT(face) & 0xf; }
397};
398
400{
401public:
403 QSSGBaseTypeProperty(const QByteArray &name, const QByteArray &typeName, const QVariant &value, QSSGRenderShaderValue::Type shaderDataType, int pid = -1)
404 : name(name), typeName(typeName), value(value), shaderDataType(shaderDataType), pid(pid)
405 { }
410 int pid;
411};
412
413QT_END_NAMESPACE
414
415#endif // QSSGRENDERBASETYPES_P_H
QSSGBaseTypeProperty()=default
QSSGBaseTypeProperty(const QByteArray &name, const QByteArray &typeName, const QVariant &value, QSSGRenderShaderValue::Type shaderDataType, int pid=-1)
QSSGRenderShaderValue::Type shaderDataType
QSSGRenderGenericVec2< bool > bvec2
QSSGRenderGenericVec4< bool > bvec4
QSSGRenderGenericVec3< bool > bvec3
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE const char qssgSamplerNames[][18]
static constexpr QSSGRenderTextureCubeFace QSSGRenderTextureCubeFaces[]
QSSGRenderTextureCubeFace
QSSGRenderSamplerType
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)