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.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
7
9
10static const char qssgSamplerNames[][18] = {
11 "sampler2D",
12 "sampler2DArray",
13 "sampler3D",
14 "samplerCube",
15 "samplerCubeArray",
16 "samplerBuffer"
17};
18
19const char *QSSGRenderTextureFormat::toString() const
20{
21 switch (format) {
22 case QSSGRenderTextureFormat::R8:
23 return "R8";
24 case QSSGRenderTextureFormat::R16:
25 return "R16";
26 case QSSGRenderTextureFormat::R16F:
27 return "R16F";
28 case QSSGRenderTextureFormat::R32I:
29 return "R32I";
30 case QSSGRenderTextureFormat::R32UI:
31 return "R32UI";
32 case QSSGRenderTextureFormat::R32F:
33 return "R32F";
34 case QSSGRenderTextureFormat::RG8:
35 return "RG8";
36 case QSSGRenderTextureFormat::RGBA8:
37 return "RGBA8";
38 case QSSGRenderTextureFormat::RGB8:
39 return "RGB8";
40 case QSSGRenderTextureFormat::SRGB8:
41 return "SRGB8";
42 case QSSGRenderTextureFormat::SRGB8A8:
43 return "SRGB8A8";
44 case QSSGRenderTextureFormat::RGB565:
45 return "RGB565";
46 case QSSGRenderTextureFormat::RGBA5551:
47 return "RGBA5551";
48 case QSSGRenderTextureFormat::Alpha8:
49 return "Alpha8";
50 case QSSGRenderTextureFormat::Luminance8:
51 return "Luminance8";
52 case QSSGRenderTextureFormat::Luminance16:
53 return "Luminance16";
54 case QSSGRenderTextureFormat::LuminanceAlpha8:
55 return "LuminanceAlpha8";
56 case QSSGRenderTextureFormat::RGBA16F:
57 return "RGBA16F";
58 case QSSGRenderTextureFormat::RG16F:
59 return "RG16F";
60 case QSSGRenderTextureFormat::RG32F:
61 return "RG32F";
62 case QSSGRenderTextureFormat::RGB32F:
63 return "RGB32F";
64 case QSSGRenderTextureFormat::RGBA32F:
65 return "RGBA32F";
66 case QSSGRenderTextureFormat::R11G11B10:
67 return "R11G11B10";
68 case QSSGRenderTextureFormat::RGB9E5:
69 return "RGB9E5";
70 case QSSGRenderTextureFormat::RGBE8:
71 return "RGBE8";
72 case QSSGRenderTextureFormat::RGBA_DXT1:
73 return "RGBA_DXT1";
74 case QSSGRenderTextureFormat::RGB_DXT1:
75 return "RGB_DXT1";
76 case QSSGRenderTextureFormat::RGBA_DXT3:
77 return "RGBA_DXT3";
78 case QSSGRenderTextureFormat::RGBA_DXT5:
79 return "RGBA_DXT5";
80 case QSSGRenderTextureFormat::R11_EAC_UNorm:
81 return "R11_EAC_UNorm";
82 case QSSGRenderTextureFormat::R11_EAC_SNorm:
83 return "R11_EAC_SNorm";
84 case QSSGRenderTextureFormat::RG11_EAC_UNorm:
85 return "RG11_EAC_UNorm";
86 case QSSGRenderTextureFormat::RG11_EAC_SNorm:
87 return "RG11_EAC_SNorm";
88 case QSSGRenderTextureFormat::RGB8_ETC2:
89 return "RGB8_ETC2";
90 case QSSGRenderTextureFormat::SRGB8_ETC2:
91 return "SRGB8_ETC2";
92 case QSSGRenderTextureFormat::RGB8_PunchThrough_Alpha1_ETC2:
93 return "RGB8_PunchThrough_Alpha1_ETC2";
94 case QSSGRenderTextureFormat::SRGB8_PunchThrough_Alpha1_ETC2:
95 return "SRGB8_PunchThrough_Alpha1_ETC2";
96 case QSSGRenderTextureFormat::RGBA8_ETC2_EAC:
97 return "RGBA8_ETC2_EAC";
98 case QSSGRenderTextureFormat::SRGB8_Alpha8_ETC2_EAC:
99 return "SRGB8_Alpha8_ETC2_EAC";
100 case QSSGRenderTextureFormat::RGBA_ASTC_4x4:
101 return "RGBA_ASTC_4x4";
102 case QSSGRenderTextureFormat::RGBA_ASTC_5x4:
103 return "RGBA_ASTC_5x4";
104 case QSSGRenderTextureFormat::RGBA_ASTC_5x5:
105 return "RGBA_ASTC_5x5";
106 case QSSGRenderTextureFormat::RGBA_ASTC_6x5:
107 return "RGBA_ASTC_6x5";
108 case QSSGRenderTextureFormat::RGBA_ASTC_6x6:
109 return "RGBA_ASTC_6x6";
110 case QSSGRenderTextureFormat::RGBA_ASTC_8x5:
111 return "RGBA_ASTC_8x5";
112 case QSSGRenderTextureFormat::RGBA_ASTC_8x6:
113 return "RGBA_ASTC_8x6";
114 case QSSGRenderTextureFormat::RGBA_ASTC_8x8:
115 return "RGBA_ASTC_8x8";
116 case QSSGRenderTextureFormat::RGBA_ASTC_10x5:
117 return "RGBA_ASTC_10x5";
118 case QSSGRenderTextureFormat::RGBA_ASTC_10x6:
119 return "RGBA_ASTC_10x6";
120 case QSSGRenderTextureFormat::RGBA_ASTC_10x8:
121 return "RGBA_ASTC_10x8";
122 case QSSGRenderTextureFormat::RGBA_ASTC_10x10:
123 return "RGBA_ASTC_10x10";
124 case QSSGRenderTextureFormat::RGBA_ASTC_12x10:
125 return "RGBA_ASTC_12x10";
126 case QSSGRenderTextureFormat::RGBA_ASTC_12x12:
127 return "RGBA_ASTC_12x12";
128 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_4x4:
129 return "SRGB8_Alpha8_ASTC_4x4";
130 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_5x4:
131 return "SRGB8_Alpha8_ASTC_5x4";
132 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_5x5:
133 return "SRGB8_Alpha8_ASTC_5x5";
134 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_6x5:
135 return "SRGB8_Alpha8_ASTC_6x5";
136 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_6x6:
137 return "SRGB8_Alpha8_ASTC_6x6";
138 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_8x5:
139 return "SRGB8_Alpha8_ASTC_8x5";
140 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_8x6:
141 return "SRGB8_Alpha8_ASTC_8x6";
142 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_8x8:
143 return "SRGB8_Alpha8_ASTC_8x8";
144 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_10x5:
145 return "SRGB8_Alpha8_ASTC_10x5";
146 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_10x6:
147 return "SRGB8_Alpha8_ASTC_10x6";
148 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_10x8:
149 return "SRGB8_Alpha8_ASTC_10x8";
150 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_10x10:
151 return "SRGB8_Alpha8_ASTC_10x10";
152 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_12x10:
153 return "SRGB8_Alpha8_ASTC_12x10";
154 case QSSGRenderTextureFormat::SRGB8_Alpha8_ASTC_12x12:
155 return "SRGB8_Alpha8_ASTC_12x12";
156 case QSSGRenderTextureFormat::BC1:
157 return "BC1";
158 case QSSGRenderTextureFormat::BC2:
159 return "BC2";
160 case QSSGRenderTextureFormat::BC3:
161 return "BC3";
162 case QSSGRenderTextureFormat::BC4:
163 return "BC4";
164 case QSSGRenderTextureFormat::BC5:
165 return "BC5";
166 case QSSGRenderTextureFormat::BC6H:
167 return "BC6H";
168 case QSSGRenderTextureFormat::BC7:
169 return "BC7";
170 case QSSGRenderTextureFormat::Depth16:
171 return "Depth16";
172 case QSSGRenderTextureFormat::Depth24:
173 return "Depth24";
174 case QSSGRenderTextureFormat::Depth32:
175 return "Depth32";
176 case QSSGRenderTextureFormat::Depth24Stencil8:
177 return "Depth24Stencil8";
178 case QSSGRenderTextureFormat::RGB10_A2:
179 return "RGB10_A2";
180 case QSSGRenderTextureFormat::RGB16F:
181 return "RGB16F";
182 case QSSGRenderTextureFormat::RGBA32UI:
183 return "RGBA32UI";
184 case QSSGRenderTextureFormat::RGB32UI:
185 return "RGB32UI";
186 case QSSGRenderTextureFormat::RGBA16UI:
187 return "RGBA16UI";
188 case QSSGRenderTextureFormat::RGB16UI:
189 return "RGB16UI";
190 case QSSGRenderTextureFormat::RGBA8UI:
191 return "RGBA8UI";
192 case QSSGRenderTextureFormat::RGB8UI:
193 return "RGB8UI";
194 case QSSGRenderTextureFormat::RGBA32I:
195 return "RGBA32I";
196 case QSSGRenderTextureFormat::RGB32I:
197 return "RGB32I";
198 case QSSGRenderTextureFormat::RGBA16I:
199 return "RGBA16I";
200 case QSSGRenderTextureFormat::RGB16I:
201 return "RGB16I";
202 case QSSGRenderTextureFormat::RGBA8I:
203 return "RGBA8I";
204 case QSSGRenderTextureFormat::RGB8I:
205 return "RGB8I";
206 case QSSGRenderTextureFormat::Unknown:
207 return "Unknown";
208 }
209
210 Q_UNREACHABLE_RETURN(nullptr);
211}
212
213qint32 QSSGRenderTextureFormat::getSizeofFormat() const noexcept
214{
215 switch (format) {
216 case R8:
217 return 1;
218 case R16F:
219 return 2;
220 case R16:
221 return 2;
222 case R32I:
223 return 4;
224 case R32F:
225 return 4;
226 case RGBE8:
227 case RGBA8:
228 return 4;
229 case RGB8:
230 return 3;
231 case RGB565:
232 return 2;
233 case RGBA5551:
234 return 2;
235 case Alpha8:
236 return 1;
237 case Luminance8:
238 return 1;
239 case LuminanceAlpha8:
240 return 1;
241 case Depth16:
242 return 2;
243 case Depth24:
244 return 3;
245 case Depth32:
246 return 4;
247 case Depth24Stencil8:
248 return 4;
249 case RGB9E5:
250 return 4;
251 case SRGB8:
252 return 3;
253 case SRGB8A8:
254 return 4;
255 case RGBA16F:
256 return 8;
257 case RG16F:
258 return 4;
259 case RG32F:
260 return 8;
261 case RGBA32F:
262 return 16;
263 case RGB32F:
264 return 12;
265 case R11G11B10:
266 return 4;
267 default:
268 break;
269 }
270 Q_ASSERT(false);
271 return 0;
272}
273
274qint32 QSSGRenderTextureFormat::getNumberOfComponent() const noexcept
275{
276 switch (format) {
277 case R8:
278 return 1;
279 case R16F:
280 return 1;
281 case R16:
282 return 1;
283 case R32I:
284 return 1;
285 case R32F:
286 return 1;
287 case RGBA8:
288 return 4;
289 case RGB8:
290 return 3;
291 case RGB565:
292 return 3;
293 case RGBA5551:
294 return 4;
295 case Alpha8:
296 return 1;
297 case Luminance8:
298 return 1;
299 case LuminanceAlpha8:
300 return 2;
301 case Depth16:
302 return 1;
303 case Depth24:
304 return 1;
305 case Depth32:
306 return 1;
307 case Depth24Stencil8:
308 return 2;
309 case RGB9E5:
310 return 3;
311 case SRGB8:
312 return 3;
313 case SRGB8A8:
314 return 4;
315 case RGBA16F:
316 return 4;
317 case RG16F:
318 return 2;
319 case RG32F:
320 return 2;
321 case RGBA32F:
322 return 4;
323 case RGB32F:
324 return 3;
325 case R11G11B10:
326 return 3;
327 case RGBE8:
328 return 4;
329 default:
330 break;
331 }
332 Q_ASSERT(false);
333 return 0;
334}
335
336void QSSGRenderTextureFormat::decodeToFloat(void *inPtr, qint32 byteOfs, float *outPtr) const
337{
338 Q_ASSERT(byteOfs >= 0);
339 outPtr[0] = 0.0f;
340 outPtr[1] = 0.0f;
341 outPtr[2] = 0.0f;
342 outPtr[3] = 0.0f;
343 quint8 *src = reinterpret_cast<quint8 *>(inPtr);
344 switch (format) {
345 case Alpha8:
346 outPtr[0] = (float(src[byteOfs])) / 255.0f;
347 break;
348
349 case Luminance8:
350 case LuminanceAlpha8:
351 case R8:
352 case RG8:
353 case RGB8:
354 case RGBA8:
355 case SRGB8:
356 case SRGB8A8:
357 for (qint32 i = 0; i < getSizeofFormat(); ++i) {
358 float val = (float(src[byteOfs + i])) / 255.0f;
359 outPtr[i] = (i < 3) ? std::pow(val, 0.4545454545f) : val;
360 }
361 break;
362 case RGBE8:
363 {
364 float pwd = powf(2.0f, int(src[byteOfs + 3]) - 128);
365 outPtr[0] = float(src[byteOfs + 0]) * pwd / 255.0;
366 outPtr[1] = float(src[byteOfs + 1]) * pwd / 255.0;
367 outPtr[2] = float(src[byteOfs + 2]) * pwd / 255.0;
368 outPtr[3] = 1.0f;
369 } break;
370
371 case R32F:
372 outPtr[0] = reinterpret_cast<float *>(src + byteOfs)[0];
373 break;
374 case RG32F:
375 outPtr[0] = reinterpret_cast<float *>(src + byteOfs)[0];
376 outPtr[1] = reinterpret_cast<float *>(src + byteOfs)[1];
377 break;
378 case RGBA32F:
379 outPtr[0] = reinterpret_cast<float *>(src + byteOfs)[0];
380 outPtr[1] = reinterpret_cast<float *>(src + byteOfs)[1];
381 outPtr[2] = reinterpret_cast<float *>(src + byteOfs)[2];
382 outPtr[3] = reinterpret_cast<float *>(src + byteOfs)[3];
383 break;
384 case RGB32F:
385 outPtr[0] = reinterpret_cast<float *>(src + byteOfs)[0];
386 outPtr[1] = reinterpret_cast<float *>(src + byteOfs)[1];
387 outPtr[2] = reinterpret_cast<float *>(src + byteOfs)[2];
388 break;
389
390 case R16F:
391 case RG16F:
392 case RGBA16F:
393 for (qint32 i = 0; i < (getSizeofFormat() >> 1); ++i) {
394 // NOTE : This only works on the assumption that we don't have any denormals,
395 // Infs or NaNs.
396 // Every pixel in our source image should be "regular"
397 quint16 h = reinterpret_cast<quint16 *>(src + byteOfs)[i];
398 quint32 sign = (h & 0x8000u) << 16u;
399 quint32 exponent = (((((h & 0x7c00u) >> 10) - 15) + 127) << 23);
400 quint32 mantissa = ((h & 0x3ffu) << 13);
401 quint32 result = sign | exponent | mantissa;
402
403 if (h == 0 || h == 0x8000)
404 result = 0;
405 memcpy(outPtr + i, &result, 4);
406 }
407 break;
408
409 case R11G11B10:
410 // place holder
411 Q_ASSERT(false);
412 break;
413
414 default:
415 outPtr[0] = 0.0f;
416 outPtr[1] = 0.0f;
417 outPtr[2] = 0.0f;
418 outPtr[3] = 0.0f;
419 break;
420 }
421}
422void QSSGRenderTextureFormat::encodeToPixel(float *inPtr, void *outPtr, qint32 byteOfs) const
423{
424 struct M8E8
425 {
426 quint8 m;
427 quint8 e;
428 M8E8() : m(0), e(0){
429 }
430 M8E8(const float val) {
431 float l2 = 1.f + std::floor(log2f(val));
432 float mm = val / powf(2.f, l2);
433 m = quint8(mm * 255.f);
434 e = quint8(l2 + 128);
435 }
436 M8E8(const float val, quint8 exp) {
437 if (val <= 0) {
438 m = e = 0;
439 return;
440 }
441 float mm = val / powf(2.f, exp - 128);
442 m = quint8(mm * 255.f);
443 e = exp;
444 }
445 };
446
447 Q_ASSERT(byteOfs >= 0);
448 quint8 *dest = reinterpret_cast<quint8 *>(outPtr);
449 switch (format) {
450 case QSSGRenderTextureFormat::Alpha8:
451 dest[byteOfs] = quint8(inPtr[0] * 255.0f);
452 break;
453
454 case Luminance8:
455 case LuminanceAlpha8:
456 case R8:
457 case RG8:
458 case RGB8:
459 case RGBA8:
460 case SRGB8:
461 case SRGB8A8:
462 for (qint32 i = 0; i < getSizeofFormat(); ++i) {
463 inPtr[i] = (inPtr[i] > 1.0f) ? 1.0f : inPtr[i];
464 if (i < 3)
465 dest[byteOfs + i] = quint8(powf(inPtr[i], 2.2f) * 255.0f);
466 else
467 dest[byteOfs + i] = quint8(inPtr[i] * 255.0f);
468 }
469 break;
470 case RGBE8:
471 {
472 float max = qMax(inPtr[0], qMax(inPtr[1], inPtr[2]));
473 M8E8 ex(max);
474 M8E8 a(inPtr[0], ex.e);
475 M8E8 b(inPtr[1], ex.e);
476 M8E8 c(inPtr[2], ex.e);
477 quint8 *dst = reinterpret_cast<quint8 *>(outPtr) + byteOfs;
478 dst[0] = a.m;
479 dst[1] = b.m;
480 dst[2] = c.m;
481 dst[3] = ex.e;
482 } break;
483
484 case R32F:
485 reinterpret_cast<float *>(dest + byteOfs)[0] = inPtr[0];
486 break;
487 case RG32F:
488 reinterpret_cast<float *>(dest + byteOfs)[0] = inPtr[0];
489 reinterpret_cast<float *>(dest + byteOfs)[1] = inPtr[1];
490 break;
491 case RGBA32F:
492 reinterpret_cast<float *>(dest + byteOfs)[0] = inPtr[0];
493 reinterpret_cast<float *>(dest + byteOfs)[1] = inPtr[1];
494 reinterpret_cast<float *>(dest + byteOfs)[2] = inPtr[2];
495 reinterpret_cast<float *>(dest + byteOfs)[3] = inPtr[3];
496 break;
497 case RGB32F:
498 reinterpret_cast<float *>(dest + byteOfs)[0] = inPtr[0];
499 reinterpret_cast<float *>(dest + byteOfs)[1] = inPtr[1];
500 reinterpret_cast<float *>(dest + byteOfs)[2] = inPtr[2];
501 break;
502
503 case R16F:
504 case RG16F:
505 case RGBA16F:
506 for (qint32 i = 0; i < (getSizeofFormat() >> 1); ++i) {
507 // NOTE : This also has the limitation of not handling infs, NaNs and
508 // denormals, but it should be
509 // sufficient for our purposes.
510 if (inPtr[i] > 65519.0f)
511 inPtr[i] = 65519.0f;
512 if (std::fabs(inPtr[i]) < 6.10352E-5f)
513 inPtr[i] = 0.0f;
514 quint32 f = reinterpret_cast<quint32 *>(inPtr)[i];
515 quint32 sign = (f & 0x80000000) >> 16;
516 qint32 exponent = (f & 0x7f800000) >> 23;
517 quint32 mantissa = (f >> 13) & 0x3ff;
518 exponent = exponent - 112;
519 if (exponent > 31)
520 exponent = 31;
521 if (exponent < 0)
522 exponent = 0;
523 exponent = exponent << 10;
524 reinterpret_cast<quint16 *>(dest + byteOfs)[i] = quint16(sign | quint32(exponent) | mantissa);
525 }
526 break;
527
528 case R11G11B10:
529 // place holder
530 Q_ASSERT(false);
531 break;
532
533 default:
534 dest[byteOfs] = 0;
535 dest[byteOfs + 1] = 0;
536 dest[byteOfs + 2] = 0;
537 dest[byteOfs + 3] = 0;
538 break;
539 }
540}
541
542const char *QSSGBaseTypeHelpers::toString(QSSGRenderWinding value)
543{
544 switch (value) {
545 case QSSGRenderWinding::Clockwise:
546 return "Clockwise";
547 case QSSGRenderWinding::CounterClockwise:
548 return "CounterClockwise";
549 }
550
551 Q_UNREACHABLE_RETURN(nullptr);
552}
553
554const char *QSSGBaseTypeHelpers::toString(QSSGCullFaceMode value)
555{
556 switch (value) {
557 case QSSGCullFaceMode::Front:
558 return "Front";
559 case QSSGCullFaceMode::Back:
560 return "Back";
561 case QSSGCullFaceMode::FrontAndBack:
562 return "FrontAndBack";
563 case QSSGCullFaceMode::Unknown:
564 return "Unknown";
565 case QSSGCullFaceMode::Disabled:
566 return "Disabled";
567 }
568
569 Q_UNREACHABLE_RETURN(nullptr);
570}
571
572const char *QSSGBaseTypeHelpers::toString(QSSGRenderTextureCubeFace value)
573{
574 switch (value) {
575 case QSSGRenderTextureCubeFace::NegX:
576 return "NegX";
577 case QSSGRenderTextureCubeFace::NegZ:
578 return "NegZ";
579 case QSSGRenderTextureCubeFace::NegY:
580 return "NegY";
581 case QSSGRenderTextureCubeFace::PosY:
582 return "PosY";
583 case QSSGRenderTextureCubeFace::PosX:
584 return "PosX";
585 case QSSGRenderTextureCubeFace::PosZ:
586 return "PosZ";
587 }
588
589 Q_UNREACHABLE_RETURN(nullptr);
590}
591
592const char *QSSGBaseTypeHelpers::toString(QSSGRenderTextureTypeValue value)
593{
594 switch (value) {
595 case QSSGRenderTextureTypeValue::Unknown:
596 return "Unknown";
597 case QSSGRenderTextureTypeValue::Diffuse:
598 return "Diffuse";
599 case QSSGRenderTextureTypeValue::Specular:
600 return "Specular";
601 case QSSGRenderTextureTypeValue::Environment:
602 return "Environment";
603 case QSSGRenderTextureTypeValue::Bump:
604 return "Bump";
605 case QSSGRenderTextureTypeValue::Normal:
606 return "Normal";
607 case QSSGRenderTextureTypeValue::Emissive:
608 return "Emissive";
609 case QSSGRenderTextureTypeValue::Anisotropy:
610 return "Anisotropy";
611 case QSSGRenderTextureTypeValue::Translucent:
612 return "Translucent";
613 }
614
615 Q_UNREACHABLE_RETURN(nullptr);
616}
617
618const char *QSSGBaseTypeHelpers::toString(QSSGDepthDrawMode value)
619{
620 switch (value) {
621 case QSSGDepthDrawMode::OpaqueOnly:
622 return "OpaqueOnly";
623 case QSSGDepthDrawMode::Always:
624 return "Always";
625 case QSSGDepthDrawMode::Never:
626 return "Never";
627 case QSSGDepthDrawMode::OpaquePrePass:
628 return "OpaquePrePass";
629 }
630
631 Q_UNREACHABLE_RETURN(nullptr);
632}
633
634const char *QSSGBaseTypeHelpers::toString(QSSGRenderComponentType value)
635{
636 switch (value) {
637 case QSSGRenderComponentType::UnsignedInt8:
638 return "UnsignedInt8";
639 case QSSGRenderComponentType::Int8:
640 return "Int8";
641 case QSSGRenderComponentType::UnsignedInt16:
642 return "UnsignedInt16";
643 case QSSGRenderComponentType::Int16:
644 return "Int16";
645 case QSSGRenderComponentType::UnsignedInt32:
646 return "UnsignedInt32";
647 case QSSGRenderComponentType::Int32:
648 return "Int32";
649 case QSSGRenderComponentType::UnsignedInt64:
650 return "UnsignedInt64";
651 case QSSGRenderComponentType::Int64:
652 return "Int64";
653 case QSSGRenderComponentType::Float16:
654 return "Float16";
655 case QSSGRenderComponentType::Float32:
656 return "Float32";
657 case QSSGRenderComponentType::Float64:
658 return "Float64";
659 }
660
661 Q_UNREACHABLE_RETURN("Unknown");
662}
663
664const char *QSSGBaseTypeHelpers::toString(QSSGRenderTextureFormat::Format value)
665{
666 return QSSGRenderTextureFormat(value).toString();
667}
668
669const char *QSSGBaseTypeHelpers::toString(QSSGRenderTextureCoordOp value)
670{
671 switch (value) {
672 case QSSGRenderTextureCoordOp::ClampToEdge:
673 return "ClampToEdge";
674 case QSSGRenderTextureCoordOp::MirroredRepeat:
675 return "MirroredRepeat";
676 case QSSGRenderTextureCoordOp::Repeat:
677 return "Repeat";
678 case QSSGRenderTextureCoordOp::Unknown:
679 return "Unknown";
680 }
681
682 Q_UNREACHABLE_RETURN(nullptr);
683}
684
685const char *QSSGBaseTypeHelpers::toString(QSSGRenderTextureFilterOp value)
686{
687 switch (value) {
688 case QSSGRenderTextureFilterOp::Nearest:
689 return "Nearest";
690 case QSSGRenderTextureFilterOp::Linear:
691 return "Linear";
692 case QSSGRenderTextureFilterOp::None:
693 return "None";
694 }
695
696 Q_UNREACHABLE_RETURN(nullptr);
697}
698
699QByteArray QSSGBaseTypeHelpers::toString(QSSGRenderSamplerType value)
700{
701 return QByteArray(qssgSamplerNames[static_cast<size_t>(value)]);
702}
703
704const char *QSSGBaseTypeHelpers::displayName(QSSGRenderTextureCubeFace face)
705{
706 switch (face) {
707 case QSSGRenderTextureCubeFace::NegX:
708 return "-X";
709 case QSSGRenderTextureCubeFace::NegZ:
710 return "-Z";
711 case QSSGRenderTextureCubeFace::NegY:
712 return "-Y";
713 case QSSGRenderTextureCubeFace::PosY:
714 return "+Y";
715 case QSSGRenderTextureCubeFace::PosX:
716 return "+X";
717 case QSSGRenderTextureCubeFace::PosZ:
718 return "+Z";
719 }
720
721 Q_UNREACHABLE_RETURN(nullptr);
722}
723
724size_t QSSGBaseTypeHelpers::getSizeOfType(QSSGRenderComponentType type)
725{
726 switch (type) {
727 case QSSGRenderComponentType::UnsignedInt8:
728 return sizeof(quint8);
729 case QSSGRenderComponentType::Int8:
730 return sizeof(qint8);
731 case QSSGRenderComponentType::UnsignedInt16:
732 return sizeof(quint16);
733 case QSSGRenderComponentType::Int16:
734 return sizeof(qint16);
735 case QSSGRenderComponentType::UnsignedInt32:
736 return sizeof(quint32);
737 case QSSGRenderComponentType::Int32:
738 return sizeof(qint32);
739 case QSSGRenderComponentType::UnsignedInt64:
740 return sizeof(quint64);
741 case QSSGRenderComponentType::Int64:
742 return sizeof(qint64);
743 case QSSGRenderComponentType::Float16:
744 return sizeof(qfloat16);
745 case QSSGRenderComponentType::Float32:
746 return sizeof(float);
747 case QSSGRenderComponentType::Float64:
748 return sizeof(double);
749 }
750 Q_UNREACHABLE_RETURN(0);
751}
752
753QT_END_NAMESPACE
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE const char qssgSamplerNames[][18]