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
12 // Conversion functions
14 * Stucture delivers format and type that can be used
15 * when creating GL texture
17 struct GLTextureFormatType
20 * Constuctor from Graphics::Format
23 constexpr GLTextureFormatType(Graphics::Format value)
28 case Graphics::Format::UNDEFINED:
35 case Graphics::Format::L8:
37 Assign(GL_LUMINANCE, GL_UNSIGNED_BYTE);
40 case Graphics::Format::L8A8:
42 Assign(GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE);
46 // Packed formats (TODO: find supported)
47 case Graphics::Format::R4G4_UNORM_PACK8:
52 case Graphics::Format::R4G4B4A4_UNORM_PACK16:
54 Assign(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
57 case Graphics::Format::B4G4R4A4_UNORM_PACK16:
60 Assign(GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4);
62 Assign(GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4);
66 case Graphics::Format::R5G6B5_UNORM_PACK16:
68 Assign(GL_RGB, GL_UNSIGNED_SHORT_5_6_5);
71 case Graphics::Format::B5G6R5_UNORM_PACK16:
74 Assign(GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5);
76 Assign(GL_RGBA, GL_UNSIGNED_SHORT_5_6_5);
80 case Graphics::Format::R5G5B5A1_UNORM_PACK16:
82 Assign(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
85 case Graphics::Format::B5G5R5A1_UNORM_PACK16:
88 Assign(GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_5_5_1);
90 Assign(GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1);
94 case Graphics::Format::A1R5G5B5_UNORM_PACK16:
101 case Graphics::Format::R8_UNORM:
103 Assign(GL_RED, GL_UNSIGNED_BYTE);
106 case Graphics::Format::R8_SNORM:
108 Assign(GL_RED, GL_BYTE);
111 case Graphics::Format::R8_USCALED:
113 Assign(GL_RED, GL_UNSIGNED_BYTE);
116 case Graphics::Format::R8_SSCALED:
118 Assign(GL_RED, GL_BYTE);
121 case Graphics::Format::R8_UINT:
123 Assign(GL_RED, GL_UNSIGNED_BYTE);
126 case Graphics::Format::R8_SINT:
128 Assign(GL_RED, GL_BYTE);
131 case Graphics::Format::R8_SRGB:
133 Assign(GL_RED, GL_BYTE);
136 case Graphics::Format::R8G8_UNORM:
138 Assign(GL_RG, GL_UNSIGNED_BYTE);
141 case Graphics::Format::R8G8_SNORM:
143 Assign(GL_RG, GL_BYTE);
146 case Graphics::Format::R8G8_USCALED:
148 Assign(GL_RG, GL_UNSIGNED_BYTE);
151 case Graphics::Format::R8G8_SSCALED:
153 Assign(GL_RG, GL_BYTE);
156 case Graphics::Format::R8G8_UINT:
158 Assign(GL_RG, GL_UNSIGNED_BYTE);
161 case Graphics::Format::R8G8_SINT:
163 Assign(GL_RG, GL_BYTE);
166 case Graphics::Format::R8G8_SRGB:
168 Assign(GL_RG, GL_BYTE);
171 case Graphics::Format::R8G8B8_UNORM:
173 Assign(GL_RGB, GL_UNSIGNED_BYTE);
176 case Graphics::Format::R8G8B8_SNORM:
178 Assign(GL_RGB, GL_BYTE);
181 case Graphics::Format::R8G8B8_USCALED:
183 Assign(GL_RGB, GL_UNSIGNED_BYTE);
186 case Graphics::Format::R8G8B8_SSCALED:
188 Assign(GL_RGB, GL_BYTE);
191 case Graphics::Format::R8G8B8_UINT:
193 Assign(GL_RGB, GL_UNSIGNED_BYTE);
196 case Graphics::Format::R8G8B8_SINT:
198 Assign(GL_RGB, GL_BYTE);
201 case Graphics::Format::R8G8B8_SRGB:
203 Assign(GL_RGB, GL_BYTE);
207 // BGR not supported in GLES
208 case Graphics::Format::B8G8R8_UNORM:
213 case Graphics::Format::B8G8R8_SNORM:
218 case Graphics::Format::B8G8R8_USCALED:
223 case Graphics::Format::B8G8R8_SSCALED:
228 case Graphics::Format::B8G8R8_UINT:
233 case Graphics::Format::B8G8R8_SINT:
238 case Graphics::Format::B8G8R8_SRGB:
245 case Graphics::Format::R8G8B8A8_UNORM:
247 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
250 case Graphics::Format::R8G8B8A8_SNORM:
252 Assign(GL_RGBA, GL_BYTE);
255 case Graphics::Format::R8G8B8A8_USCALED:
257 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
260 case Graphics::Format::R8G8B8A8_SSCALED:
262 Assign(GL_RGBA, GL_BYTE);
265 case Graphics::Format::R8G8B8A8_UINT:
267 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
270 case Graphics::Format::R8G8B8A8_SINT:
272 Assign(GL_RGBA, GL_BYTE);
275 case Graphics::Format::R8G8B8A8_SRGB:
277 Assign(GL_RGBA, GL_BYTE);
281 // BGRA when only support GL_BGRA_EXT. otherwise, use RGBA
282 case Graphics::Format::B8G8R8A8_UNORM:
285 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
287 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
291 case Graphics::Format::B8G8R8A8_SNORM:
294 Assign(GL_BGRA_EXT, GL_BYTE);
296 Assign(GL_RGBA, GL_BYTE);
300 case Graphics::Format::B8G8R8A8_USCALED:
303 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
305 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
309 case Graphics::Format::B8G8R8A8_SSCALED:
312 Assign(GL_BGRA_EXT, GL_BYTE);
314 Assign(GL_RGBA, GL_BYTE);
318 case Graphics::Format::B8G8R8A8_UINT:
321 Assign(GL_BGRA_EXT, GL_UNSIGNED_BYTE);
323 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
327 case Graphics::Format::B8G8R8A8_SINT:
330 Assign(GL_BGRA_EXT, GL_BYTE);
332 Assign(GL_RGBA, GL_BYTE);
336 case Graphics::Format::B8G8R8A8_SRGB:
339 Assign(GL_BGRA_EXT, GL_BYTE);
341 Assign(GL_RGBA, GL_BYTE);
346 // ABGR not supported
347 case Graphics::Format::A8B8G8R8_UNORM_PACK32:
352 case Graphics::Format::A8B8G8R8_SNORM_PACK32:
357 case Graphics::Format::A8B8G8R8_USCALED_PACK32:
362 case Graphics::Format::A8B8G8R8_SSCALED_PACK32:
367 case Graphics::Format::A8B8G8R8_UINT_PACK32:
372 case Graphics::Format::A8B8G8R8_SINT_PACK32:
377 case Graphics::Format::A8B8G8R8_SRGB_PACK32:
383 // TBD which of the formats are supported
384 case Graphics::Format::A2R10G10B10_UNORM_PACK32:
389 case Graphics::Format::A2R10G10B10_SNORM_PACK32:
394 case Graphics::Format::A2R10G10B10_USCALED_PACK32:
399 case Graphics::Format::A2R10G10B10_SSCALED_PACK32:
404 case Graphics::Format::A2R10G10B10_UINT_PACK32:
409 case Graphics::Format::A2R10G10B10_SINT_PACK32:
414 case Graphics::Format::A2B10G10R10_UNORM_PACK32:
419 case Graphics::Format::A2B10G10R10_SNORM_PACK32:
424 case Graphics::Format::A2B10G10R10_USCALED_PACK32:
429 case Graphics::Format::A2B10G10R10_SSCALED_PACK32:
434 case Graphics::Format::A2B10G10R10_UINT_PACK32:
439 case Graphics::Format::A2B10G10R10_SINT_PACK32:
444 case Graphics::Format::R16_UNORM:
449 case Graphics::Format::R16_SNORM:
454 case Graphics::Format::R16_USCALED:
459 case Graphics::Format::R16_SSCALED:
464 case Graphics::Format::R16_UINT:
469 case Graphics::Format::R16_SINT:
474 case Graphics::Format::R16_SFLOAT:
479 case Graphics::Format::R16G16_UNORM:
484 case Graphics::Format::R16G16_SNORM:
489 case Graphics::Format::R16G16_USCALED:
494 case Graphics::Format::R16G16_SSCALED:
499 case Graphics::Format::R16G16_UINT:
504 case Graphics::Format::R16G16_SINT:
509 case Graphics::Format::R16G16_SFLOAT:
514 case Graphics::Format::R16G16B16_UNORM:
519 case Graphics::Format::R16G16B16_SNORM:
524 case Graphics::Format::R16G16B16_USCALED:
529 case Graphics::Format::R16G16B16_SSCALED:
534 case Graphics::Format::R16G16B16_UINT:
539 case Graphics::Format::R16G16B16_SINT:
544 case Graphics::Format::R16G16B16_SFLOAT:
546 // GLES 3.0 floating point formats.
547 Assign(GL_RGB, GL_HALF_FLOAT);
550 case Graphics::Format::R16G16B16A16_UNORM:
555 case Graphics::Format::R16G16B16A16_SNORM:
560 case Graphics::Format::R16G16B16A16_USCALED:
565 case Graphics::Format::R16G16B16A16_SSCALED:
570 case Graphics::Format::R16G16B16A16_UINT:
575 case Graphics::Format::R16G16B16A16_SINT:
580 case Graphics::Format::R16G16B16A16_SFLOAT:
585 case Graphics::Format::R32_UINT:
590 case Graphics::Format::R32_SINT:
595 case Graphics::Format::R32_SFLOAT:
600 case Graphics::Format::R32G32_UINT:
605 case Graphics::Format::R32G32_SINT:
610 case Graphics::Format::R32G32_SFLOAT:
615 case Graphics::Format::R32G32B32_UINT:
620 case Graphics::Format::R32G32B32_SINT:
625 case Graphics::Format::R32G32B32_SFLOAT:
627 // GLES 3.0 floating point formats.
628 Assign(GL_RGB, GL_FLOAT);
631 case Graphics::Format::R32G32B32A32_UINT:
636 case Graphics::Format::R32G32B32A32_SINT:
641 case Graphics::Format::R32G32B32A32_SFLOAT:
646 case Graphics::Format::R64_UINT:
651 case Graphics::Format::R64_SINT:
656 case Graphics::Format::R64_SFLOAT:
661 case Graphics::Format::R64G64_UINT:
666 case Graphics::Format::R64G64_SINT:
671 case Graphics::Format::R64G64_SFLOAT:
676 case Graphics::Format::R64G64B64_UINT:
681 case Graphics::Format::R64G64B64_SINT:
686 case Graphics::Format::R64G64B64_SFLOAT:
691 case Graphics::Format::R64G64B64A64_UINT:
696 case Graphics::Format::R64G64B64A64_SINT:
701 case Graphics::Format::R64G64B64A64_SFLOAT:
706 case Graphics::Format::B10G11R11_UFLOAT_PACK32:
711 case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
716 case Graphics::Format::D16_UNORM:
718 // GLES 3.0 depth and stencil formats
719 Assign(GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
722 case Graphics::Format::X8_D24_UNORM_PACK32:
727 case Graphics::Format::D32_SFLOAT:
729 // GLES 3.0 depth and stencil formats
730 Assign(GL_DEPTH_COMPONENT, GL_FLOAT);
733 case Graphics::Format::S8_UINT:
738 case Graphics::Format::D16_UNORM_S8_UINT:
743 case Graphics::Format::D24_UNORM_S8_UINT:
745 // GLES 3.0 depth and stencil formats
746 Assign(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
749 case Graphics::Format::D32_SFLOAT_S8_UINT:
754 case Graphics::Format::BC1_RGB_UNORM_BLOCK:
759 case Graphics::Format::BC1_RGB_SRGB_BLOCK:
764 case Graphics::Format::BC1_RGBA_UNORM_BLOCK:
769 case Graphics::Format::BC1_RGBA_SRGB_BLOCK:
774 case Graphics::Format::BC2_UNORM_BLOCK:
779 case Graphics::Format::BC2_SRGB_BLOCK:
784 case Graphics::Format::BC3_UNORM_BLOCK:
789 case Graphics::Format::BC3_SRGB_BLOCK:
794 case Graphics::Format::BC4_UNORM_BLOCK:
799 case Graphics::Format::BC4_SNORM_BLOCK:
804 case Graphics::Format::BC5_UNORM_BLOCK:
809 case Graphics::Format::BC5_SNORM_BLOCK:
814 case Graphics::Format::BC6H_UFLOAT_BLOCK:
819 case Graphics::Format::BC6H_SFLOAT_BLOCK:
824 case Graphics::Format::BC7_UNORM_BLOCK:
829 case Graphics::Format::BC7_SRGB_BLOCK:
834 case Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK:
836 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.
837 Assign(GL_COMPRESSED_RGB8_ETC2, 0);
840 case Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK:
842 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.
843 Assign(GL_COMPRESSED_SRGB8_ETC2, 0);
846 case Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK:
848 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.
849 Assign(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 0);
852 case Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK:
854 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.
855 Assign(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 0);
858 case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK:
863 case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK:
868 case Graphics::Format::EAC_R11_UNORM_BLOCK:
870 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_R11_EAC.
871 Assign(GL_COMPRESSED_R11_EAC, 0);
874 case Graphics::Format::EAC_R11_SNORM_BLOCK:
876 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.
877 Assign(GL_COMPRESSED_SIGNED_R11_EAC, 0);
880 case Graphics::Format::EAC_R11G11_UNORM_BLOCK:
882 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.
883 Assign(GL_COMPRESSED_RG11_EAC, 0);
886 case Graphics::Format::EAC_R11G11_SNORM_BLOCK:
888 ///! Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.
889 Assign(GL_COMPRESSED_SIGNED_RG11_EAC, 0);
892 case Graphics::Format::ASTC_4x4_UNORM_BLOCK:
894 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.
895 Assign(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 0);
898 case Graphics::Format::ASTC_4x4_SRGB_BLOCK:
900 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.
901 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 0);
904 case Graphics::Format::ASTC_5x4_UNORM_BLOCK:
906 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.
907 Assign(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 0);
910 case Graphics::Format::ASTC_5x4_SRGB_BLOCK:
912 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.
913 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 0);
916 case Graphics::Format::ASTC_5x5_UNORM_BLOCK:
918 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.
919 Assign(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 0);
922 case Graphics::Format::ASTC_5x5_SRGB_BLOCK:
924 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.
925 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 0);
928 case Graphics::Format::ASTC_6x5_UNORM_BLOCK:
930 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.
931 Assign(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 0);
934 case Graphics::Format::ASTC_6x5_SRGB_BLOCK:
936 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.
937 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 0);
940 case Graphics::Format::ASTC_6x6_UNORM_BLOCK:
942 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.
943 Assign(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 0);
946 case Graphics::Format::ASTC_6x6_SRGB_BLOCK:
948 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.
949 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 0);
952 case Graphics::Format::ASTC_8x5_UNORM_BLOCK:
954 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.
955 Assign(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 0);
958 case Graphics::Format::ASTC_8x5_SRGB_BLOCK:
960 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.
961 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 0);
964 case Graphics::Format::ASTC_8x6_UNORM_BLOCK:
966 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.
967 Assign(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 0);
970 case Graphics::Format::ASTC_8x6_SRGB_BLOCK:
972 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.
973 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 0);
976 case Graphics::Format::ASTC_8x8_UNORM_BLOCK:
978 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.
979 Assign(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 0);
982 case Graphics::Format::ASTC_8x8_SRGB_BLOCK:
984 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.
985 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 0);
988 case Graphics::Format::ASTC_10x5_UNORM_BLOCK:
990 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.
991 Assign(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 0);
994 case Graphics::Format::ASTC_10x5_SRGB_BLOCK:
996 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.
997 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 0);
1000 case Graphics::Format::ASTC_10x6_UNORM_BLOCK:
1002 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.
1003 Assign(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 0);
1006 case Graphics::Format::ASTC_10x6_SRGB_BLOCK:
1008 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.
1009 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 0);
1012 case Graphics::Format::ASTC_10x8_UNORM_BLOCK:
1014 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.
1015 Assign(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 0);
1018 case Graphics::Format::ASTC_10x8_SRGB_BLOCK:
1020 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.
1021 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 0);
1024 case Graphics::Format::ASTC_10x10_UNORM_BLOCK:
1026 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.
1027 Assign(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 0);
1030 case Graphics::Format::ASTC_10x10_SRGB_BLOCK:
1032 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.
1033 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 0);
1036 case Graphics::Format::ASTC_12x10_UNORM_BLOCK:
1038 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.
1039 Assign(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 0);
1042 case Graphics::Format::ASTC_12x10_SRGB_BLOCK:
1044 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.
1045 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 0);
1048 case Graphics::Format::ASTC_12x12_UNORM_BLOCK:
1050 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.
1051 Assign(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 0);
1054 case Graphics::Format::ASTC_12x12_SRGB_BLOCK:
1056 ///! Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.
1057 Assign(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 0);
1060 case Graphics::Format::PVRTC1_2BPP_UNORM_BLOCK_IMG:
1065 case Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG:
1067 ///! Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.
1068 Assign(0x8C00, 0); ///! < Hardcoded so we can test before we move to GLES 3.0 or greater.
1072 case Graphics::Format::PVRTC2_2BPP_UNORM_BLOCK_IMG:
1077 case Graphics::Format::PVRTC2_4BPP_UNORM_BLOCK_IMG:
1082 case Graphics::Format::PVRTC1_2BPP_SRGB_BLOCK_IMG:
1087 case Graphics::Format::PVRTC1_4BPP_SRGB_BLOCK_IMG:
1092 case Graphics::Format::PVRTC2_2BPP_SRGB_BLOCK_IMG:
1097 case Graphics::Format::PVRTC2_4BPP_SRGB_BLOCK_IMG:
1105 constexpr inline void Assign(uint32_t f, uint32_t t)
1115 struct GLSamplerFilter
1117 constexpr explicit GLSamplerFilter(Graphics::SamplerFilter filter)
1121 case Graphics::SamplerFilter::NEAREST:
1123 glFilter = GL_NEAREST;
1126 case Graphics::SamplerFilter::LINEAR:
1128 glFilter = GL_LINEAR;
1133 uint32_t glFilter{0};
1136 struct GLSamplerFilterAndMipMapMode
1138 constexpr explicit GLSamplerFilterAndMipMapMode(Graphics::SamplerFilter filter,
1139 Graphics::SamplerMipmapMode mipMapMode)
1143 case Graphics::SamplerFilter::NEAREST:
1147 case Graphics::SamplerMipmapMode::NONE:
1149 glFilter = GL_NEAREST;
1152 case Graphics::SamplerMipmapMode::NEAREST:
1154 glFilter = GL_NEAREST_MIPMAP_NEAREST;
1157 case Graphics::SamplerMipmapMode::LINEAR:
1159 glFilter = GL_NEAREST_MIPMAP_LINEAR;
1166 case Graphics::SamplerFilter::LINEAR:
1170 case Graphics::SamplerMipmapMode::NONE:
1172 glFilter = GL_LINEAR;
1175 case Graphics::SamplerMipmapMode::NEAREST:
1177 glFilter = GL_LINEAR_MIPMAP_NEAREST;
1180 case Graphics::SamplerMipmapMode::LINEAR:
1182 glFilter = GL_LINEAR_MIPMAP_LINEAR;
1191 inline explicit operator uint32_t() const
1196 inline operator int() const
1198 return static_cast<int>(glFilter);
1201 uint32_t glFilter{0};
1204 /** Converts vertex format to GL */
1205 struct GLVertexFormat
1207 constexpr explicit GLVertexFormat(Graphics::VertexInputFormat gfxFormat)
1211 case VertexInputFormat::FVECTOR2:
1217 case VertexInputFormat::FVECTOR3:
1223 case VertexInputFormat::FVECTOR4:
1229 case VertexInputFormat::FLOAT:
1235 case VertexInputFormat::INTEGER:
1241 case VertexInputFormat::IVECTOR2:
1247 case VertexInputFormat::IVECTOR3:
1253 case VertexInputFormat::IVECTOR4:
1259 case VertexInputFormat::UNDEFINED:
1272 struct GLTextureTarget
1274 constexpr explicit GLTextureTarget(Graphics::TextureType graphicsTextureType)
1276 switch(graphicsTextureType)
1278 case Graphics::TextureType::TEXTURE_2D:
1280 target = GL_TEXTURE_2D;
1283 case Graphics::TextureType::TEXTURE_3D:
1285 target = GL_TEXTURE_3D;
1288 case Graphics::TextureType::TEXTURE_CUBEMAP:
1290 target = GL_TEXTURE_CUBE_MAP;
1295 GLenum target{GL_TEXTURE_2D};
1298 struct GLAddressMode
1300 constexpr explicit GLAddressMode(Graphics::SamplerAddressMode graphicsAddressMode)
1302 switch(graphicsAddressMode)
1304 case Graphics::SamplerAddressMode::REPEAT:
1306 texParameter = GL_REPEAT;
1309 case Graphics::SamplerAddressMode::MIRRORED_REPEAT:
1311 texParameter = GL_MIRRORED_REPEAT;
1314 case Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
1316 texParameter = GL_CLAMP_TO_EDGE;
1319 case Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
1321 texParameter = GL_CLAMP_TO_EDGE;
1324 case Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
1326 texParameter = GL_CLAMP_TO_EDGE;
1331 GLenum texParameter{GL_CLAMP_TO_EDGE};
1335 * @brief Descriptor of single buffer binding within
1338 struct VertexBufferBindingDescriptor
1340 const GLES::Buffer* buffer{nullptr};
1341 uint32_t offset{0u};
1345 * @brief Descriptor of ix buffer binding within
1348 struct IndexBufferBindingDescriptor
1350 const GLES::Buffer* buffer{nullptr};
1352 Graphics::Format format{};
1356 * @brief Descriptor of uniform buffer binding within
1359 struct UniformBufferBindingDescriptor
1361 const GLES::Buffer* buffer{nullptr};
1362 uint32_t binding{0u};
1363 uint32_t offset{0u};
1364 bool emulated; ///<true if UBO is emulated for old gfx API
1368 * @brief The descriptor of draw call
1370 struct DrawCallDescriptor
1373 * @brief Enum specifying type of the draw call
1379 DRAW_INDEXED_INDIRECT
1382 Type type{}; ///< Type of the draw call
1385 * Union contains data for all types of draw calls.
1390 * @brief Vertex array draw
1394 uint32_t vertexCount;
1395 uint32_t instanceCount;
1396 uint32_t firstVertex;
1397 uint32_t firstInstance;
1401 * @brief Indexed draw
1405 uint32_t indexCount;
1406 uint32_t instanceCount;
1407 uint32_t firstIndex;
1408 int32_t vertexOffset;
1409 uint32_t firstInstance;
1413 * @brief Indexed draw indirect
1417 const GLES::Buffer* buffer;
1421 } drawIndexedIndirect;
1426 * @brief Topologu conversion from Graphics to GLES
1430 explicit constexpr GLESTopology(PrimitiveTopology topology)
1434 case PrimitiveTopology::POINT_LIST:
1436 primitiveTopology = GL_POINTS;
1439 case PrimitiveTopology::LINE_LIST:
1441 primitiveTopology = GL_LINES;
1444 case PrimitiveTopology::LINE_LOOP:
1446 primitiveTopology = GL_LINE_LOOP;
1449 case PrimitiveTopology::LINE_STRIP:
1451 primitiveTopology = GL_LINE_STRIP;
1454 case PrimitiveTopology::TRIANGLE_LIST:
1456 primitiveTopology = GL_TRIANGLES;
1459 case PrimitiveTopology::TRIANGLE_STRIP:
1461 primitiveTopology = GL_TRIANGLE_STRIP;
1464 case PrimitiveTopology::TRIANGLE_FAN:
1466 primitiveTopology = GL_TRIANGLE_FAN;
1473 * @brief Explicit type conversion operator
1474 * @return converted value
1476 constexpr inline operator GLenum() const
1478 return primitiveTopology;
1481 GLenum primitiveTopology{0}; ///< Topology
1485 * @brief Index format conversion structure
1487 struct GLIndexFormat
1489 explicit constexpr GLIndexFormat(Format _format)
1493 // TODO: add more formats
1494 case Format::R16_UINT:
1496 format = GL_UNSIGNED_SHORT;
1507 * @brief Explicit type conversion operator
1508 * @return converted value
1510 constexpr inline operator GLenum() const
1515 GLenum format{0}; ///< Converted format
1519 * @brief Conversion of blending function factor
1523 constexpr explicit GLBlendFunc(Graphics::BlendFactor factor)
1527 case Graphics::BlendFactor::ZERO:
1532 case Graphics::BlendFactor::ONE:
1537 case Graphics::BlendFactor::SRC_COLOR:
1539 glFactor = GL_SRC_COLOR;
1542 case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
1544 glFactor = GL_ONE_MINUS_SRC_COLOR;
1547 case Graphics::BlendFactor::DST_COLOR:
1549 glFactor = GL_DST_COLOR;
1552 case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
1554 glFactor = GL_ONE_MINUS_DST_COLOR;
1557 case Graphics::BlendFactor::SRC_ALPHA:
1559 glFactor = GL_SRC_ALPHA;
1562 case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
1564 glFactor = GL_ONE_MINUS_SRC_ALPHA;
1567 case Graphics::BlendFactor::DST_ALPHA:
1569 glFactor = GL_DST_ALPHA;
1572 case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
1574 glFactor = GL_ONE_MINUS_DST_ALPHA;
1577 case Graphics::BlendFactor::CONSTANT_COLOR:
1579 glFactor = GL_CONSTANT_COLOR;
1582 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
1584 glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
1587 case Graphics::BlendFactor::CONSTANT_ALPHA:
1589 glFactor = GL_CONSTANT_ALPHA;
1592 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
1594 glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
1597 case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
1599 glFactor = GL_SRC_ALPHA_SATURATE;
1602 // Below may be unsupported without extension
1603 case Graphics::BlendFactor::SRC1_COLOR:
1608 case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
1613 case Graphics::BlendFactor::SRC1_ALPHA:
1618 case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
1627 * @brief Explicit type conversion operator
1628 * @return converted value
1630 constexpr inline operator GLenum() const
1635 GLenum glFactor{0u};
1639 * @brief Converts Blend Op to GL
1643 constexpr explicit GLBlendOp(Graphics::BlendOp blendOp)
1647 case Graphics::BlendOp::ADD:
1649 glBlendOp = GL_FUNC_ADD;
1652 case Graphics::BlendOp::SUBTRACT:
1654 glBlendOp = GL_FUNC_SUBTRACT;
1657 case Graphics::BlendOp::REVERSE_SUBTRACT:
1659 glBlendOp = GL_FUNC_REVERSE_SUBTRACT;
1662 case Graphics::BlendOp::MIN:
1667 case Graphics::BlendOp::MAX:
1676 * @brief Explicit type conversion operator
1677 * @return converted value
1679 constexpr inline operator GLenum() const
1684 GLenum glBlendOp{0u};
1688 * @brief Converts GL cull mode
1692 constexpr explicit GLCullMode(Graphics::CullMode cullMode)
1696 case Graphics::CullMode::NONE: // this isn't really accepted by GL!
1698 glCullMode = GL_NONE;
1701 case Graphics::CullMode::FRONT:
1703 glCullMode = GL_FRONT;
1706 case Graphics::CullMode::BACK:
1708 glCullMode = GL_BACK;
1711 case Graphics::CullMode::FRONT_AND_BACK:
1713 glCullMode = GL_FRONT_AND_BACK;
1720 * @brief Explicit type conversion operator
1721 * @return converted value
1723 constexpr inline operator GLenum() const
1728 GLenum glCullMode{0u};
1732 * @brief enum with GL types
1737 FLOAT_VEC2 = 0x8B50,
1738 FLOAT_VEC3 = 0x8B51,
1739 FLOAT_VEC4 = 0x8B52,
1747 FLOAT_MAT2 = 0x8B5A,
1748 FLOAT_MAT3 = 0x8B5B,
1749 FLOAT_MAT4 = 0x8B5C,
1750 SAMPLER_2D = 0x8B5E,
1751 SAMPLER_CUBE = 0x8B60,
1753 UNSIGNED_BYTE = 0x1401,
1755 UNSIGNED_SHORT = 0x1403,
1757 UNSIGNED_INT = 0x1405,
1763 * @brief GL type conversion (used with reflection)
1765 struct GLTypeConversion
1767 constexpr explicit GLTypeConversion(GLenum value)
1773 type = GLType::FLOAT_VEC2;
1778 type = GLType::FLOAT_VEC3;
1783 type = GLType::FLOAT_VEC4;
1788 type = GLType::INT_VEC2;
1793 type = GLType::INT_VEC3;
1798 type = GLType::INT_VEC4;
1803 type = GLType::BOOL;
1808 type = GLType::BOOL_VEC2;
1813 type = GLType::BOOL_VEC3;
1818 type = GLType::BOOL_VEC4;
1823 type = GLType::FLOAT_MAT2;
1828 type = GLType::FLOAT_MAT3;
1833 type = GLType::FLOAT_MAT4;
1838 type = GLType::SAMPLER_2D;
1841 case GL_SAMPLER_CUBE:
1843 type = GLType::SAMPLER_CUBE;
1848 type = GLType::FLOAT;
1853 type = GLType::UNDEFINED;
1858 GLType type{GLType::UNDEFINED};
1861 } // namespace Dali::Graphics::GLES
1863 #endif //DALI_GRAPHICS_API_TYPES_H