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:
217 case Graphics::Format::B8G8R8_SNORM:
222 case Graphics::Format::B8G8R8_USCALED:
227 case Graphics::Format::B8G8R8_SSCALED:
232 case Graphics::Format::B8G8R8_UINT:
237 case Graphics::Format::B8G8R8_SINT:
242 case Graphics::Format::B8G8R8_SRGB:
249 case Graphics::Format::R8G8B8A8_UNORM:
251 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
254 case Graphics::Format::R8G8B8A8_SNORM:
256 Assign(GL_RGBA, GL_BYTE);
259 case Graphics::Format::R8G8B8A8_USCALED:
261 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
264 case Graphics::Format::R8G8B8A8_SSCALED:
266 Assign(GL_RGBA, GL_BYTE);
269 case Graphics::Format::R8G8B8A8_UINT:
271 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
274 case Graphics::Format::R8G8B8A8_SINT:
276 Assign(GL_RGBA, GL_BYTE);
279 case Graphics::Format::R8G8B8A8_SRGB:
281 Assign(GL_RGBA, GL_BYTE);
285 // BGRA when only support GL_BGRA_EXT. otherwise, use RGBA
286 case Graphics::Format::B8G8R8A8_UNORM:
289 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
291 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
295 case Graphics::Format::B8G8R8A8_SNORM:
298 Assign(GL_BGRA_EXT, GL_BYTE);
300 Assign(GL_RGBA, GL_BYTE);
304 case Graphics::Format::B8G8R8A8_USCALED:
307 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
309 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
313 case Graphics::Format::B8G8R8A8_SSCALED:
316 Assign(GL_BGRA_EXT, GL_BYTE);
318 Assign(GL_RGBA, GL_BYTE);
322 case Graphics::Format::B8G8R8A8_UINT:
325 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
327 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
331 case Graphics::Format::B8G8R8A8_SINT:
334 Assign(GL_BGRA_EXT, GL_BYTE);
336 Assign(GL_RGBA, GL_BYTE);
340 case Graphics::Format::B8G8R8A8_SRGB:
343 Assign(GL_BGRA_EXT, GL_BYTE);
345 Assign(GL_RGBA, GL_BYTE);
350 // ABGR not supported
351 case Graphics::Format::A8B8G8R8_UNORM_PACK32:
356 case Graphics::Format::A8B8G8R8_SNORM_PACK32:
361 case Graphics::Format::A8B8G8R8_USCALED_PACK32:
366 case Graphics::Format::A8B8G8R8_SSCALED_PACK32:
371 case Graphics::Format::A8B8G8R8_UINT_PACK32:
376 case Graphics::Format::A8B8G8R8_SINT_PACK32:
381 case Graphics::Format::A8B8G8R8_SRGB_PACK32:
387 // TBD which of the formats are supported
388 case Graphics::Format::A2R10G10B10_UNORM_PACK32:
393 case Graphics::Format::A2R10G10B10_SNORM_PACK32:
398 case Graphics::Format::A2R10G10B10_USCALED_PACK32:
403 case Graphics::Format::A2R10G10B10_SSCALED_PACK32:
408 case Graphics::Format::A2R10G10B10_UINT_PACK32:
413 case Graphics::Format::A2R10G10B10_SINT_PACK32:
418 case Graphics::Format::A2B10G10R10_UNORM_PACK32:
423 case Graphics::Format::A2B10G10R10_SNORM_PACK32:
428 case Graphics::Format::A2B10G10R10_USCALED_PACK32:
433 case Graphics::Format::A2B10G10R10_SSCALED_PACK32:
438 case Graphics::Format::A2B10G10R10_UINT_PACK32:
443 case Graphics::Format::A2B10G10R10_SINT_PACK32:
448 case Graphics::Format::R16_UNORM:
453 case Graphics::Format::R16_SNORM:
458 case Graphics::Format::R16_USCALED:
463 case Graphics::Format::R16_SSCALED:
468 case Graphics::Format::R16_UINT:
473 case Graphics::Format::R16_SINT:
478 case Graphics::Format::R16_SFLOAT:
483 case Graphics::Format::R16G16_UNORM:
488 case Graphics::Format::R16G16_SNORM:
493 case Graphics::Format::R16G16_USCALED:
498 case Graphics::Format::R16G16_SSCALED:
503 case Graphics::Format::R16G16_UINT:
508 case Graphics::Format::R16G16_SINT:
513 case Graphics::Format::R16G16_SFLOAT:
518 case Graphics::Format::R16G16B16_UNORM:
523 case Graphics::Format::R16G16B16_SNORM:
528 case Graphics::Format::R16G16B16_USCALED:
533 case Graphics::Format::R16G16B16_SSCALED:
538 case Graphics::Format::R16G16B16_UINT:
543 case Graphics::Format::R16G16B16_SINT:
548 case Graphics::Format::R16G16B16_SFLOAT:
550 // GLES 3.0 floating point formats.
551 Assign(GL_RGB, GL_HALF_FLOAT);
554 case Graphics::Format::R16G16B16A16_UNORM:
559 case Graphics::Format::R16G16B16A16_SNORM:
564 case Graphics::Format::R16G16B16A16_USCALED:
569 case Graphics::Format::R16G16B16A16_SSCALED:
574 case Graphics::Format::R16G16B16A16_UINT:
579 case Graphics::Format::R16G16B16A16_SINT:
584 case Graphics::Format::R16G16B16A16_SFLOAT:
589 case Graphics::Format::R32_UINT:
594 case Graphics::Format::R32_SINT:
599 case Graphics::Format::R32_SFLOAT:
604 case Graphics::Format::R32G32_UINT:
609 case Graphics::Format::R32G32_SINT:
614 case Graphics::Format::R32G32_SFLOAT:
619 case Graphics::Format::R32G32B32_UINT:
624 case Graphics::Format::R32G32B32_SINT:
629 case Graphics::Format::R32G32B32_SFLOAT:
631 // GLES 3.0 floating point formats.
632 Assign(GL_RGB, GL_FLOAT);
635 case Graphics::Format::R32G32B32A32_UINT:
640 case Graphics::Format::R32G32B32A32_SINT:
645 case Graphics::Format::R32G32B32A32_SFLOAT:
650 case Graphics::Format::R64_UINT:
655 case Graphics::Format::R64_SINT:
660 case Graphics::Format::R64_SFLOAT:
665 case Graphics::Format::R64G64_UINT:
670 case Graphics::Format::R64G64_SINT:
675 case Graphics::Format::R64G64_SFLOAT:
680 case Graphics::Format::R64G64B64_UINT:
685 case Graphics::Format::R64G64B64_SINT:
690 case Graphics::Format::R64G64B64_SFLOAT:
695 case Graphics::Format::R64G64B64A64_UINT:
700 case Graphics::Format::R64G64B64A64_SINT:
705 case Graphics::Format::R64G64B64A64_SFLOAT:
710 case Graphics::Format::B10G11R11_UFLOAT_PACK32:
715 case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
720 case Graphics::Format::D16_UNORM:
722 // GLES 3.0 depth and stencil formats
723 Assign(GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
726 case Graphics::Format::X8_D24_UNORM_PACK32:
731 case Graphics::Format::D32_SFLOAT:
733 // GLES 3.0 depth and stencil formats
734 Assign(GL_DEPTH_COMPONENT, GL_FLOAT);
737 case Graphics::Format::S8_UINT:
742 case Graphics::Format::D16_UNORM_S8_UINT:
747 case Graphics::Format::D24_UNORM_S8_UINT:
749 // GLES 3.0 depth and stencil formats
750 Assign(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
753 case Graphics::Format::D32_SFLOAT_S8_UINT:
758 case Graphics::Format::BC1_RGB_UNORM_BLOCK:
763 case Graphics::Format::BC1_RGB_SRGB_BLOCK:
768 case Graphics::Format::BC1_RGBA_UNORM_BLOCK:
773 case Graphics::Format::BC1_RGBA_SRGB_BLOCK:
778 case Graphics::Format::BC2_UNORM_BLOCK:
783 case Graphics::Format::BC2_SRGB_BLOCK:
788 case Graphics::Format::BC3_UNORM_BLOCK:
793 case Graphics::Format::BC3_SRGB_BLOCK:
798 case Graphics::Format::BC4_UNORM_BLOCK:
803 case Graphics::Format::BC4_SNORM_BLOCK:
808 case Graphics::Format::BC5_UNORM_BLOCK:
813 case Graphics::Format::BC5_SNORM_BLOCK:
818 case Graphics::Format::BC6H_UFLOAT_BLOCK:
823 case Graphics::Format::BC6H_SFLOAT_BLOCK:
828 case Graphics::Format::BC7_UNORM_BLOCK:
833 case Graphics::Format::BC7_SRGB_BLOCK:
838 case Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK:
840 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.
841 Assign(GL_COMPRESSED_RGB8_ETC2, 0);
844 case Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK:
846 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.
847 Assign(GL_COMPRESSED_SRGB8_ETC2, 0);
850 case Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK:
852 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.
853 Assign(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 0);
856 case Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK:
858 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.
859 Assign(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 0);
862 case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK:
867 case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK:
872 case Graphics::Format::EAC_R11_UNORM_BLOCK:
874 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.
875 Assign(GL_COMPRESSED_R11_EAC, 0);
878 case Graphics::Format::EAC_R11_SNORM_BLOCK:
880 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.
881 Assign(GL_COMPRESSED_SIGNED_R11_EAC, 0);
884 case Graphics::Format::EAC_R11G11_UNORM_BLOCK:
886 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.
887 Assign(GL_COMPRESSED_RG11_EAC, 0);
890 case Graphics::Format::EAC_R11G11_SNORM_BLOCK:
892 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.
893 Assign(GL_COMPRESSED_SIGNED_RG11_EAC, 0);
896 case Graphics::Format::ASTC_4x4_UNORM_BLOCK:
898 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.
899 Assign(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 0);
902 case Graphics::Format::ASTC_4x4_SRGB_BLOCK:
904 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.
905 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 0);
908 case Graphics::Format::ASTC_5x4_UNORM_BLOCK:
910 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.
911 Assign(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 0);
914 case Graphics::Format::ASTC_5x4_SRGB_BLOCK:
916 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.
917 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 0);
920 case Graphics::Format::ASTC_5x5_UNORM_BLOCK:
922 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.
923 Assign(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 0);
926 case Graphics::Format::ASTC_5x5_SRGB_BLOCK:
928 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.
929 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 0);
932 case Graphics::Format::ASTC_6x5_UNORM_BLOCK:
934 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.
935 Assign(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 0);
938 case Graphics::Format::ASTC_6x5_SRGB_BLOCK:
940 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.
941 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 0);
944 case Graphics::Format::ASTC_6x6_UNORM_BLOCK:
946 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.
947 Assign(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 0);
950 case Graphics::Format::ASTC_6x6_SRGB_BLOCK:
952 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.
953 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 0);
956 case Graphics::Format::ASTC_8x5_UNORM_BLOCK:
958 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.
959 Assign(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 0);
962 case Graphics::Format::ASTC_8x5_SRGB_BLOCK:
964 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.
965 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 0);
968 case Graphics::Format::ASTC_8x6_UNORM_BLOCK:
970 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.
971 Assign(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 0);
974 case Graphics::Format::ASTC_8x6_SRGB_BLOCK:
976 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.
977 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 0);
980 case Graphics::Format::ASTC_8x8_UNORM_BLOCK:
982 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.
983 Assign(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 0);
986 case Graphics::Format::ASTC_8x8_SRGB_BLOCK:
988 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.
989 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 0);
992 case Graphics::Format::ASTC_10x5_UNORM_BLOCK:
994 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.
995 Assign(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 0);
998 case Graphics::Format::ASTC_10x5_SRGB_BLOCK:
1000 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.
1001 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 0);
1004 case Graphics::Format::ASTC_10x6_UNORM_BLOCK:
1006 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.
1007 Assign(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 0);
1010 case Graphics::Format::ASTC_10x6_SRGB_BLOCK:
1012 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.
1013 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 0);
1016 case Graphics::Format::ASTC_10x8_UNORM_BLOCK:
1018 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.
1019 Assign(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 0);
1022 case Graphics::Format::ASTC_10x8_SRGB_BLOCK:
1024 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.
1025 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 0);
1028 case Graphics::Format::ASTC_10x10_UNORM_BLOCK:
1030 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.
1031 Assign(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 0);
1034 case Graphics::Format::ASTC_10x10_SRGB_BLOCK:
1036 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.
1037 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 0);
1040 case Graphics::Format::ASTC_12x10_UNORM_BLOCK:
1042 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.
1043 Assign(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 0);
1046 case Graphics::Format::ASTC_12x10_SRGB_BLOCK:
1048 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.
1049 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 0);
1052 case Graphics::Format::ASTC_12x12_UNORM_BLOCK:
1054 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.
1055 Assign(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 0);
1058 case Graphics::Format::ASTC_12x12_SRGB_BLOCK:
1060 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.
1061 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 0);
1064 case Graphics::Format::PVRTC1_2BPP_UNORM_BLOCK_IMG:
1069 case Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG:
1071 ///! Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.
1072 Assign(0x8C00, 0); ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
1076 case Graphics::Format::PVRTC2_2BPP_UNORM_BLOCK_IMG:
1081 case Graphics::Format::PVRTC2_4BPP_UNORM_BLOCK_IMG:
1086 case Graphics::Format::PVRTC1_2BPP_SRGB_BLOCK_IMG:
1091 case Graphics::Format::PVRTC1_4BPP_SRGB_BLOCK_IMG:
1096 case Graphics::Format::PVRTC2_2BPP_SRGB_BLOCK_IMG:
1101 case Graphics::Format::PVRTC2_4BPP_SRGB_BLOCK_IMG:
1109 constexpr inline void Assign(uint32_t f, uint32_t t)
1119 struct GLSamplerFilter
1121 constexpr explicit GLSamplerFilter(Graphics::SamplerFilter filter)
1125 case Graphics::SamplerFilter::NEAREST:
1127 glFilter = GL_NEAREST;
1130 case Graphics::SamplerFilter::LINEAR:
1132 glFilter = GL_LINEAR;
1137 uint32_t glFilter{0};
1140 struct GLSamplerFilterAndMipMapMode
1142 constexpr explicit GLSamplerFilterAndMipMapMode(Graphics::SamplerFilter filter,
1143 Graphics::SamplerMipmapMode mipMapMode)
1147 case Graphics::SamplerFilter::NEAREST:
1151 case Graphics::SamplerMipmapMode::NONE:
1153 glFilter = GL_NEAREST;
1156 case Graphics::SamplerMipmapMode::NEAREST:
1158 glFilter = GL_NEAREST_MIPMAP_NEAREST;
1161 case Graphics::SamplerMipmapMode::LINEAR:
1163 glFilter = GL_NEAREST_MIPMAP_LINEAR;
1170 case Graphics::SamplerFilter::LINEAR:
1174 case Graphics::SamplerMipmapMode::NONE:
1176 glFilter = GL_LINEAR;
1179 case Graphics::SamplerMipmapMode::NEAREST:
1181 glFilter = GL_LINEAR_MIPMAP_NEAREST;
1184 case Graphics::SamplerMipmapMode::LINEAR:
1186 glFilter = GL_LINEAR_MIPMAP_LINEAR;
1195 inline explicit operator uint32_t() const
1200 inline operator int() const
1202 return static_cast<int>(glFilter);
1205 uint32_t glFilter{0};
1208 /** Converts vertex format to GL */
1209 struct GLVertexFormat
1211 constexpr explicit GLVertexFormat(Graphics::VertexInputFormat gfxFormat)
1215 case VertexInputFormat::FVECTOR2:
1221 case VertexInputFormat::FVECTOR3:
1227 case VertexInputFormat::FVECTOR4:
1233 case VertexInputFormat::FLOAT:
1239 case VertexInputFormat::INTEGER:
1245 case VertexInputFormat::IVECTOR2:
1251 case VertexInputFormat::IVECTOR3:
1257 case VertexInputFormat::IVECTOR4:
1263 case VertexInputFormat::UNDEFINED:
1276 struct GLTextureTarget
1278 constexpr explicit GLTextureTarget(Graphics::TextureType graphicsTextureType)
1280 switch(graphicsTextureType)
1282 case Graphics::TextureType::TEXTURE_2D:
1284 target = GL_TEXTURE_2D;
1287 case Graphics::TextureType::TEXTURE_3D:
1289 target = GL_TEXTURE_3D;
1292 case Graphics::TextureType::TEXTURE_CUBEMAP:
1294 target = GL_TEXTURE_CUBE_MAP;
1299 GLenum target{GL_TEXTURE_2D};
1302 struct GLAddressMode
1304 constexpr explicit GLAddressMode(Graphics::SamplerAddressMode graphicsAddressMode)
1306 switch(graphicsAddressMode)
1308 case Graphics::SamplerAddressMode::REPEAT:
1310 texParameter = GL_REPEAT;
1313 case Graphics::SamplerAddressMode::MIRRORED_REPEAT:
1315 texParameter = GL_MIRRORED_REPEAT;
1318 case Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
1320 texParameter = GL_CLAMP_TO_EDGE;
1323 case Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
1325 texParameter = GL_CLAMP_TO_EDGE;
1328 case Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
1330 texParameter = GL_CLAMP_TO_EDGE;
1335 GLenum texParameter{GL_CLAMP_TO_EDGE};
1340 constexpr explicit GLCompareOp(Graphics::CompareOp compareOp)
1344 case Graphics::CompareOp::NEVER:
1347 case Graphics::CompareOp::LESS:
1350 case Graphics::CompareOp::EQUAL:
1353 case Graphics::CompareOp::LESS_OR_EQUAL:
1356 case Graphics::CompareOp::GREATER:
1359 case Graphics::CompareOp::NOT_EQUAL:
1362 case Graphics::CompareOp::GREATER_OR_EQUAL:
1365 case Graphics::CompareOp::ALWAYS:
1375 constexpr explicit GLStencilOp(Graphics::StencilOp stencilOp)
1379 case Graphics::StencilOp::KEEP:
1382 case Graphics::StencilOp::ZERO:
1385 case Graphics::StencilOp::REPLACE:
1388 case Graphics::StencilOp::INCREMENT_AND_CLAMP:
1391 case Graphics::StencilOp::DECREMENT_AND_CLAMP:
1394 case Graphics::StencilOp::INVERT:
1397 case Graphics::StencilOp::INCREMENT_AND_WRAP:
1400 case Graphics::StencilOp::DECREMENT_AND_WRAP:
1409 * @brief Descriptor of single buffer binding within
1412 struct VertexBufferBindingDescriptor
1414 const GLES::Buffer* buffer{nullptr};
1415 uint32_t offset{0u};
1419 * @brief Descriptor of ix buffer binding within
1422 struct IndexBufferBindingDescriptor
1424 const GLES::Buffer* buffer{nullptr};
1426 Graphics::Format format{};
1430 * @brief Descriptor of uniform buffer binding within
1433 struct UniformBufferBindingDescriptor
1435 const GLES::Buffer* buffer{nullptr};
1436 uint32_t binding{0u};
1437 uint32_t offset{0u};
1438 bool emulated; ///<true if UBO is emulated for old gfx API
1442 * @brief The descriptor of draw call
1444 struct DrawCallDescriptor
1447 * @brief Enum specifying type of the draw call
1453 DRAW_INDEXED_INDIRECT
1456 Type type{}; ///< Type of the draw call
1459 * Union contains data for all types of draw calls.
1464 * @brief Vertex array draw
1468 uint32_t vertexCount;
1469 uint32_t instanceCount;
1470 uint32_t firstVertex;
1471 uint32_t firstInstance;
1475 * @brief Indexed draw
1479 uint32_t indexCount;
1480 uint32_t instanceCount;
1481 uint32_t firstIndex;
1482 int32_t vertexOffset;
1483 uint32_t firstInstance;
1487 * @brief Indexed draw indirect
1491 const GLES::Buffer* buffer;
1495 } drawIndexedIndirect;
1500 * @brief Topologu conversion from Graphics to GLES
1504 explicit constexpr GLESTopology(PrimitiveTopology topology)
1508 case PrimitiveTopology::POINT_LIST:
1510 primitiveTopology = GL_POINTS;
1513 case PrimitiveTopology::LINE_LIST:
1515 primitiveTopology = GL_LINES;
1518 case PrimitiveTopology::LINE_LOOP:
1520 primitiveTopology = GL_LINE_LOOP;
1523 case PrimitiveTopology::LINE_STRIP:
1525 primitiveTopology = GL_LINE_STRIP;
1528 case PrimitiveTopology::TRIANGLE_LIST:
1530 primitiveTopology = GL_TRIANGLES;
1533 case PrimitiveTopology::TRIANGLE_STRIP:
1535 primitiveTopology = GL_TRIANGLE_STRIP;
1538 case PrimitiveTopology::TRIANGLE_FAN:
1540 primitiveTopology = GL_TRIANGLE_FAN;
1547 * @brief Explicit type conversion operator
1548 * @return converted value
1550 constexpr inline operator GLenum() const
1552 return primitiveTopology;
1555 GLenum primitiveTopology{0}; ///< Topology
1559 * @brief Index format conversion structure
1561 struct GLIndexFormat
1563 explicit constexpr GLIndexFormat(Format _format)
1567 // TODO: add more formats
1568 case Format::R16_UINT:
1570 format = GL_UNSIGNED_SHORT;
1581 * @brief Explicit type conversion operator
1582 * @return converted value
1584 constexpr inline operator GLenum() const
1589 GLenum format{0}; ///< Converted format
1593 * @brief Conversion of blending function factor
1597 constexpr explicit GLBlendFunc(Graphics::BlendFactor factor)
1601 case Graphics::BlendFactor::ZERO:
1606 case Graphics::BlendFactor::ONE:
1611 case Graphics::BlendFactor::SRC_COLOR:
1613 glFactor = GL_SRC_COLOR;
1616 case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
1618 glFactor = GL_ONE_MINUS_SRC_COLOR;
1621 case Graphics::BlendFactor::DST_COLOR:
1623 glFactor = GL_DST_COLOR;
1626 case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
1628 glFactor = GL_ONE_MINUS_DST_COLOR;
1631 case Graphics::BlendFactor::SRC_ALPHA:
1633 glFactor = GL_SRC_ALPHA;
1636 case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
1638 glFactor = GL_ONE_MINUS_SRC_ALPHA;
1641 case Graphics::BlendFactor::DST_ALPHA:
1643 glFactor = GL_DST_ALPHA;
1646 case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
1648 glFactor = GL_ONE_MINUS_DST_ALPHA;
1651 case Graphics::BlendFactor::CONSTANT_COLOR:
1653 glFactor = GL_CONSTANT_COLOR;
1656 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
1658 glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
1661 case Graphics::BlendFactor::CONSTANT_ALPHA:
1663 glFactor = GL_CONSTANT_ALPHA;
1666 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
1668 glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
1671 case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
1673 glFactor = GL_SRC_ALPHA_SATURATE;
1676 // Below may be unsupported without extension
1677 case Graphics::BlendFactor::SRC1_COLOR:
1682 case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
1687 case Graphics::BlendFactor::SRC1_ALPHA:
1692 case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
1701 * @brief Explicit type conversion operator
1702 * @return converted value
1704 constexpr inline operator GLenum() const
1709 GLenum glFactor{0u};
1713 * @brief Converts Blend Op to GL
1717 constexpr explicit GLBlendOp(Graphics::BlendOp blendOp)
1721 case Graphics::BlendOp::ADD:
1723 glBlendOp = GL_FUNC_ADD;
1726 case Graphics::BlendOp::SUBTRACT:
1728 glBlendOp = GL_FUNC_SUBTRACT;
1731 case Graphics::BlendOp::REVERSE_SUBTRACT:
1733 glBlendOp = GL_FUNC_REVERSE_SUBTRACT;
1736 case Graphics::BlendOp::MIN:
1741 case Graphics::BlendOp::MAX:
1750 * @brief Explicit type conversion operator
1751 * @return converted value
1753 constexpr inline operator GLenum() const
1758 GLenum glBlendOp{0u};
1762 * @brief Converts GL cull mode
1766 constexpr explicit GLCullMode(Graphics::CullMode cullMode)
1770 case Graphics::CullMode::NONE: // this isn't really accepted by GL!
1772 glCullMode = GL_NONE;
1775 case Graphics::CullMode::FRONT:
1777 glCullMode = GL_FRONT;
1780 case Graphics::CullMode::BACK:
1782 glCullMode = GL_BACK;
1785 case Graphics::CullMode::FRONT_AND_BACK:
1787 glCullMode = GL_FRONT_AND_BACK;
1794 * @brief Explicit type conversion operator
1795 * @return converted value
1797 constexpr inline operator GLenum() const
1802 GLenum glCullMode{0u};
1806 * @brief enum with GL types
1811 FLOAT_VEC2 = 0x8B50,
1812 FLOAT_VEC3 = 0x8B51,
1813 FLOAT_VEC4 = 0x8B52,
1821 FLOAT_MAT2 = 0x8B5A,
1822 FLOAT_MAT3 = 0x8B5B,
1823 FLOAT_MAT4 = 0x8B5C,
1824 SAMPLER_2D = 0x8B5E,
1825 SAMPLER_CUBE = 0x8B60,
1827 UNSIGNED_BYTE = 0x1401,
1829 UNSIGNED_SHORT = 0x1403,
1831 UNSIGNED_INT = 0x1405,
1837 * @brief GL type conversion (used with reflection)
1839 struct GLTypeConversion
1841 constexpr explicit GLTypeConversion(GLenum value)
1847 type = GLType::FLOAT_VEC2;
1852 type = GLType::FLOAT_VEC3;
1857 type = GLType::FLOAT_VEC4;
1862 type = GLType::INT_VEC2;
1867 type = GLType::INT_VEC3;
1872 type = GLType::INT_VEC4;
1877 type = GLType::BOOL;
1882 type = GLType::BOOL_VEC2;
1887 type = GLType::BOOL_VEC3;
1892 type = GLType::BOOL_VEC4;
1897 type = GLType::FLOAT_MAT2;
1902 type = GLType::FLOAT_MAT3;
1907 type = GLType::FLOAT_MAT4;
1912 type = GLType::SAMPLER_2D;
1915 case GL_SAMPLER_CUBE:
1917 type = GLType::SAMPLER_CUBE;
1922 type = GLType::FLOAT;
1927 type = GLType::UNDEFINED;
1932 GLType type{GLType::UNDEFINED};
1935 enum class GLESVersion
1944 * The descriptor of BeginRenderPass command
1946 struct BeginRenderPassDescriptor
1948 const GLES::RenderPass* renderPass{};
1949 const GLES::RenderTarget* renderTarget{};
1950 Rect2D renderArea{};
1951 std::vector<ClearValue> clearValues{};
1954 } // namespace Dali::Graphics::GLES
1956 #endif //DALI_GRAPHICS_API_TYPES_H