1 #ifndef DALI_GRAPHICS_GLES_TYPES_H
2 #define DALI_GRAPHICS_GLES_TYPES_H
5 #include <dali/graphics-api/graphics-types.h>
6 #include <dali/integration-api/gl-abstraction.h>
7 #include <dali/integration-api/gl-defines.h>
9 namespace Dali::Graphics::GLES
16 // Conversion functions
18 * Stucture delivers format and type that can be used
19 * when creating GL texture
21 struct GLTextureFormatType
24 * Constuctor from Graphics::Format
27 constexpr GLTextureFormatType(Graphics::Format value)
32 case Graphics::Format::UNDEFINED:
39 case Graphics::Format::L8:
41 Assign(GL_LUMINANCE, GL_UNSIGNED_BYTE);
44 case Graphics::Format::L8A8:
46 Assign(GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
50 // Packed formats (TODO: find supported)
51 case Graphics::Format::R4G4_UNORM_PACK8:
56 case Graphics::Format::R4G4B4A4_UNORM_PACK16:
58 Assign(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
61 case Graphics::Format::B4G4R4A4_UNORM_PACK16:
64 Assign(GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4);
66 Assign(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
70 case Graphics::Format::R5G6B5_UNORM_PACK16:
72 Assign(GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
75 case Graphics::Format::B5G6R5_UNORM_PACK16:
78 Assign(GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5);
80 Assign(GL_RGBA, GL_UNSIGNED_SHORT_5_6_5);
84 case Graphics::Format::R5G5B5A1_UNORM_PACK16:
86 Assign(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
89 case Graphics::Format::B5G5R5A1_UNORM_PACK16:
92 Assign(GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_5_5_1);
94 Assign(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
98 case Graphics::Format::A1R5G5B5_UNORM_PACK16:
105 case Graphics::Format::R8_UNORM:
107 Assign(GL_RED, GL_UNSIGNED_BYTE);
110 case Graphics::Format::R8_SNORM:
112 Assign(GL_RED, GL_BYTE);
115 case Graphics::Format::R8_USCALED:
117 Assign(GL_RED, GL_UNSIGNED_BYTE);
120 case Graphics::Format::R8_SSCALED:
122 Assign(GL_RED, GL_BYTE);
125 case Graphics::Format::R8_UINT:
127 Assign(GL_RED, GL_UNSIGNED_BYTE);
130 case Graphics::Format::R8_SINT:
132 Assign(GL_RED, GL_BYTE);
135 case Graphics::Format::R8_SRGB:
137 Assign(GL_RED, GL_BYTE);
140 case Graphics::Format::R8G8_UNORM:
142 Assign(GL_RG, GL_UNSIGNED_BYTE);
145 case Graphics::Format::R8G8_SNORM:
147 Assign(GL_RG, GL_BYTE);
150 case Graphics::Format::R8G8_USCALED:
152 Assign(GL_RG, GL_UNSIGNED_BYTE);
155 case Graphics::Format::R8G8_SSCALED:
157 Assign(GL_RG, GL_BYTE);
160 case Graphics::Format::R8G8_UINT:
162 Assign(GL_RG, GL_UNSIGNED_BYTE);
165 case Graphics::Format::R8G8_SINT:
167 Assign(GL_RG, GL_BYTE);
170 case Graphics::Format::R8G8_SRGB:
172 Assign(GL_RG, GL_BYTE);
175 case Graphics::Format::R8G8B8_UNORM:
177 Assign(GL_RGB, GL_UNSIGNED_BYTE);
180 case Graphics::Format::R8G8B8_SNORM:
182 Assign(GL_RGB, GL_BYTE);
185 case Graphics::Format::R8G8B8_USCALED:
187 Assign(GL_RGB, GL_UNSIGNED_BYTE);
190 case Graphics::Format::R8G8B8_SSCALED:
192 Assign(GL_RGB, GL_BYTE);
195 case Graphics::Format::R8G8B8_UINT:
197 Assign(GL_RGB, GL_UNSIGNED_BYTE);
200 case Graphics::Format::R8G8B8_SINT:
202 Assign(GL_RGB, GL_BYTE);
205 case Graphics::Format::R8G8B8_SRGB:
207 Assign(GL_RGB, GL_BYTE);
211 // BGR not supported in GLES
212 case Graphics::Format::B8G8R8_UNORM:
213 case Graphics::Format::B8G8R8_SNORM:
214 case Graphics::Format::B8G8R8_USCALED:
215 case Graphics::Format::B8G8R8_SSCALED:
216 case Graphics::Format::B8G8R8_UINT:
217 case Graphics::Format::B8G8R8_SINT:
218 case Graphics::Format::B8G8R8_SRGB:
225 case Graphics::Format::R8G8B8A8_UNORM:
227 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
230 case Graphics::Format::R8G8B8A8_SNORM:
232 Assign(GL_RGBA, GL_BYTE);
235 case Graphics::Format::R8G8B8A8_USCALED:
237 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
240 case Graphics::Format::R8G8B8A8_SSCALED:
242 Assign(GL_RGBA, GL_BYTE);
245 case Graphics::Format::R8G8B8A8_UINT:
247 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
250 case Graphics::Format::R8G8B8A8_SINT:
252 Assign(GL_RGBA, GL_BYTE);
255 case Graphics::Format::R8G8B8A8_SRGB:
257 Assign(GL_RGBA, GL_BYTE);
261 // BGRA when only support GL_BGRA_EXT. otherwise, use RGBA
262 case Graphics::Format::B8G8R8A8_UNORM:
265 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
267 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
271 case Graphics::Format::B8G8R8A8_SNORM:
274 Assign(GL_BGRA_EXT, GL_BYTE);
276 Assign(GL_RGBA, GL_BYTE);
280 case Graphics::Format::B8G8R8A8_USCALED:
283 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
285 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
289 case Graphics::Format::B8G8R8A8_SSCALED:
292 Assign(GL_BGRA_EXT, GL_BYTE);
294 Assign(GL_RGBA, GL_BYTE);
298 case Graphics::Format::B8G8R8A8_UINT:
301 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
303 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
307 case Graphics::Format::B8G8R8A8_SINT:
310 Assign(GL_BGRA_EXT, GL_BYTE);
312 Assign(GL_RGBA, GL_BYTE);
316 case Graphics::Format::B8G8R8A8_SRGB:
319 Assign(GL_BGRA_EXT, GL_BYTE);
321 Assign(GL_RGBA, GL_BYTE);
326 // ABGR not supported
327 case Graphics::Format::A8B8G8R8_UNORM_PACK32:
328 case Graphics::Format::A8B8G8R8_SNORM_PACK32:
329 case Graphics::Format::A8B8G8R8_USCALED_PACK32:
330 case Graphics::Format::A8B8G8R8_SSCALED_PACK32:
331 case Graphics::Format::A8B8G8R8_UINT_PACK32:
332 case Graphics::Format::A8B8G8R8_SINT_PACK32:
333 case Graphics::Format::A8B8G8R8_SRGB_PACK32:
339 // TBD which of the formats are supported
340 case Graphics::Format::A2R10G10B10_UNORM_PACK32:
341 case Graphics::Format::A2R10G10B10_SNORM_PACK32:
342 case Graphics::Format::A2R10G10B10_USCALED_PACK32:
343 case Graphics::Format::A2R10G10B10_SSCALED_PACK32:
344 case Graphics::Format::A2R10G10B10_UINT_PACK32:
345 case Graphics::Format::A2R10G10B10_SINT_PACK32:
346 case Graphics::Format::A2B10G10R10_UNORM_PACK32:
347 case Graphics::Format::A2B10G10R10_SNORM_PACK32:
348 case Graphics::Format::A2B10G10R10_USCALED_PACK32:
349 case Graphics::Format::A2B10G10R10_SSCALED_PACK32:
350 case Graphics::Format::A2B10G10R10_UINT_PACK32:
351 case Graphics::Format::A2B10G10R10_SINT_PACK32:
356 case Graphics::Format::R16_UNORM:
357 case Graphics::Format::R16_SNORM:
358 case Graphics::Format::R16_USCALED:
359 case Graphics::Format::R16_SSCALED:
360 case Graphics::Format::R16_UINT:
361 case Graphics::Format::R16_SINT:
362 case Graphics::Format::R16_SFLOAT:
363 case Graphics::Format::R16G16_UNORM:
364 case Graphics::Format::R16G16_SNORM:
365 case Graphics::Format::R16G16_USCALED:
366 case Graphics::Format::R16G16_SSCALED:
367 case Graphics::Format::R16G16_UINT:
368 case Graphics::Format::R16G16_SINT:
369 case Graphics::Format::R16G16_SFLOAT:
370 case Graphics::Format::R16G16B16_UNORM:
371 case Graphics::Format::R16G16B16_SNORM:
372 case Graphics::Format::R16G16B16_USCALED:
373 case Graphics::Format::R16G16B16_SSCALED:
374 case Graphics::Format::R16G16B16_UINT:
375 case Graphics::Format::R16G16B16_SINT:
380 case Graphics::Format::R16G16B16_SFLOAT:
382 // GLES 3.0 floating point formats.
383 AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_HALF_FLOAT); // DALi uses compact internal format
386 case Graphics::Format::R16G16B16A16_UNORM:
387 case Graphics::Format::R16G16B16A16_SNORM:
388 case Graphics::Format::R16G16B16A16_USCALED:
389 case Graphics::Format::R16G16B16A16_SSCALED:
390 case Graphics::Format::R16G16B16A16_UINT:
391 case Graphics::Format::R16G16B16A16_SINT:
392 case Graphics::Format::R16G16B16A16_SFLOAT:
393 case Graphics::Format::R32_UINT:
394 case Graphics::Format::R32_SINT:
395 case Graphics::Format::R32_SFLOAT:
396 case Graphics::Format::R32G32_UINT:
397 case Graphics::Format::R32G32_SINT:
398 case Graphics::Format::R32G32_SFLOAT:
399 case Graphics::Format::R32G32B32_UINT:
400 case Graphics::Format::R32G32B32_SINT:
405 case Graphics::Format::R32G32B32_SFLOAT:
407 AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT); // DALi uses compact internal format
410 case Graphics::Format::R32G32B32A32_UINT:
411 case Graphics::Format::R32G32B32A32_SINT:
412 case Graphics::Format::R32G32B32A32_SFLOAT:
417 case Graphics::Format::R64_UINT:
418 case Graphics::Format::R64_SINT:
419 case Graphics::Format::R64_SFLOAT:
420 case Graphics::Format::R64G64_UINT:
421 case Graphics::Format::R64G64_SINT:
422 case Graphics::Format::R64G64_SFLOAT:
423 case Graphics::Format::R64G64B64_UINT:
424 case Graphics::Format::R64G64B64_SINT:
425 case Graphics::Format::R64G64B64_SFLOAT:
426 case Graphics::Format::R64G64B64A64_UINT:
427 case Graphics::Format::R64G64B64A64_SINT:
428 case Graphics::Format::R64G64B64A64_SFLOAT:
433 case Graphics::Format::R11G11B10_UFLOAT_PACK32:
435 AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT);
438 case Graphics::Format::B10G11R11_UFLOAT_PACK32:
439 case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
444 case Graphics::Format::D16_UNORM:
446 // GLES 3.0 depth and stencil formats
447 Assign(GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
450 case Graphics::Format::X8_D24_UNORM_PACK32:
455 case Graphics::Format::D32_SFLOAT:
457 // GLES 3.0 depth and stencil formats
458 AssignInternal(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT32F, GL_FLOAT);
461 case Graphics::Format::S8_UINT:
462 case Graphics::Format::D16_UNORM_S8_UINT:
467 case Graphics::Format::D24_UNORM_S8_UINT:
469 // GLES 3.0 depth and stencil formats
470 AssignInternal(GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8);
473 case Graphics::Format::D32_SFLOAT_S8_UINT:
478 case Graphics::Format::BC1_RGB_UNORM_BLOCK:
479 case Graphics::Format::BC1_RGB_SRGB_BLOCK:
480 case Graphics::Format::BC1_RGBA_UNORM_BLOCK:
481 case Graphics::Format::BC1_RGBA_SRGB_BLOCK:
482 case Graphics::Format::BC2_UNORM_BLOCK:
483 case Graphics::Format::BC2_SRGB_BLOCK:
484 case Graphics::Format::BC3_UNORM_BLOCK:
485 case Graphics::Format::BC3_SRGB_BLOCK:
486 case Graphics::Format::BC4_UNORM_BLOCK:
487 case Graphics::Format::BC4_SNORM_BLOCK:
488 case Graphics::Format::BC5_UNORM_BLOCK:
489 case Graphics::Format::BC5_SNORM_BLOCK:
490 case Graphics::Format::BC6H_UFLOAT_BLOCK:
491 case Graphics::Format::BC6H_SFLOAT_BLOCK:
492 case Graphics::Format::BC7_UNORM_BLOCK:
493 case Graphics::Format::BC7_SRGB_BLOCK:
498 case Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK:
500 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.
501 Assign(GL_COMPRESSED_RGB8_ETC2, 0);
504 case Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK:
506 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.
507 Assign(GL_COMPRESSED_SRGB8_ETC2, 0);
510 case Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK:
512 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.
513 Assign(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 0);
516 case Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK:
518 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.
519 Assign(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 0);
522 case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK:
524 Assign(GL_COMPRESSED_RGBA8_ETC2_EAC, 0);
527 case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK:
529 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 0);
532 case Graphics::Format::EAC_R11_UNORM_BLOCK:
534 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.
535 Assign(GL_COMPRESSED_R11_EAC, 0);
538 case Graphics::Format::EAC_R11_SNORM_BLOCK:
540 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.
541 Assign(GL_COMPRESSED_SIGNED_R11_EAC, 0);
544 case Graphics::Format::EAC_R11G11_UNORM_BLOCK:
546 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.
547 Assign(GL_COMPRESSED_RG11_EAC, 0);
550 case Graphics::Format::EAC_R11G11_SNORM_BLOCK:
552 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.
553 Assign(GL_COMPRESSED_SIGNED_RG11_EAC, 0);
556 case Graphics::Format::ASTC_4x4_UNORM_BLOCK:
558 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.
559 Assign(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 0);
562 case Graphics::Format::ASTC_4x4_SRGB_BLOCK:
564 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.
565 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 0);
568 case Graphics::Format::ASTC_5x4_UNORM_BLOCK:
570 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.
571 Assign(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 0);
574 case Graphics::Format::ASTC_5x4_SRGB_BLOCK:
576 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.
577 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 0);
580 case Graphics::Format::ASTC_5x5_UNORM_BLOCK:
582 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.
583 Assign(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 0);
586 case Graphics::Format::ASTC_5x5_SRGB_BLOCK:
588 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.
589 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 0);
592 case Graphics::Format::ASTC_6x5_UNORM_BLOCK:
594 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.
595 Assign(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 0);
598 case Graphics::Format::ASTC_6x5_SRGB_BLOCK:
600 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.
601 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 0);
604 case Graphics::Format::ASTC_6x6_UNORM_BLOCK:
606 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.
607 Assign(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 0);
610 case Graphics::Format::ASTC_6x6_SRGB_BLOCK:
612 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.
613 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 0);
616 case Graphics::Format::ASTC_8x5_UNORM_BLOCK:
618 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.
619 Assign(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 0);
622 case Graphics::Format::ASTC_8x5_SRGB_BLOCK:
624 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.
625 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 0);
628 case Graphics::Format::ASTC_8x6_UNORM_BLOCK:
630 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.
631 Assign(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 0);
634 case Graphics::Format::ASTC_8x6_SRGB_BLOCK:
636 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.
637 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 0);
640 case Graphics::Format::ASTC_8x8_UNORM_BLOCK:
642 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.
643 Assign(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 0);
646 case Graphics::Format::ASTC_8x8_SRGB_BLOCK:
648 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.
649 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 0);
652 case Graphics::Format::ASTC_10x5_UNORM_BLOCK:
654 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.
655 Assign(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 0);
658 case Graphics::Format::ASTC_10x5_SRGB_BLOCK:
660 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.
661 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 0);
664 case Graphics::Format::ASTC_10x6_UNORM_BLOCK:
666 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.
667 Assign(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 0);
670 case Graphics::Format::ASTC_10x6_SRGB_BLOCK:
672 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.
673 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 0);
676 case Graphics::Format::ASTC_10x8_UNORM_BLOCK:
678 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.
679 Assign(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 0);
682 case Graphics::Format::ASTC_10x8_SRGB_BLOCK:
684 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.
685 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 0);
688 case Graphics::Format::ASTC_10x10_UNORM_BLOCK:
690 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.
691 Assign(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 0);
694 case Graphics::Format::ASTC_10x10_SRGB_BLOCK:
696 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.
697 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 0);
700 case Graphics::Format::ASTC_12x10_UNORM_BLOCK:
702 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.
703 Assign(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 0);
706 case Graphics::Format::ASTC_12x10_SRGB_BLOCK:
708 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.
709 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 0);
712 case Graphics::Format::ASTC_12x12_UNORM_BLOCK:
714 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.
715 Assign(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 0);
718 case Graphics::Format::ASTC_12x12_SRGB_BLOCK:
720 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.
721 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 0);
724 case Graphics::Format::PVRTC1_2BPP_UNORM_BLOCK_IMG:
729 case Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG:
731 ///! Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.
732 Assign(0x8C00, 0); ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
736 case Graphics::Format::PVRTC2_2BPP_UNORM_BLOCK_IMG:
737 case Graphics::Format::PVRTC2_4BPP_UNORM_BLOCK_IMG:
738 case Graphics::Format::PVRTC1_2BPP_SRGB_BLOCK_IMG:
739 case Graphics::Format::PVRTC1_4BPP_SRGB_BLOCK_IMG:
740 case Graphics::Format::PVRTC2_2BPP_SRGB_BLOCK_IMG:
741 case Graphics::Format::PVRTC2_4BPP_SRGB_BLOCK_IMG:
749 constexpr inline void Assign(uint32_t f, uint32_t t)
755 constexpr inline void AssignInternal(uint32_t f, uint32_t i, uint32_t t)
763 uint32_t internalFormat{0};
767 struct FormatCompression
770 * Constuctor from Graphics::Format
773 constexpr explicit FormatCompression(Graphics::Format value)
777 case Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK:
778 case Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK:
779 case Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK:
780 case Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK:
781 case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK:
782 case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK:
783 case Graphics::Format::EAC_R11_UNORM_BLOCK:
784 case Graphics::Format::EAC_R11_SNORM_BLOCK:
785 case Graphics::Format::EAC_R11G11_UNORM_BLOCK:
786 case Graphics::Format::EAC_R11G11_SNORM_BLOCK:
787 case Graphics::Format::ASTC_4x4_UNORM_BLOCK:
788 case Graphics::Format::ASTC_4x4_SRGB_BLOCK:
789 case Graphics::Format::ASTC_5x4_UNORM_BLOCK:
790 case Graphics::Format::ASTC_5x4_SRGB_BLOCK:
791 case Graphics::Format::ASTC_5x5_UNORM_BLOCK:
792 case Graphics::Format::ASTC_5x5_SRGB_BLOCK:
793 case Graphics::Format::ASTC_6x5_UNORM_BLOCK:
794 case Graphics::Format::ASTC_6x5_SRGB_BLOCK:
795 case Graphics::Format::ASTC_6x6_UNORM_BLOCK:
796 case Graphics::Format::ASTC_6x6_SRGB_BLOCK:
797 case Graphics::Format::ASTC_8x5_UNORM_BLOCK:
798 case Graphics::Format::ASTC_8x5_SRGB_BLOCK:
799 case Graphics::Format::ASTC_8x6_UNORM_BLOCK:
800 case Graphics::Format::ASTC_8x6_SRGB_BLOCK:
801 case Graphics::Format::ASTC_8x8_UNORM_BLOCK:
802 case Graphics::Format::ASTC_8x8_SRGB_BLOCK:
803 case Graphics::Format::ASTC_10x5_UNORM_BLOCK:
804 case Graphics::Format::ASTC_10x5_SRGB_BLOCK:
805 case Graphics::Format::ASTC_10x6_UNORM_BLOCK:
806 case Graphics::Format::ASTC_10x6_SRGB_BLOCK:
807 case Graphics::Format::ASTC_10x8_UNORM_BLOCK:
808 case Graphics::Format::ASTC_10x8_SRGB_BLOCK:
809 case Graphics::Format::ASTC_10x10_UNORM_BLOCK:
810 case Graphics::Format::ASTC_10x10_SRGB_BLOCK:
811 case Graphics::Format::ASTC_12x10_UNORM_BLOCK:
812 case Graphics::Format::ASTC_12x10_SRGB_BLOCK:
813 case Graphics::Format::ASTC_12x12_UNORM_BLOCK:
814 case Graphics::Format::ASTC_12x12_SRGB_BLOCK:
815 case Graphics::Format::PVRTC1_2BPP_UNORM_BLOCK_IMG:
816 case Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG:
817 case Graphics::Format::PVRTC2_2BPP_UNORM_BLOCK_IMG:
818 case Graphics::Format::PVRTC2_4BPP_UNORM_BLOCK_IMG:
819 case Graphics::Format::PVRTC1_2BPP_SRGB_BLOCK_IMG:
820 case Graphics::Format::PVRTC1_4BPP_SRGB_BLOCK_IMG:
821 case Graphics::Format::PVRTC2_2BPP_SRGB_BLOCK_IMG:
822 case Graphics::Format::PVRTC2_4BPP_SRGB_BLOCK_IMG:
829 bool compressed{false};
832 struct GLSamplerFilter
834 constexpr explicit GLSamplerFilter(Graphics::SamplerFilter filter)
838 case Graphics::SamplerFilter::NEAREST:
840 glFilter = GL_NEAREST;
843 case Graphics::SamplerFilter::LINEAR:
845 glFilter = GL_LINEAR;
850 uint32_t glFilter{0};
853 struct GLSamplerFilterAndMipMapMode
855 constexpr explicit GLSamplerFilterAndMipMapMode(Graphics::SamplerFilter filter,
856 Graphics::SamplerMipmapMode mipMapMode)
860 case Graphics::SamplerFilter::NEAREST:
864 case Graphics::SamplerMipmapMode::NONE:
866 glFilter = GL_NEAREST;
869 case Graphics::SamplerMipmapMode::NEAREST:
871 glFilter = GL_NEAREST_MIPMAP_NEAREST;
874 case Graphics::SamplerMipmapMode::LINEAR:
876 glFilter = GL_NEAREST_MIPMAP_LINEAR;
883 case Graphics::SamplerFilter::LINEAR:
887 case Graphics::SamplerMipmapMode::NONE:
889 glFilter = GL_LINEAR;
892 case Graphics::SamplerMipmapMode::NEAREST:
894 glFilter = GL_LINEAR_MIPMAP_NEAREST;
897 case Graphics::SamplerMipmapMode::LINEAR:
899 glFilter = GL_LINEAR_MIPMAP_LINEAR;
908 inline explicit operator uint32_t() const
913 inline operator int() const
915 return static_cast<int>(glFilter);
918 uint32_t glFilter{0};
921 /** Converts vertex format to GL */
922 struct GLVertexFormat
924 constexpr explicit GLVertexFormat(Graphics::VertexInputFormat gfxFormat)
928 case VertexInputFormat::FVECTOR2:
934 case VertexInputFormat::FVECTOR3:
940 case VertexInputFormat::FVECTOR4:
946 case VertexInputFormat::FLOAT:
952 case VertexInputFormat::INTEGER:
958 case VertexInputFormat::IVECTOR2:
964 case VertexInputFormat::IVECTOR3:
970 case VertexInputFormat::IVECTOR4:
976 case VertexInputFormat::UNDEFINED:
989 struct GLTextureTarget
991 constexpr explicit GLTextureTarget(Graphics::TextureType graphicsTextureType)
993 switch(graphicsTextureType)
995 case Graphics::TextureType::TEXTURE_2D:
997 target = GL_TEXTURE_2D;
1000 case Graphics::TextureType::TEXTURE_3D:
1002 target = GL_TEXTURE_3D;
1005 case Graphics::TextureType::TEXTURE_CUBEMAP:
1007 target = GL_TEXTURE_CUBE_MAP;
1012 GLenum target{GL_TEXTURE_2D};
1015 struct GLAddressMode
1017 constexpr explicit GLAddressMode(Graphics::SamplerAddressMode graphicsAddressMode)
1019 switch(graphicsAddressMode)
1021 case Graphics::SamplerAddressMode::REPEAT:
1023 texParameter = GL_REPEAT;
1026 case Graphics::SamplerAddressMode::MIRRORED_REPEAT:
1028 texParameter = GL_MIRRORED_REPEAT;
1031 case Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
1033 texParameter = GL_CLAMP_TO_EDGE;
1036 case Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
1038 texParameter = GL_CLAMP_TO_EDGE;
1041 case Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
1043 texParameter = GL_CLAMP_TO_EDGE;
1048 GLenum texParameter{GL_CLAMP_TO_EDGE};
1053 constexpr explicit GLCompareOp(Graphics::CompareOp compareOp)
1057 case Graphics::CompareOp::NEVER:
1060 case Graphics::CompareOp::LESS:
1063 case Graphics::CompareOp::EQUAL:
1066 case Graphics::CompareOp::LESS_OR_EQUAL:
1069 case Graphics::CompareOp::GREATER:
1072 case Graphics::CompareOp::NOT_EQUAL:
1075 case Graphics::CompareOp::GREATER_OR_EQUAL:
1078 case Graphics::CompareOp::ALWAYS:
1088 constexpr explicit GLStencilOp(Graphics::StencilOp stencilOp)
1092 case Graphics::StencilOp::KEEP:
1095 case Graphics::StencilOp::ZERO:
1098 case Graphics::StencilOp::REPLACE:
1101 case Graphics::StencilOp::INCREMENT_AND_CLAMP:
1104 case Graphics::StencilOp::DECREMENT_AND_CLAMP:
1107 case Graphics::StencilOp::INVERT:
1110 case Graphics::StencilOp::INCREMENT_AND_WRAP:
1113 case Graphics::StencilOp::DECREMENT_AND_WRAP:
1122 * @brief Descriptor of single buffer binding within
1125 struct VertexBufferBindingDescriptor
1127 const GLES::Buffer* buffer{nullptr};
1128 uint32_t offset{0u};
1132 * @brief Descriptor of ix buffer binding within
1135 struct IndexBufferBindingDescriptor
1137 const GLES::Buffer* buffer{nullptr};
1139 Graphics::Format format{};
1143 * @brief Descriptor of uniform buffer binding within
1146 struct UniformBufferBindingDescriptor
1148 const GLES::Buffer* buffer{nullptr};
1149 uint32_t binding{0u};
1150 uint32_t offset{0u};
1151 bool emulated; ///<true if UBO is emulated for old gfx API
1155 * @brief The descriptor of draw call
1157 struct DrawCallDescriptor
1160 * @brief Enum specifying type of the draw call
1166 DRAW_INDEXED_INDIRECT,
1169 Type type{}; ///< Type of the draw call
1172 * Union contains data for all types of draw calls.
1177 * @brief Vertex array draw
1181 uint32_t vertexCount;
1182 uint32_t instanceCount;
1183 uint32_t firstVertex;
1184 uint32_t firstInstance;
1188 * @brief Indexed draw
1192 uint32_t indexCount;
1193 uint32_t instanceCount;
1194 uint32_t firstIndex;
1195 int32_t vertexOffset;
1196 uint32_t firstInstance;
1200 * @brief Indexed draw indirect
1204 const GLES::Buffer* buffer;
1208 } drawIndexedIndirect;
1213 * @brief Topologu conversion from Graphics to GLES
1217 explicit constexpr GLESTopology(PrimitiveTopology topology)
1221 case PrimitiveTopology::POINT_LIST:
1223 primitiveTopology = GL_POINTS;
1226 case PrimitiveTopology::LINE_LIST:
1228 primitiveTopology = GL_LINES;
1231 case PrimitiveTopology::LINE_LOOP:
1233 primitiveTopology = GL_LINE_LOOP;
1236 case PrimitiveTopology::LINE_STRIP:
1238 primitiveTopology = GL_LINE_STRIP;
1241 case PrimitiveTopology::TRIANGLE_LIST:
1243 primitiveTopology = GL_TRIANGLES;
1246 case PrimitiveTopology::TRIANGLE_STRIP:
1248 primitiveTopology = GL_TRIANGLE_STRIP;
1251 case PrimitiveTopology::TRIANGLE_FAN:
1253 primitiveTopology = GL_TRIANGLE_FAN;
1260 * @brief Explicit type conversion operator
1261 * @return converted value
1263 constexpr inline operator GLenum() const
1265 return primitiveTopology;
1268 GLenum primitiveTopology{0}; ///< Topology
1272 * @brief Index format conversion structure
1274 struct GLIndexFormat
1276 explicit constexpr GLIndexFormat(Format _format)
1280 // TODO: add more formats
1281 case Format::R16_UINT:
1283 format = GL_UNSIGNED_SHORT;
1286 case Format::R32_UINT:
1288 format = GL_UNSIGNED_INT;
1299 * @brief Explicit type conversion operator
1300 * @return converted value
1302 constexpr inline operator GLenum() const
1307 GLenum format{0}; ///< Converted format
1311 * @brief Conversion of blending function factor
1315 constexpr explicit GLBlendFunc(Graphics::BlendFactor factor)
1319 case Graphics::BlendFactor::ZERO:
1324 case Graphics::BlendFactor::ONE:
1329 case Graphics::BlendFactor::SRC_COLOR:
1331 glFactor = GL_SRC_COLOR;
1334 case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
1336 glFactor = GL_ONE_MINUS_SRC_COLOR;
1339 case Graphics::BlendFactor::DST_COLOR:
1341 glFactor = GL_DST_COLOR;
1344 case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
1346 glFactor = GL_ONE_MINUS_DST_COLOR;
1349 case Graphics::BlendFactor::SRC_ALPHA:
1351 glFactor = GL_SRC_ALPHA;
1354 case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
1356 glFactor = GL_ONE_MINUS_SRC_ALPHA;
1359 case Graphics::BlendFactor::DST_ALPHA:
1361 glFactor = GL_DST_ALPHA;
1364 case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
1366 glFactor = GL_ONE_MINUS_DST_ALPHA;
1369 case Graphics::BlendFactor::CONSTANT_COLOR:
1371 glFactor = GL_CONSTANT_COLOR;
1374 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
1376 glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
1379 case Graphics::BlendFactor::CONSTANT_ALPHA:
1381 glFactor = GL_CONSTANT_ALPHA;
1384 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
1386 glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
1389 case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
1391 glFactor = GL_SRC_ALPHA_SATURATE;
1394 // Below may be unsupported without extension
1395 case Graphics::BlendFactor::SRC1_COLOR:
1400 case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
1405 case Graphics::BlendFactor::SRC1_ALPHA:
1410 case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
1419 * @brief Explicit type conversion operator
1420 * @return converted value
1422 constexpr inline operator GLenum() const
1427 GLenum glFactor{0u};
1431 * @brief Converts Blend Op to GL
1435 constexpr explicit GLBlendOp(Graphics::BlendOp blendOp)
1439 case Graphics::BlendOp::ADD:
1441 glBlendOp = GL_FUNC_ADD;
1444 case Graphics::BlendOp::SUBTRACT:
1446 glBlendOp = GL_FUNC_SUBTRACT;
1449 case Graphics::BlendOp::REVERSE_SUBTRACT:
1451 glBlendOp = GL_FUNC_REVERSE_SUBTRACT;
1454 case Graphics::BlendOp::MIN:
1459 case Graphics::BlendOp::MAX:
1464 case Graphics::BlendOp::MULTIPLY:
1466 glBlendOp = GL_MULTIPLY;
1469 case Graphics::BlendOp::SCREEN:
1471 glBlendOp = GL_SCREEN;
1474 case Graphics::BlendOp::OVERLAY:
1476 glBlendOp = GL_OVERLAY;
1479 case Graphics::BlendOp::DARKEN:
1481 glBlendOp = GL_DARKEN;
1484 case Graphics::BlendOp::LIGHTEN:
1486 glBlendOp = GL_LIGHTEN;
1489 case Graphics::BlendOp::COLOR_DODGE:
1491 glBlendOp = GL_COLORDODGE;
1494 case Graphics::BlendOp::COLOR_BURN:
1496 glBlendOp = GL_COLORBURN;
1499 case Graphics::BlendOp::HARD_LIGHT:
1501 glBlendOp = GL_HARDLIGHT;
1504 case Graphics::BlendOp::SOFT_LIGHT:
1506 glBlendOp = GL_SOFTLIGHT;
1509 case Graphics::BlendOp::DIFFERENCE:
1511 glBlendOp = GL_DIFFERENCE;
1514 case Graphics::BlendOp::EXCLUSION:
1516 glBlendOp = GL_EXCLUSION;
1519 case Graphics::BlendOp::HUE:
1521 glBlendOp = GL_HSL_HUE;
1524 case Graphics::BlendOp::SATURATION:
1526 glBlendOp = GL_HSL_SATURATION;
1529 case Graphics::BlendOp::COLOR:
1531 glBlendOp = GL_HSL_COLOR;
1534 case Graphics::BlendOp::LUMINOSITY:
1536 glBlendOp = GL_HSL_LUMINOSITY;
1543 * @brief Explicit type conversion operator
1544 * @return converted value
1546 constexpr inline operator GLenum() const
1551 GLenum glBlendOp{0u};
1555 * @brief Converts GL cull mode
1559 constexpr explicit GLCullMode(Graphics::CullMode cullMode)
1563 case Graphics::CullMode::NONE: // this isn't really accepted by GL!
1565 glCullMode = GL_NONE;
1568 case Graphics::CullMode::FRONT:
1570 glCullMode = GL_FRONT;
1573 case Graphics::CullMode::BACK:
1575 glCullMode = GL_BACK;
1578 case Graphics::CullMode::FRONT_AND_BACK:
1580 glCullMode = GL_FRONT_AND_BACK;
1587 * @brief Explicit type conversion operator
1588 * @return converted value
1590 constexpr inline operator GLenum() const
1595 GLenum glCullMode{0u};
1599 * @brief enum with GL types
1604 FLOAT_VEC2 = 0x8B50,
1605 FLOAT_VEC3 = 0x8B51,
1606 FLOAT_VEC4 = 0x8B52,
1614 FLOAT_MAT2 = 0x8B5A,
1615 FLOAT_MAT3 = 0x8B5B,
1616 FLOAT_MAT4 = 0x8B5C,
1617 SAMPLER_2D = 0x8B5E,
1618 SAMPLER_CUBE = 0x8B60,
1620 UNSIGNED_BYTE = 0x1401,
1622 UNSIGNED_SHORT = 0x1403,
1624 UNSIGNED_INT = 0x1405,
1630 * @brief GL type conversion (used with reflection)
1632 struct GLTypeConversion
1634 constexpr explicit GLTypeConversion(GLenum value)
1640 type = GLType::FLOAT_VEC2;
1645 type = GLType::FLOAT_VEC3;
1650 type = GLType::FLOAT_VEC4;
1655 type = GLType::INT_VEC2;
1660 type = GLType::INT_VEC3;
1665 type = GLType::INT_VEC4;
1670 type = GLType::BOOL;
1675 type = GLType::BOOL_VEC2;
1680 type = GLType::BOOL_VEC3;
1685 type = GLType::BOOL_VEC4;
1690 type = GLType::FLOAT_MAT2;
1695 type = GLType::FLOAT_MAT3;
1700 type = GLType::FLOAT_MAT4;
1705 type = GLType::SAMPLER_2D;
1708 case GL_SAMPLER_CUBE:
1710 type = GLType::SAMPLER_CUBE;
1715 type = GLType::FLOAT;
1725 type = GLType::UNDEFINED;
1730 GLType type{GLType::UNDEFINED};
1733 enum class GLESVersion
1742 * @brief Types of bond texture cached in the context
1744 enum class BoundTextureType
1749 TEXTURE_EXTERNAL_OES
1753 * This class stores indirect pointer, used by the CommandBuffer
1754 * to store data allocated within resizeable pool
1759 uint32_t ptr; // relative pointer
1760 void** base; // base pointer
1762 inline T* operator->()
1764 return reinterpret_cast<T*>((reinterpret_cast<uint8_t*>(*base) + ptr));
1767 inline T& operator*()
1769 return *reinterpret_cast<T*>((reinterpret_cast<uint8_t*>(*base) + ptr));
1772 // Returns indirect pointer casted to requested type
1775 auto val = reinterpret_cast<T*>((reinterpret_cast<uint8_t*>(*base) + ptr));
1779 inline T& operator[](int index)
1781 return reinterpret_cast<T*>((reinterpret_cast<uint8_t*>(*base) + ptr))[index];
1784 // Fake assignment operator for void* type
1785 inline IndirectPtr<T>& operator=(void* p)
1794 * The descriptor of BeginRenderPass command
1796 struct BeginRenderPassDescriptor
1798 const GLES::RenderPass* renderPass;
1799 const GLES::RenderTarget* renderTarget;
1801 IndirectPtr<ClearValue> clearValues;
1802 uint32_t clearValuesCount;
1805 } // namespace Dali::Graphics::GLES
1807 #endif //DALI_GRAPHICS_API_TYPES_H