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_RED, GL_UNSIGNED_BYTE);
40 case Graphics::Format::L8A8:
46 // Packed formats (TODO: find supported)
47 case Graphics::Format::R4G4_UNORM_PACK8:
52 case Graphics::Format::R4G4B4A4_UNORM_PACK16:
57 case Graphics::Format::B4G4R4A4_UNORM_PACK16:
62 case Graphics::Format::R5G6B5_UNORM_PACK16:
67 case Graphics::Format::B5G6R5_UNORM_PACK16:
72 case Graphics::Format::R5G5B5A1_UNORM_PACK16:
77 case Graphics::Format::B5G5R5A1_UNORM_PACK16:
82 case Graphics::Format::A1R5G5B5_UNORM_PACK16:
89 case Graphics::Format::R8_UNORM:
91 Assign(GL_RED, GL_UNSIGNED_BYTE);
94 case Graphics::Format::R8_SNORM:
96 Assign(GL_RED, GL_BYTE);
99 case Graphics::Format::R8_USCALED:
101 Assign(GL_RED, GL_UNSIGNED_BYTE);
104 case Graphics::Format::R8_SSCALED:
106 Assign(GL_RED, GL_BYTE);
109 case Graphics::Format::R8_UINT:
111 Assign(GL_RED, GL_UNSIGNED_BYTE);
114 case Graphics::Format::R8_SINT:
116 Assign(GL_RED, GL_BYTE);
119 case Graphics::Format::R8_SRGB:
121 Assign(GL_RED, GL_BYTE);
124 case Graphics::Format::R8G8_UNORM:
126 Assign(GL_RG, GL_UNSIGNED_BYTE);
129 case Graphics::Format::R8G8_SNORM:
131 Assign(GL_RG, GL_BYTE);
134 case Graphics::Format::R8G8_USCALED:
136 Assign(GL_RG, GL_UNSIGNED_BYTE);
139 case Graphics::Format::R8G8_SSCALED:
141 Assign(GL_RG, GL_BYTE);
144 case Graphics::Format::R8G8_UINT:
146 Assign(GL_RG, GL_UNSIGNED_BYTE);
149 case Graphics::Format::R8G8_SINT:
151 Assign(GL_RG, GL_BYTE);
154 case Graphics::Format::R8G8_SRGB:
156 Assign(GL_RG, GL_BYTE);
159 case Graphics::Format::R8G8B8_UNORM:
161 Assign(GL_RGB, GL_UNSIGNED_BYTE);
164 case Graphics::Format::R8G8B8_SNORM:
166 Assign(GL_RGB, GL_BYTE);
169 case Graphics::Format::R8G8B8_USCALED:
171 Assign(GL_RGB, GL_UNSIGNED_BYTE);
174 case Graphics::Format::R8G8B8_SSCALED:
176 Assign(GL_RGB, GL_BYTE);
179 case Graphics::Format::R8G8B8_UINT:
181 Assign(GL_RGB, GL_UNSIGNED_BYTE);
184 case Graphics::Format::R8G8B8_SINT:
186 Assign(GL_RGB, GL_BYTE);
189 case Graphics::Format::R8G8B8_SRGB:
191 Assign(GL_RGB, GL_BYTE);
195 // BGR not supported in GLES
196 case Graphics::Format::B8G8R8_UNORM:
201 case Graphics::Format::B8G8R8_SNORM:
206 case Graphics::Format::B8G8R8_USCALED:
211 case Graphics::Format::B8G8R8_SSCALED:
216 case Graphics::Format::B8G8R8_UINT:
221 case Graphics::Format::B8G8R8_SINT:
226 case Graphics::Format::B8G8R8_SRGB:
233 case Graphics::Format::R8G8B8A8_UNORM:
235 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
238 case Graphics::Format::R8G8B8A8_SNORM:
240 Assign(GL_RGBA, GL_BYTE);
243 case Graphics::Format::R8G8B8A8_USCALED:
245 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
248 case Graphics::Format::R8G8B8A8_SSCALED:
250 Assign(GL_RGBA, GL_BYTE);
253 case Graphics::Format::R8G8B8A8_UINT:
255 Assign(GL_RGBA, GL_UNSIGNED_BYTE);
258 case Graphics::Format::R8G8B8A8_SINT:
260 Assign(GL_RGBA, GL_BYTE);
263 case Graphics::Format::R8G8B8A8_SRGB:
265 Assign(GL_RGBA, GL_BYTE);
269 // BGRA (seems to be not supported)
270 case Graphics::Format::B8G8R8A8_UNORM:
272 Assign(0, GL_UNSIGNED_BYTE);
275 case Graphics::Format::B8G8R8A8_SNORM:
280 case Graphics::Format::B8G8R8A8_USCALED:
282 Assign(0, GL_UNSIGNED_BYTE);
285 case Graphics::Format::B8G8R8A8_SSCALED:
290 case Graphics::Format::B8G8R8A8_UINT:
292 Assign(0, GL_UNSIGNED_BYTE);
295 case Graphics::Format::B8G8R8A8_SINT:
300 case Graphics::Format::B8G8R8A8_SRGB:
306 // ABGR not supported
307 case Graphics::Format::A8B8G8R8_UNORM_PACK32:
312 case Graphics::Format::A8B8G8R8_SNORM_PACK32:
317 case Graphics::Format::A8B8G8R8_USCALED_PACK32:
322 case Graphics::Format::A8B8G8R8_SSCALED_PACK32:
327 case Graphics::Format::A8B8G8R8_UINT_PACK32:
332 case Graphics::Format::A8B8G8R8_SINT_PACK32:
337 case Graphics::Format::A8B8G8R8_SRGB_PACK32:
343 // TBD which of the formats are supported
344 case Graphics::Format::A2R10G10B10_UNORM_PACK32:
349 case Graphics::Format::A2R10G10B10_SNORM_PACK32:
354 case Graphics::Format::A2R10G10B10_USCALED_PACK32:
359 case Graphics::Format::A2R10G10B10_SSCALED_PACK32:
364 case Graphics::Format::A2R10G10B10_UINT_PACK32:
369 case Graphics::Format::A2R10G10B10_SINT_PACK32:
374 case Graphics::Format::A2B10G10R10_UNORM_PACK32:
379 case Graphics::Format::A2B10G10R10_SNORM_PACK32:
384 case Graphics::Format::A2B10G10R10_USCALED_PACK32:
389 case Graphics::Format::A2B10G10R10_SSCALED_PACK32:
394 case Graphics::Format::A2B10G10R10_UINT_PACK32:
399 case Graphics::Format::A2B10G10R10_SINT_PACK32:
404 case Graphics::Format::R16_UNORM:
409 case Graphics::Format::R16_SNORM:
414 case Graphics::Format::R16_USCALED:
419 case Graphics::Format::R16_SSCALED:
424 case Graphics::Format::R16_UINT:
429 case Graphics::Format::R16_SINT:
434 case Graphics::Format::R16_SFLOAT:
439 case Graphics::Format::R16G16_UNORM:
444 case Graphics::Format::R16G16_SNORM:
449 case Graphics::Format::R16G16_USCALED:
454 case Graphics::Format::R16G16_SSCALED:
459 case Graphics::Format::R16G16_UINT:
464 case Graphics::Format::R16G16_SINT:
469 case Graphics::Format::R16G16_SFLOAT:
474 case Graphics::Format::R16G16B16_UNORM:
479 case Graphics::Format::R16G16B16_SNORM:
484 case Graphics::Format::R16G16B16_USCALED:
489 case Graphics::Format::R16G16B16_SSCALED:
494 case Graphics::Format::R16G16B16_UINT:
499 case Graphics::Format::R16G16B16_SINT:
504 case Graphics::Format::R16G16B16_SFLOAT:
509 case Graphics::Format::R16G16B16A16_UNORM:
514 case Graphics::Format::R16G16B16A16_SNORM:
519 case Graphics::Format::R16G16B16A16_USCALED:
524 case Graphics::Format::R16G16B16A16_SSCALED:
529 case Graphics::Format::R16G16B16A16_UINT:
534 case Graphics::Format::R16G16B16A16_SINT:
539 case Graphics::Format::R16G16B16A16_SFLOAT:
544 case Graphics::Format::R32_UINT:
549 case Graphics::Format::R32_SINT:
554 case Graphics::Format::R32_SFLOAT:
559 case Graphics::Format::R32G32_UINT:
564 case Graphics::Format::R32G32_SINT:
569 case Graphics::Format::R32G32_SFLOAT:
574 case Graphics::Format::R32G32B32_UINT:
579 case Graphics::Format::R32G32B32_SINT:
584 case Graphics::Format::R32G32B32_SFLOAT:
589 case Graphics::Format::R32G32B32A32_UINT:
594 case Graphics::Format::R32G32B32A32_SINT:
599 case Graphics::Format::R32G32B32A32_SFLOAT:
604 case Graphics::Format::R64_UINT:
609 case Graphics::Format::R64_SINT:
614 case Graphics::Format::R64_SFLOAT:
619 case Graphics::Format::R64G64_UINT:
624 case Graphics::Format::R64G64_SINT:
629 case Graphics::Format::R64G64_SFLOAT:
634 case Graphics::Format::R64G64B64_UINT:
639 case Graphics::Format::R64G64B64_SINT:
644 case Graphics::Format::R64G64B64_SFLOAT:
649 case Graphics::Format::R64G64B64A64_UINT:
654 case Graphics::Format::R64G64B64A64_SINT:
659 case Graphics::Format::R64G64B64A64_SFLOAT:
664 case Graphics::Format::B10G11R11_UFLOAT_PACK32:
669 case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
674 case Graphics::Format::D16_UNORM:
679 case Graphics::Format::X8_D24_UNORM_PACK32:
684 case Graphics::Format::D32_SFLOAT:
689 case Graphics::Format::S8_UINT:
694 case Graphics::Format::D16_UNORM_S8_UINT:
699 case Graphics::Format::D24_UNORM_S8_UINT:
704 case Graphics::Format::D32_SFLOAT_S8_UINT:
709 case Graphics::Format::BC1_RGB_UNORM_BLOCK:
714 case Graphics::Format::BC1_RGB_SRGB_BLOCK:
719 case Graphics::Format::BC1_RGBA_UNORM_BLOCK:
724 case Graphics::Format::BC1_RGBA_SRGB_BLOCK:
729 case Graphics::Format::BC2_UNORM_BLOCK:
734 case Graphics::Format::BC2_SRGB_BLOCK:
739 case Graphics::Format::BC3_UNORM_BLOCK:
744 case Graphics::Format::BC3_SRGB_BLOCK:
749 case Graphics::Format::BC4_UNORM_BLOCK:
754 case Graphics::Format::BC4_SNORM_BLOCK:
759 case Graphics::Format::BC5_UNORM_BLOCK:
764 case Graphics::Format::BC5_SNORM_BLOCK:
769 case Graphics::Format::BC6H_UFLOAT_BLOCK:
774 case Graphics::Format::BC6H_SFLOAT_BLOCK:
779 case Graphics::Format::BC7_UNORM_BLOCK:
784 case Graphics::Format::BC7_SRGB_BLOCK:
789 case Graphics::Format::ETC2_R8G8B8_UNORM_BLOCK:
794 case Graphics::Format::ETC2_R8G8B8_SRGB_BLOCK:
799 case Graphics::Format::ETC2_R8G8B8A1_UNORM_BLOCK:
804 case Graphics::Format::ETC2_R8G8B8A1_SRGB_BLOCK:
809 case Graphics::Format::ETC2_R8G8B8A8_UNORM_BLOCK:
814 case Graphics::Format::ETC2_R8G8B8A8_SRGB_BLOCK:
819 case Graphics::Format::EAC_R11_UNORM_BLOCK:
824 case Graphics::Format::EAC_R11_SNORM_BLOCK:
829 case Graphics::Format::EAC_R11G11_UNORM_BLOCK:
834 case Graphics::Format::EAC_R11G11_SNORM_BLOCK:
839 case Graphics::Format::ASTC_4x4_UNORM_BLOCK:
844 case Graphics::Format::ASTC_4x4_SRGB_BLOCK:
849 case Graphics::Format::ASTC_5x4_UNORM_BLOCK:
854 case Graphics::Format::ASTC_5x4_SRGB_BLOCK:
859 case Graphics::Format::ASTC_5x5_UNORM_BLOCK:
864 case Graphics::Format::ASTC_5x5_SRGB_BLOCK:
869 case Graphics::Format::ASTC_6x5_UNORM_BLOCK:
874 case Graphics::Format::ASTC_6x5_SRGB_BLOCK:
879 case Graphics::Format::ASTC_6x6_UNORM_BLOCK:
884 case Graphics::Format::ASTC_6x6_SRGB_BLOCK:
889 case Graphics::Format::ASTC_8x5_UNORM_BLOCK:
894 case Graphics::Format::ASTC_8x5_SRGB_BLOCK:
899 case Graphics::Format::ASTC_8x6_UNORM_BLOCK:
904 case Graphics::Format::ASTC_8x6_SRGB_BLOCK:
909 case Graphics::Format::ASTC_8x8_UNORM_BLOCK:
914 case Graphics::Format::ASTC_8x8_SRGB_BLOCK:
919 case Graphics::Format::ASTC_10x5_UNORM_BLOCK:
924 case Graphics::Format::ASTC_10x5_SRGB_BLOCK:
929 case Graphics::Format::ASTC_10x6_UNORM_BLOCK:
934 case Graphics::Format::ASTC_10x6_SRGB_BLOCK:
939 case Graphics::Format::ASTC_10x8_UNORM_BLOCK:
944 case Graphics::Format::ASTC_10x8_SRGB_BLOCK:
949 case Graphics::Format::ASTC_10x10_UNORM_BLOCK:
954 case Graphics::Format::ASTC_10x10_SRGB_BLOCK:
959 case Graphics::Format::ASTC_12x10_UNORM_BLOCK:
964 case Graphics::Format::ASTC_12x10_SRGB_BLOCK:
969 case Graphics::Format::ASTC_12x12_UNORM_BLOCK:
974 case Graphics::Format::ASTC_12x12_SRGB_BLOCK:
979 case Graphics::Format::PVRTC1_2BPP_UNORM_BLOCK_IMG:
984 case Graphics::Format::PVRTC1_4BPP_UNORM_BLOCK_IMG:
989 case Graphics::Format::PVRTC2_2BPP_UNORM_BLOCK_IMG:
994 case Graphics::Format::PVRTC2_4BPP_UNORM_BLOCK_IMG:
999 case Graphics::Format::PVRTC1_2BPP_SRGB_BLOCK_IMG:
1004 case Graphics::Format::PVRTC1_4BPP_SRGB_BLOCK_IMG:
1009 case Graphics::Format::PVRTC2_2BPP_SRGB_BLOCK_IMG:
1014 case Graphics::Format::PVRTC2_4BPP_SRGB_BLOCK_IMG:
1022 constexpr inline void Assign(uint32_t f, uint32_t t)
1032 struct GLSamplerFilterAndMipMapMode
1034 GLSamplerFilterAndMipMapMode() = default;
1035 GLSamplerFilterAndMipMapMode(Graphics::SamplerFilter filter,
1036 Graphics::SamplerMipmapMode mipMapMode)
1040 case Graphics::SamplerFilter::NEAREST:
1044 case Graphics::SamplerMipmapMode::NONE:
1046 glFilter = GL_NEAREST;
1049 case Graphics::SamplerMipmapMode::NEAREST:
1051 glFilter = GL_NEAREST_MIPMAP_NEAREST;
1054 case Graphics::SamplerMipmapMode::LINEAR:
1056 glFilter = GL_NEAREST_MIPMAP_NEAREST;
1061 case Graphics::SamplerFilter::LINEAR:
1065 case Graphics::SamplerMipmapMode::NONE:
1067 glFilter = GL_LINEAR;
1070 case Graphics::SamplerMipmapMode::NEAREST:
1072 glFilter = GL_LINEAR_MIPMAP_NEAREST;
1075 case Graphics::SamplerMipmapMode::LINEAR:
1077 glFilter = GL_LINEAR_MIPMAP_NEAREST;
1085 inline explicit operator uint32_t() const
1090 inline operator int() const
1092 return static_cast<int>(glFilter);
1095 uint32_t glFilter{0};
1098 /** Converts vertex format to GL */
1099 struct GLVertexFormat
1101 constexpr explicit GLVertexFormat(Graphics::VertexInputFormat gfxFormat)
1105 case VertexInputFormat::FVECTOR2:
1111 case VertexInputFormat::FVECTOR3:
1117 case VertexInputFormat::FVECTOR4:
1123 case VertexInputFormat::FLOAT:
1129 case VertexInputFormat::INTEGER:
1135 case VertexInputFormat::IVECTOR2:
1141 case VertexInputFormat::IVECTOR3:
1147 case VertexInputFormat::IVECTOR4:
1153 case VertexInputFormat::UNDEFINED:
1167 * @brief Descriptor of single buffer binding within
1170 struct VertexBufferBindingDescriptor
1172 const GLES::Buffer* buffer{nullptr};
1173 uint32_t offset{0u};
1177 * @brief Descriptor of ix buffer binding within
1180 struct IndexBufferBindingDescriptor
1182 const GLES::Buffer* buffer{nullptr};
1184 Graphics::Format format{};
1188 * @brief The descriptor of draw call
1190 struct DrawCallDescriptor
1193 * @brief Enum specifying type of the draw call
1199 DRAW_INDEXED_INDIRECT
1202 Type type{}; ///< Type of the draw call
1205 * Union contains data for all types of draw calls.
1210 * @brief Vertex array draw
1214 uint32_t vertexCount;
1215 uint32_t instanceCount;
1216 uint32_t firstVertex;
1217 uint32_t firstInstance;
1221 * @brief Indexed draw
1225 uint32_t indexCount;
1226 uint32_t instanceCount;
1227 uint32_t firstIndex;
1228 int32_t vertexOffset;
1229 uint32_t firstInstance;
1233 * @brief Indexed draw indirect
1237 const GLES::Buffer* buffer;
1241 } drawIndexedIndirect;
1246 * @brief Topologu conversion from Graphics to GLES
1250 explicit constexpr GLESTopology(PrimitiveTopology topology)
1254 case PrimitiveTopology::POINT_LIST:
1256 primitiveTopology = GL_POINTS;
1259 case PrimitiveTopology::LINE_LIST:
1261 primitiveTopology = GL_LINES;
1264 case PrimitiveTopology::LINE_LOOP:
1266 primitiveTopology = GL_LINE_LOOP;
1269 case PrimitiveTopology::LINE_STRIP:
1271 primitiveTopology = GL_LINE_STRIP;
1274 case PrimitiveTopology::TRIANGLE_LIST:
1276 primitiveTopology = GL_TRIANGLES;
1279 case PrimitiveTopology::TRIANGLE_STRIP:
1281 primitiveTopology = GL_TRIANGLE_STRIP;
1284 case PrimitiveTopology::TRIANGLE_FAN:
1286 primitiveTopology = GL_TRIANGLE_FAN;
1293 * @brief Explicit type conversion operator
1294 * @return converted value
1296 constexpr inline operator GLenum() const
1298 return primitiveTopology;
1301 GLenum primitiveTopology{0}; ///< Topology
1305 * @brief Index format conversion structure
1307 struct GLIndexFormat
1309 explicit constexpr GLIndexFormat(Format _format)
1313 // TODO: add more formats
1314 case Format::R16_UINT:
1316 format = GL_UNSIGNED_SHORT;
1327 * @brief Explicit type conversion operator
1328 * @return converted value
1330 constexpr inline operator GLenum() const
1335 GLenum format{0}; ///< Converted format
1338 } // namespace Dali::Graphics::GLES
1340 #endif //DALI_GRAPHICS_API_TYPES_H