1/*
2================================================================================================
3
4Description : OpenGL formats/types and properties.
5Author : J.M.P. van Waveren
6Date : 07/17/2016
7Language : C99
8Format : Real tabs with the tab size equal to 4 spaces.
9Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved.
10
11
12LICENSE
13=======
14
15Copyright 2016 Oculus VR, LLC.
16SPDX-License-Identifier: Apache-2.0
17
18
19DESCRIPTION
20===========
21
22This header stores the OpenGL formats/types and two simple routines
23to derive the format/type from an internal format. These routines
24are useful to verify the data in a KTX container files. The OpenGL
25constants are generally useful to convert files like KTX and glTF
26to different graphics APIs.
27
28This header stores the OpenGL formats/types that are used as parameters
29to the following OpenGL functions:
30
31void glTexImage2D( GLenum target, GLint level, GLint internalFormat,
32 GLsizei width, GLsizei height, GLint border,
33 GLenum format, GLenum type, const GLvoid * data );
34void glTexImage3D( GLenum target, GLint level, GLint internalFormat,
35 GLsizei width, GLsizei height, GLsizei depth, GLint border,
36 GLenum format, GLenum type, const GLvoid * data );
37void glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat,
38 GLsizei width, GLsizei height, GLint border,
39 GLsizei imageSize, const GLvoid * data );
40void glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat,
41 GLsizei width, GLsizei height, GLsizei depth, GLint border,
42 GLsizei imageSize, const GLvoid * data );
43void glTexStorage2D( GLenum target, GLsizei levels, GLenum internalformat,
44 GLsizei width, GLsizei height );
45void glTexStorage3D( GLenum target, GLsizei levels, GLenum internalformat,
46 GLsizei width, GLsizei height, GLsizei depth );
47void glVertexAttribPointer( GLuint index, GLint size, GLenum type, GLboolean normalized,
48 GLsizei stride, const GLvoid * pointer);
49
50
51IMPLEMENTATION
52==============
53
54This file does not include OpenGL / OpenGL ES headers because:
55
56 1. Including OpenGL / OpenGL ES headers is platform dependent and
57 may require a separate installation of an OpenGL SDK.
58 2. The OpenGL format/type constants are the same between extensions and core.
59 3. The OpenGL format/type constants are the same between OpenGL and OpenGL ES.
60 4. The OpenGL constants in this header are also used to derive Vulkan formats
61 from the OpenGL formats/types stored in files like KTX and glTF. These file
62 formats may use OpenGL formats/types that are not supported by the OpenGL
63 implementation on the platform but are supported by the Vulkan implementation.
64
65
66ENTRY POINTS
67============
68
69static inline GLenum glGetFormatFromInternalFormat( const GLenum internalFormat );
70static inline GLenum glGetTypeFromInternalFormat( const GLenum internalFormat );
71static inline void glGetFormatSize( const GLenum internalFormat, GlFormatSize * pFormatSize );
72static inline unsigned int glGetTypeSizeFromType( const GLenum type );
73static inline GLenum glGetInternalFormatFromVkFormat ( VkFormat format );
74
75MODIFICATIONS for use in libktx
76===============================
77
782018.3.23 Added glGetTypeSizeFromType. Mark Callow, Edgewise Consulting.
792019.3.09 #if 0 around GL type declarations. 〃
802019.5.30 Use common ktxFormatSize to return results. 〃
812019.5.30 Return blockSizeInBits 0 for default case of glGetFormatSize. 〃
822019.5.30 Added glGetInternalFormatFromVkFormat. 〃
83
84================================================================================================
85*/
86
87#if !defined( GL_FORMAT_H )
88#define GL_FORMAT_H
89
90#include <assert.h>
91#include "formatsize.h"
92#include "vkformat_enum.h"
93
94#if defined(_WIN32) && !defined(__MINGW32__)
95#ifndef NOMINMAX
96#define NOMINMAX
97#endif
98#ifndef __cplusplus
99#undef inline
100#define inline __inline
101#endif // __cplusplus
102#endif
103
104/*
105===========================================================================
106Avoid warnings or even errors when using strict C99. "Redefinition of
107(type) is a C11 feature." All includers in libktx also include ktx.h where
108they are also defined.
109===========================================================================
110*/
111#if 0
112typedef unsigned int GLenum;
113typedef unsigned char GLboolean;
114typedef unsigned int GLuint;
115#endif
116
117#if !defined( GL_INVALID_VALUE )
118#define GL_INVALID_VALUE 0x0501
119#endif
120
121/*
122================================================================================================================================
123
124Format to glTexImage2D and glTexImage3D.
125
126================================================================================================================================
127*/
128
129#if !defined( GL_RED )
130#define GL_RED 0x1903 // same as GL_RED_EXT
131#endif
132#if !defined( GL_GREEN )
133#define GL_GREEN 0x1904 // deprecated
134#endif
135#if !defined( GL_BLUE )
136#define GL_BLUE 0x1905 // deprecated
137#endif
138#if !defined( GL_ALPHA )
139#define GL_ALPHA 0x1906 // deprecated
140#endif
141#if !defined( GL_LUMINANCE )
142#define GL_LUMINANCE 0x1909 // deprecated
143#endif
144#if !defined( GL_SLUMINANCE )
145#define GL_SLUMINANCE 0x8C46 // deprecated, same as GL_SLUMINANCE_EXT
146#endif
147#if !defined( GL_LUMINANCE_ALPHA )
148#define GL_LUMINANCE_ALPHA 0x190A // deprecated
149#endif
150#if !defined( GL_SLUMINANCE_ALPHA )
151#define GL_SLUMINANCE_ALPHA 0x8C44 // deprecated, same as GL_SLUMINANCE_ALPHA_EXT
152#endif
153#if !defined( GL_INTENSITY )
154#define GL_INTENSITY 0x8049 // deprecated, same as GL_INTENSITY_EXT
155#endif
156#if !defined( GL_RG )
157#define GL_RG 0x8227 // same as GL_RG_EXT
158#endif
159#if !defined( GL_RGB )
160#define GL_RGB 0x1907
161#endif
162#if !defined( GL_BGR )
163#define GL_BGR 0x80E0 // same as GL_BGR_EXT
164#endif
165#if !defined( GL_RGBA )
166#define GL_RGBA 0x1908
167#endif
168#if !defined( GL_BGRA )
169#define GL_BGRA 0x80E1 // same as GL_BGRA_EXT
170#endif
171#if !defined( GL_RED_INTEGER )
172#define GL_RED_INTEGER 0x8D94 // same as GL_RED_INTEGER_EXT
173#endif
174#if !defined( GL_GREEN_INTEGER )
175#define GL_GREEN_INTEGER 0x8D95 // deprecated, same as GL_GREEN_INTEGER_EXT
176#endif
177#if !defined( GL_BLUE_INTEGER )
178#define GL_BLUE_INTEGER 0x8D96 // deprecated, same as GL_BLUE_INTEGER_EXT
179#endif
180#if !defined( GL_ALPHA_INTEGER )
181#define GL_ALPHA_INTEGER 0x8D97 // deprecated, same as GL_ALPHA_INTEGER_EXT
182#endif
183#if !defined( GL_LUMINANCE_INTEGER )
184#define GL_LUMINANCE_INTEGER 0x8D9C // deprecated, same as GL_LUMINANCE_INTEGER_EXT
185#endif
186#if !defined( GL_LUMINANCE_ALPHA_INTEGER )
187#define GL_LUMINANCE_ALPHA_INTEGER 0x8D9D // deprecated, same as GL_LUMINANCE_ALPHA_INTEGER_EXT
188#endif
189#if !defined( GL_RG_INTEGER )
190#define GL_RG_INTEGER 0x8228 // same as GL_RG_INTEGER_EXT
191#endif
192#if !defined( GL_RGB_INTEGER )
193#define GL_RGB_INTEGER 0x8D98 // same as GL_RGB_INTEGER_EXT
194#endif
195#if !defined( GL_BGR_INTEGER )
196#define GL_BGR_INTEGER 0x8D9A // same as GL_BGR_INTEGER_EXT
197#endif
198#if !defined( GL_RGBA_INTEGER )
199#define GL_RGBA_INTEGER 0x8D99 // same as GL_RGBA_INTEGER_EXT
200#endif
201#if !defined( GL_BGRA_INTEGER )
202#define GL_BGRA_INTEGER 0x8D9B // same as GL_BGRA_INTEGER_EXT
203#endif
204#if !defined( GL_COLOR_INDEX )
205#define GL_COLOR_INDEX 0x1900 // deprecated
206#endif
207#if !defined( GL_STENCIL_INDEX )
208#define GL_STENCIL_INDEX 0x1901
209#endif
210#if !defined( GL_DEPTH_COMPONENT )
211#define GL_DEPTH_COMPONENT 0x1902
212#endif
213#if !defined( GL_DEPTH_STENCIL )
214#define GL_DEPTH_STENCIL 0x84F9 // same as GL_DEPTH_STENCIL_NV and GL_DEPTH_STENCIL_EXT and GL_DEPTH_STENCIL_OES
215#endif
216
217/*
218================================================================================================================================
219
220Type to glTexImage2D, glTexImage3D and glVertexAttribPointer.
221
222================================================================================================================================
223*/
224
225#if !defined( GL_BYTE )
226#define GL_BYTE 0x1400
227#endif
228#if !defined( GL_UNSIGNED_BYTE )
229#define GL_UNSIGNED_BYTE 0x1401
230#endif
231#if !defined( GL_SHORT )
232#define GL_SHORT 0x1402
233#endif
234#if !defined( GL_UNSIGNED_SHORT )
235#define GL_UNSIGNED_SHORT 0x1403
236#endif
237#if !defined( GL_INT )
238#define GL_INT 0x1404
239#endif
240#if !defined( GL_UNSIGNED_INT )
241#define GL_UNSIGNED_INT 0x1405
242#endif
243#if !defined( GL_INT64 )
244#define GL_INT64 0x140E // same as GL_INT64_NV and GL_INT64_ARB
245#endif
246#if !defined( GL_UNSIGNED_INT64 )
247#define GL_UNSIGNED_INT64 0x140F // same as GL_UNSIGNED_INT64_NV and GL_UNSIGNED_INT64_ARB
248#endif
249#if !defined( GL_HALF_FLOAT )
250#define GL_HALF_FLOAT 0x140B // same as GL_HALF_FLOAT_NV and GL_HALF_FLOAT_ARB
251#endif
252#if !defined( GL_HALF_FLOAT_OES )
253#define GL_HALF_FLOAT_OES 0x8D61 // Note that this different from GL_HALF_FLOAT.
254#endif
255#if !defined( GL_FLOAT )
256#define GL_FLOAT 0x1406
257#endif
258#if !defined( GL_DOUBLE )
259#define GL_DOUBLE 0x140A // same as GL_DOUBLE_EXT
260#endif
261#if !defined( GL_UNSIGNED_BYTE_3_3_2 )
262#define GL_UNSIGNED_BYTE_3_3_2 0x8032 // same as GL_UNSIGNED_BYTE_3_3_2_EXT
263#endif
264#if !defined( GL_UNSIGNED_BYTE_2_3_3_REV )
265#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 // same as GL_UNSIGNED_BYTE_2_3_3_REV_EXT
266#endif
267#if !defined( GL_UNSIGNED_SHORT_5_6_5 )
268#define GL_UNSIGNED_SHORT_5_6_5 0x8363 // same as GL_UNSIGNED_SHORT_5_6_5_EXT
269#endif
270#if !defined( GL_UNSIGNED_SHORT_5_6_5_REV )
271#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 // same as GL_UNSIGNED_SHORT_5_6_5_REV_EXT
272#endif
273#if !defined( GL_UNSIGNED_SHORT_4_4_4_4 )
274#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 // same as GL_UNSIGNED_SHORT_4_4_4_4_EXT
275#endif
276#if !defined( GL_UNSIGNED_SHORT_4_4_4_4_REV )
277#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 // same as GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG and GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT
278#endif
279#if !defined( GL_UNSIGNED_SHORT_5_5_5_1 )
280#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 // same as GL_UNSIGNED_SHORT_5_5_5_1_EXT
281#endif
282#if !defined( GL_UNSIGNED_SHORT_1_5_5_5_REV )
283#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 // same as GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
284#endif
285#if !defined( GL_UNSIGNED_INT_8_8_8_8 )
286#define GL_UNSIGNED_INT_8_8_8_8 0x8035 // same as GL_UNSIGNED_INT_8_8_8_8_EXT
287#endif
288#if !defined( GL_UNSIGNED_INT_8_8_8_8_REV )
289#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 // same as GL_UNSIGNED_INT_8_8_8_8_REV_EXT
290#endif
291#if !defined( GL_UNSIGNED_INT_10_10_10_2 )
292#define GL_UNSIGNED_INT_10_10_10_2 0x8036 // same as GL_UNSIGNED_INT_10_10_10_2_EXT
293#endif
294#if !defined( GL_UNSIGNED_INT_2_10_10_10_REV )
295#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 // same as GL_UNSIGNED_INT_2_10_10_10_REV_EXT
296#endif
297#if !defined( GL_UNSIGNED_INT_10F_11F_11F_REV )
298#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B // same as GL_UNSIGNED_INT_10F_11F_11F_REV_EXT
299#endif
300#if !defined( GL_UNSIGNED_INT_5_9_9_9_REV )
301#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E // same as GL_UNSIGNED_INT_5_9_9_9_REV_EXT
302#endif
303#if !defined( GL_UNSIGNED_INT_24_8 )
304#define GL_UNSIGNED_INT_24_8 0x84FA // same as GL_UNSIGNED_INT_24_8_NV and GL_UNSIGNED_INT_24_8_EXT and GL_UNSIGNED_INT_24_8_OES
305#endif
306#if !defined( GL_FLOAT_32_UNSIGNED_INT_24_8_REV )
307#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD // same as GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV and GL_FLOAT_32_UNSIGNED_INT_24_8_REV_ARB
308#endif
309
310/*
311================================================================================================================================
312
313Internal format to glTexImage2D, glTexImage3D, glCompressedTexImage2D, glCompressedTexImage3D, glTexStorage2D, glTexStorage3D
314
315================================================================================================================================
316*/
317
318//
319// 8 bits per component
320//
321
322#if !defined( GL_R8 )
323#define GL_R8 0x8229 // same as GL_R8_EXT
324#endif
325#if !defined( GL_RG8 )
326#define GL_RG8 0x822B // same as GL_RG8_EXT
327#endif
328#if !defined( GL_RGB8 )
329#define GL_RGB8 0x8051 // same as GL_RGB8_EXT and GL_RGB8_OES
330#endif
331#if !defined( GL_RGBA8 )
332#define GL_RGBA8 0x8058 // same as GL_RGBA8_EXT and GL_RGBA8_OES
333#endif
334
335#if !defined( GL_R8_SNORM )
336#define GL_R8_SNORM 0x8F94
337#endif
338#if !defined( GL_RG8_SNORM )
339#define GL_RG8_SNORM 0x8F95
340#endif
341#if !defined( GL_RGB8_SNORM )
342#define GL_RGB8_SNORM 0x8F96
343#endif
344#if !defined( GL_RGBA8_SNORM )
345#define GL_RGBA8_SNORM 0x8F97
346#endif
347
348#if !defined( GL_R8UI )
349#define GL_R8UI 0x8232
350#endif
351#if !defined( GL_RG8UI )
352#define GL_RG8UI 0x8238
353#endif
354#if !defined( GL_RGB8UI )
355#define GL_RGB8UI 0x8D7D // same as GL_RGB8UI_EXT
356#endif
357#if !defined( GL_RGBA8UI )
358#define GL_RGBA8UI 0x8D7C // same as GL_RGBA8UI_EXT
359#endif
360
361#if !defined( GL_R8I )
362#define GL_R8I 0x8231
363#endif
364#if !defined( GL_RG8I )
365#define GL_RG8I 0x8237
366#endif
367#if !defined( GL_RGB8I )
368#define GL_RGB8I 0x8D8F // same as GL_RGB8I_EXT
369#endif
370#if !defined( GL_RGBA8I )
371#define GL_RGBA8I 0x8D8E // same as GL_RGBA8I_EXT
372#endif
373
374#if !defined( GL_SR8 )
375#define GL_SR8 0x8FBD // same as GL_SR8_EXT
376#endif
377#if !defined( GL_SRG8 )
378#define GL_SRG8 0x8FBE // same as GL_SRG8_EXT
379#endif
380#if !defined( GL_SRGB8 )
381#define GL_SRGB8 0x8C41 // same as GL_SRGB8_EXT
382#endif
383#if !defined( GL_SRGB8_ALPHA8 )
384#define GL_SRGB8_ALPHA8 0x8C43 // same as GL_SRGB8_ALPHA8_EXT
385#endif
386
387//
388// 16 bits per component
389//
390
391#if !defined( GL_R16 )
392#define GL_R16 0x822A // same as GL_R16_EXT
393#endif
394#if !defined( GL_RG16 )
395#define GL_RG16 0x822C // same as GL_RG16_EXT
396#endif
397#if !defined( GL_RGB16 )
398#define GL_RGB16 0x8054 // same as GL_RGB16_EXT
399#endif
400#if !defined( GL_RGBA16 )
401#define GL_RGBA16 0x805B // same as GL_RGBA16_EXT
402#endif
403
404#if !defined( GL_R16_SNORM )
405#define GL_R16_SNORM 0x8F98 // same as GL_R16_SNORM_EXT
406#endif
407#if !defined( GL_RG16_SNORM )
408#define GL_RG16_SNORM 0x8F99 // same as GL_RG16_SNORM_EXT
409#endif
410#if !defined( GL_RGB16_SNORM )
411#define GL_RGB16_SNORM 0x8F9A // same as GL_RGB16_SNORM_EXT
412#endif
413#if !defined( GL_RGBA16_SNORM )
414#define GL_RGBA16_SNORM 0x8F9B // same as GL_RGBA16_SNORM_EXT
415#endif
416
417#if !defined( GL_R16UI )
418#define GL_R16UI 0x8234
419#endif
420#if !defined( GL_RG16UI )
421#define GL_RG16UI 0x823A
422#endif
423#if !defined( GL_RGB16UI )
424#define GL_RGB16UI 0x8D77 // same as GL_RGB16UI_EXT
425#endif
426#if !defined( GL_RGBA16UI )
427#define GL_RGBA16UI 0x8D76 // same as GL_RGBA16UI_EXT
428#endif
429
430#if !defined( GL_R16I )
431#define GL_R16I 0x8233
432#endif
433#if !defined( GL_RG16I )
434#define GL_RG16I 0x8239
435#endif
436#if !defined( GL_RGB16I )
437#define GL_RGB16I 0x8D89 // same as GL_RGB16I_EXT
438#endif
439#if !defined( GL_RGBA16I )
440#define GL_RGBA16I 0x8D88 // same as GL_RGBA16I_EXT
441#endif
442
443#if !defined( GL_R16F )
444#define GL_R16F 0x822D // same as GL_R16F_EXT
445#endif
446#if !defined( GL_RG16F )
447#define GL_RG16F 0x822F // same as GL_RG16F_EXT
448#endif
449#if !defined( GL_RGB16F )
450#define GL_RGB16F 0x881B // same as GL_RGB16F_EXT and GL_RGB16F_ARB
451#endif
452#if !defined( GL_RGBA16F )
453#define GL_RGBA16F 0x881A // sama as GL_RGBA16F_EXT and GL_RGBA16F_ARB
454#endif
455
456//
457// 32 bits per component
458//
459
460#if !defined( GL_R32UI )
461#define GL_R32UI 0x8236
462#endif
463#if !defined( GL_RG32UI )
464#define GL_RG32UI 0x823C
465#endif
466#if !defined( GL_RGB32UI )
467#define GL_RGB32UI 0x8D71 // same as GL_RGB32UI_EXT
468#endif
469#if !defined( GL_RGBA32UI )
470#define GL_RGBA32UI 0x8D70 // same as GL_RGBA32UI_EXT
471#endif
472
473#if !defined( GL_R32I )
474#define GL_R32I 0x8235
475#endif
476#if !defined( GL_RG32I )
477#define GL_RG32I 0x823B
478#endif
479#if !defined( GL_RGB32I )
480#define GL_RGB32I 0x8D83 // same as GL_RGB32I_EXT
481#endif
482#if !defined( GL_RGBA32I )
483#define GL_RGBA32I 0x8D82 // same as GL_RGBA32I_EXT
484#endif
485
486#if !defined( GL_R32F )
487#define GL_R32F 0x822E // same as GL_R32F_EXT
488#endif
489#if !defined( GL_RG32F )
490#define GL_RG32F 0x8230 // same as GL_RG32F_EXT
491#endif
492#if !defined( GL_RGB32F )
493#define GL_RGB32F 0x8815 // same as GL_RGB32F_EXT and GL_RGB32F_ARB
494#endif
495#if !defined( GL_RGBA32F )
496#define GL_RGBA32F 0x8814 // same as GL_RGBA32F_EXT and GL_RGBA32F_ARB
497#endif
498
499//
500// Packed
501//
502
503#if !defined( GL_R3_G3_B2 )
504#define GL_R3_G3_B2 0x2A10
505#endif
506#if !defined( GL_RGB4 )
507#define GL_RGB4 0x804F // same as GL_RGB4_EXT
508#endif
509#if !defined( GL_RGB5 )
510#define GL_RGB5 0x8050 // same as GL_RGB5_EXT
511#endif
512#if !defined( GL_RGB565 )
513#define GL_RGB565 0x8D62 // same as GL_RGB565_EXT and GL_RGB565_OES
514#endif
515#if !defined( GL_RGB10 )
516#define GL_RGB10 0x8052 // same as GL_RGB10_EXT
517#endif
518#if !defined( GL_RGB12 )
519#define GL_RGB12 0x8053 // same as GL_RGB12_EXT
520#endif
521#if !defined( GL_RGBA2 )
522#define GL_RGBA2 0x8055 // same as GL_RGBA2_EXT
523#endif
524#if !defined( GL_RGBA4 )
525#define GL_RGBA4 0x8056 // same as GL_RGBA4_EXT and GL_RGBA4_OES
526#endif
527#if !defined( GL_RGBA12 )
528#define GL_RGBA12 0x805A // same as GL_RGBA12_EXT
529#endif
530#if !defined( GL_RGB5_A1 )
531#define GL_RGB5_A1 0x8057 // same as GL_RGB5_A1_EXT and GL_RGB5_A1_OES
532#endif
533#if !defined( GL_RGB10_A2 )
534#define GL_RGB10_A2 0x8059 // same as GL_RGB10_A2_EXT
535#endif
536#if !defined( GL_RGB10_A2UI )
537#define GL_RGB10_A2UI 0x906F
538#endif
539#if !defined( GL_R11F_G11F_B10F )
540#define GL_R11F_G11F_B10F 0x8C3A // same as GL_R11F_G11F_B10F_APPLE and GL_R11F_G11F_B10F_EXT
541#endif
542#if !defined( GL_RGB9_E5 )
543#define GL_RGB9_E5 0x8C3D // same as GL_RGB9_E5_APPLE and GL_RGB9_E5_EXT
544#endif
545
546//
547// Alpha
548//
549
550#if !defined( GL_ALPHA4 )
551#define GL_ALPHA4 0x803B // deprecated, same as GL_ALPHA4_EXT
552#endif
553#if !defined( GL_ALPHA8 )
554#define GL_ALPHA8 0x803C // deprecated, same as GL_ALPHA8_EXT
555#endif
556#if !defined( GL_ALPHA8_SNORM )
557#define GL_ALPHA8_SNORM 0x9014 // deprecated
558#endif
559#if !defined( GL_ALPHA8UI_EXT )
560#define GL_ALPHA8UI_EXT 0x8D7E // deprecated
561#endif
562#if !defined( GL_ALPHA8I_EXT )
563#define GL_ALPHA8I_EXT 0x8D90 // deprecated
564#endif
565#if !defined( GL_ALPHA12 )
566#define GL_ALPHA12 0x803D // deprecated, same as GL_ALPHA12_EXT
567#endif
568#if !defined( GL_ALPHA16 )
569#define GL_ALPHA16 0x803E // deprecated, same as GL_ALPHA16_EXT
570#endif
571#if !defined( GL_ALPHA16_SNORM )
572#define GL_ALPHA16_SNORM 0x9018 // deprecated
573#endif
574#if !defined( GL_ALPHA16UI_EXT )
575#define GL_ALPHA16UI_EXT 0x8D78 // deprecated
576#endif
577#if !defined( GL_ALPHA16I_EXT )
578#define GL_ALPHA16I_EXT 0x8D8A // deprecated
579#endif
580#if !defined( GL_ALPHA16F_ARB )
581#define GL_ALPHA16F_ARB 0x881C // deprecated, same as GL_ALPHA_FLOAT16_APPLE and GL_ALPHA_FLOAT16_ATI
582#endif
583#if !defined( GL_ALPHA32UI_EXT )
584#define GL_ALPHA32UI_EXT 0x8D72 // deprecated
585#endif
586#if !defined( GL_ALPHA32I_EXT )
587#define GL_ALPHA32I_EXT 0x8D84 // deprecated
588#endif
589#if !defined( GL_ALPHA32F_ARB )
590#define GL_ALPHA32F_ARB 0x8816 // deprecated, same as GL_ALPHA_FLOAT32_APPLE and GL_ALPHA_FLOAT32_ATI
591#endif
592
593//
594// Luminance
595//
596
597#if !defined( GL_LUMINANCE4 )
598#define GL_LUMINANCE4 0x803F // deprecated, same as GL_LUMINANCE4_EXT
599#endif
600#if !defined( GL_LUMINANCE8 )
601#define GL_LUMINANCE8 0x8040 // deprecated, same as GL_LUMINANCE8_EXT
602#endif
603#if !defined( GL_LUMINANCE8_SNORM )
604#define GL_LUMINANCE8_SNORM 0x9015 // deprecated
605#endif
606#if !defined( GL_SLUMINANCE8 )
607#define GL_SLUMINANCE8 0x8C47 // deprecated, same as GL_SLUMINANCE8_EXT
608#endif
609#if !defined( GL_LUMINANCE8UI_EXT )
610#define GL_LUMINANCE8UI_EXT 0x8D80 // deprecated
611#endif
612#if !defined( GL_LUMINANCE8I_EXT )
613#define GL_LUMINANCE8I_EXT 0x8D92 // deprecated
614#endif
615#if !defined( GL_LUMINANCE12 )
616#define GL_LUMINANCE12 0x8041 // deprecated, same as GL_LUMINANCE12_EXT
617#endif
618#if !defined( GL_LUMINANCE16 )
619#define GL_LUMINANCE16 0x8042 // deprecated, same as GL_LUMINANCE16_EXT
620#endif
621#if !defined( GL_LUMINANCE16_SNORM )
622#define GL_LUMINANCE16_SNORM 0x9019 // deprecated
623#endif
624#if !defined( GL_LUMINANCE16UI_EXT )
625#define GL_LUMINANCE16UI_EXT 0x8D7A // deprecated
626#endif
627#if !defined( GL_LUMINANCE16I_EXT )
628#define GL_LUMINANCE16I_EXT 0x8D8C // deprecated
629#endif
630#if !defined( GL_LUMINANCE16F_ARB )
631#define GL_LUMINANCE16F_ARB 0x881E // deprecated, same as GL_LUMINANCE_FLOAT16_APPLE and GL_LUMINANCE_FLOAT16_ATI
632#endif
633#if !defined( GL_LUMINANCE32UI_EXT )
634#define GL_LUMINANCE32UI_EXT 0x8D74 // deprecated
635#endif
636#if !defined( GL_LUMINANCE32I_EXT )
637#define GL_LUMINANCE32I_EXT 0x8D86 // deprecated
638#endif
639#if !defined( GL_LUMINANCE32F_ARB )
640#define GL_LUMINANCE32F_ARB 0x8818 // deprecated, same as GL_LUMINANCE_FLOAT32_APPLE and GL_LUMINANCE_FLOAT32_ATI
641#endif
642
643//
644// Luminance/Alpha
645//
646
647#if !defined( GL_LUMINANCE4_ALPHA4 )
648#define GL_LUMINANCE4_ALPHA4 0x8043 // deprecated, same as GL_LUMINANCE4_ALPHA4_EXT
649#endif
650#if !defined( GL_LUMINANCE6_ALPHA2 )
651#define GL_LUMINANCE6_ALPHA2 0x8044 // deprecated, same as GL_LUMINANCE6_ALPHA2_EXT
652#endif
653#if !defined( GL_LUMINANCE8_ALPHA8 )
654#define GL_LUMINANCE8_ALPHA8 0x8045 // deprecated, same as GL_LUMINANCE8_ALPHA8_EXT
655#endif
656#if !defined( GL_LUMINANCE8_ALPHA8_SNORM )
657#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 // deprecated
658#endif
659#if !defined( GL_SLUMINANCE8_ALPHA8 )
660#define GL_SLUMINANCE8_ALPHA8 0x8C45 // deprecated, same as GL_SLUMINANCE8_ALPHA8_EXT
661#endif
662#if !defined( GL_LUMINANCE_ALPHA8UI_EXT )
663#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 // deprecated
664#endif
665#if !defined( GL_LUMINANCE_ALPHA8I_EXT )
666#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 // deprecated
667#endif
668#if !defined( GL_LUMINANCE12_ALPHA4 )
669#define GL_LUMINANCE12_ALPHA4 0x8046 // deprecated, same as GL_LUMINANCE12_ALPHA4_EXT
670#endif
671#if !defined( GL_LUMINANCE12_ALPHA12 )
672#define GL_LUMINANCE12_ALPHA12 0x8047 // deprecated, same as GL_LUMINANCE12_ALPHA12_EXT
673#endif
674#if !defined( GL_LUMINANCE16_ALPHA16 )
675#define GL_LUMINANCE16_ALPHA16 0x8048 // deprecated, same as GL_LUMINANCE16_ALPHA16_EXT
676#endif
677#if !defined( GL_LUMINANCE16_ALPHA16_SNORM )
678#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A // deprecated
679#endif
680#if !defined( GL_LUMINANCE_ALPHA16UI_EXT )
681#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B // deprecated
682#endif
683#if !defined( GL_LUMINANCE_ALPHA16I_EXT )
684#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D // deprecated
685#endif
686#if !defined( GL_LUMINANCE_ALPHA16F_ARB )
687#define GL_LUMINANCE_ALPHA16F_ARB 0x881F // deprecated, same as GL_LUMINANCE_ALPHA_FLOAT16_APPLE and GL_LUMINANCE_ALPHA_FLOAT16_ATI
688#endif
689#if !defined( GL_LUMINANCE_ALPHA32UI_EXT )
690#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 // deprecated
691#endif
692#if !defined( GL_LUMINANCE_ALPHA32I_EXT )
693#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 // deprecated
694#endif
695#if !defined( GL_LUMINANCE_ALPHA32F_ARB )
696#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 // deprecated, same as GL_LUMINANCE_ALPHA_FLOAT32_APPLE and GL_LUMINANCE_ALPHA_FLOAT32_ATI
697#endif
698
699//
700// Intensity
701//
702
703#if !defined( GL_INTENSITY4 )
704#define GL_INTENSITY4 0x804A // deprecated, same as GL_INTENSITY4_EXT
705#endif
706#if !defined( GL_INTENSITY8 )
707#define GL_INTENSITY8 0x804B // deprecated, same as GL_INTENSITY8_EXT
708#endif
709#if !defined( GL_INTENSITY8_SNORM )
710#define GL_INTENSITY8_SNORM 0x9017 // deprecated
711#endif
712#if !defined( GL_INTENSITY8UI_EXT )
713#define GL_INTENSITY8UI_EXT 0x8D7F // deprecated
714#endif
715#if !defined( GL_INTENSITY8I_EXT )
716#define GL_INTENSITY8I_EXT 0x8D91 // deprecated
717#endif
718#if !defined( GL_INTENSITY12 )
719#define GL_INTENSITY12 0x804C // deprecated, same as GL_INTENSITY12_EXT
720#endif
721#if !defined( GL_INTENSITY16 )
722#define GL_INTENSITY16 0x804D // deprecated, same as GL_INTENSITY16_EXT
723#endif
724#if !defined( GL_INTENSITY16_SNORM )
725#define GL_INTENSITY16_SNORM 0x901B // deprecated
726#endif
727#if !defined( GL_INTENSITY16UI_EXT )
728#define GL_INTENSITY16UI_EXT 0x8D79 // deprecated
729#endif
730#if !defined( GL_INTENSITY16I_EXT )
731#define GL_INTENSITY16I_EXT 0x8D8B // deprecated
732#endif
733#if !defined( GL_INTENSITY16F_ARB )
734#define GL_INTENSITY16F_ARB 0x881D // deprecated, same as GL_INTENSITY_FLOAT16_APPLE and GL_INTENSITY_FLOAT16_ATI
735#endif
736#if !defined( GL_INTENSITY32UI_EXT )
737#define GL_INTENSITY32UI_EXT 0x8D73 // deprecated
738#endif
739#if !defined( GL_INTENSITY32I_EXT )
740#define GL_INTENSITY32I_EXT 0x8D85 // deprecated
741#endif
742#if !defined( GL_INTENSITY32F_ARB )
743#define GL_INTENSITY32F_ARB 0x8817 // deprecated, same as GL_INTENSITY_FLOAT32_APPLE and GL_INTENSITY_FLOAT32_ATI
744#endif
745
746//
747// Generic compression
748//
749
750#if !defined( GL_COMPRESSED_RED )
751#define GL_COMPRESSED_RED 0x8225
752#endif
753#if !defined( GL_COMPRESSED_ALPHA )
754#define GL_COMPRESSED_ALPHA 0x84E9 // deprecated, same as GL_COMPRESSED_ALPHA_ARB
755#endif
756#if !defined( GL_COMPRESSED_LUMINANCE )
757#define GL_COMPRESSED_LUMINANCE 0x84EA // deprecated, same as GL_COMPRESSED_LUMINANCE_ARB
758#endif
759#if !defined( GL_COMPRESSED_SLUMINANCE )
760#define GL_COMPRESSED_SLUMINANCE 0x8C4A // deprecated, same as GL_COMPRESSED_SLUMINANCE_EXT
761#endif
762#if !defined( GL_COMPRESSED_LUMINANCE_ALPHA )
763#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB // deprecated, same as GL_COMPRESSED_LUMINANCE_ALPHA_ARB
764#endif
765#if !defined( GL_COMPRESSED_SLUMINANCE_ALPHA )
766#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B // deprecated, same as GL_COMPRESSED_SLUMINANCE_ALPHA_EXT
767#endif
768#if !defined( GL_COMPRESSED_INTENSITY )
769#define GL_COMPRESSED_INTENSITY 0x84EC // deprecated, same as GL_COMPRESSED_INTENSITY_ARB
770#endif
771#if !defined( GL_COMPRESSED_RG )
772#define GL_COMPRESSED_RG 0x8226
773#endif
774#if !defined( GL_COMPRESSED_RGB )
775#define GL_COMPRESSED_RGB 0x84ED // same as GL_COMPRESSED_RGB_ARB
776#endif
777#if !defined( GL_COMPRESSED_RGBA )
778#define GL_COMPRESSED_RGBA 0x84EE // same as GL_COMPRESSED_RGBA_ARB
779#endif
780#if !defined( GL_COMPRESSED_SRGB )
781#define GL_COMPRESSED_SRGB 0x8C48 // same as GL_COMPRESSED_SRGB_EXT
782#endif
783#if !defined( GL_COMPRESSED_SRGB_ALPHA )
784#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 // same as GL_COMPRESSED_SRGB_ALPHA_EXT
785#endif
786
787//
788// FXT1
789//
790
791#if !defined( GL_COMPRESSED_RGB_FXT1_3DFX )
792#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 // deprecated
793#endif
794#if !defined( GL_COMPRESSED_RGBA_FXT1_3DFX )
795#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 // deprecated
796#endif
797
798//
799// S3TC/DXT/BC
800//
801
802#if !defined( GL_COMPRESSED_RGB_S3TC_DXT1_EXT )
803#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
804#endif
805#if !defined( GL_COMPRESSED_RGBA_S3TC_DXT1_EXT )
806#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
807#endif
808#if !defined( GL_COMPRESSED_RGBA_S3TC_DXT3_EXT )
809#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
810#endif
811#if !defined( GL_COMPRESSED_RGBA_S3TC_DXT5_EXT )
812#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
813#endif
814
815#if !defined( GL_COMPRESSED_SRGB_S3TC_DXT1_EXT )
816#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
817#endif
818#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT )
819#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
820#endif
821#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT )
822#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
823#endif
824#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT )
825#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
826#endif
827
828#if !defined( GL_COMPRESSED_LUMINANCE_LATC1_EXT )
829#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
830#endif
831#if !defined( GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT )
832#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
833#endif
834#if !defined( GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT )
835#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71
836#endif
837#if !defined( GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT )
838#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73
839#endif
840
841#if !defined( GL_COMPRESSED_RED_RGTC1 )
842#define GL_COMPRESSED_RED_RGTC1 0x8DBB // same as GL_COMPRESSED_RED_RGTC1_EXT
843#endif
844#if !defined( GL_COMPRESSED_RG_RGTC2 )
845#define GL_COMPRESSED_RG_RGTC2 0x8DBD // same as GL_COMPRESSED_RG_RGTC2_EXT
846#endif
847#if !defined( GL_COMPRESSED_SIGNED_RED_RGTC1 )
848#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC // same as GL_COMPRESSED_SIGNED_RED_RGTC1_EXT
849#endif
850#if !defined( GL_COMPRESSED_SIGNED_RG_RGTC2 )
851#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE // same as GL_COMPRESSED_SIGNED_RG_RGTC2_EXT
852#endif
853
854#if !defined( GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT )
855#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E // same as GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
856#endif
857#if !defined( GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT )
858#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F // same as GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
859#endif
860#if !defined( GL_COMPRESSED_RGBA_BPTC_UNORM )
861#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C // same as GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
862#endif
863#if !defined( GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM )
864#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D // same as GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
865#endif
866
867//
868// ETC
869//
870
871#if !defined( GL_ETC1_RGB8_OES )
872#define GL_ETC1_RGB8_OES 0x8D64
873#endif
874
875#if !defined( GL_COMPRESSED_RGB8_ETC2 )
876#define GL_COMPRESSED_RGB8_ETC2 0x9274
877#endif
878#if !defined( GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 )
879#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
880#endif
881#if !defined( GL_COMPRESSED_RGBA8_ETC2_EAC )
882#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
883#endif
884
885#if !defined( GL_COMPRESSED_SRGB8_ETC2 )
886#define GL_COMPRESSED_SRGB8_ETC2 0x9275
887#endif
888#if !defined( GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 )
889#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
890#endif
891#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC )
892#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
893#endif
894
895#if !defined( GL_COMPRESSED_R11_EAC )
896#define GL_COMPRESSED_R11_EAC 0x9270
897#endif
898#if !defined( GL_COMPRESSED_RG11_EAC )
899#define GL_COMPRESSED_RG11_EAC 0x9272
900#endif
901#if !defined( GL_COMPRESSED_SIGNED_R11_EAC )
902#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
903#endif
904#if !defined( GL_COMPRESSED_SIGNED_RG11_EAC )
905#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
906#endif
907
908//
909// PVRTC
910//
911
912#if !defined( GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG )
913#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
914#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
915#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
916#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
917#endif
918#if !defined( GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG )
919#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
920#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
921#endif
922#if !defined( GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT )
923#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
924#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
925#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
926#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
927#endif
928#if !defined( GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG )
929#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0
930#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1
931#endif
932
933//
934// ASTC
935//
936
937#if !defined( GL_COMPRESSED_RGBA_ASTC_4x4_KHR )
938#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
939#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
940#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
941#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
942#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
943#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
944#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
945#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
946#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
947#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
948#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
949#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
950#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
951#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
952#endif
953
954#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR )
955#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
956#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
957#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
958#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
959#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
960#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
961#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
962#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
963#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
964#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
965#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
966#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
967#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
968#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
969#endif
970
971#if !defined( GL_COMPRESSED_RGBA_ASTC_3x3x3_OES )
972#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
973#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
974#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
975#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
976#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
977#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
978#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
979#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
980#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
981#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
982#endif
983
984#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES )
985#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
986#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
987#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
988#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
989#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
990#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
991#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
992#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
993#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
994#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
995#endif
996
997//
998// ATC
999//
1000
1001#if !defined( GL_ATC_RGB_AMD )
1002#define GL_ATC_RGB_AMD 0x8C92
1003#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
1004#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
1005#endif
1006
1007//
1008// Palletized (combined palette)
1009//
1010
1011#if !defined( GL_PALETTE4_RGB8_OES )
1012#define GL_PALETTE4_RGB8_OES 0x8B90
1013#define GL_PALETTE4_RGBA8_OES 0x8B91
1014#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
1015#define GL_PALETTE4_RGBA4_OES 0x8B93
1016#define GL_PALETTE4_RGB5_A1_OES 0x8B94
1017#define GL_PALETTE8_RGB8_OES 0x8B95
1018#define GL_PALETTE8_RGBA8_OES 0x8B96
1019#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
1020#define GL_PALETTE8_RGBA4_OES 0x8B98
1021#define GL_PALETTE8_RGB5_A1_OES 0x8B99
1022#endif
1023
1024//
1025// Palletized (separate palette)
1026//
1027
1028#if !defined( GL_COLOR_INDEX1_EXT )
1029#define GL_COLOR_INDEX1_EXT 0x80E2 // deprecated
1030#define GL_COLOR_INDEX2_EXT 0x80E3 // deprecated
1031#define GL_COLOR_INDEX4_EXT 0x80E4 // deprecated
1032#define GL_COLOR_INDEX8_EXT 0x80E5 // deprecated
1033#define GL_COLOR_INDEX12_EXT 0x80E6 // deprecated
1034#define GL_COLOR_INDEX16_EXT 0x80E7 // deprecated
1035#endif
1036
1037//
1038// Depth/stencil
1039//
1040
1041#if !defined( GL_DEPTH_COMPONENT16 )
1042#define GL_DEPTH_COMPONENT16 0x81A5 // same as GL_DEPTH_COMPONENT16_SGIX and GL_DEPTH_COMPONENT16_ARB
1043#endif
1044#if !defined( GL_DEPTH_COMPONENT24 )
1045#define GL_DEPTH_COMPONENT24 0x81A6 // same as GL_DEPTH_COMPONENT24_SGIX and GL_DEPTH_COMPONENT24_ARB
1046#endif
1047#if !defined( GL_DEPTH_COMPONENT32 )
1048#define GL_DEPTH_COMPONENT32 0x81A7 // same as GL_DEPTH_COMPONENT32_SGIX and GL_DEPTH_COMPONENT32_ARB and GL_DEPTH_COMPONENT32_OES
1049#endif
1050#if !defined( GL_DEPTH_COMPONENT32F )
1051#define GL_DEPTH_COMPONENT32F 0x8CAC // same as GL_DEPTH_COMPONENT32F_ARB
1052#endif
1053#if !defined( GL_DEPTH_COMPONENT32F_NV )
1054#define GL_DEPTH_COMPONENT32F_NV 0x8DAB // note that this is different from GL_DEPTH_COMPONENT32F
1055#endif
1056#if !defined( GL_STENCIL_INDEX1 )
1057#define GL_STENCIL_INDEX1 0x8D46 // same as GL_STENCIL_INDEX1_EXT
1058#endif
1059#if !defined( GL_STENCIL_INDEX4 )
1060#define GL_STENCIL_INDEX4 0x8D47 // same as GL_STENCIL_INDEX4_EXT
1061#endif
1062#if !defined( GL_STENCIL_INDEX8 )
1063#define GL_STENCIL_INDEX8 0x8D48 // same as GL_STENCIL_INDEX8_EXT
1064#endif
1065#if !defined( GL_STENCIL_INDEX16 )
1066#define GL_STENCIL_INDEX16 0x8D49 // same as GL_STENCIL_INDEX16_EXT
1067#endif
1068#if !defined( GL_DEPTH24_STENCIL8 )
1069#define GL_DEPTH24_STENCIL8 0x88F0 // same as GL_DEPTH24_STENCIL8_EXT and GL_DEPTH24_STENCIL8_OES
1070#endif
1071#if !defined( GL_DEPTH32F_STENCIL8 )
1072#define GL_DEPTH32F_STENCIL8 0x8CAD // same as GL_DEPTH32F_STENCIL8_ARB
1073#endif
1074#if !defined( GL_DEPTH32F_STENCIL8_NV )
1075#define GL_DEPTH32F_STENCIL8_NV 0x8DAC // note that this is different from GL_DEPTH32F_STENCIL8
1076#endif
1077
1078static inline GLenum glGetFormatFromInternalFormat( const GLenum internalFormat )
1079{
1080 switch ( internalFormat )
1081 {
1082 //
1083 // 8 bits per component
1084 //
1085 case GL_R8: return GL_RED; // 1-component, 8-bit unsigned normalized
1086 case GL_RG8: return GL_RG; // 2-component, 8-bit unsigned normalized
1087 case GL_RGB8: return GL_RGB; // 3-component, 8-bit unsigned normalized
1088 case GL_RGBA8: return GL_RGBA; // 4-component, 8-bit unsigned normalized
1089
1090 case GL_R8_SNORM: return GL_RED; // 1-component, 8-bit signed normalized
1091 case GL_RG8_SNORM: return GL_RG; // 2-component, 8-bit signed normalized
1092 case GL_RGB8_SNORM: return GL_RGB; // 3-component, 8-bit signed normalized
1093 case GL_RGBA8_SNORM: return GL_RGBA; // 4-component, 8-bit signed normalized
1094
1095 case GL_R8UI: return GL_RED; // 1-component, 8-bit unsigned integer
1096 case GL_RG8UI: return GL_RG; // 2-component, 8-bit unsigned integer
1097 case GL_RGB8UI: return GL_RGB; // 3-component, 8-bit unsigned integer
1098 case GL_RGBA8UI: return GL_RGBA; // 4-component, 8-bit unsigned integer
1099
1100 case GL_R8I: return GL_RED; // 1-component, 8-bit signed integer
1101 case GL_RG8I: return GL_RG; // 2-component, 8-bit signed integer
1102 case GL_RGB8I: return GL_RGB; // 3-component, 8-bit signed integer
1103 case GL_RGBA8I: return GL_RGBA; // 4-component, 8-bit signed integer
1104
1105 case GL_SR8: return GL_RED; // 1-component, 8-bit sRGB
1106 case GL_SRG8: return GL_RG; // 2-component, 8-bit sRGB
1107 case GL_SRGB8: return GL_RGB; // 3-component, 8-bit sRGB
1108 case GL_SRGB8_ALPHA8: return GL_RGBA; // 4-component, 8-bit sRGB
1109
1110 //
1111 // 16 bits per component
1112 //
1113 case GL_R16: return GL_RED; // 1-component, 16-bit unsigned normalized
1114 case GL_RG16: return GL_RG; // 2-component, 16-bit unsigned normalized
1115 case GL_RGB16: return GL_RGB; // 3-component, 16-bit unsigned normalized
1116 case GL_RGBA16: return GL_RGBA; // 4-component, 16-bit unsigned normalized
1117
1118 case GL_R16_SNORM: return GL_RED; // 1-component, 16-bit signed normalized
1119 case GL_RG16_SNORM: return GL_RG; // 2-component, 16-bit signed normalized
1120 case GL_RGB16_SNORM: return GL_RGB; // 3-component, 16-bit signed normalized
1121 case GL_RGBA16_SNORM: return GL_RGBA; // 4-component, 16-bit signed normalized
1122
1123 case GL_R16UI: return GL_RED; // 1-component, 16-bit unsigned integer
1124 case GL_RG16UI: return GL_RG; // 2-component, 16-bit unsigned integer
1125 case GL_RGB16UI: return GL_RGB; // 3-component, 16-bit unsigned integer
1126 case GL_RGBA16UI: return GL_RGBA; // 4-component, 16-bit unsigned integer
1127
1128 case GL_R16I: return GL_RED; // 1-component, 16-bit signed integer
1129 case GL_RG16I: return GL_RG; // 2-component, 16-bit signed integer
1130 case GL_RGB16I: return GL_RGB; // 3-component, 16-bit signed integer
1131 case GL_RGBA16I: return GL_RGBA; // 4-component, 16-bit signed integer
1132
1133 case GL_R16F: return GL_RED; // 1-component, 16-bit floating-point
1134 case GL_RG16F: return GL_RG; // 2-component, 16-bit floating-point
1135 case GL_RGB16F: return GL_RGB; // 3-component, 16-bit floating-point
1136 case GL_RGBA16F: return GL_RGBA; // 4-component, 16-bit floating-point
1137
1138 //
1139 // 32 bits per component
1140 //
1141 case GL_R32UI: return GL_RED; // 1-component, 32-bit unsigned integer
1142 case GL_RG32UI: return GL_RG; // 2-component, 32-bit unsigned integer
1143 case GL_RGB32UI: return GL_RGB; // 3-component, 32-bit unsigned integer
1144 case GL_RGBA32UI: return GL_RGBA; // 4-component, 32-bit unsigned integer
1145
1146 case GL_R32I: return GL_RED; // 1-component, 32-bit signed integer
1147 case GL_RG32I: return GL_RG; // 2-component, 32-bit signed integer
1148 case GL_RGB32I: return GL_RGB; // 3-component, 32-bit signed integer
1149 case GL_RGBA32I: return GL_RGBA; // 4-component, 32-bit signed integer
1150
1151 case GL_R32F: return GL_RED; // 1-component, 32-bit floating-point
1152 case GL_RG32F: return GL_RG; // 2-component, 32-bit floating-point
1153 case GL_RGB32F: return GL_RGB; // 3-component, 32-bit floating-point
1154 case GL_RGBA32F: return GL_RGBA; // 4-component, 32-bit floating-point
1155
1156 //
1157 // Packed
1158 //
1159 case GL_R3_G3_B2: return GL_RGB; // 3-component 3:3:2, unsigned normalized
1160 case GL_RGB4: return GL_RGB; // 3-component 4:4:4, unsigned normalized
1161 case GL_RGB5: return GL_RGB; // 3-component 5:5:5, unsigned normalized
1162 case GL_RGB565: return GL_RGB; // 3-component 5:6:5, unsigned normalized
1163 case GL_RGB10: return GL_RGB; // 3-component 10:10:10, unsigned normalized
1164 case GL_RGB12: return GL_RGB; // 3-component 12:12:12, unsigned normalized
1165 case GL_RGBA2: return GL_RGBA; // 4-component 2:2:2:2, unsigned normalized
1166 case GL_RGBA4: return GL_RGBA; // 4-component 4:4:4:4, unsigned normalized
1167 case GL_RGBA12: return GL_RGBA; // 4-component 12:12:12:12, unsigned normalized
1168 case GL_RGB5_A1: return GL_RGBA; // 4-component 5:5:5:1, unsigned normalized
1169 case GL_RGB10_A2: return GL_RGBA; // 4-component 10:10:10:2, unsigned normalized
1170 case GL_RGB10_A2UI: return GL_RGBA; // 4-component 10:10:10:2, unsigned integer
1171 case GL_R11F_G11F_B10F: return GL_RGB; // 3-component 11:11:10, floating-point
1172 case GL_RGB9_E5: return GL_RGB; // 3-component/exp 9:9:9/5, floating-point
1173
1174 //
1175 // S3TC/DXT/BC
1176 //
1177
1178 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GL_RGB; // line through 3D space, 4x4 blocks, unsigned normalized
1179 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return GL_RGBA; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized
1180 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return GL_RGBA; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized
1181 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return GL_RGBA; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized
1182
1183 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return GL_RGB; // line through 3D space, 4x4 blocks, sRGB
1184 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return GL_RGBA; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB
1185 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return GL_RGBA; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB
1186 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return GL_RGBA; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB
1187
1188 case GL_COMPRESSED_LUMINANCE_LATC1_EXT: return GL_RED; // line through 1D space, 4x4 blocks, unsigned normalized
1189 case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: return GL_RG; // two lines through 1D space, 4x4 blocks, unsigned normalized
1190 case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: return GL_RED; // line through 1D space, 4x4 blocks, signed normalized
1191 case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: return GL_RG; // two lines through 1D space, 4x4 blocks, signed normalized
1192
1193 case GL_COMPRESSED_RED_RGTC1: return GL_RED; // line through 1D space, 4x4 blocks, unsigned normalized
1194 case GL_COMPRESSED_RG_RGTC2: return GL_RG; // two lines through 1D space, 4x4 blocks, unsigned normalized
1195 case GL_COMPRESSED_SIGNED_RED_RGTC1: return GL_RED; // line through 1D space, 4x4 blocks, signed normalized
1196 case GL_COMPRESSED_SIGNED_RG_RGTC2: return GL_RG; // two lines through 1D space, 4x4 blocks, signed normalized
1197
1198 case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return GL_RGB; // 3-component, 4x4 blocks, unsigned floating-point
1199 case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: return GL_RGB; // 3-component, 4x4 blocks, signed floating-point
1200 case GL_COMPRESSED_RGBA_BPTC_UNORM: return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized
1201 case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: return GL_RGBA; // 4-component, 4x4 blocks, sRGB
1202
1203 //
1204 // ETC
1205 //
1206 case GL_ETC1_RGB8_OES: return GL_RGB; // 3-component ETC1, 4x4 blocks, unsigned normalized
1207
1208 case GL_COMPRESSED_RGB8_ETC2: return GL_RGB; // 3-component ETC2, 4x4 blocks, unsigned normalized
1209 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_RGBA; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized
1210 case GL_COMPRESSED_RGBA8_ETC2_EAC: return GL_RGBA; // 4-component ETC2, 4x4 blocks, unsigned normalized
1211
1212 case GL_COMPRESSED_SRGB8_ETC2: return GL_RGB; // 3-component ETC2, 4x4 blocks, sRGB
1213 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_RGBA; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB
1214 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return GL_RGBA; // 4-component ETC2, 4x4 blocks, sRGB
1215
1216 case GL_COMPRESSED_R11_EAC: return GL_RED; // 1-component ETC, 4x4 blocks, unsigned normalized
1217 case GL_COMPRESSED_RG11_EAC: return GL_RG; // 2-component ETC, 4x4 blocks, unsigned normalized
1218 case GL_COMPRESSED_SIGNED_R11_EAC: return GL_RED; // 1-component ETC, 4x4 blocks, signed normalized
1219 case GL_COMPRESSED_SIGNED_RG11_EAC: return GL_RG; // 2-component ETC, 4x4 blocks, signed normalized
1220
1221 //
1222 // PVRTC
1223 //
1224 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: return GL_RGB; // 3-component PVRTC, 16x8 blocks, unsigned normalized
1225 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: return GL_RGB; // 3-component PVRTC, 8x8 blocks, unsigned normalized
1226 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: return GL_RGBA; // 4-component PVRTC, 16x8 blocks, unsigned normalized
1227 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: return GL_RGBA; // 4-component PVRTC, 8x8 blocks, unsigned normalized
1228 case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 8x4 blocks, unsigned normalized
1229 case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 4x4 blocks, unsigned normalized
1230
1231 case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: return GL_RGB; // 3-component PVRTC, 16x8 blocks, sRGB
1232 case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: return GL_RGB; // 3-component PVRTC, 8x8 blocks, sRGB
1233 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: return GL_RGBA; // 4-component PVRTC, 16x8 blocks, sRGB
1234 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: return GL_RGBA; // 4-component PVRTC, 8x8 blocks, sRGB
1235 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 8x4 blocks, sRGB
1236 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 4x4 blocks, sRGB
1237
1238 //
1239 // ASTC
1240 //
1241 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: return GL_RGBA; // 4-component ASTC, 4x4 blocks, unsigned normalized
1242 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: return GL_RGBA; // 4-component ASTC, 5x4 blocks, unsigned normalized
1243 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: return GL_RGBA; // 4-component ASTC, 5x5 blocks, unsigned normalized
1244 case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: return GL_RGBA; // 4-component ASTC, 6x5 blocks, unsigned normalized
1245 case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: return GL_RGBA; // 4-component ASTC, 6x6 blocks, unsigned normalized
1246 case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: return GL_RGBA; // 4-component ASTC, 8x5 blocks, unsigned normalized
1247 case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: return GL_RGBA; // 4-component ASTC, 8x6 blocks, unsigned normalized
1248 case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: return GL_RGBA; // 4-component ASTC, 8x8 blocks, unsigned normalized
1249 case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: return GL_RGBA; // 4-component ASTC, 10x5 blocks, unsigned normalized
1250 case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: return GL_RGBA; // 4-component ASTC, 10x6 blocks, unsigned normalized
1251 case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: return GL_RGBA; // 4-component ASTC, 10x8 blocks, unsigned normalized
1252 case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: return GL_RGBA; // 4-component ASTC, 10x10 blocks, unsigned normalized
1253 case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: return GL_RGBA; // 4-component ASTC, 12x10 blocks, unsigned normalized
1254 case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: return GL_RGBA; // 4-component ASTC, 12x12 blocks, unsigned normalized
1255
1256 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: return GL_RGBA; // 4-component ASTC, 4x4 blocks, sRGB
1257 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: return GL_RGBA; // 4-component ASTC, 5x4 blocks, sRGB
1258 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: return GL_RGBA; // 4-component ASTC, 5x5 blocks, sRGB
1259 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: return GL_RGBA; // 4-component ASTC, 6x5 blocks, sRGB
1260 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: return GL_RGBA; // 4-component ASTC, 6x6 blocks, sRGB
1261 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: return GL_RGBA; // 4-component ASTC, 8x5 blocks, sRGB
1262 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: return GL_RGBA; // 4-component ASTC, 8x6 blocks, sRGB
1263 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: return GL_RGBA; // 4-component ASTC, 8x8 blocks, sRGB
1264 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: return GL_RGBA; // 4-component ASTC, 10x5 blocks, sRGB
1265 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: return GL_RGBA; // 4-component ASTC, 10x6 blocks, sRGB
1266 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: return GL_RGBA; // 4-component ASTC, 10x8 blocks, sRGB
1267 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: return GL_RGBA; // 4-component ASTC, 10x10 blocks, sRGB
1268 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: return GL_RGBA; // 4-component ASTC, 12x10 blocks, sRGB
1269 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return GL_RGBA; // 4-component ASTC, 12x12 blocks, sRGB
1270
1271 case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: return GL_RGBA; // 4-component ASTC, 3x3x3 blocks, unsigned normalized
1272 case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: return GL_RGBA; // 4-component ASTC, 4x3x3 blocks, unsigned normalized
1273 case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: return GL_RGBA; // 4-component ASTC, 4x4x3 blocks, unsigned normalized
1274 case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: return GL_RGBA; // 4-component ASTC, 4x4x4 blocks, unsigned normalized
1275 case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: return GL_RGBA; // 4-component ASTC, 5x4x4 blocks, unsigned normalized
1276 case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: return GL_RGBA; // 4-component ASTC, 5x5x4 blocks, unsigned normalized
1277 case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: return GL_RGBA; // 4-component ASTC, 5x5x5 blocks, unsigned normalized
1278 case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: return GL_RGBA; // 4-component ASTC, 6x5x5 blocks, unsigned normalized
1279 case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: return GL_RGBA; // 4-component ASTC, 6x6x5 blocks, unsigned normalized
1280 case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: return GL_RGBA; // 4-component ASTC, 6x6x6 blocks, unsigned normalized
1281
1282 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: return GL_RGBA; // 4-component ASTC, 3x3x3 blocks, sRGB
1283 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: return GL_RGBA; // 4-component ASTC, 4x3x3 blocks, sRGB
1284 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: return GL_RGBA; // 4-component ASTC, 4x4x3 blocks, sRGB
1285 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: return GL_RGBA; // 4-component ASTC, 4x4x4 blocks, sRGB
1286 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: return GL_RGBA; // 4-component ASTC, 5x4x4 blocks, sRGB
1287 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: return GL_RGBA; // 4-component ASTC, 5x5x4 blocks, sRGB
1288 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: return GL_RGBA; // 4-component ASTC, 5x5x5 blocks, sRGB
1289 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: return GL_RGBA; // 4-component ASTC, 6x5x5 blocks, sRGB
1290 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: return GL_RGBA; // 4-component ASTC, 6x6x5 blocks, sRGB
1291 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: return GL_RGBA; // 4-component ASTC, 6x6x6 blocks, sRGB
1292
1293 //
1294 // ATC
1295 //
1296 case GL_ATC_RGB_AMD: return GL_RGB; // 3-component, 4x4 blocks, unsigned normalized
1297 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized
1298 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized
1299
1300 //
1301 // Palletized
1302 //
1303 case GL_PALETTE4_RGB8_OES: return GL_RGB; // 3-component 8:8:8, 4-bit palette, unsigned normalized
1304 case GL_PALETTE4_RGBA8_OES: return GL_RGBA; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized
1305 case GL_PALETTE4_R5_G6_B5_OES: return GL_RGB; // 3-component 5:6:5, 4-bit palette, unsigned normalized
1306 case GL_PALETTE4_RGBA4_OES: return GL_RGBA; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized
1307 case GL_PALETTE4_RGB5_A1_OES: return GL_RGBA; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized
1308 case GL_PALETTE8_RGB8_OES: return GL_RGB; // 3-component 8:8:8, 8-bit palette, unsigned normalized
1309 case GL_PALETTE8_RGBA8_OES: return GL_RGBA; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized
1310 case GL_PALETTE8_R5_G6_B5_OES: return GL_RGB; // 3-component 5:6:5, 8-bit palette, unsigned normalized
1311 case GL_PALETTE8_RGBA4_OES: return GL_RGBA; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized
1312 case GL_PALETTE8_RGB5_A1_OES: return GL_RGBA; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized
1313
1314 //
1315 // Depth/stencil
1316 //
1317 case GL_DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT;
1318 case GL_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT;
1319 case GL_DEPTH_COMPONENT32: return GL_DEPTH_COMPONENT;
1320 case GL_DEPTH_COMPONENT32F: return GL_DEPTH_COMPONENT;
1321 case GL_DEPTH_COMPONENT32F_NV: return GL_DEPTH_COMPONENT;
1322 case GL_STENCIL_INDEX1: return GL_STENCIL_INDEX;
1323 case GL_STENCIL_INDEX4: return GL_STENCIL_INDEX;
1324 case GL_STENCIL_INDEX8: return GL_STENCIL_INDEX;
1325 case GL_STENCIL_INDEX16: return GL_STENCIL_INDEX;
1326 case GL_DEPTH24_STENCIL8: return GL_DEPTH_STENCIL;
1327 case GL_DEPTH32F_STENCIL8: return GL_DEPTH_STENCIL;
1328 case GL_DEPTH32F_STENCIL8_NV: return GL_DEPTH_STENCIL;
1329
1330 default: return GL_INVALID_VALUE;
1331 }
1332}
1333
1334static inline GLenum glGetTypeFromInternalFormat( const GLenum internalFormat )
1335{
1336 switch ( internalFormat )
1337 {
1338 //
1339 // 8 bits per component
1340 //
1341 case GL_R8: return GL_UNSIGNED_BYTE; // 1-component, 8-bit unsigned normalized
1342 case GL_RG8: return GL_UNSIGNED_BYTE; // 2-component, 8-bit unsigned normalized
1343 case GL_RGB8: return GL_UNSIGNED_BYTE; // 3-component, 8-bit unsigned normalized
1344 case GL_RGBA8: return GL_UNSIGNED_BYTE; // 4-component, 8-bit unsigned normalized
1345
1346 case GL_R8_SNORM: return GL_BYTE; // 1-component, 8-bit signed normalized
1347 case GL_RG8_SNORM: return GL_BYTE; // 2-component, 8-bit signed normalized
1348 case GL_RGB8_SNORM: return GL_BYTE; // 3-component, 8-bit signed normalized
1349 case GL_RGBA8_SNORM: return GL_BYTE; // 4-component, 8-bit signed normalized
1350
1351 case GL_R8UI: return GL_UNSIGNED_BYTE; // 1-component, 8-bit unsigned integer
1352 case GL_RG8UI: return GL_UNSIGNED_BYTE; // 2-component, 8-bit unsigned integer
1353 case GL_RGB8UI: return GL_UNSIGNED_BYTE; // 3-component, 8-bit unsigned integer
1354 case GL_RGBA8UI: return GL_UNSIGNED_BYTE; // 4-component, 8-bit unsigned integer
1355
1356 case GL_R8I: return GL_BYTE; // 1-component, 8-bit signed integer
1357 case GL_RG8I: return GL_BYTE; // 2-component, 8-bit signed integer
1358 case GL_RGB8I: return GL_BYTE; // 3-component, 8-bit signed integer
1359 case GL_RGBA8I: return GL_BYTE; // 4-component, 8-bit signed integer
1360
1361 case GL_SR8: return GL_UNSIGNED_BYTE; // 1-component, 8-bit sRGB
1362 case GL_SRG8: return GL_UNSIGNED_BYTE; // 2-component, 8-bit sRGB
1363 case GL_SRGB8: return GL_UNSIGNED_BYTE; // 3-component, 8-bit sRGB
1364 case GL_SRGB8_ALPHA8: return GL_UNSIGNED_BYTE; // 4-component, 8-bit sRGB
1365
1366 //
1367 // 16 bits per component
1368 //
1369 case GL_R16: return GL_UNSIGNED_SHORT; // 1-component, 16-bit unsigned normalized
1370 case GL_RG16: return GL_UNSIGNED_SHORT; // 2-component, 16-bit unsigned normalized
1371 case GL_RGB16: return GL_UNSIGNED_SHORT; // 3-component, 16-bit unsigned normalized
1372 case GL_RGBA16: return GL_UNSIGNED_SHORT; // 4-component, 16-bit unsigned normalized
1373
1374 case GL_R16_SNORM: return GL_SHORT; // 1-component, 16-bit signed normalized
1375 case GL_RG16_SNORM: return GL_SHORT; // 2-component, 16-bit signed normalized
1376 case GL_RGB16_SNORM: return GL_SHORT; // 3-component, 16-bit signed normalized
1377 case GL_RGBA16_SNORM: return GL_SHORT; // 4-component, 16-bit signed normalized
1378
1379 case GL_R16UI: return GL_UNSIGNED_SHORT; // 1-component, 16-bit unsigned integer
1380 case GL_RG16UI: return GL_UNSIGNED_SHORT; // 2-component, 16-bit unsigned integer
1381 case GL_RGB16UI: return GL_UNSIGNED_SHORT; // 3-component, 16-bit unsigned integer
1382 case GL_RGBA16UI: return GL_UNSIGNED_SHORT; // 4-component, 16-bit unsigned integer
1383
1384 case GL_R16I: return GL_SHORT; // 1-component, 16-bit signed integer
1385 case GL_RG16I: return GL_SHORT; // 2-component, 16-bit signed integer
1386 case GL_RGB16I: return GL_SHORT; // 3-component, 16-bit signed integer
1387 case GL_RGBA16I: return GL_SHORT; // 4-component, 16-bit signed integer
1388
1389 case GL_R16F: return GL_HALF_FLOAT; // 1-component, 16-bit floating-point
1390 case GL_RG16F: return GL_HALF_FLOAT; // 2-component, 16-bit floating-point
1391 case GL_RGB16F: return GL_HALF_FLOAT; // 3-component, 16-bit floating-point
1392 case GL_RGBA16F: return GL_HALF_FLOAT; // 4-component, 16-bit floating-point
1393
1394 //
1395 // 32 bits per component
1396 //
1397 case GL_R32UI: return GL_UNSIGNED_INT; // 1-component, 32-bit unsigned integer
1398 case GL_RG32UI: return GL_UNSIGNED_INT; // 2-component, 32-bit unsigned integer
1399 case GL_RGB32UI: return GL_UNSIGNED_INT; // 3-component, 32-bit unsigned integer
1400 case GL_RGBA32UI: return GL_UNSIGNED_INT; // 4-component, 32-bit unsigned integer
1401
1402 case GL_R32I: return GL_INT; // 1-component, 32-bit signed integer
1403 case GL_RG32I: return GL_INT; // 2-component, 32-bit signed integer
1404 case GL_RGB32I: return GL_INT; // 3-component, 32-bit signed integer
1405 case GL_RGBA32I: return GL_INT; // 4-component, 32-bit signed integer
1406
1407 case GL_R32F: return GL_FLOAT; // 1-component, 32-bit floating-point
1408 case GL_RG32F: return GL_FLOAT; // 2-component, 32-bit floating-point
1409 case GL_RGB32F: return GL_FLOAT; // 3-component, 32-bit floating-point
1410 case GL_RGBA32F: return GL_FLOAT; // 4-component, 32-bit floating-point
1411
1412 //
1413 // Packed
1414 //
1415 case GL_R3_G3_B2: return GL_UNSIGNED_BYTE_2_3_3_REV; // 3-component 3:3:2, unsigned normalized
1416 case GL_RGB4: return GL_UNSIGNED_SHORT_4_4_4_4; // 3-component 4:4:4, unsigned normalized
1417 case GL_RGB5: return GL_UNSIGNED_SHORT_5_5_5_1; // 3-component 5:5:5, unsigned normalized
1418 case GL_RGB565: return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, unsigned normalized
1419 case GL_RGB10: return GL_UNSIGNED_INT_10_10_10_2; // 3-component 10:10:10, unsigned normalized
1420 case GL_RGB12: return GL_UNSIGNED_SHORT; // 3-component 12:12:12, unsigned normalized
1421 case GL_RGBA2: return GL_UNSIGNED_BYTE; // 4-component 2:2:2:2, unsigned normalized
1422 case GL_RGBA4: return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, unsigned normalized
1423 case GL_RGBA12: return GL_UNSIGNED_SHORT; // 4-component 12:12:12:12, unsigned normalized
1424 case GL_RGB5_A1: return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, unsigned normalized
1425 case GL_RGB10_A2: return GL_UNSIGNED_INT_2_10_10_10_REV; // 4-component 10:10:10:2, unsigned normalized
1426 case GL_RGB10_A2UI: return GL_UNSIGNED_INT_2_10_10_10_REV; // 4-component 10:10:10:2, unsigned integer
1427 case GL_R11F_G11F_B10F: return GL_UNSIGNED_INT_10F_11F_11F_REV; // 3-component 11:11:10, floating-point
1428 case GL_RGB9_E5: return GL_UNSIGNED_INT_5_9_9_9_REV; // 3-component/exp 9:9:9/5, floating-point
1429
1430 //
1431 // S3TC/DXT/BC
1432 //
1433
1434 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space, 4x4 blocks, unsigned normalized
1435 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized
1436 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized
1437 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized
1438
1439 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space, 4x4 blocks, sRGB
1440 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB
1441 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB
1442 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB
1443
1444 case GL_COMPRESSED_LUMINANCE_LATC1_EXT: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, unsigned normalized
1445 case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, unsigned normalized
1446 case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, signed normalized
1447 case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, signed normalized
1448
1449 case GL_COMPRESSED_RED_RGTC1: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, unsigned normalized
1450 case GL_COMPRESSED_RG_RGTC2: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, unsigned normalized
1451 case GL_COMPRESSED_SIGNED_RED_RGTC1: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, signed normalized
1452 case GL_COMPRESSED_SIGNED_RG_RGTC2: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, signed normalized
1453
1454 case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return GL_FLOAT; // 3-component, 4x4 blocks, unsigned floating-point
1455 case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: return GL_FLOAT; // 3-component, 4x4 blocks, signed floating-point
1456 case GL_COMPRESSED_RGBA_BPTC_UNORM: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized
1457 case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, sRGB
1458
1459 //
1460 // ETC
1461 //
1462 case GL_ETC1_RGB8_OES: return GL_UNSIGNED_BYTE; // 3-component ETC1, 4x4 blocks, unsigned normalized" ),
1463
1464 case GL_COMPRESSED_RGB8_ETC2: return GL_UNSIGNED_BYTE; // 3-component ETC2, 4x4 blocks, unsigned normalized
1465 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_UNSIGNED_BYTE; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized
1466 case GL_COMPRESSED_RGBA8_ETC2_EAC: return GL_UNSIGNED_BYTE; // 4-component ETC2, 4x4 blocks, unsigned normalized
1467
1468 case GL_COMPRESSED_SRGB8_ETC2: return GL_UNSIGNED_BYTE; // 3-component ETC2, 4x4 blocks, sRGB
1469 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_UNSIGNED_BYTE; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB
1470 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return GL_UNSIGNED_BYTE; // 4-component ETC2, 4x4 blocks, sRGB
1471
1472 case GL_COMPRESSED_R11_EAC: return GL_UNSIGNED_BYTE; // 1-component ETC, 4x4 blocks, unsigned normalized
1473 case GL_COMPRESSED_RG11_EAC: return GL_UNSIGNED_BYTE; // 2-component ETC, 4x4 blocks, unsigned normalized
1474 case GL_COMPRESSED_SIGNED_R11_EAC: return GL_UNSIGNED_BYTE; // 1-component ETC, 4x4 blocks, signed normalized
1475 case GL_COMPRESSED_SIGNED_RG11_EAC: return GL_UNSIGNED_BYTE; // 2-component ETC, 4x4 blocks, signed normalized
1476
1477 //
1478 // PVRTC
1479 //
1480 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 16x8 blocks, unsigned normalized
1481 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 8x8 blocks, unsigned normalized
1482 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 16x8 blocks, unsigned normalized
1483 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x8 blocks, unsigned normalized
1484 case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x4 blocks, unsigned normalized
1485 case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 4x4 blocks, unsigned normalized
1486
1487 case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 16x8 blocks, sRGB
1488 case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 8x8 blocks, sRGB
1489 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 16x8 blocks, sRGB
1490 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x8 blocks, sRGB
1491 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x4 blocks, sRGB
1492 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 4x4 blocks, sRGB
1493
1494 //
1495 // ASTC
1496 //
1497 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4 blocks, unsigned normalized
1498 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4 blocks, unsigned normalized
1499 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5 blocks, unsigned normalized
1500 case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5 blocks, unsigned normalized
1501 case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6 blocks, unsigned normalized
1502 case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x5 blocks, unsigned normalized
1503 case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x6 blocks, unsigned normalized
1504 case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x8 blocks, unsigned normalized
1505 case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x5 blocks, unsigned normalized
1506 case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x6 blocks, unsigned normalized
1507 case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x8 blocks, unsigned normalized
1508 case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x10 blocks, unsigned normalized
1509 case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x10 blocks, unsigned normalized
1510 case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x12 blocks, unsigned normalized
1511
1512 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4 blocks, sRGB
1513 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4 blocks, sRGB
1514 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5 blocks, sRGB
1515 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5 blocks, sRGB
1516 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6 blocks, sRGB
1517 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x5 blocks, sRGB
1518 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x6 blocks, sRGB
1519 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x8 blocks, sRGB
1520 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x5 blocks, sRGB
1521 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x6 blocks, sRGB
1522 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x8 blocks, sRGB
1523 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x10 blocks, sRGB
1524 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x10 blocks, sRGB
1525 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x12 blocks, sRGB
1526
1527 case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 3x3x3 blocks, unsigned normalized
1528 case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x3x3 blocks, unsigned normalized
1529 case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x3 blocks, unsigned normalized
1530 case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x4 blocks, unsigned normalized
1531 case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4x4 blocks, unsigned normalized
1532 case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x4 blocks, unsigned normalized
1533 case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x5 blocks, unsigned normalized
1534 case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5x5 blocks, unsigned normalized
1535 case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x5 blocks, unsigned normalized
1536 case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x6 blocks, unsigned normalized
1537
1538 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 3x3x3 blocks, sRGB
1539 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x3x3 blocks, sRGB
1540 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x3 blocks, sRGB
1541 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x4 blocks, sRGB
1542 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4x4 blocks, sRGB
1543 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x4 blocks, sRGB
1544 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x5 blocks, sRGB
1545 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5x5 blocks, sRGB
1546 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x5 blocks, sRGB
1547 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x6 blocks, sRGB
1548
1549 //
1550 // ATC
1551 //
1552 case GL_ATC_RGB_AMD: return GL_UNSIGNED_BYTE; // 3-component, 4x4 blocks, unsigned normalized
1553 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized
1554 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized
1555
1556 //
1557 // Palletized
1558 //
1559 case GL_PALETTE4_RGB8_OES: return GL_UNSIGNED_BYTE; // 3-component 8:8:8, 4-bit palette, unsigned normalized
1560 case GL_PALETTE4_RGBA8_OES: return GL_UNSIGNED_BYTE; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized
1561 case GL_PALETTE4_R5_G6_B5_OES: return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, 4-bit palette, unsigned normalized
1562 case GL_PALETTE4_RGBA4_OES: return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized
1563 case GL_PALETTE4_RGB5_A1_OES: return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized
1564 case GL_PALETTE8_RGB8_OES: return GL_UNSIGNED_BYTE; // 3-component 8:8:8, 8-bit palette, unsigned normalized
1565 case GL_PALETTE8_RGBA8_OES: return GL_UNSIGNED_BYTE; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized
1566 case GL_PALETTE8_R5_G6_B5_OES: return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, 8-bit palette, unsigned normalized
1567 case GL_PALETTE8_RGBA4_OES: return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized
1568 case GL_PALETTE8_RGB5_A1_OES: return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized
1569
1570 //
1571 // Depth/stencil
1572 //
1573 case GL_DEPTH_COMPONENT16: return GL_UNSIGNED_SHORT;
1574 case GL_DEPTH_COMPONENT24: return GL_UNSIGNED_INT_24_8;
1575 case GL_DEPTH_COMPONENT32: return GL_UNSIGNED_INT;
1576 case GL_DEPTH_COMPONENT32F: return GL_FLOAT;
1577 case GL_DEPTH_COMPONENT32F_NV: return GL_FLOAT;
1578 case GL_STENCIL_INDEX1: return GL_UNSIGNED_BYTE;
1579 case GL_STENCIL_INDEX4: return GL_UNSIGNED_BYTE;
1580 case GL_STENCIL_INDEX8: return GL_UNSIGNED_BYTE;
1581 case GL_STENCIL_INDEX16: return GL_UNSIGNED_SHORT;
1582 case GL_DEPTH24_STENCIL8: return GL_UNSIGNED_INT_24_8;
1583 case GL_DEPTH32F_STENCIL8: return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
1584 case GL_DEPTH32F_STENCIL8_NV: return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
1585
1586 default: return GL_INVALID_VALUE;
1587 }
1588}
1589
1590static inline unsigned int glGetTypeSizeFromType(GLenum type)
1591{
1592 switch (type) {
1593 case GL_BYTE:
1594 case GL_UNSIGNED_BYTE:
1595 case GL_UNSIGNED_BYTE_3_3_2:
1596 case GL_UNSIGNED_BYTE_2_3_3_REV:
1597 return 1;
1598
1599 case GL_SHORT:
1600 case GL_UNSIGNED_SHORT:
1601 case GL_UNSIGNED_SHORT_5_6_5:
1602 case GL_UNSIGNED_SHORT_4_4_4_4:
1603 case GL_UNSIGNED_SHORT_5_5_5_1:
1604 case GL_UNSIGNED_SHORT_5_6_5_REV:
1605 case GL_UNSIGNED_SHORT_4_4_4_4_REV:
1606 case GL_UNSIGNED_SHORT_1_5_5_5_REV:
1607 case GL_HALF_FLOAT:
1608 return 2;
1609
1610 case GL_INT:
1611 case GL_UNSIGNED_INT:
1612 case GL_UNSIGNED_INT_8_8_8_8:
1613 case GL_UNSIGNED_INT_8_8_8_8_REV:
1614 case GL_UNSIGNED_INT_10_10_10_2:
1615 case GL_UNSIGNED_INT_2_10_10_10_REV:
1616 case GL_UNSIGNED_INT_24_8:
1617 case GL_UNSIGNED_INT_10F_11F_11F_REV:
1618 case GL_UNSIGNED_INT_5_9_9_9_REV:
1619 case GL_FLOAT:
1620 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
1621 return 4;
1622
1623 default:
1624 return GL_INVALID_VALUE;
1625 }
1626}
1627
1628static inline void glGetFormatSize( const GLenum internalFormat, ktxFormatSize * pFormatSize )
1629{
1630 pFormatSize->minBlocksX = pFormatSize->minBlocksY = 1;
1631 switch ( internalFormat )
1632 {
1633 //
1634 // 8 bits per component
1635 //
1636 case GL_R8: // 1-component, 8-bit unsigned normalized
1637 case GL_R8_SNORM: // 1-component, 8-bit signed normalized
1638 case GL_R8UI: // 1-component, 8-bit unsigned integer
1639 case GL_R8I: // 1-component, 8-bit signed integer
1640 case GL_SR8: // 1-component, 8-bit sRGB
1641 pFormatSize->flags = 0;
1642 pFormatSize->paletteSizeInBits = 0;
1643 pFormatSize->blockSizeInBits = 1 * 8;
1644 pFormatSize->blockWidth = 1;
1645 pFormatSize->blockHeight = 1;
1646 pFormatSize->blockDepth = 1;
1647 break;
1648 case GL_RG8: // 2-component, 8-bit unsigned normalized
1649 case GL_RG8_SNORM: // 2-component, 8-bit signed normalized
1650 case GL_RG8UI: // 2-component, 8-bit unsigned integer
1651 case GL_RG8I: // 2-component, 8-bit signed integer
1652 case GL_SRG8: // 2-component, 8-bit sRGB
1653 pFormatSize->flags = 0;
1654 pFormatSize->paletteSizeInBits = 0;
1655 pFormatSize->blockSizeInBits = 2 * 8;
1656 pFormatSize->blockWidth = 1;
1657 pFormatSize->blockHeight = 1;
1658 pFormatSize->blockDepth = 1;
1659 break;
1660 case GL_RGB8: // 3-component, 8-bit unsigned normalized
1661 case GL_RGB8_SNORM: // 3-component, 8-bit signed normalized
1662 case GL_RGB8UI: // 3-component, 8-bit unsigned integer
1663 case GL_RGB8I: // 3-component, 8-bit signed integer
1664 case GL_SRGB8: // 3-component, 8-bit sRGB
1665 pFormatSize->flags = 0;
1666 pFormatSize->paletteSizeInBits = 0;
1667 pFormatSize->blockSizeInBits = 3 * 8;
1668 pFormatSize->blockWidth = 1;
1669 pFormatSize->blockHeight = 1;
1670 pFormatSize->blockDepth = 1;
1671 break;
1672 case GL_RGBA8: // 4-component, 8-bit unsigned normalized
1673 case GL_RGBA8_SNORM: // 4-component, 8-bit signed normalized
1674 case GL_RGBA8UI: // 4-component, 8-bit unsigned integer
1675 case GL_RGBA8I: // 4-component, 8-bit signed integer
1676 case GL_SRGB8_ALPHA8: // 4-component, 8-bit sRGB
1677 pFormatSize->flags = 0;
1678 pFormatSize->paletteSizeInBits = 0;
1679 pFormatSize->blockSizeInBits = 4 * 8;
1680 pFormatSize->blockWidth = 1;
1681 pFormatSize->blockHeight = 1;
1682 pFormatSize->blockDepth = 1;
1683 break;
1684
1685 //
1686 // 16 bits per component
1687 //
1688 case GL_R16: // 1-component, 16-bit unsigned normalized
1689 case GL_R16_SNORM: // 1-component, 16-bit signed normalized
1690 case GL_R16UI: // 1-component, 16-bit unsigned integer
1691 case GL_R16I: // 1-component, 16-bit signed integer
1692 case GL_R16F: // 1-component, 16-bit floating-point
1693 pFormatSize->flags = 0;
1694 pFormatSize->paletteSizeInBits = 0;
1695 pFormatSize->blockSizeInBits = 2 * 8;
1696 pFormatSize->blockWidth = 1;
1697 pFormatSize->blockHeight = 1;
1698 pFormatSize->blockDepth = 1;
1699 break;
1700 case GL_RG16: // 2-component, 16-bit unsigned normalized
1701 case GL_RG16_SNORM: // 2-component, 16-bit signed normalized
1702 case GL_RG16UI: // 2-component, 16-bit unsigned integer
1703 case GL_RG16I: // 2-component, 16-bit signed integer
1704 case GL_RG16F: // 2-component, 16-bit floating-point
1705 pFormatSize->flags = 0;
1706 pFormatSize->paletteSizeInBits = 0;
1707 pFormatSize->blockSizeInBits = 4 * 8;
1708 pFormatSize->blockWidth = 1;
1709 pFormatSize->blockHeight = 1;
1710 pFormatSize->blockDepth = 1;
1711 break;
1712 case GL_RGB16: // 3-component, 16-bit unsigned normalized
1713 case GL_RGB16_SNORM: // 3-component, 16-bit signed normalized
1714 case GL_RGB16UI: // 3-component, 16-bit unsigned integer
1715 case GL_RGB16I: // 3-component, 16-bit signed integer
1716 case GL_RGB16F: // 3-component, 16-bit floating-point
1717 pFormatSize->flags = 0;
1718 pFormatSize->paletteSizeInBits = 0;
1719 pFormatSize->blockSizeInBits = 6 * 8;
1720 pFormatSize->blockWidth = 1;
1721 pFormatSize->blockHeight = 1;
1722 pFormatSize->blockDepth = 1;
1723 break;
1724 case GL_RGBA16: // 4-component, 16-bit unsigned normalized
1725 case GL_RGBA16_SNORM: // 4-component, 16-bit signed normalized
1726 case GL_RGBA16UI: // 4-component, 16-bit unsigned integer
1727 case GL_RGBA16I: // 4-component, 16-bit signed integer
1728 case GL_RGBA16F: // 4-component, 16-bit floating-point
1729 pFormatSize->flags = 0;
1730 pFormatSize->paletteSizeInBits = 0;
1731 pFormatSize->blockSizeInBits = 8 * 8;
1732 pFormatSize->blockWidth = 1;
1733 pFormatSize->blockHeight = 1;
1734 pFormatSize->blockDepth = 1;
1735 break;
1736
1737 //
1738 // 32 bits per component
1739 //
1740 case GL_R32UI: // 1-component, 32-bit unsigned integer
1741 case GL_R32I: // 1-component, 32-bit signed integer
1742 case GL_R32F: // 1-component, 32-bit floating-point
1743 pFormatSize->flags = 0;
1744 pFormatSize->paletteSizeInBits = 0;
1745 pFormatSize->blockSizeInBits = 4 * 8;
1746 pFormatSize->blockWidth = 1;
1747 pFormatSize->blockHeight = 1;
1748 pFormatSize->blockDepth = 1;
1749 break;
1750 case GL_RG32UI: // 2-component, 32-bit unsigned integer
1751 case GL_RG32I: // 2-component, 32-bit signed integer
1752 case GL_RG32F: // 2-component, 32-bit floating-point
1753 pFormatSize->flags = 0;
1754 pFormatSize->paletteSizeInBits = 0;
1755 pFormatSize->blockSizeInBits = 8 * 8;
1756 pFormatSize->blockWidth = 1;
1757 pFormatSize->blockHeight = 1;
1758 pFormatSize->blockDepth = 1;
1759 break;
1760 case GL_RGB32UI: // 3-component, 32-bit unsigned integer
1761 case GL_RGB32I: // 3-component, 32-bit signed integer
1762 case GL_RGB32F: // 3-component, 32-bit floating-point
1763 pFormatSize->flags = 0;
1764 pFormatSize->paletteSizeInBits = 0;
1765 pFormatSize->blockSizeInBits = 12 * 8;
1766 pFormatSize->blockWidth = 1;
1767 pFormatSize->blockHeight = 1;
1768 pFormatSize->blockDepth = 1;
1769 break;
1770 case GL_RGBA32UI: // 4-component, 32-bit unsigned integer
1771 case GL_RGBA32I: // 4-component, 32-bit signed integer
1772 case GL_RGBA32F: // 4-component, 32-bit floating-point
1773 pFormatSize->flags = 0;
1774 pFormatSize->paletteSizeInBits = 0;
1775 pFormatSize->blockSizeInBits = 16 * 8;
1776 pFormatSize->blockWidth = 1;
1777 pFormatSize->blockHeight = 1;
1778 pFormatSize->blockDepth = 1;
1779 break;
1780
1781 //
1782 // Packed
1783 //
1784 case GL_R3_G3_B2: // 3-component 3:3:2, unsigned normalized
1785 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1786 pFormatSize->paletteSizeInBits = 0;
1787 pFormatSize->blockSizeInBits = 8;
1788 pFormatSize->blockWidth = 1;
1789 pFormatSize->blockHeight = 1;
1790 pFormatSize->blockDepth = 1;
1791 break;
1792 case GL_RGB4: // 3-component 4:4:4, unsigned normalized
1793 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1794 pFormatSize->paletteSizeInBits = 0;
1795 pFormatSize->blockSizeInBits = 12;
1796 pFormatSize->blockWidth = 1;
1797 pFormatSize->blockHeight = 1;
1798 pFormatSize->blockDepth = 1;
1799 break;
1800 case GL_RGB5: // 3-component 5:5:5, unsigned normalized
1801 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1802 pFormatSize->paletteSizeInBits = 0;
1803 pFormatSize->blockSizeInBits = 16;
1804 pFormatSize->blockWidth = 1;
1805 pFormatSize->blockHeight = 1;
1806 pFormatSize->blockDepth = 1;
1807 break;
1808 case GL_RGB565: // 3-component 5:6:5, unsigned normalized
1809 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1810 pFormatSize->paletteSizeInBits = 0;
1811 pFormatSize->blockSizeInBits = 16;
1812 pFormatSize->blockWidth = 1;
1813 pFormatSize->blockHeight = 1;
1814 pFormatSize->blockDepth = 1;
1815 break;
1816 case GL_RGB10: // 3-component 10:10:10, unsigned normalized
1817 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1818 pFormatSize->paletteSizeInBits = 0;
1819 pFormatSize->blockSizeInBits = 32;
1820 pFormatSize->blockWidth = 1;
1821 pFormatSize->blockHeight = 1;
1822 pFormatSize->blockDepth = 1;
1823 break;
1824 case GL_RGB12: // 3-component 12:12:12, unsigned normalized
1825 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1826 pFormatSize->paletteSizeInBits = 0;
1827 pFormatSize->blockSizeInBits = 36;
1828 pFormatSize->blockWidth = 1;
1829 pFormatSize->blockHeight = 1;
1830 pFormatSize->blockDepth = 1;
1831 break;
1832 case GL_RGBA2: // 4-component 2:2:2:2, unsigned normalized
1833 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1834 pFormatSize->paletteSizeInBits = 0;
1835 pFormatSize->blockSizeInBits = 8;
1836 pFormatSize->blockWidth = 1;
1837 pFormatSize->blockHeight = 1;
1838 pFormatSize->blockDepth = 1;
1839 break;
1840 case GL_RGBA4: // 4-component 4:4:4:4, unsigned normalized
1841 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1842 pFormatSize->paletteSizeInBits = 0;
1843 pFormatSize->blockSizeInBits = 16;
1844 pFormatSize->blockWidth = 1;
1845 pFormatSize->blockHeight = 1;
1846 pFormatSize->blockDepth = 1;
1847 break;
1848 case GL_RGBA12: // 4-component 12:12:12:12, unsigned normalized
1849 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1850 pFormatSize->paletteSizeInBits = 0;
1851 pFormatSize->blockSizeInBits = 48;
1852 pFormatSize->blockWidth = 1;
1853 pFormatSize->blockHeight = 1;
1854 pFormatSize->blockDepth = 1;
1855 break;
1856 case GL_RGB5_A1: // 4-component 5:5:5:1, unsigned normalized
1857 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1858 pFormatSize->paletteSizeInBits = 0;
1859 pFormatSize->blockSizeInBits = 32;
1860 pFormatSize->blockWidth = 1;
1861 pFormatSize->blockHeight = 1;
1862 pFormatSize->blockDepth = 1;
1863 break;
1864 case GL_RGB10_A2: // 4-component 10:10:10:2, unsigned normalized
1865 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1866 pFormatSize->paletteSizeInBits = 0;
1867 pFormatSize->blockSizeInBits = 32;
1868 pFormatSize->blockWidth = 1;
1869 pFormatSize->blockHeight = 1;
1870 pFormatSize->blockDepth = 1;
1871 break;
1872 case GL_RGB10_A2UI: // 4-component 10:10:10:2, unsigned integer
1873 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1874 pFormatSize->paletteSizeInBits = 0;
1875 pFormatSize->blockSizeInBits = 32;
1876 pFormatSize->blockWidth = 1;
1877 pFormatSize->blockHeight = 1;
1878 pFormatSize->blockDepth = 1;
1879 break;
1880 case GL_R11F_G11F_B10F: // 3-component 11:11:10, floating-point
1881 case GL_RGB9_E5: // 3-component/exp 9:9:9/5, floating-point
1882 pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT;
1883 pFormatSize->paletteSizeInBits = 0;
1884 pFormatSize->blockSizeInBits = 32;
1885 pFormatSize->blockWidth = 1;
1886 pFormatSize->blockHeight = 1;
1887 pFormatSize->blockDepth = 1;
1888 break;
1889
1890 //
1891 // S3TC/DXT/BC
1892 //
1893 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // line through 3D space, 4x4 blocks, unsigned normalized
1894 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized
1895 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: // line through 3D space, 4x4 blocks, sRGB
1896 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB
1897 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1898 pFormatSize->paletteSizeInBits = 0;
1899 pFormatSize->blockSizeInBits = 64;
1900 pFormatSize->blockWidth = 4;
1901 pFormatSize->blockHeight = 4;
1902 pFormatSize->blockDepth = 1;
1903 break;
1904 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized
1905 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized
1906 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: // line through 3D space plus line through 1D space, 4x4 blocks, sRGB
1907 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB
1908 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1909 pFormatSize->paletteSizeInBits = 0;
1910 pFormatSize->blockSizeInBits = 128;
1911 pFormatSize->blockWidth = 4;
1912 pFormatSize->blockHeight = 4;
1913 pFormatSize->blockDepth = 1;
1914 break;
1915
1916 case GL_COMPRESSED_LUMINANCE_LATC1_EXT: // line through 1D space, 4x4 blocks, unsigned normalized
1917 case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: // line through 1D space, 4x4 blocks, signed normalized
1918 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1919 pFormatSize->paletteSizeInBits = 0;
1920 pFormatSize->blockSizeInBits = 64;
1921 pFormatSize->blockWidth = 4;
1922 pFormatSize->blockHeight = 4;
1923 pFormatSize->blockDepth = 1;
1924 break;
1925 case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: // two lines through 1D space, 4x4 blocks, unsigned normalized
1926 case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: // two lines through 1D space, 4x4 blocks, signed normalized
1927 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1928 pFormatSize->paletteSizeInBits = 0;
1929 pFormatSize->blockSizeInBits = 128;
1930 pFormatSize->blockWidth = 4;
1931 pFormatSize->blockHeight = 4;
1932 pFormatSize->blockDepth = 1;
1933 break;
1934
1935 case GL_COMPRESSED_RED_RGTC1: // line through 1D space, 4x4 blocks, unsigned normalized
1936 case GL_COMPRESSED_SIGNED_RED_RGTC1: // line through 1D space, 4x4 blocks, signed normalized
1937 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1938 pFormatSize->paletteSizeInBits = 0;
1939 pFormatSize->blockSizeInBits = 64;
1940 pFormatSize->blockWidth = 4;
1941 pFormatSize->blockHeight = 4;
1942 pFormatSize->blockDepth = 1;
1943 break;
1944 case GL_COMPRESSED_RG_RGTC2: // two lines through 1D space, 4x4 blocks, unsigned normalized
1945 case GL_COMPRESSED_SIGNED_RG_RGTC2: // two lines through 1D space, 4x4 blocks, signed normalized
1946 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1947 pFormatSize->paletteSizeInBits = 0;
1948 pFormatSize->blockSizeInBits = 128;
1949 pFormatSize->blockWidth = 4;
1950 pFormatSize->blockHeight = 4;
1951 pFormatSize->blockDepth = 1;
1952 break;
1953
1954 case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: // 3-component, 4x4 blocks, unsigned floating-point
1955 case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: // 3-component, 4x4 blocks, signed floating-point
1956 case GL_COMPRESSED_RGBA_BPTC_UNORM: // 4-component, 4x4 blocks, unsigned normalized
1957 case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: // 4-component, 4x4 blocks, sRGB
1958 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1959 pFormatSize->paletteSizeInBits = 0;
1960 pFormatSize->blockSizeInBits = 128;
1961 pFormatSize->blockWidth = 4;
1962 pFormatSize->blockHeight = 4;
1963 pFormatSize->blockDepth = 1;
1964 break;
1965
1966 //
1967 // ETC
1968 //
1969 case GL_ETC1_RGB8_OES: // 3-component ETC1, 4x4 blocks, unsigned normalized" ),
1970 case GL_COMPRESSED_RGB8_ETC2: // 3-component ETC2, 4x4 blocks, unsigned normalized
1971 case GL_COMPRESSED_SRGB8_ETC2: // 3-component ETC2, 4x4 blocks, sRGB
1972 case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized
1973 case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB
1974 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1975 pFormatSize->paletteSizeInBits = 0;
1976 pFormatSize->blockSizeInBits = 64;
1977 pFormatSize->blockWidth = 4;
1978 pFormatSize->blockHeight = 4;
1979 pFormatSize->blockDepth = 1;
1980 break;
1981 case GL_COMPRESSED_RGBA8_ETC2_EAC: // 4-component ETC2, 4x4 blocks, unsigned normalized
1982 case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: // 4-component ETC2, 4x4 blocks, sRGB
1983 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1984 pFormatSize->paletteSizeInBits = 0;
1985 pFormatSize->blockSizeInBits = 128;
1986 pFormatSize->blockWidth = 4;
1987 pFormatSize->blockHeight = 4;
1988 pFormatSize->blockDepth = 1;
1989 break;
1990
1991 case GL_COMPRESSED_R11_EAC: // 1-component ETC, 4x4 blocks, unsigned normalized
1992 case GL_COMPRESSED_SIGNED_R11_EAC: // 1-component ETC, 4x4 blocks, signed normalized
1993 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
1994 pFormatSize->paletteSizeInBits = 0;
1995 pFormatSize->blockSizeInBits = 64;
1996 pFormatSize->blockWidth = 4;
1997 pFormatSize->blockHeight = 4;
1998 pFormatSize->blockDepth = 1;
1999 break;
2000 case GL_COMPRESSED_RG11_EAC: // 2-component ETC, 4x4 blocks, unsigned normalized
2001 case GL_COMPRESSED_SIGNED_RG11_EAC: // 2-component ETC, 4x4 blocks, signed normalized
2002 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2003 pFormatSize->paletteSizeInBits = 0;
2004 pFormatSize->blockSizeInBits = 128;
2005 pFormatSize->blockWidth = 4;
2006 pFormatSize->blockHeight = 4;
2007 pFormatSize->blockDepth = 1;
2008 break;
2009
2010 //
2011 // PVRTC
2012 //
2013 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: // 3-component PVRTC, 8x4 blocks, unsigned normalized
2014 case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: // 3-component PVRTC, 8x4 blocks, sRGB
2015 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: // 4-component PVRTC, 8x4 blocks, unsigned normalized
2016 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: // 4-component PVRTC, 8x4 blocks, sRGB
2017 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2018 pFormatSize->paletteSizeInBits = 0;
2019 pFormatSize->blockSizeInBits = 64;
2020 pFormatSize->blockWidth = 8;
2021 pFormatSize->blockHeight = 4;
2022 pFormatSize->blockDepth = 1;
2023 pFormatSize->minBlocksX = 2;
2024 pFormatSize->minBlocksY = 2;
2025 break;
2026 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: // 3-component PVRTC, 4x4 blocks, unsigned normalized
2027 case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: // 3-component PVRTC, 4x4 blocks, sRGB
2028 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: // 4-component PVRTC, 4x4 blocks, unsigned normalized
2029 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: // 4-component PVRTC, 4x4 blocks, sRGB
2030 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2031 pFormatSize->paletteSizeInBits = 0;
2032 pFormatSize->blockSizeInBits = 64;
2033 pFormatSize->blockWidth = 4;
2034 pFormatSize->blockHeight = 4;
2035 pFormatSize->blockDepth = 1;
2036 pFormatSize->minBlocksX = 2;
2037 pFormatSize->minBlocksY = 2;
2038 break;
2039 case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: // 4-component PVRTC, 8x4 blocks, unsigned normalized
2040 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: // 4-component PVRTC, 8x4 blocks, sRGB
2041 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2042 pFormatSize->paletteSizeInBits = 0;
2043 pFormatSize->blockSizeInBits = 64;
2044 pFormatSize->blockWidth = 8;
2045 pFormatSize->blockHeight = 4;
2046 pFormatSize->blockDepth = 1;
2047 break;
2048 case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: // 4-component PVRTC, 4x4 blocks, unsigned normalized
2049 case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: // 4-component PVRTC, 4x4 blocks, sRGB
2050 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2051 pFormatSize->paletteSizeInBits = 0;
2052 pFormatSize->blockSizeInBits = 64;
2053 pFormatSize->blockWidth = 4;
2054 pFormatSize->blockHeight = 4;
2055 pFormatSize->blockDepth = 1;
2056 break;
2057
2058 //
2059 // ASTC
2060 //
2061 case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: // 4-component ASTC, 4x4 blocks, unsigned normalized
2062 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: // 4-component ASTC, 4x4 blocks, sRGB
2063 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2064 pFormatSize->paletteSizeInBits = 0;
2065 pFormatSize->blockSizeInBits = 128;
2066 pFormatSize->blockWidth = 4;
2067 pFormatSize->blockHeight = 4;
2068 pFormatSize->blockDepth = 1;
2069 break;
2070 case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: // 4-component ASTC, 5x4 blocks, unsigned normalized
2071 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: // 4-component ASTC, 5x4 blocks, sRGB
2072 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2073 pFormatSize->paletteSizeInBits = 0;
2074 pFormatSize->blockSizeInBits = 128;
2075 pFormatSize->blockWidth = 5;
2076 pFormatSize->blockHeight = 4;
2077 pFormatSize->blockDepth = 1;
2078 break;
2079 case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: // 4-component ASTC, 5x5 blocks, unsigned normalized
2080 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: // 4-component ASTC, 5x5 blocks, sRGB
2081 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2082 pFormatSize->paletteSizeInBits = 0;
2083 pFormatSize->blockSizeInBits = 128;
2084 pFormatSize->blockWidth = 5;
2085 pFormatSize->blockHeight = 5;
2086 pFormatSize->blockDepth = 1;
2087 break;
2088 case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: // 4-component ASTC, 6x5 blocks, unsigned normalized
2089 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: // 4-component ASTC, 6x5 blocks, sRGB
2090 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2091 pFormatSize->paletteSizeInBits = 0;
2092 pFormatSize->blockSizeInBits = 128;
2093 pFormatSize->blockWidth = 6;
2094 pFormatSize->blockHeight = 5;
2095 pFormatSize->blockDepth = 1;
2096 break;
2097 case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: // 4-component ASTC, 6x6 blocks, unsigned normalized
2098 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: // 4-component ASTC, 6x6 blocks, sRGB
2099 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2100 pFormatSize->paletteSizeInBits = 0;
2101 pFormatSize->blockSizeInBits = 128;
2102 pFormatSize->blockWidth = 6;
2103 pFormatSize->blockHeight = 6;
2104 pFormatSize->blockDepth = 1;
2105 break;
2106 case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: // 4-component ASTC, 8x5 blocks, unsigned normalized
2107 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: // 4-component ASTC, 8x5 blocks, sRGB
2108 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2109 pFormatSize->paletteSizeInBits = 0;
2110 pFormatSize->blockSizeInBits = 128;
2111 pFormatSize->blockWidth = 8;
2112 pFormatSize->blockHeight = 5;
2113 pFormatSize->blockDepth = 1;
2114 break;
2115 case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: // 4-component ASTC, 8x6 blocks, unsigned normalized
2116 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: // 4-component ASTC, 8x6 blocks, sRGB
2117 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2118 pFormatSize->paletteSizeInBits = 0;
2119 pFormatSize->blockSizeInBits = 128;
2120 pFormatSize->blockWidth = 8;
2121 pFormatSize->blockHeight = 6;
2122 pFormatSize->blockDepth = 1;
2123 break;
2124 case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: // 4-component ASTC, 8x8 blocks, unsigned normalized
2125 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: // 4-component ASTC, 8x8 blocks, sRGB
2126 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2127 pFormatSize->paletteSizeInBits = 0;
2128 pFormatSize->blockSizeInBits = 128;
2129 pFormatSize->blockWidth = 8;
2130 pFormatSize->blockHeight = 8;
2131 pFormatSize->blockDepth = 1;
2132 break;
2133 case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: // 4-component ASTC, 10x5 blocks, unsigned normalized
2134 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: // 4-component ASTC, 10x5 blocks, sRGB
2135 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2136 pFormatSize->paletteSizeInBits = 0;
2137 pFormatSize->blockSizeInBits = 128;
2138 pFormatSize->blockWidth = 10;
2139 pFormatSize->blockHeight = 5;
2140 pFormatSize->blockDepth = 1;
2141 break;
2142 case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: // 4-component ASTC, 10x6 blocks, unsigned normalized
2143 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: // 4-component ASTC, 10x6 blocks, sRGB
2144 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2145 pFormatSize->paletteSizeInBits = 0;
2146 pFormatSize->blockSizeInBits = 128;
2147 pFormatSize->blockWidth = 10;
2148 pFormatSize->blockHeight = 6;
2149 pFormatSize->blockDepth = 1;
2150 break;
2151 case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: // 4-component ASTC, 10x8 blocks, unsigned normalized
2152 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: // 4-component ASTC, 10x8 blocks, sRGB
2153 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2154 pFormatSize->paletteSizeInBits = 0;
2155 pFormatSize->blockSizeInBits = 128;
2156 pFormatSize->blockWidth = 10;
2157 pFormatSize->blockHeight = 8;
2158 pFormatSize->blockDepth = 1;
2159 break;
2160 case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: // 4-component ASTC, 10x10 blocks, unsigned normalized
2161 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: // 4-component ASTC, 10x10 blocks, sRGB
2162 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2163 pFormatSize->paletteSizeInBits = 0;
2164 pFormatSize->blockSizeInBits = 128;
2165 pFormatSize->blockWidth = 10;
2166 pFormatSize->blockHeight = 10;
2167 pFormatSize->blockDepth = 1;
2168 break;
2169 case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: // 4-component ASTC, 12x10 blocks, unsigned normalized
2170 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: // 4-component ASTC, 12x10 blocks, sRGB
2171 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2172 pFormatSize->paletteSizeInBits = 0;
2173 pFormatSize->blockSizeInBits = 128;
2174 pFormatSize->blockWidth = 12;
2175 pFormatSize->blockHeight = 10;
2176 pFormatSize->blockDepth = 1;
2177 break;
2178 case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: // 4-component ASTC, 12x12 blocks, unsigned normalized
2179 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: // 4-component ASTC, 12x12 blocks, sRGB
2180 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2181 pFormatSize->paletteSizeInBits = 0;
2182 pFormatSize->blockSizeInBits = 128;
2183 pFormatSize->blockWidth = 12;
2184 pFormatSize->blockHeight = 12;
2185 pFormatSize->blockDepth = 1;
2186 break;
2187
2188 case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: // 4-component ASTC, 3x3x3 blocks, unsigned normalized
2189 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: // 4-component ASTC, 3x3x3 blocks, sRGB
2190 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2191 pFormatSize->paletteSizeInBits = 0;
2192 pFormatSize->blockSizeInBits = 128;
2193 pFormatSize->blockWidth = 3;
2194 pFormatSize->blockHeight = 3;
2195 pFormatSize->blockDepth = 3;
2196 break;
2197 case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: // 4-component ASTC, 4x3x3 blocks, unsigned normalized
2198 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: // 4-component ASTC, 4x3x3 blocks, sRGB
2199 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2200 pFormatSize->paletteSizeInBits = 0;
2201 pFormatSize->blockSizeInBits = 128;
2202 pFormatSize->blockWidth = 4;
2203 pFormatSize->blockHeight = 3;
2204 pFormatSize->blockDepth = 3;
2205 break;
2206 case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: // 4-component ASTC, 4x4x3 blocks, unsigned normalized
2207 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: // 4-component ASTC, 4x4x3 blocks, sRGB
2208 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2209 pFormatSize->paletteSizeInBits = 0;
2210 pFormatSize->blockSizeInBits = 128;
2211 pFormatSize->blockWidth = 4;
2212 pFormatSize->blockHeight = 4;
2213 pFormatSize->blockDepth = 3;
2214 break;
2215 case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: // 4-component ASTC, 4x4x4 blocks, unsigned normalized
2216 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: // 4-component ASTC, 4x4x4 blocks, sRGB
2217 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2218 pFormatSize->paletteSizeInBits = 0;
2219 pFormatSize->blockSizeInBits = 128;
2220 pFormatSize->blockWidth = 4;
2221 pFormatSize->blockHeight = 4;
2222 pFormatSize->blockDepth = 4;
2223 break;
2224 case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: // 4-component ASTC, 5x4x4 blocks, unsigned normalized
2225 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: // 4-component ASTC, 5x4x4 blocks, sRGB
2226 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2227 pFormatSize->paletteSizeInBits = 0;
2228 pFormatSize->blockSizeInBits = 128;
2229 pFormatSize->blockWidth = 5;
2230 pFormatSize->blockHeight = 4;
2231 pFormatSize->blockDepth = 4;
2232 break;
2233 case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: // 4-component ASTC, 5x5x4 blocks, unsigned normalized
2234 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: // 4-component ASTC, 5x5x4 blocks, sRGB
2235 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2236 pFormatSize->paletteSizeInBits = 0;
2237 pFormatSize->blockSizeInBits = 128;
2238 pFormatSize->blockWidth = 5;
2239 pFormatSize->blockHeight = 5;
2240 pFormatSize->blockDepth = 4;
2241 break;
2242 case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: // 4-component ASTC, 5x5x5 blocks, unsigned normalized
2243 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: // 4-component ASTC, 5x5x5 blocks, sRGB
2244 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2245 pFormatSize->paletteSizeInBits = 0;
2246 pFormatSize->blockSizeInBits = 128;
2247 pFormatSize->blockWidth = 5;
2248 pFormatSize->blockHeight = 5;
2249 pFormatSize->blockDepth = 5;
2250 break;
2251 case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: // 4-component ASTC, 6x5x5 blocks, unsigned normalized
2252 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: // 4-component ASTC, 6x5x5 blocks, sRGB
2253 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2254 pFormatSize->paletteSizeInBits = 0;
2255 pFormatSize->blockSizeInBits = 128;
2256 pFormatSize->blockWidth = 6;
2257 pFormatSize->blockHeight = 5;
2258 pFormatSize->blockDepth = 5;
2259 break;
2260 case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: // 4-component ASTC, 6x6x5 blocks, unsigned normalized
2261 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: // 4-component ASTC, 6x6x5 blocks, sRGB
2262 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2263 pFormatSize->paletteSizeInBits = 0;
2264 pFormatSize->blockSizeInBits = 128;
2265 pFormatSize->blockWidth = 6;
2266 pFormatSize->blockHeight = 6;
2267 pFormatSize->blockDepth = 5;
2268 break;
2269 case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: // 4-component ASTC, 6x6x6 blocks, unsigned normalized
2270 case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: // 4-component ASTC, 6x6x6 blocks, sRGB
2271 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2272 pFormatSize->paletteSizeInBits = 0;
2273 pFormatSize->blockSizeInBits = 128;
2274 pFormatSize->blockWidth = 6;
2275 pFormatSize->blockHeight = 6;
2276 pFormatSize->blockDepth = 6;
2277 break;
2278
2279 //
2280 // ATC
2281 //
2282 case GL_ATC_RGB_AMD: // 3-component, 4x4 blocks, unsigned normalized
2283 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2284 pFormatSize->paletteSizeInBits = 0;
2285 pFormatSize->blockSizeInBits = 64;
2286 pFormatSize->blockWidth = 4;
2287 pFormatSize->blockHeight = 4;
2288 pFormatSize->blockDepth = 1;
2289 break;
2290 case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: // 4-component, 4x4 blocks, unsigned normalized
2291 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: // 4-component, 4x4 blocks, unsigned normalized
2292 pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT;
2293 pFormatSize->paletteSizeInBits = 0;
2294 pFormatSize->blockSizeInBits = 128;
2295 pFormatSize->blockWidth = 4;
2296 pFormatSize->blockHeight = 4;
2297 pFormatSize->blockDepth = 1;
2298 break;
2299
2300 //
2301 // Palletized
2302 //
2303 case GL_PALETTE4_RGB8_OES: // 3-component 8:8:8, 4-bit palette, unsigned normalized
2304 pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT;
2305 pFormatSize->paletteSizeInBits = 16 * 24;
2306 pFormatSize->blockSizeInBits = 4;
2307 pFormatSize->blockWidth = 1;
2308 pFormatSize->blockHeight = 1;
2309 pFormatSize->blockDepth = 1;
2310 break;
2311 case GL_PALETTE4_RGBA8_OES: // 4-component 8:8:8:8, 4-bit palette, unsigned normalized
2312 pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT;
2313 pFormatSize->paletteSizeInBits = 16 * 32;
2314 pFormatSize->blockSizeInBits = 4;
2315 pFormatSize->blockWidth = 1;
2316 pFormatSize->blockHeight = 1;
2317 pFormatSize->blockDepth = 1;
2318 break;
2319 case GL_PALETTE4_R5_G6_B5_OES: // 3-component 5:6:5, 4-bit palette, unsigned normalized
2320 case GL_PALETTE4_RGBA4_OES: // 4-component 4:4:4:4, 4-bit palette, unsigned normalized
2321 case GL_PALETTE4_RGB5_A1_OES: // 4-component 5:5:5:1, 4-bit palette, unsigned normalized
2322 pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT;
2323 pFormatSize->paletteSizeInBits = 16 * 16;
2324 pFormatSize->blockSizeInBits = 4;
2325 pFormatSize->blockWidth = 1;
2326 pFormatSize->blockHeight = 1;
2327 pFormatSize->blockDepth = 1;
2328 break;
2329 case GL_PALETTE8_RGB8_OES: // 3-component 8:8:8, 8-bit palette, unsigned normalized
2330 pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT;
2331 pFormatSize->paletteSizeInBits = 256 * 24;
2332 pFormatSize->blockSizeInBits = 8;
2333 pFormatSize->blockWidth = 1;
2334 pFormatSize->blockHeight = 1;
2335 pFormatSize->blockDepth = 1;
2336 break;
2337 case GL_PALETTE8_RGBA8_OES: // 4-component 8:8:8:8, 8-bit palette, unsigned normalized
2338 pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT;
2339 pFormatSize->paletteSizeInBits = 256 * 32;
2340 pFormatSize->blockSizeInBits = 8;
2341 pFormatSize->blockWidth = 1;
2342 pFormatSize->blockHeight = 1;
2343 pFormatSize->blockDepth = 1;
2344 break;
2345 case GL_PALETTE8_R5_G6_B5_OES: // 3-component 5:6:5, 8-bit palette, unsigned normalized
2346 case GL_PALETTE8_RGBA4_OES: // 4-component 4:4:4:4, 8-bit palette, unsigned normalized
2347 case GL_PALETTE8_RGB5_A1_OES: // 4-component 5:5:5:1, 8-bit palette, unsigned normalized
2348 pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT;
2349 pFormatSize->paletteSizeInBits = 256 * 16;
2350 pFormatSize->blockSizeInBits = 8;
2351 pFormatSize->blockWidth = 1;
2352 pFormatSize->blockHeight = 1;
2353 pFormatSize->blockDepth = 1;
2354 break;
2355
2356 //
2357 // Depth/stencil
2358 //
2359 case GL_DEPTH_COMPONENT16:
2360 pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT;
2361 pFormatSize->paletteSizeInBits = 0;
2362 pFormatSize->blockSizeInBits = 16;
2363 pFormatSize->blockWidth = 1;
2364 pFormatSize->blockHeight = 1;
2365 pFormatSize->blockDepth = 1;
2366 break;
2367 case GL_DEPTH_COMPONENT24:
2368 case GL_DEPTH_COMPONENT32:
2369 case GL_DEPTH_COMPONENT32F:
2370 case GL_DEPTH_COMPONENT32F_NV:
2371 pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT;
2372 pFormatSize->paletteSizeInBits = 0;
2373 pFormatSize->blockSizeInBits = 32;
2374 pFormatSize->blockWidth = 1;
2375 pFormatSize->blockHeight = 1;
2376 pFormatSize->blockDepth = 1;
2377 break;
2378 case GL_STENCIL_INDEX1:
2379 pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT;
2380 pFormatSize->paletteSizeInBits = 0;
2381 pFormatSize->blockSizeInBits = 1;
2382 pFormatSize->blockWidth = 1;
2383 pFormatSize->blockHeight = 1;
2384 pFormatSize->blockDepth = 1;
2385 break;
2386 case GL_STENCIL_INDEX4:
2387 pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT;
2388 pFormatSize->paletteSizeInBits = 0;
2389 pFormatSize->blockSizeInBits = 4;
2390 pFormatSize->blockWidth = 1;
2391 pFormatSize->blockHeight = 1;
2392 pFormatSize->blockDepth = 1;
2393 break;
2394 case GL_STENCIL_INDEX8:
2395 pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT;
2396 pFormatSize->paletteSizeInBits = 0;
2397 pFormatSize->blockSizeInBits = 8;
2398 pFormatSize->blockWidth = 1;
2399 pFormatSize->blockHeight = 1;
2400 pFormatSize->blockDepth = 1;
2401 break;
2402 case GL_STENCIL_INDEX16:
2403 pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT;
2404 pFormatSize->paletteSizeInBits = 0;
2405 pFormatSize->blockSizeInBits = 16;
2406 pFormatSize->blockWidth = 1;
2407 pFormatSize->blockHeight = 1;
2408 pFormatSize->blockDepth = 1;
2409 break;
2410 case GL_DEPTH24_STENCIL8:
2411 pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT;
2412 pFormatSize->paletteSizeInBits = 0;
2413 pFormatSize->blockSizeInBits = 32;
2414 pFormatSize->blockWidth = 1;
2415 pFormatSize->blockHeight = 1;
2416 pFormatSize->blockDepth = 1;
2417 break;
2418 case GL_DEPTH32F_STENCIL8:
2419 case GL_DEPTH32F_STENCIL8_NV:
2420 pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT;
2421 pFormatSize->paletteSizeInBits = 0;
2422 pFormatSize->blockSizeInBits = 64;
2423 pFormatSize->blockWidth = 1;
2424 pFormatSize->blockHeight = 1;
2425 pFormatSize->blockDepth = 1;
2426 break;
2427
2428 default:
2429 pFormatSize->flags = 0;
2430 pFormatSize->paletteSizeInBits = 0;
2431 pFormatSize->blockSizeInBits = 0 * 8;
2432 pFormatSize->blockWidth = 1;
2433 pFormatSize->blockHeight = 1;
2434 pFormatSize->blockDepth = 1;
2435 break;
2436 }
2437}
2438
2439static inline GLint glGetInternalFormatFromVkFormat( VkFormat vkFormat )
2440{
2441 switch ( vkFormat )
2442 {
2443 //
2444 // 8 bits per component
2445 //
2446 case VK_FORMAT_R8_UNORM: return GL_R8; // 1-component, 8-bit unsigned normalized
2447 case VK_FORMAT_R8G8_UNORM: return GL_RG8; // 2-component, 8-bit unsigned normalized
2448 case VK_FORMAT_R8G8B8_UNORM: return GL_RGB8; // 3-component, 8-bit unsigned normalized
2449 case VK_FORMAT_R8G8B8A8_UNORM: return GL_RGBA8; // 4-component, 8-bit unsigned normalized
2450
2451 case VK_FORMAT_R8_SNORM: return GL_R8_SNORM; // 1-component, 8-bit signed normalized
2452 case VK_FORMAT_R8G8_SNORM: return GL_RG8_SNORM; // 2-component, 8-bit signed normalized
2453 case VK_FORMAT_R8G8B8_SNORM: return GL_RGB8_SNORM; // 3-component, 8-bit signed normalized
2454 case VK_FORMAT_R8G8B8A8_SNORM: return GL_RGBA8_SNORM; // 4-component, 8-bit signed normalized
2455
2456 case VK_FORMAT_R8_UINT: return GL_R8UI; // 1-component, 8-bit unsigned integer
2457 case VK_FORMAT_R8G8_UINT: return GL_RG8UI; // 2-component, 8-bit unsigned integer
2458 case VK_FORMAT_R8G8B8_UINT: return GL_RGB8UI; // 3-component, 8-bit unsigned integer
2459 case VK_FORMAT_R8G8B8A8_UINT: return GL_RGBA8UI; // 4-component, 8-bit unsigned integer
2460
2461 case VK_FORMAT_R8_SINT: return GL_R8I; // 1-component, 8-bit signed integer
2462 case VK_FORMAT_R8G8_SINT: return GL_RG8I; // 2-component, 8-bit signed integer
2463 case VK_FORMAT_R8G8B8_SINT: return GL_RGB8I; // 3-component, 8-bit signed integer
2464 case VK_FORMAT_R8G8B8A8_SINT: return GL_RGBA8I; // 4-component, 8-bit signed integer
2465
2466 case VK_FORMAT_R8_SRGB: return GL_SR8; // 1-component, 8-bit sRGB
2467 case VK_FORMAT_R8G8_SRGB: return GL_SRG8; // 2-component, 8-bit sRGB
2468 case VK_FORMAT_R8G8B8_SRGB: return GL_SRGB8; // 3-component, 8-bit sRGB
2469 case VK_FORMAT_R8G8B8A8_SRGB: return GL_SRGB8_ALPHA8; // 4-component, 8-bit sRGB
2470
2471 //
2472 // 16 bits per component
2473 //
2474 case VK_FORMAT_R16_UNORM: return GL_R16; // 1-component, 16-bit unsigned normalized
2475 case VK_FORMAT_R16G16_UNORM: return GL_RG16; // 2-component, 16-bit unsigned normalized
2476 case VK_FORMAT_R16G16B16_UNORM: return GL_RGB16; // 3-component, 16-bit unsigned normalized
2477 case VK_FORMAT_R16G16B16A16_UNORM: return GL_RGBA16; // 4-component, 16-bit unsigned normalized
2478
2479 case VK_FORMAT_R16_SNORM: return GL_R16_SNORM; // 1-component, 16-bit signed normalized
2480 case VK_FORMAT_R16G16_SNORM: return GL_RG16_SNORM; // 2-component, 16-bit signed normalized
2481 case VK_FORMAT_R16G16B16_SNORM: return GL_RGB16_SNORM; // 3-component, 16-bit signed normalized
2482 case VK_FORMAT_R16G16B16A16_SNORM: return GL_RGBA16_SNORM; // 4-component, 16-bit signed normalized
2483
2484 case VK_FORMAT_R16_UINT: return GL_R16UI; // 1-component, 16-bit unsigned integer
2485 case VK_FORMAT_R16G16_UINT: return GL_RG16UI; // 2-component, 16-bit unsigned integer
2486 case VK_FORMAT_R16G16B16_UINT: return GL_RGB16UI; // 3-component, 16-bit unsigned integer
2487 case VK_FORMAT_R16G16B16A16_UINT: return GL_RGBA16UI; // 4-component, 16-bit unsigned integer
2488
2489 case VK_FORMAT_R16_SINT: return GL_R16I; // 1-component, 16-bit signed integer
2490 case VK_FORMAT_R16G16_SINT: return GL_RG16I; // 2-component, 16-bit signed integer
2491 case VK_FORMAT_R16G16B16_SINT: return GL_RGB16I; // 3-component, 16-bit signed integer
2492 case VK_FORMAT_R16G16B16A16_SINT: return GL_RGBA16I; // 4-component, 16-bit signed integer
2493
2494 case VK_FORMAT_R16_SFLOAT: return GL_R16F; // 1-component, 16-bit floating-point
2495 case VK_FORMAT_R16G16_SFLOAT: return GL_RG16F; // 2-component, 16-bit floating-point
2496 case VK_FORMAT_R16G16B16_SFLOAT: return GL_RGB16F; // 3-component, 16-bit floating-point
2497 case VK_FORMAT_R16G16B16A16_SFLOAT: return GL_RGBA16F; // 4-component, 16-bit floating-point
2498
2499 //
2500 // 32 bits per component
2501 //
2502 case VK_FORMAT_R32_UINT: return GL_R32UI; // 1-component, 32-bit unsigned integer
2503 case VK_FORMAT_R32G32_UINT: return GL_RG32UI; // 2-component, 32-bit unsigned integer
2504 case VK_FORMAT_R32G32B32_UINT: return GL_RGB32UI; // 3-component, 32-bit unsigned integer
2505 case VK_FORMAT_R32G32B32A32_UINT: return GL_RGBA32UI; // 4-component, 32-bit unsigned integer
2506
2507 case VK_FORMAT_R32_SINT: return GL_R32I; // 1-component, 32-bit signed integer
2508 case VK_FORMAT_R32G32_SINT: return GL_RG32I; // 2-component, 32-bit signed integer
2509 case VK_FORMAT_R32G32B32_SINT: return GL_RGB32I; // 3-component, 32-bit signed integer
2510 case VK_FORMAT_R32G32B32A32_SINT: return GL_RGBA32I; // 4-component, 32-bit signed integer
2511
2512 case VK_FORMAT_R32_SFLOAT: return GL_R32F; // 1-component, 32-bit floating-point
2513 case VK_FORMAT_R32G32_SFLOAT: return GL_RG32F; // 2-component, 32-bit floating-point
2514 case VK_FORMAT_R32G32B32_SFLOAT: return GL_RGB32F; // 3-component, 32-bit floating-point
2515 case VK_FORMAT_R32G32B32A32_SFLOAT: return GL_RGBA32F; // 4-component, 32-bit floating-point
2516
2517 //
2518 // Packed
2519 //
2520 case VK_FORMAT_R5G5B5A1_UNORM_PACK16: return GL_RGB5; // 3-component 5:5:5, unsigned normalized
2521 case VK_FORMAT_R5G6B5_UNORM_PACK16: return GL_RGB565; // 3-component 5:6:5, unsigned normalized
2522 case VK_FORMAT_R4G4B4A4_UNORM_PACK16: return GL_RGBA4; // 4-component 4:4:4:4, unsigned normalized
2523 case VK_FORMAT_A1R5G5B5_UNORM_PACK16: return GL_RGB5_A1; // 4-component 5:5:5:1, unsigned normalized
2524 case VK_FORMAT_A2R10G10B10_UNORM_PACK32: return GL_RGB10_A2; // 4-component 10:10:10:2, unsigned normalized
2525 case VK_FORMAT_A2R10G10B10_UINT_PACK32: return GL_RGB10_A2UI; // 4-component 10:10:10:2, unsigned integer
2526 case VK_FORMAT_B10G11R11_UFLOAT_PACK32: return GL_R11F_G11F_B10F; // 3-component 11:11:10, floating-point
2527 case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: return GL_RGB9_E5; // 3-component/exp 9:9:9/5, floating-point
2528
2529 //
2530 // S3TC/DXT/BC
2531 //
2532
2533 case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; // line through 3D space, 4x4 blocks, unsigned normalized
2534 case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized
2535 case VK_FORMAT_BC2_UNORM_BLOCK: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized
2536 case VK_FORMAT_BC3_UNORM_BLOCK: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized
2537
2538 case VK_FORMAT_BC1_RGB_SRGB_BLOCK: return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; // line through 3D space, 4x4 blocks, sRGB
2539 case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB
2540 case VK_FORMAT_BC2_SRGB_BLOCK: return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB
2541 case VK_FORMAT_BC3_SRGB_BLOCK: return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB
2542
2543 case VK_FORMAT_BC4_UNORM_BLOCK: return GL_COMPRESSED_RED_RGTC1; // line through 1D space, 4x4 blocks, unsigned normalized
2544 case VK_FORMAT_BC5_UNORM_BLOCK: return GL_COMPRESSED_RG_RGTC2; // two lines through 1D space, 4x4 blocks, unsigned normalized
2545 case VK_FORMAT_BC4_SNORM_BLOCK: return GL_COMPRESSED_SIGNED_RED_RGTC1; // line through 1D space, 4x4 blocks, signed normalized
2546 case VK_FORMAT_BC5_SNORM_BLOCK: return GL_COMPRESSED_SIGNED_RG_RGTC2; // two lines through 1D space, 4x4 blocks, signed normalized
2547
2548 case VK_FORMAT_BC6H_UFLOAT_BLOCK: return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT; // 3-component, 4x4 blocks, unsigned floating-point
2549 case VK_FORMAT_BC6H_SFLOAT_BLOCK: return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT; // 3-component, 4x4 blocks, signed floating-point
2550 case VK_FORMAT_BC7_UNORM_BLOCK: return GL_COMPRESSED_RGBA_BPTC_UNORM; // 4-component, 4x4 blocks, unsigned normalized
2551 case VK_FORMAT_BC7_SRGB_BLOCK: return GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM; // 4-component, 4x4 blocks, sRGB
2552
2553 //
2554 // ETC
2555 //
2556 case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return GL_COMPRESSED_RGB8_ETC2; // 3-component ETC2, 4x4 blocks, unsigned normalized
2557 case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized
2558 case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: return GL_COMPRESSED_RGBA8_ETC2_EAC; // 4-component ETC2, 4x4 blocks, unsigned normalized
2559
2560 case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ETC2; // 3-component ETC2, 4x4 blocks, sRGB
2561 case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB
2562 case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; // 4-component ETC2, 4x4 blocks, sRGB
2563
2564 case VK_FORMAT_EAC_R11_UNORM_BLOCK: return GL_COMPRESSED_R11_EAC; // 1-component ETC, 4x4 blocks, unsigned normalized
2565 case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: return GL_COMPRESSED_RG11_EAC; // 2-component ETC, 4x4 blocks, unsigned normalized
2566 case VK_FORMAT_EAC_R11_SNORM_BLOCK: return GL_COMPRESSED_SIGNED_R11_EAC; // 1-component ETC, 4x4 blocks, signed normalized
2567 case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: return GL_COMPRESSED_SIGNED_RG11_EAC; // 2-component ETC, 4x4 blocks, signed normalized
2568
2569 //
2570 // PVRTC
2571 //
2572 case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; // 3- or 4-component PVRTC, 16x8 blocks, unsigned normalized
2573 case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; // 3- or 4-component PVRTC, 8x8 blocks, unsigned normalized
2574 case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: return GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG; // 3- or 4-component PVRTC, 16x8 blocks, unsigned normalized
2575 case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: return GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG; // 3- or 4-component PVRTC, 4x4 blocks, unsigned normalized
2576
2577 case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT; // 4-component PVRTC, 16x8 blocks, sRGB
2578 case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT; // 4-component PVRTC, 8x8 blocks, sRGB
2579 case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: return GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG; // 4-component PVRTC, 8x4 blocks, sRGB
2580 case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: return GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG; // 4-component PVRTC, 4x4 blocks, sRGB
2581
2582 //
2583 // ASTC
2584 //
2585 case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_4x4_KHR; // 4-component ASTC, 4x4 blocks, unsigned normalized
2586 case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_5x4_KHR; // 4-component ASTC, 5x4 blocks, unsigned normalized
2587 case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_5x5_KHR; // 4-component ASTC, 5x5 blocks, unsigned normalized
2588 case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_6x5_KHR; // 4-component ASTC, 6x5 blocks, unsigned normalized
2589 case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_6x6_KHR; // 4-component ASTC, 6x6 blocks, unsigned normalized
2590 case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_8x5_KHR; // 4-component ASTC, 8x5 blocks, unsigned normalized
2591 case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_8x6_KHR; // 4-component ASTC, 8x6 blocks, unsigned normalized
2592 case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_8x8_KHR; // 4-component ASTC, 8x8 blocks, unsigned normalized
2593 case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_10x5_KHR; // 4-component ASTC, 10x5 blocks, unsigned normalized
2594 case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_10x6_KHR; // 4-component ASTC, 10x6 blocks, unsigned normalized
2595 case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_10x8_KHR; // 4-component ASTC, 10x8 blocks, unsigned normalized
2596 case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_10x10_KHR; // 4-component ASTC, 10x10 blocks, unsigned normalized
2597 case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_12x10_KHR; // 4-component ASTC, 12x10 blocks, unsigned normalized
2598 case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: return GL_COMPRESSED_RGBA_ASTC_12x12_KHR; // 4-component ASTC, 12x12 blocks, unsigned normalized
2599
2600 case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; // 4-component ASTC, 4x4 blocks, sRGB
2601 case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; // 4-component ASTC, 5x4 blocks, sRGB
2602 case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; // 4-component ASTC, 5x5 blocks, sRGB
2603 case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; // 4-component ASTC, 6x5 blocks, sRGB
2604 case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; // 4-component ASTC, 6x6 blocks, sRGB
2605 case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; // 4-component ASTC, 8x5 blocks, sRGB
2606 case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; // 4-component ASTC, 8x6 blocks, sRGB
2607 case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; // 4-component ASTC, 8x8 blocks, sRGB
2608 case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; // 4-component ASTC, 10x5 blocks, sRGB
2609 case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; // 4-component ASTC, 10x6 blocks, sRGB
2610 case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; // 4-component ASTC, 10x8 blocks, sRGB
2611 case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; // 4-component ASTC, 10x10 blocks, sRGB
2612 case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; // 4-component ASTC, 12x10 blocks, sRGB
2613 case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; // 4-component ASTC, 12x12 blocks, sRGB
2614
2615 // XXX FIXME Update once Vulkan ASTC HDR & 3D extensions are released.
2616#if 0
2617 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_3x3x3_OES; // 4-component ASTC, 3x3x3 blocks, unsigned normalized
2618 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_4x3x3_OES; // 4-component ASTC, 4x3x3 blocks, unsigned normalized
2619 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_4x4x3_OES; // 4-component ASTC, 4x4x3 blocks, unsigned normalized
2620 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_4x4x4_OES; // 4-component ASTC, 4x4x4 blocks, unsigned normalized
2621 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_5x4x4_OES; // 4-component ASTC, 5x4x4 blocks, unsigned normalized
2622 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_5x5x4_OES; // 4-component ASTC, 5x5x4 blocks, unsigned normalized
2623 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_5x5x5_OES; // 4-component ASTC, 5x5x5 blocks, unsigned normalized
2624 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_6x5x5_OES; // 4-component ASTC, 6x5x5 blocks, unsigned normalized
2625 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_6x6x5_OES; // 4-component ASTC, 6x6x5 blocks, unsigned normalized
2626 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_RGBA_ASTC_6x6x6_OES; // 4-component ASTC, 6x6x6 blocks, unsigned normalized
2627
2628 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES; // 4-component ASTC, 3x3x3 blocks, sRGB
2629 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES; // 4-component ASTC, 4x3x3 blocks, sRGB
2630 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES; // 4-component ASTC, 4x4x3 blocks, sRGB
2631 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES; // 4-component ASTC, 4x4x4 blocks, sRGB
2632 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES; // 4-component ASTC, 5x4x4 blocks, sRGB
2633 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES; // 4-component ASTC, 5x5x4 blocks, sRGB
2634 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES; // 4-component ASTC, 5x5x5 blocks, sRGB
2635 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES; // 4-component ASTC, 6x5x5 blocks, sRGB
2636 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES; // 4-component ASTC, 6x6x5 blocks, sRGB
2637 case VK_FORMAT_UNDEFINED: return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES; // 4-component ASTC, 6x6x6 blocks, sRGB
2638#endif
2639
2640 //
2641 // Depth/stencil
2642 //
2643 case VK_FORMAT_D16_UNORM: return GL_DEPTH_COMPONENT16;
2644 case VK_FORMAT_X8_D24_UNORM_PACK32: return GL_DEPTH_COMPONENT24;
2645 case VK_FORMAT_D32_SFLOAT: return GL_DEPTH_COMPONENT32F;
2646 case VK_FORMAT_S8_UINT: return GL_STENCIL_INDEX8;
2647 case VK_FORMAT_D24_UNORM_S8_UINT: return GL_DEPTH24_STENCIL8;
2648 case VK_FORMAT_D32_SFLOAT_S8_UINT: return GL_DEPTH32F_STENCIL8;
2649
2650 default: return GL_INVALID_VALUE;
2651 }
2652}
2653
2654#endif // !GL_FORMAT_H
2655